From: Bastian Dehn Date: Sun, 16 Feb 2025 07:39:05 +0000 (+0100) Subject: add option descriptor post scan rotation X-Git-Tag: v1.1.0^2~4^2~40 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=c9dd5e8bf88311d5610b8399b0d0cafaa3c32880;p=sane-kds-s2000w-net.git add option descriptor post scan rotation --- diff --git a/src/kds_s2000w_option_descriptors.c b/src/kds_s2000w_option_descriptors.c index fd8cf32..ebba09a 100644 --- a/src/kds_s2000w_option_descriptors.c +++ b/src/kds_s2000w_option_descriptors.c @@ -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; } diff --git a/tests/kds_s2000w_option_descriptor_tests.c b/tests/kds_s2000w_option_descriptor_tests.c index 056e18e..abaf57e 100644 --- a/tests/kds_s2000w_option_descriptor_tests.c +++ b/tests/kds_s2000w_option_descriptor_tests.c @@ -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);