]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add change output type change color
authorBastian Dehn <hhaalo@arcor.de>
Mon, 29 Jan 2024 20:34:28 +0000 (21:34 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 29 Jan 2024 20:34:28 +0000 (21:34 +0100)
src/kds_s2000w_handler.c

index 6f40472ee32678f8c001bd51538dd0c7354c74d2..e916359041f9f77ac32e7d7ef488dc601d32f698 100644 (file)
@@ -61,6 +61,22 @@ void _load_options()
        resp = NULL;
 }
 
+void _reset_output_type()
+{
+       json_object* value_object = json_object_object_get(config, "OutputType");
+       const char* reset_value_ptr = "Images";
+       _write_string_value_to_json(value_object, (void*) reset_value_ptr);
+       value_object = NULL;
+}
+
+void _color_change_to_color_bw()
+{
+       json_object* value_object = json_object_object_get(config, "ColorMode");
+       const char* reset_value_ptr = "Color_BW";
+       _write_string_value_to_json(value_object, (void*) reset_value_ptr);
+       value_object = NULL;
+}
+
 current_state* kds_s2000w_handler_open()
 {
        state = malloc(sizeof(current_state));
@@ -251,6 +267,11 @@ void kds_s2000w_handler_set_option(int option, void* value, int* info)
                case 4:
                        value_object = json_object_object_get(config, "ColorMode");
                        _write_string_value_to_json(value_object, value);
+
+                       if (strcmp((const char*) value, "Color_BW") != 0) {
+                               _reset_output_type();
+                               *info = RELOAD_OPTIONS;
+                       }
                        break;
                case 5:
                        value_object = json_object_object_get(config, "SkipBlankPages");
@@ -269,17 +290,16 @@ void kds_s2000w_handler_set_option(int option, void* value, int* info)
                        _write_int_value_to_json(value_object, value);
                        break;
                case 9:
+                       value_object = json_object_object_get(config, "OutputType");
+                       _write_string_value_to_json(value_object, value);
+                       value_object = NULL;
+
                        value_object = json_object_object_get(config, "ColorMode");
                        const char* color_mode = json_object_get_string(value_object);
                        if (strcmp(color_mode, "Color_BW") != 0) {
-                               value_object = NULL;
+                               _color_change_to_color_bw();
                                *info = RELOAD_OPTIONS;
-                               break;
                        }
-
-                       value_object = NULL;
-                       value_object = json_object_object_get(config, "OutputType");
-                       _write_string_value_to_json(value_object, value);
                        break;
                case 10:
                        value_object = json_object_object_get(config, "ColorAutoBrightnessMode");