]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change laod options with config name
authorBastian Dehn <hhaalo@arcor.de>
Mon, 22 Sep 2025 13:34:07 +0000 (15:34 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 22 Sep 2025 13:34:07 +0000 (15:34 +0200)
src/kds_s2000w_handler_opts.c

index 2e7ae7cf6cfd8710af52834e0c8cbc5d8fed52ba..cbb74109ca4733f485d522ae322f4f8e696c4db2 100644 (file)
@@ -243,29 +243,28 @@ void _kds_s2000w_handler_opts_set_enable_color_drop_out_aggressiveness(json_obje
        color_drop_out_aggressiveness->cap &= ~SANE_CAP_SOFT_SELECT;
 }
 
-void _kds_s2000w_handler_opts_set_info_option(uint32_t option, int32_t* info) {
+void _kds_s2000w_handler_opts_set_info_option(option_descriptor* descriptor, int32_t* info) {
        if (info == NULL)
                return;
 
-       switch (option) {
-       case 3:
+       if (strcmp(descriptor->config_name, COLOR_MODE) == 0) {
                *info = RELOAD_PARAMS;
-               break;
-       case 7:
-       case 8:
-       case 14:
-       case 16:
-       case 19:
-       case 21:
-       case 24:
+               return;
+       }
+
+       if (strcmp(descriptor->config_name, CROPPING_MODE) == 0
+               || strcmp(descriptor->config_name, CROPPING_IMAGE) == 0
+               || strcmp(descriptor->config_name, FOREGROUND_BOLDNESS_MODE) == 0
+               || strcmp(descriptor->config_name, BACKGROUND_SMOOTHING_MODE) == 0
+               || strcmp(descriptor->config_name, COLOR_DROP_OUT) == 0
+               || strcmp(descriptor->config_name, COLOR_AUTO_BRIGHTNESS_MODE) == 0
+               || strcmp(descriptor->config_name, COLOR_BALANCE_MODE) == 0) {
                *info = RELOAD_OPTIONS;
-               break;
-       case 31:
-               *info = RELOAD_OPTIONS | RELOAD_PARAMS;
-               break;
-       default:
-               break;
+               return;
        }
+
+       if (strcmp(descriptor->config_name, RESET) == 0)
+               *info = RELOAD_OPTIONS | RELOAD_PARAMS;
 }
 
 void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value, int32_t* info)
@@ -347,8 +346,7 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
        value_object = json_object_object_get(config, descriptor->config_name);
        _kds_s2000w_handler_opts_write_value_to_json(value_object, descriptor->descriptor.type, value);
 
-       switch(option) {
-       case 2:
+       if (strcmp(descriptor->config_name, COLOR_MODE) == 0) {
                if (strcmp(value, "Flatbed") == 0)
                        h->current_scan_status->feeder = Flatbed;
 
@@ -357,32 +355,34 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
 
                if (strcmp(value, "Automatic") == 0)
                        h->current_scan_status->feeder = Automatic;
+       }
 
-               break;
-       case 7:
+       if (strcmp(descriptor->config_name, CROPPING_MODE) == 0) {
                _kds_s2000w_handler_opts_set_enable_cropping_image(config);
                _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(config);
-               break;
-       case 8:
+       }
+
+       if (strcmp(descriptor->config_name, CROPPING_IMAGE) == 0)
                _kds_s2000w_handler_opts_set_enable_suboptions_cropping_image(config);
-               break;
-       case 14:
+
+       if (strcmp(descriptor->config_name, FOREGROUND_BOLDNESS_MODE) == 0)
                _kds_s2000w_handler_opts_set_enable_boldness_aggressiveness(config);
-               break;
-       case 16:
+
+       if (strcmp(descriptor->config_name, BACKGROUND_SMOOTHING_MODE) == 0)
                _kds_s2000w_handler_opts_set_enable_smoothing_aggressiveness(config);
-               break;
-       case 19:
+
+       if (strcmp(descriptor->config_name, COLOR_DROP_OUT) == 0)
                _kds_s2000w_handler_opts_set_enable_color_drop_out_aggressiveness(config);
-               break;
-       case 21:
+
+       if (strcmp(descriptor->config_name, COLOR_AUTO_BRIGHTNESS_MODE) == 0)
                _kds_s2000w_handler_opts_set_enable_color_brightness_and_contrast(config);
-               break;
-       case 24:
+
+       if (strcmp(descriptor->config_name, COLOR_BALANCE_MODE) == 0) {
                _kds_s2000w_handler_opts_set_enable_color_balance(config);
                _kds_s2000w_handler_opts_set_enable_color_aggressiveness(config);
-               break;
-       case 31:
+       }
+
+       if (strcmp(descriptor->config_name, RESET) == 0) {
                _kds_s2000w_handler_opts_set_option_to_default(h);
                config = json_object_object_get(h->current_scanner_config, "Configuration");
 
@@ -395,11 +395,8 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value
                _kds_s2000w_handler_opts_set_enable_color_brightness_and_contrast(config);
                _kds_s2000w_handler_opts_set_enable_color_aggressiveness(config);
                _kds_s2000w_handler_opts_set_enable_color_balance(config);
-               break;
-       default:
-               break;
        }
 
-       _kds_s2000w_handler_opts_set_info_option(option, info);
+       _kds_s2000w_handler_opts_set_info_option(descriptor, info);
        _kds_s2000w_handler_opts_set_options(h);
 }
\ No newline at end of file