From cf94e585f54cee1b0e9f91290cf5f26525106e3c Mon Sep 17 00:00:00 2001 From: Thierry HUCHARD Date: Sun, 15 Mar 2020 16:57:14 +0100 Subject: [PATCH] Full definition of ADF support. --- backend/escl/escl.h | 1 + backend/escl/escl_capabilities.c | 9 +++++++++ backend/escl/escl_newjob.c | 34 +++++++++++++++----------------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/backend/escl/escl.h b/backend/escl/escl.h index 8df47e861..79ca2b594 100644 --- a/backend/escl/escl.h +++ b/backend/escl/escl.h @@ -124,6 +124,7 @@ typedef struct capst int RiskyRightMargin; int RiskyTopMargin; int RiskyBottomMargin; + int duplex; } caps_t; typedef struct capabilities diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c index b7b9b3791..8789b3447 100644 --- a/backend/escl/escl_capabilities.c +++ b/backend/escl/escl_capabilities.c @@ -327,12 +327,21 @@ print_xml_c(xmlNode *node, capabilities_t *scanner, int type) scanner->Sources = char_to_array(scanner->Sources, &scanner->SourcesSize, (SANE_String_Const)"Platen", 0); scanner->source = PLATEN; print_xml_c(node->children, scanner, PLATEN); + scanner->caps[scanner->source].duplex = 0; } else if (!strcmp((const char *)node->name, "AdfSimplexInputCaps")) { scanner->Sources = char_to_array(scanner->Sources, &scanner->SourcesSize, (SANE_String_Const)"Feeder", 0); if (scanner->source == -1) scanner->source = ADFSIMPLEX; print_xml_c(node->children, scanner, ADFSIMPLEX); + scanner->caps[scanner->source].duplex = 0; } + else if (!strcmp((const char *)node->name, "AdfDuplexInputCaps")) { + scanner->Sources = char_to_array(scanner->Sources, &scanner->SourcesSize, (SANE_String_Const)"Feeder", 0); + if (scanner->source == -1) scanner->source = ADFDUPLEX; + print_xml_c(node->children, scanner, ADFDUPLEX); + scanner->caps[scanner->source].duplex = 1; + } + AdfDuplexInputCap else print_xml_c(node->children, scanner, type); node = node->next; diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c index 20311ccf4..7049326a2 100644 --- a/backend/escl/escl_newjob.c +++ b/backend/escl/escl_newjob.c @@ -69,17 +69,10 @@ static const char settings[] = " %d" \ " %d" \ " %s" \ + " i%s" \ + "%s" \ ""; -static char formatExtJPEG[] = - " image/jpeg"; - -static char formatExtPNG[] = - " image/png"; - -static char formatExtTIFF[] = - " image/tiff"; - /** * \fn static size_t download_callback(void *str, size_t size, size_t nmemb, void *userp) * \brief Callback function that stocks in memory the content of the 'job'. Example below : @@ -144,6 +137,7 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu char *temporary = NULL; char *f_ext = ""; char *format_ext = NULL; + char duplex_mode[1024] = { 0 }; *status = SANE_STATUS_GOOD; if (name == NULL || scanner == NULL) { @@ -167,17 +161,19 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu curl_handle = curl_easy_init(); if (scanner->caps[scanner->source].format_ext == 1) { - if (!strcmp(scanner->caps[scanner->source].default_format, "image/jpeg")) - format_ext = formatExtJPEG; - else if (!strcmp(scanner->caps[scanner->source].default_format, "image/png")) - format_ext = formatExtPNG; - else if (!strcmp(scanner->caps[scanner->source].default_format, "image/tiff")) - format_ext = formatExtTIFF; - else - format_ext = f_ext; + char f_ext_tmp[1024]; + snprintf(f_ext_tmp, sizeof(f_ext_tmp), + " %s", + scanner->caps[scanner->source].default_format); + format_ext = f_exti_tmp; } else format_ext = f_ext; + if(!strcmp(scanner->Sources[scanner->source], "Feeder")) { + snprintf(duplex_mode, sizeof(duplex_mode), + " %s", + scanner->caps[scanner->source].duplex ? "true" : "false"); + } DBG( 1, "Create NewJob : %s\n", scanner->caps[scanner->source].default_format); if (curl_handle != NULL) { snprintf(cap_data, sizeof(cap_data), settings, @@ -190,7 +186,9 @@ escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *statu scanner->caps[scanner->source].default_color, scanner->caps[scanner->source].default_resolution, scanner->caps[scanner->source].default_resolution, - scanner->Sources[scanner->source]); + scanner->Sources[scanner->source], + scanner->Sources[scanner->source], + duplex_mode[0] == 0 ? "" : duplex_mode); DBG( 1, "Create NewJob : %s\n", cap_data); upload->read_data = strdup(cap_data); upload->size = strlen(cap_data);