]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add cancel for start read and get params methods
authorBastian Dehn <hhaalo@arcor.de>
Thu, 29 Feb 2024 16:14:40 +0000 (17:14 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 29 Feb 2024 16:14:40 +0000 (17:14 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_net.c

index f78d0cd4d35da65b3400d94f217a77fb69e639b9..f3a8ba79fd2ea0337da4ad81876a9c2fbc723f8b 100644 (file)
@@ -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;
index 5ae74ec8732988c4111bba4902e667b6232ce121..477c442ffa82733282e403a68043aa1bca7b7111 100644 (file)
@@ -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;
        }