Skip to content

Commit

Permalink
Added option to use device network name instead of hardware model name
Browse files Browse the repository at this point in the history
    If there are many devices around, "Scanner on a second floor" may be
    much more informative that "Kyocera ECOSYS M2040dn"

    Formally it violates SANE Standard, that is why it is made
    configurable
  • Loading branch information
alexpevzner committed Dec 31, 2019
1 parent 3e647e1 commit 102c1cf
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
8 changes: 8 additions & 0 deletions airscan-conf.c
Expand Up @@ -713,6 +713,14 @@ conf_load_from_ini (inifile *ini)
} else {
conf_perror(rec, "usage: discovery = enable | disable");
}
} else if (inifile_match_name(rec->variable, "model")) {
if (inifile_match_name(rec->value, "network")) {
conf.model_is_netname = true;
} else if (inifile_match_name(rec->value, "hardware")) {
conf.model_is_netname = false;
} else {
conf_perror(rec, "usage: model = network | hardware");
}
}
} else if (inifile_match_name(rec->section, "debug")) {
if (inifile_match_name(rec->variable, "trace")) {
Expand Down
9 changes: 7 additions & 2 deletions airscan-device.c
Expand Up @@ -1019,8 +1019,13 @@ device_list_get (void)
dev_list[i] = info;

info->name = g_strdup(devices[i]->name);
info->vendor = g_strdup(devices[i]->opt.caps.vendor);
info->model = g_strdup(devices[i]->opt.caps.model);
if (conf.model_is_netname) {
info->vendor = g_strdup("AirScan");
info->model = g_strdup(devices[i]->name);
} else {
info->vendor = g_strdup(devices[i]->opt.caps.vendor);
info->model = g_strdup(devices[i]->opt.caps.model);
}
info->type = "eSCL network scanner";
}

Expand Down
12 changes: 12 additions & 0 deletions airscan.conf
Expand Up @@ -28,10 +28,22 @@
#"Some Bas Scanner" = disable

# Various options
#
# If there are are a lot of scanners on LAN, but you are only interested in
# few of them, you may disable automatic discovery and configure scanners
# manually
# discovery = enable -- enables automatic discovery of scanners (default)
# discovery = disable -- disables scanners discovery
#
# Scanner "model" is a string that most of SANE apps display in a list
# of devices. By specification, it must be hardware model, but for
# networking scanners it may be must more convenient to show scanner's
# network name instead
# model = network -- use network device name (default)
# model = hardware -- use hardware model name
[options]
#discovery = disable
#model = network

# Configuration of debug facilities
# trace = path -- enables protocol trace and configures
Expand Down
11 changes: 6 additions & 5 deletions airscan.h
Expand Up @@ -98,13 +98,14 @@ struct conf_device {
/* Backend configuration
*/
typedef struct {
bool dbg_enabled; /* Debugging enabled */
const char *dbg_trace; /* Trace directory */
conf_device *devices; /* Manually configured devices */
bool discovery; /* Scanners discovery enabled */
bool dbg_enabled; /* Debugging enabled */
const char *dbg_trace; /* Trace directory */
conf_device *devices; /* Manually configured devices */
bool discovery; /* Scanners discovery enabled */
bool model_is_netname; /* Use network name instead of model */
} conf_data;

#define CONF_INIT { false, NULL, NULL, true }
#define CONF_INIT { false, NULL, NULL, true, true }

extern conf_data conf;

Expand Down
9 changes: 8 additions & 1 deletion sane-airscan.5
Expand Up @@ -121,7 +121,14 @@ Miscellaneous options all goes to the \fB[options]\fR section\. Currently the fo
.nf

[options]
discovery = enable | disabele ; Enable or disable devices discovery
; If there are a lot of scanners around and you are only
; interested if few of them, disable auto discovery and
; configure scanners manually
discovery = enable | disable

; Choose what SANE apps will show in a list of devices:
; scanner network (the default) name or hardware model name
model = network | hardware
.
.fi
.
Expand Down

0 comments on commit 102c1cf

Please sign in to comment.