kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'escl-devices-list-properties' into 'master'
Adds to the list of detected devices the different supported trays See merge request sane-project/backends!564escl-fix-sleep-mode
commit
adbfcd1696
|
@ -93,7 +93,9 @@ escl_free_device(ESCL_Device *current)
|
|||
free((void*)current->ip_address);
|
||||
free((void*)current->model_name);
|
||||
free((void*)current->type);
|
||||
free(current->unix_socket);
|
||||
free((void*)current->is);
|
||||
free((void*)current->uuid);
|
||||
free((void*)current->unix_socket);
|
||||
free(current);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -133,6 +135,10 @@ escl_check_and_add_device(ESCL_Device *current)
|
|||
DBG (10, "Scanner Type allocation failure.\n");
|
||||
return (SANE_STATUS_NO_MEM);
|
||||
}
|
||||
if (!current->is) {
|
||||
DBG (10, "Scanner Is allocation failure.\n");
|
||||
return (SANE_STATUS_NO_MEM);
|
||||
}
|
||||
++num_devices;
|
||||
current->next = list_devices_primary;
|
||||
list_devices_primary = current;
|
||||
|
@ -173,14 +179,20 @@ escl_add_in_list(ESCL_Device *current)
|
|||
* \return escl_add_in_list(current)
|
||||
*/
|
||||
SANE_Status
|
||||
escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type)
|
||||
escl_device_add(int port_nb,
|
||||
const char *model_name,
|
||||
char *ip_address,
|
||||
const char *is,
|
||||
const char *uuid,
|
||||
char *type)
|
||||
{
|
||||
char tmp[PATH_MAX] = { 0 };
|
||||
char *model = NULL;
|
||||
ESCL_Device *current = NULL;
|
||||
DBG (10, "escl_device_add\n");
|
||||
for (current = list_devices_primary; current; current = current->next) {
|
||||
if (strcmp(current->ip_address, ip_address) == 0)
|
||||
if ((strcmp(current->ip_address, ip_address) == 0) ||
|
||||
(uuid && current->uuid && !strcmp(current->uuid, uuid)))
|
||||
{
|
||||
if (strcmp(current->type, type))
|
||||
{
|
||||
|
@ -189,6 +201,10 @@ escl_device_add(int port_nb, const char *model_name, char *ip_address, char *typ
|
|||
{
|
||||
free (current->type);
|
||||
current->type = strdup(type);
|
||||
if (strcmp(current->ip_address, ip_address)) {
|
||||
free (current->ip_address);
|
||||
current->ip_address = strdup(ip_address);
|
||||
}
|
||||
current->port_nb = port_nb;
|
||||
current->https = SANE_TRUE;
|
||||
}
|
||||
|
@ -214,7 +230,12 @@ escl_device_add(int port_nb, const char *model_name, char *ip_address, char *typ
|
|||
model = (char*)(tmp[0] != 0 ? tmp : model_name);
|
||||
current->model_name = strdup(model);
|
||||
current->ip_address = strdup(ip_address);
|
||||
memset(tmp, 0, PATH_MAX);
|
||||
snprintf(tmp, sizeof(tmp), "%s scanner", (is ? is : "flatbed or ADF"));
|
||||
current->is = strdup(tmp);
|
||||
current->type = strdup(type);
|
||||
if (uuid)
|
||||
current->uuid = strdup(uuid);
|
||||
return escl_add_in_list(current);
|
||||
}
|
||||
|
||||
|
@ -331,7 +352,7 @@ convertFromESCLDev(ESCL_Device *cdev)
|
|||
DBG (10, "Model allocation failure.\n");
|
||||
goto freename;
|
||||
}
|
||||
sdev->type = strdup("flatbed scanner");
|
||||
sdev->type = strdup(cdev->is);
|
||||
if (!sdev->type) {
|
||||
DBG (10, "Scanner Type allocation failure.\n");
|
||||
goto freevendor;
|
||||
|
@ -443,7 +464,9 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
return status;
|
||||
}
|
||||
escl_device->model_name = opt_model ? opt_model : strdup("Unknown model");
|
||||
escl_device->type = strdup("flatbed scanner");
|
||||
escl_device->is = strdup("flatbed or ADF scanner");
|
||||
escl_device->type = strdup("In url");
|
||||
escl_device->uuid = NULL;
|
||||
}
|
||||
|
||||
if (strncmp(line, "[device]", 8) == 0) {
|
||||
|
@ -485,6 +508,8 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line,
|
|||
escl_device->type = strdup(type_space);
|
||||
}
|
||||
}
|
||||
escl_device->is = strdup("flatbed or ADF scanner");
|
||||
escl_device->uuid = NULL;
|
||||
status = escl_check_and_add_device(escl_device);
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
escl_device = NULL;
|
||||
|
|
|
@ -90,12 +90,14 @@ typedef struct {
|
|||
typedef struct ESCL_Device {
|
||||
struct ESCL_Device *next;
|
||||
|
||||
char *model_name;
|
||||
int port_nb;
|
||||
char *ip_address;
|
||||
char *type;
|
||||
char *model_name;
|
||||
int port_nb;
|
||||
char *ip_address;
|
||||
char *is;
|
||||
char *uuid;
|
||||
char *type;
|
||||
SANE_Bool https;
|
||||
char *unix_socket;
|
||||
char *unix_socket;
|
||||
} ESCL_Device;
|
||||
|
||||
typedef struct capst
|
||||
|
@ -212,35 +214,68 @@ enum
|
|||
#define MM_TO_PIXEL(millimeters, dpi) (SANE_Word)round(SANE_UNFIX(millimeters) * (dpi) / 25.4)
|
||||
|
||||
ESCL_Device *escl_devices(SANE_Status *status);
|
||||
SANE_Status escl_device_add(int port_nb, const char *model_name,
|
||||
char *ip_address, char *type);
|
||||
SANE_Status escl_device_add(int port_nb,
|
||||
const char *model_name,
|
||||
char *ip_address,
|
||||
const char *is,
|
||||
const char *uuid,
|
||||
char *type);
|
||||
|
||||
SANE_Status escl_status(const ESCL_Device *device,
|
||||
int source,
|
||||
const char* jobId,
|
||||
SANE_Status *job);
|
||||
capabilities_t *escl_capabilities(const ESCL_Device *device, SANE_Status *status);
|
||||
char *escl_newjob(capabilities_t *scanner, const ESCL_Device *device,
|
||||
SANE_Status *status);
|
||||
SANE_Status escl_scan(capabilities_t *scanner, const ESCL_Device *device,
|
||||
char *result);
|
||||
void escl_scanner(const ESCL_Device *device, char *result);
|
||||
|
||||
capabilities_t *escl_capabilities(const ESCL_Device *device,
|
||||
SANE_Status *status);
|
||||
|
||||
char *escl_newjob(capabilities_t *scanner,
|
||||
const ESCL_Device *device,
|
||||
SANE_Status *status);
|
||||
|
||||
SANE_Status escl_scan(capabilities_t *scanner,
|
||||
const ESCL_Device *device,
|
||||
char *result);
|
||||
|
||||
void escl_scanner(const ESCL_Device *device,
|
||||
char *result);
|
||||
|
||||
typedef void CURL;
|
||||
void escl_curl_url(CURL *handle, const ESCL_Device *device, SANE_String_Const path);
|
||||
|
||||
unsigned char *escl_crop_surface(capabilities_t *scanner, unsigned char *surface,
|
||||
int w, int h, int bps, int *width, int *height);
|
||||
void escl_curl_url(CURL *handle,
|
||||
const ESCL_Device *device,
|
||||
SANE_String_Const path);
|
||||
|
||||
unsigned char *escl_crop_surface(capabilities_t *scanner,
|
||||
unsigned char *surface,
|
||||
int w,
|
||||
int h,
|
||||
int bps,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
// JPEG
|
||||
SANE_Status get_JPEG_data(capabilities_t *scanner, int *width, int *height, int *bps);
|
||||
SANE_Status get_JPEG_data(capabilities_t *scanner,
|
||||
int *width,
|
||||
int *height,
|
||||
int *bps);
|
||||
|
||||
// PNG
|
||||
SANE_Status get_PNG_data(capabilities_t *scanner, int *width, int *height, int *bps);
|
||||
SANE_Status get_PNG_data(capabilities_t *scanner,
|
||||
int *width,
|
||||
int *height,
|
||||
int *bps);
|
||||
|
||||
// TIFF
|
||||
SANE_Status get_TIFF_data(capabilities_t *scanner, int *width, int *height, int *bps);
|
||||
SANE_Status get_TIFF_data(capabilities_t *scanner,
|
||||
int *width,
|
||||
int *height,
|
||||
int *bps);
|
||||
|
||||
// PDF
|
||||
SANE_Status get_PDF_data(capabilities_t *scanner, int *width, int *height, int *bps);
|
||||
SANE_Status get_PDF_data(capabilities_t *scanner,
|
||||
int *width,
|
||||
int *height,
|
||||
int *bps);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,6 +63,9 @@ resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interfac
|
|||
void __sane_unused__ *userdata)
|
||||
{
|
||||
char a[AVAHI_ADDRESS_STR_MAX], *t;
|
||||
const char *is;
|
||||
const char *uuid;
|
||||
AvahiStringList *s;
|
||||
assert(r);
|
||||
switch (event) {
|
||||
case AVAHI_RESOLVER_FAILURE:
|
||||
|
@ -70,8 +73,19 @@ resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interfac
|
|||
case AVAHI_RESOLVER_FOUND:
|
||||
avahi_address_snprint(a, sizeof(a), address);
|
||||
t = avahi_string_list_to_string(txt);
|
||||
if (strstr(t, "\"rs=eSCL\"") || strstr(t, "\"rs=/eSCL\""))
|
||||
escl_device_add(port, name, a, (char*)type);
|
||||
if (strstr(t, "\"rs=eSCL\"") || strstr(t, "\"rs=/eSCL\"")) {
|
||||
s = avahi_string_list_find(txt, "is");
|
||||
if (s && s->size > 3)
|
||||
is = (const char*)s->text + 3;
|
||||
else
|
||||
uuid = (const char*)NULL;
|
||||
s = avahi_string_list_find(txt, "uuid");
|
||||
if (s && s->size > 5)
|
||||
uuid = (const char*)s->text + 5;
|
||||
else
|
||||
uuid = (const char*)NULL;
|
||||
escl_device_add(port, name, a, is, uuid, (char*)type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue