]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add option descriptor post scan rotation
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 07:39:05 +0000 (08:39 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Feb 2025 07:39:05 +0000 (08:39 +0100)
src/kds_s2000w_option_descriptors.c
tests/kds_s2000w_option_descriptor_tests.c

index fd8cf321ae51ea59c9a0d3668e6f3c8210ae727a..ebba09af51ca47d539fac62e2ea5b3b3176e708a 100644 (file)
@@ -3,7 +3,7 @@
 #include "kds_s2000w_option_descriptors.h"
 #include "kds_s2000w_debug.h"
 
-#define MAX_OPTION_COUNT 25
+#define MAX_OPTION_COUNT 26
 
 SANE_Option_Descriptor* descriptor_array = NULL;
 
@@ -29,6 +29,7 @@ SANE_String_Const* constraint_scan_source = NULL;
 SANE_String_Const* constraint_color_sharpen = NULL;
 SANE_String_Const* constraint_multifeed_sensitivity = NULL;
 SANE_String_Const* constraint_multifeed_response = NULL;
+SANE_String_Const* constraint_post_scan_rotation = NULL;
 
 SANE_Option_Descriptor _kds_s2000w_option_descriptor_standard_group()
 {
@@ -572,6 +573,33 @@ SANE_Option_Descriptor _kds_s2000w_option_descriptor_multifeed_response()
        return descriptor;
 }
 
+SANE_Option_Descriptor _kds_s2000w_option_descriptor_post_scan_rotation()
+{
+       kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_post_scan_rotation");
+
+       constraint_post_scan_rotation = malloc(sizeof(SANE_String_Const*) * 6);
+       constraint_post_scan_rotation[0] = "None";
+       constraint_post_scan_rotation[1] = "Automatic";
+       constraint_post_scan_rotation[2] = "Automatic90";
+       constraint_post_scan_rotation[3] = "Automatic180";
+       constraint_post_scan_rotation[4] = "Automatic270";
+       constraint_post_scan_rotation[5] = NULL;
+
+       SANE_Option_Descriptor descriptor = {
+               "post-scan-rotation",
+               "Post Scan Rotation",
+               "Post Scan Rotation",
+               SANE_TYPE_STRING,
+               SANE_UNIT_NONE,
+               sizeof(SANE_String_Const*) * 6,
+               SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT,
+               SANE_CONSTRAINT_STRING_LIST,
+               {.string_list = constraint_post_scan_rotation}
+       };
+
+       return descriptor;
+}
+
 void kds_s2000w_option_descriptors_init()
 {
        kds_s2000w_debug_printf(ALL, "kds_s2000w_option_descriptor_init_option_descriptors");
@@ -601,7 +629,8 @@ void kds_s2000w_option_descriptors_init()
        descriptor_array[21] = _kds_s2000w_option_descriptor_binarization_contrast();
        descriptor_array[22] = _kds_s2000w_option_descriptor_multifeed_sensitivity();
        descriptor_array[23] = _kds_s2000w_option_descriptor_multifeed_response();
-       descriptor_array[24] = _kds_s2000w_option_descriptor_config_reset();
+       descriptor_array[24] = _kds_s2000w_option_descriptor_post_scan_rotation();
+       descriptor_array[25] = _kds_s2000w_option_descriptor_config_reset();
 }
 
 void kds_s2000w_option_descriptors_free()
@@ -634,6 +663,8 @@ void kds_s2000w_option_descriptors_free()
        constraint_multifeed_sensitivity = NULL;
        free(constraint_multifeed_response);
        constraint_multifeed_response = NULL;
+       free(constraint_post_scan_rotation);
+       constraint_post_scan_rotation = NULL;
        free(descriptor_array);
        descriptor_array = NULL;
 }
index 056e18e3c6fbe9d77fda9973b45d09fdadec3aa6..abaf57e5692270267509d800a327f258a8f337ee 100644 (file)
@@ -4,7 +4,7 @@
 #include "kds_s2000w_client_mock.h"
 #include "../src/kds_s2000w_option_descriptors.h"
 
-#define MAX_OPTION_COUNT 25
+#define MAX_OPTION_COUNT 26
 
 int setup(void** state)
 {
@@ -439,6 +439,26 @@ void kds_s2000w_option_get_descriptor_twentyfour_test()
 {
        SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(24);
 
+       assert_string_equal("post-scan-rotation", option->name);
+       assert_string_equal("Post Scan Rotation", option->title);
+       assert_string_equal("Post Scan Rotation", option->desc);
+       assert_int_equal(SANE_TYPE_STRING, option->type);
+       assert_int_equal(SANE_UNIT_NONE, option->unit);
+       assert_int_equal(sizeof(SANE_String_Const*) * 6, option->size);
+       assert_int_equal(SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT, option->cap);
+       assert_int_equal(SANE_CONSTRAINT_STRING_LIST, option->constraint_type);
+       assert_string_equal("None", option->constraint.string_list[0]);
+       assert_string_equal("Automatic", option->constraint.string_list[1]);
+       assert_string_equal("Automatic90", option->constraint.string_list[2]);
+       assert_string_equal("Automatic180", option->constraint.string_list[3]);
+       assert_string_equal("Automatic270", option->constraint.string_list[4]);
+       assert_null(option->constraint.string_list[5]);
+}
+
+void kds_s2000w_option_get_descriptor_twentyfive_test()
+{
+       SANE_Option_Descriptor* option = kds_s2000w_option_descriptors_get(25);
+
        assert_string_equal("config-reset", option->name);
        assert_string_equal("reset config", option->title);
        assert_string_equal("load default configuration from scanner", option->desc);