Jeremy White : sane.ds: Add partial stub support for ICAP_PIXELTYPE, with tests. Fixes a first crash in Adobe Acrobat scanning support.

Alexandre Julliard julliard at winehq.org
Tue Feb 10 07:45:31 CST 2009


Module: wine
Branch: master
Commit: 272c1881dd813d8b1111482ea984fdd126fde139
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=272c1881dd813d8b1111482ea984fdd126fde139

Author: Jeremy White <jwhite at winehq.org>
Date:   Mon Feb  9 13:01:27 2009 -0600

sane.ds: Add partial stub support for ICAP_PIXELTYPE, with tests. Fixes a first crash in Adobe Acrobat scanning support.

---

 dlls/sane.ds/capability.c |   53 ++++++++++++++++++++++++++++++++++++++++++++-
 dlls/sane.ds/sane_i.h     |    1 +
 dlls/twain_32/tests/dsm.c |    4 ++-
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/dlls/sane.ds/capability.c b/dlls/sane.ds/capability.c
index e68bc80..84d6b40 100644
--- a/dlls/sane.ds/capability.c
+++ b/dlls/sane.ds/capability.c
@@ -125,7 +125,8 @@ static TW_UINT16 msg_get_enum(pTW_CAPABILITY pCapability, const TW_UINT32 *value
 static TW_UINT16 TWAIN_GetSupportedCaps(pTW_CAPABILITY pCapability)
 {
     TW_ARRAY *a;
-    static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT, ICAP_XFERMECH };
+    static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT,
+                    ICAP_XFERMECH, ICAP_PIXELTYPE };
 
     pCapability->hContainer = GlobalAlloc (0, FIELD_OFFSET( TW_ARRAY, ItemList[sizeof(supported_caps)] ));
     pCapability->ConType = TWON_ARRAY;
@@ -235,6 +236,52 @@ static TW_UINT16 SANE_CAPXferCount (pTW_CAPABILITY pCapability, TW_UINT16 action
     return twCC;
 }
 
+/* ICAP_PIXELTYPE */
+static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 action)
+{
+    static const TW_UINT32 possible_values[] = { TWPT_BW, TWPT_GRAY, TWPT_RGB };
+    TW_UINT32 val;
+    TW_UINT16 twCC = TWCC_BADCAP;
+
+    TRACE("ICAP_PIXELTYPE\n");
+
+    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 = msg_get_enum(pCapability, possible_values, sizeof(possible_values) / sizeof(possible_values[0]),
+                    TWTY_UINT16, activeDS.capXferMech, TWPT_BW);
+            break;
+
+        case MSG_SET:
+            twCC = msg_set(pCapability, &val);
+            if (twCC == TWCC_SUCCESS)
+            {
+               activeDS.capPixelType = (TW_UINT16) val;
+               FIXME("Partial Stub:  PIXELTYPE set to %d, but ignored\n", val);
+            }
+            break;
+
+        case MSG_GETDEFAULT:
+            twCC = set_onevalue(pCapability, TWTY_UINT16, TWPT_BW);
+            break;
+
+        case MSG_RESET:
+            activeDS.capPixelType = TWPT_BW;
+            /* .. fall through intentional .. */
+
+        case MSG_GETCURRENT:
+            twCC = set_onevalue(pCapability, TWTY_UINT16, activeDS.capPixelType);
+            break;
+    }
+
+    return twCC;
+}
+
 TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
 {
     TW_UINT16 twCC = TWCC_CAPUNSUPPORTED;
@@ -254,6 +301,10 @@ TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
             twCC = SANE_CAPXferCount (pCapability, action);
             break;
 
+        case ICAP_PIXELTYPE:
+            twCC = SANE_ICAPPixelType (pCapability, action);
+            break;
+
         case ICAP_XFERMECH:
             twCC = SANE_ICAPXferMech (pCapability, action);
             break;
diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h
index badb4db..3c123d0 100644
--- a/dlls/sane.ds/sane_i.h
+++ b/dlls/sane.ds/sane_i.h
@@ -72,6 +72,7 @@ struct tagActiveDS
 #endif
     /* Capabilities */
     TW_UINT16		capXferMech;		/* ICAP_XFERMECH */
+    TW_UINT16		capPixelType;		/* ICAP_PIXELTYPE */
 } activeDS;
 
 /* Helper functions */
diff --git a/dlls/twain_32/tests/dsm.c b/dlls/twain_32/tests/dsm.c
index 231edff..92e322b 100644
--- a/dlls/twain_32/tests/dsm.c
+++ b/dlls/twain_32/tests/dsm.c
@@ -341,8 +341,10 @@ static void test_single_source(TW_IDENTITY *appid, TW_IDENTITY *source)
         ok(capabilities[ICAP_BITDEPTH], "ICAP_BITDEPTH not supported\n");
         todo_wine
         ok(capabilities[ICAP_BITORDER], "ICAP_BITORDER not supported\n");
-        todo_wine
         ok(capabilities[ICAP_PIXELTYPE], "ICAP_PIXELTYPE not supported\n");
+        if (capabilities[ICAP_PIXELTYPE])
+            test_onevalue_cap(appid, source, ICAP_PIXELTYPE, TWTY_UINT16,
+                TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET);
         todo_wine
         ok(capabilities[ICAP_UNITS], "ICAP_UNITS not supported\n");
         ok(capabilities[ICAP_XFERMECH], "ICAP_XFERMECH not supported\n");




More information about the wine-cvs mailing list