Module: wine Branch: master Commit: 28b708ca9eb14a4c8c3151158569ff3a50cf93b7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=28b708ca9eb14a4c8c31511585...
Author: Jeremy White jwhite@codeweavers.com Date: Thu Mar 5 13:15:20 2009 -0600
sane.ds: Add support for CAP_FEEDERENABLED.
---
dlls/sane.ds/capability.c | 87 ++++++++++++++++++++++++++++++++++++++++++++- dlls/sane.ds/options.c | 15 ++++++++ dlls/sane.ds/sane_i.h | 1 + dlls/twain_32/tests/dsm.c | 3 ++ 4 files changed, 105 insertions(+), 1 deletions(-)
diff --git a/dlls/sane.ds/capability.c b/dlls/sane.ds/capability.c index 7a37399..ee2d5dd 100644 --- a/dlls/sane.ds/capability.c +++ b/dlls/sane.ds/capability.c @@ -166,7 +166,7 @@ static TW_UINT16 TWAIN_GetSupportedCaps(pTW_CAPABILITY pCapability) { TW_ARRAY *a; static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT, CAP_UICONTROLLABLE, - CAP_AUTOFEED, + CAP_AUTOFEED, CAP_FEEDERENABLED, ICAP_XFERMECH, ICAP_PIXELTYPE, ICAP_UNITS, ICAP_BITDEPTH, ICAP_COMPRESSION, ICAP_PIXELFLAVOR, ICAP_XRESOLUTION, ICAP_YRESOLUTION, ICAP_PHYSICALHEIGHT, ICAP_PHYSICALWIDTH };
@@ -881,6 +881,80 @@ static TW_UINT16 SANE_CAPAutofeed (pTW_CAPABILITY pCapability, TW_UINT16 action) return twCC; }
+/* CAP_FEEDERENABLED */ +static TW_UINT16 SANE_CAPFeederEnabled (pTW_CAPABILITY pCapability, TW_UINT16 action) +{ + TW_UINT16 twCC = TWCC_BADCAP; +#ifdef SONAME_LIBSANE + TW_UINT32 val; + TW_BOOL enabled; + SANE_Status status; + SANE_Char source[64]; + + TRACE("CAP_FEEDERENABLED\n"); + + if (sane_option_get_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, sizeof(source), NULL) != SANE_STATUS_GOOD) + return TWCC_BADCAP; + + if (strcmp(source, "Auto") == 0 || strcmp(source, "ADF") == 0) + enabled = TRUE; + else + enabled = FALSE; + + switch (action) + { + case MSG_QUERYSUPPORT: + twCC = set_onevalue(pCapability, TWTY_INT32, + TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET ); + break; + + case MSG_GET: + twCC = set_onevalue(pCapability, TWTY_BOOL, enabled); + break; + + case MSG_SET: + twCC = msg_set(pCapability, &val); + if (twCC == TWCC_SUCCESS) + { + if (val) + enabled = TRUE; + else + enabled = FALSE; + + strcpy(source, "ADF"); + status = sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL); + if (status != SANE_STATUS_GOOD) + { + strcpy(source, "Auto"); + status = sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL); + } + if (status != SANE_STATUS_GOOD) + { + ERR("Error %s: Could not set source to either ADF or Auto\n", psane_strstatus(status)); + return sane_status_to_twcc(status); + } + } + break; + + case MSG_GETDEFAULT: + twCC = set_onevalue(pCapability, TWTY_BOOL, TRUE); + break; + + case MSG_RESET: + strcpy(source, "Auto"); + if (sane_option_set_str(activeDS.deviceHandle, SANE_NAME_SCAN_SOURCE, source, NULL) == SANE_STATUS_GOOD) + enabled = TRUE; + twCC = TWCC_SUCCESS; + /* .. fall through intentional .. */ + + case MSG_GETCURRENT: + twCC = set_onevalue(pCapability, TWTY_BOOL, enabled); + break; + } +#endif + return twCC; +} +
TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action) @@ -910,6 +984,10 @@ TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action) twCC = SANE_CAPAutofeed (pCapability, action); break;
+ case CAP_FEEDERENABLED: + twCC = SANE_CAPFeederEnabled (pCapability, action); + break; + case ICAP_PIXELTYPE: twCC = SANE_ICAPPixelType (pCapability, action); break; @@ -974,5 +1052,12 @@ TW_UINT16 SANE_SaneSetDefaults (void) if (SANE_SaneCapability(&cap, MSG_RESET) == TWCC_SUCCESS) GlobalFree(cap.hContainer);
+ memset(&cap, 0, sizeof(cap)); + cap.Cap = CAP_FEEDERENABLED; + cap.ConType = TWON_DONTCARE16; + + if (SANE_SaneCapability(&cap, MSG_RESET) == TWCC_SUCCESS) + GlobalFree(cap.hContainer); + return TWCC_SUCCESS; } diff --git a/dlls/sane.ds/options.c b/dlls/sane.ds/options.c index 1997abc..3fccb45 100644 --- a/dlls/sane.ds/options.c +++ b/dlls/sane.ds/options.c @@ -111,6 +111,21 @@ SANE_Status sane_option_set_bool(SANE_Handle h, const char *option_name, SANE_Bo return psane_control_option(h, optno, SANE_ACTION_SET_VALUE, (void *) &val, status); }
+SANE_Status sane_option_get_str(SANE_Handle h, const char *option_name, SANE_String val, size_t len, SANE_Int *status) +{ + SANE_Status rc; + int optno; + const SANE_Option_Descriptor *opt; + + rc = sane_find_option(h, option_name, &opt, &optno, SANE_TYPE_STRING); + if (rc != SANE_STATUS_GOOD) + return rc; + + if (opt->size < len) + return psane_control_option(h, optno, SANE_ACTION_GET_VALUE, (void *) val, status); + else + return SANE_STATUS_NO_MEM; +}
/* Important: SANE has the side effect of of overwriting val with the returned value */ SANE_Status sane_option_set_str(SANE_Handle h, const char *option_name, SANE_String val, SANE_Int *status) diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h index 81c9a9e..de2172c 100644 --- a/dlls/sane.ds/sane_i.h +++ b/dlls/sane.ds/sane_i.h @@ -224,6 +224,7 @@ HWND ScanningDialogBox(HWND dialog, LONG progress); #ifdef SONAME_LIBSANE SANE_Status sane_option_get_int(SANE_Handle h, const char *option_name, SANE_Int *val); SANE_Status sane_option_set_int(SANE_Handle h, const char *option_name, SANE_Int val, SANE_Int *status); +SANE_Status sane_option_get_str(SANE_Handle h, const char *option_name, SANE_String val, size_t len, SANE_Int *status); SANE_Status sane_option_set_str(SANE_Handle h, const char *option_name, SANE_String val, SANE_Int *status); SANE_Status sane_option_probe_resolution(SANE_Handle h, const char *option_name, SANE_Int *minval, SANE_Int *maxval, SANE_Int *quant); SANE_Status sane_option_probe_mode(SANE_Handle h, SANE_String_Const **choices, char *current, int current_size); diff --git a/dlls/twain_32/tests/dsm.c b/dlls/twain_32/tests/dsm.c index c4744f9..17c106b 100644 --- a/dlls/twain_32/tests/dsm.c +++ b/dlls/twain_32/tests/dsm.c @@ -583,6 +583,9 @@ static void test_single_source(TW_IDENTITY *appid, TW_IDENTITY *source) if (capabilities[CAP_AUTOFEED]) test_onevalue_cap(appid, source, CAP_AUTOFEED, TWTY_BOOL, TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET); + if (capabilities[CAP_FEEDERENABLED]) + test_onevalue_cap(appid, source, CAP_FEEDERENABLED, TWTY_BOOL, + TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET);
} }