From: Bastian Dehn Date: Thu, 29 Feb 2024 16:14:40 +0000 (+0100) Subject: add cancel for start read and get params methods X-Git-Tag: v1.0.0^2~151 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=09b13056fd8230f81c64c211d8a05c1f156dbc7f;p=sane-kds-s2000w-net.git add cancel for start read and get params methods --- diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index f78d0cd..f3a8ba7 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -213,7 +213,6 @@ void reset_handler(handler* h) free(h->current_metadata->image); h->current_metadata->image = NULL; - h->sessionid = 0; h->state = NOTCONNECTED; h->current_scan_status->current_image_number = 1; h->current_scan_status->available_images = 0; diff --git a/src/kds_s2000w_net.c b/src/kds_s2000w_net.c index 5ae74ec..477c442 100644 --- a/src/kds_s2000w_net.c +++ b/src/kds_s2000w_net.c @@ -122,6 +122,7 @@ void _sane_kds_s2000w_net_cancel(SANE_Handle handle) debug_printf(ALL, "sane_kds_s2000w_net_cancel"); handler* h = (handler*) handle; h->read_info->cancel = 1; + kds_s2000w_handler_stop_scan(h); return; } @@ -131,6 +132,13 @@ SANE_Status _sane_kds_s2000w_net_get_parameters(SANE_Handle handle, debug_printf(ALL, "sane_kds_s2000w_net_get_parameters"); handler* h = (handler*) handle; + // cancel + if (h->read_info->cancel) { + h->read_info->cancel = 0; + reset_handler(h); + return SANE_STATUS_CANCELLED; + } + params->format = h->current_metadata->format; params->last_frame = h->current_metadata->is_last; params->bytes_per_line = h->current_metadata->bytes_per_line; @@ -156,6 +164,12 @@ SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle) { debug_printf(ALL, "sane_kds_s2000w_net_start"); handler* h = (handler*) handle; + // cancel + if (h->read_info->cancel) { + h->read_info->cancel = 0; + reset_handler(h); + return SANE_STATUS_CANCELLED; + } if (!h->read_info->scan_started) { h->read_info->cancel = 0; @@ -182,10 +196,11 @@ SANE_Status _sane_kds_s2000w_net_read(SANE_Handle handle, SANE_Byte* data, { debug_printf(ALL, "sane_kds_s2000w_net_read"); handler* h = (handler*) handle; + // cancel if (h->read_info->cancel) { + h->read_info->cancel = 0; reset_handler(h); - kds_s2000w_handler_stop_scan(h); *length = 0; return SANE_STATUS_CANCELLED; }