JobState, if it exists, decides whether to proceed to the next page.

merge-requests/463/merge
Thierry HUCHARD 2020-05-10 22:20:30 +02:00
rodzic 70daed5132
commit dc2b9aeade
4 zmienionych plików z 60 dodań i 9 usunięć

Wyświetl plik

@ -1144,13 +1144,16 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len)
} }
else { else {
SANE_Status status = SANE_STATUS_EOF; SANE_Status status = SANE_STATUS_EOF;
SANE_Status job = SANE_STATUS_UNSUPPORTED;
*len = 0; *len = 0;
free(handler->scanner->img_data); free(handler->scanner->img_data);
handler->scanner->img_data = NULL; handler->scanner->img_data = NULL;
if (handler->scanner->source != PLATEN) { if (handler->scanner->source != PLATEN) {
SANE_Bool next_page = SANE_FALSE; SANE_Bool next_page = SANE_FALSE;
SANE_Status st = escl_status(handler->device, SANE_Status st = escl_status(handler->device,
handler->scanner->source); handler->scanner->source,
handler->result,
&job);
DBG(10, "eSCL : command returned status %s\n", sane_strstatus(st)); DBG(10, "eSCL : command returned status %s\n", sane_strstatus(st));
// Thank's Alexander Pevzner (pzz@apevzner.com) // Thank's Alexander Pevzner (pzz@apevzner.com)
switch (st) { switch (st) {
@ -1158,7 +1161,8 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len)
case SANE_STATUS_UNSUPPORTED: case SANE_STATUS_UNSUPPORTED:
case SANE_STATUS_DEVICE_BUSY: case SANE_STATUS_DEVICE_BUSY:
DBG(10, "eSCL : next page\n"); DBG(10, "eSCL : next page\n");
next_page = SANE_TRUE; if (job != SANE_STATUS_GOOD)
next_page = SANE_TRUE;
default: default:
break; break;
} }

Wyświetl plik

@ -181,7 +181,10 @@ enum
ESCL_Device *escl_devices(SANE_Status *status); ESCL_Device *escl_devices(SANE_Status *status);
SANE_Status escl_device_add(int port_nb, const char *model_name, SANE_Status escl_device_add(int port_nb, const char *model_name,
char *ip_address, char *type); char *ip_address, char *type);
SANE_Status escl_status(const ESCL_Device *device, int source); 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); capabilities_t *escl_capabilities(const ESCL_Device *device, SANE_Status *status);
char *escl_newjob(capabilities_t *scanner, const ESCL_Device *device, char *escl_newjob(capabilities_t *scanner, const ESCL_Device *device,
SANE_Status *status); SANE_Status *status);

Wyświetl plik

@ -70,7 +70,10 @@ CURL_CALL:
if (i >= 15) return; if (i >= 15) return;
} }
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);
if (SANE_STATUS_GOOD != escl_status(device, PLATEN)) if (SANE_STATUS_GOOD != escl_status(device,
PLATEN,
NULL,
NULL))
goto CURL_CALL; goto CURL_CALL;
} }
} }

Wyświetl plik

@ -84,7 +84,36 @@ find_nodes_s(xmlNode *node)
} }
static void static void
print_xml_platen_and_adf_status(xmlNode *node, SANE_Status *platen, SANE_Status *adf) print_xml_job_status(xmlNode *node,
SANE_Status *job)
{
while (node) {
if (node->type == XML_ELEMENT_NODE) {
if (find_nodes_s(node)) {
if (strcmp((const char *)node->name, "JobState") == 0) {
const char *state = (const char *)xmlNodeGetContent(node);
if (!strcmp(state, "Processing")) {
*job = SANE_STATUS_DEVICE_BUSY;
DBG(10, "jobId Processing SANE_STATUS_DEVICE_BUSY\n");
}
if (!strcmp(state, "Completed")) {
*job = SANE_STATUS_GOOD;
DBG(10, "jobId Completed SANE_STATUS_GOOD\n");
}
}
}
}
print_xml_job_status(node->children, job);
node = node->next;
}
}
static void
print_xml_platen_and_adf_status(xmlNode *node,
SANE_Status *platen,
SANE_Status *adf,
const char* jobId,
SANE_Status *job)
{ {
while (node) { while (node) {
if (node->type == XML_ELEMENT_NODE) { if (node->type == XML_ELEMENT_NODE) {
@ -104,7 +133,7 @@ print_xml_platen_and_adf_status(xmlNode *node, SANE_Status *platen, SANE_Status
} }
} }
// Thank's Alexander Pevzner (pzz@apevzner.com) // Thank's Alexander Pevzner (pzz@apevzner.com)
else if (strcmp((const char *)node->name, "AdfState") == 0) { else if (adf && strcmp((const char *)node->name, "AdfState") == 0) {
const char *state = (const char *)xmlNodeGetContent(node); const char *state = (const char *)xmlNodeGetContent(node);
if (!strcmp(state, "ScannerAdfLoaded")){ if (!strcmp(state, "ScannerAdfLoaded")){
DBG(10, "ScannerAdfLoaded SANE_STATUS_GOOD\n"); DBG(10, "ScannerAdfLoaded SANE_STATUS_GOOD\n");
@ -128,9 +157,18 @@ print_xml_platen_and_adf_status(xmlNode *node, SANE_Status *platen, SANE_Status
*adf = SANE_STATUS_UNSUPPORTED; *adf = SANE_STATUS_UNSUPPORTED;
} }
} }
else if (jobId && job && strcmp((const char *)node->name, "JobUri") == 0) {
if (strstr((const char *)xmlNodeGetContent(node), jobId)) {
print_xml_job_status(node, job);
}
}
} }
} }
print_xml_platen_and_adf_status(node->children, platen, adf); print_xml_platen_and_adf_status(node->children,
platen,
adf,
jobId,
job);
node = node->next; node = node->next;
} }
} }
@ -144,7 +182,10 @@ print_xml_platen_and_adf_status(xmlNode *node, SANE_Status *platen, SANE_Status
* \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL)
*/ */
SANE_Status SANE_Status
escl_status(const ESCL_Device *device, int source) escl_status(const ESCL_Device *device,
int source,
const char* jobId,
SANE_Status *job)
{ {
SANE_Status status = SANE_STATUS_DEVICE_BUSY; SANE_Status status = SANE_STATUS_DEVICE_BUSY;
SANE_Status platen= SANE_STATUS_DEVICE_BUSY; SANE_Status platen= SANE_STATUS_DEVICE_BUSY;
@ -186,7 +227,7 @@ escl_status(const ESCL_Device *device, int source)
} }
/* Decode Job status */ /* Decode Job status */
// Thank's Alexander Pevzner (pzz@apevzner.com) // Thank's Alexander Pevzner (pzz@apevzner.com)
print_xml_platen_and_adf_status(node, &platen, &adf); print_xml_platen_and_adf_status(node, &platen, &adf, jobId, job);
if (platen != SANE_STATUS_GOOD && if (platen != SANE_STATUS_GOOD &&
platen != SANE_STATUS_UNSUPPORTED) { platen != SANE_STATUS_UNSUPPORTED) {
status = platen; status = platen;