pixma: made backend obey local_only setting in sane_get_devices

merge-requests/228/merge
Louis Lagendijk 2019-11-30 23:51:03 +01:00
rodzic 6c0282e06f
commit 072487ee7b
5 zmienionych plików z 17 dodań i 13 usunięć

Wyświetl plik

@ -242,12 +242,12 @@ cleanup_device_list (void)
} }
static void static void
find_scanners (void) find_scanners (SANE_Bool local_only)
{ {
unsigned i, nscanners; unsigned i, nscanners;
cleanup_device_list (); cleanup_device_list ();
nscanners = pixma_find_scanners (conf_devices); nscanners = pixma_find_scanners (conf_devices, local_only);
PDBG (pixma_dbg (3, "pixma_find_scanners() found %u devices\n", nscanners)); PDBG (pixma_dbg (3, "pixma_find_scanners() found %u devices\n", nscanners));
dev_list = dev_list =
(const SANE_Device **) calloc (nscanners + 1, sizeof (*dev_list)); (const SANE_Device **) calloc (nscanners + 1, sizeof (*dev_list));
@ -1602,11 +1602,9 @@ sane_exit (void)
SANE_Status SANE_Status
sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
{ {
UNUSED (local_only);
if (!device_list) if (!device_list)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
find_scanners (); find_scanners (local_only);
*device_list = dev_list; *device_list = dev_list;
return (dev_list) ? SANE_STATUS_GOOD : SANE_STATUS_NO_MEM; return (dev_list) ? SANE_STATUS_GOOD : SANE_STATUS_NO_MEM;
} }
@ -1623,7 +1621,7 @@ sane_open (SANE_String_Const name, SANE_Handle * h)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
*h = NULL; *h = NULL;
nscanners = pixma_find_scanners (conf_devices); nscanners = pixma_find_scanners (conf_devices, SANE_FALSE);
if (nscanners == 0) if (nscanners == 0)
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
if (name[0] == '\0') if (name[0] == '\0')

Wyświetl plik

@ -45,6 +45,9 @@
#ifndef PIXMA_H #ifndef PIXMA_H
#define PIXMA_H #define PIXMA_H
#include "../include/sane/sane.h"
/*! /*!
* \mainpage Scanner driver for Canon PIXMA MP series * \mainpage Scanner driver for Canon PIXMA MP series
* \section example Sample code for application * \section example Sample code for application
@ -404,7 +407,7 @@ void pixma_set_debug_level (int level);
* *
* \return The number of scanners found currently. The return value is * \return The number of scanners found currently. The return value is
* guaranteed to be valid until the next call to pixma_find_scanners(). */ * guaranteed to be valid until the next call to pixma_find_scanners(). */
int pixma_find_scanners (const char **conf_devices); int pixma_find_scanners (const char **conf_devices, SANE_Bool local_only);
/** Return the model name of the device \a devnr. */ /** Return the model name of the device \a devnr. */
const char *pixma_get_device_model (unsigned devnr); const char *pixma_get_device_model (unsigned devnr);

Wyświetl plik

@ -58,7 +58,7 @@
#include "pixma_io.h" #include "pixma_io.h"
#include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_usb.h"
#include "../include/sane/sane.h"
#ifdef __GNUC__ #ifdef __GNUC__
# define UNUSED(v) (void) v # define UNUSED(v) (void) v
@ -1164,9 +1164,9 @@ pixma_fill_gamma_table (double gamma, uint8_t * table, unsigned n)
} }
int int
pixma_find_scanners (const char **conf_devices) pixma_find_scanners (const char **conf_devices, SANE_Bool local_only)
{ {
return pixma_collect_devices (conf_devices, pixma_devices); return pixma_collect_devices (conf_devices, pixma_devices, local_only);
} }
const char * const char *

Wyświetl plik

@ -93,7 +93,7 @@ void pixma_io_cleanup (void);
* \return Number of devices found */ * \return Number of devices found */
unsigned pixma_collect_devices (const char ** conf_devices, unsigned pixma_collect_devices (const char ** conf_devices,
const struct pixma_config_t *const const struct pixma_config_t *const
pixma_devices[]); pixma_devices[], SANE_Bool local_only);
/** Get device configuration. */ /** Get device configuration. */
const struct pixma_config_t *pixma_get_device_config (unsigned devnr); const struct pixma_config_t *pixma_get_device_config (unsigned devnr);

Wyświetl plik

@ -55,6 +55,7 @@
#include "pixma_bjnp.h" #include "pixma_bjnp.h"
#include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_usb.h"
#include "../include/sane/sane.h"
#ifdef __GNUC__ #ifdef __GNUC__
@ -349,7 +350,7 @@ pixma_io_cleanup (void)
unsigned unsigned
pixma_collect_devices (const char **conf_devices, pixma_collect_devices (const char **conf_devices,
const struct pixma_config_t *const pixma_devices[]) const struct pixma_config_t *const pixma_devices[], SANE_Bool local_only)
{ {
unsigned i, j; unsigned i, j;
struct scanner_info_t *si; struct scanner_info_t *si;
@ -374,7 +375,9 @@ pixma_collect_devices (const char **conf_devices,
} }
} }
} }
sanei_bjnp_find_devices(conf_devices, attach_bjnp, pixma_devices); if (! local_only)
sanei_bjnp_find_devices(conf_devices, attach_bjnp, pixma_devices);
si = first_scanner; si = first_scanner;
while (j < nscanners) while (j < nscanners)
{ {