Jeremy White : sane.ds: Revise the logic around processing events to reflect the need for us to generate and post a message to drive Sane events .

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


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

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

sane.ds: Revise the logic around processing events to reflect the need for us to generate and post a message to drive Sane events.

---

 dlls/sane.ds/ds_ctrl.c |   40 ++++++++++++++++++++--------------------
 dlls/sane.ds/sane_i.h  |    4 ++--
 dlls/sane.ds/ui.c      |    6 ++++--
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/dlls/sane.ds/ds_ctrl.c b/dlls/sane.ds/ds_ctrl.c
index 2c8d312..2b90e9f 100644
--- a/dlls/sane.ds/ds_ctrl.c
+++ b/dlls/sane.ds/ds_ctrl.c
@@ -292,30 +292,25 @@ TW_UINT16 SANE_FileSystemRename (pTW_IDENTITY pOrigin,
 TW_UINT16 SANE_ProcessEvent (pTW_IDENTITY pOrigin, 
                               TW_MEMREF pData)
 {
-    TW_UINT16 twRC = TWRC_SUCCESS;
+    TW_UINT16 twRC = TWRC_NOTDSEVENT;
     pTW_EVENT pEvent = (pTW_EVENT) pData;
+    MSG *pMsg = pEvent->pEvent;
 
-    TRACE("DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT\n");
+    TRACE("DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT  msg 0x%x, wParam 0x%lx\n", pMsg->message, pMsg->wParam);
 
-    if (activeDS.currentState < 5 || activeDS.currentState > 7)
+    activeDS.twCC = TWCC_SUCCESS;
+    if (pMsg->message == activeDS.windowMessage && activeDS.windowMessage)
     {
-        twRC = TWRC_FAILURE;
-        activeDS.twCC = TWCC_SEQERROR;
+        twRC = TWRC_DSEVENT;
+        pEvent->TWMessage = pMsg->wParam;
     }
     else
+        pEvent->TWMessage = MSG_NULL;  /* no message to the application */
+
+    if (activeDS.currentState < 5 || activeDS.currentState > 7)
     {
-        if (activeDS.pendingEvent.TWMessage != MSG_NULL)
-        {
-            pEvent->TWMessage = activeDS.pendingEvent.TWMessage;
-            activeDS.pendingEvent.TWMessage = MSG_NULL;
-            twRC = TWRC_NOTDSEVENT;
-        }
-        else
-        {
-            pEvent->TWMessage = MSG_NULL;  /* no message to the application */
-            twRC = TWRC_NOTDSEVENT;
-        }
-        activeDS.twCC = TWCC_SUCCESS;
+        twRC = TWRC_FAILURE;
+        activeDS.twCC = TWCC_SEQERROR;
     }
 
     return twRC;
@@ -355,7 +350,8 @@ TW_UINT16 SANE_PendingXfersEndXfer (pTW_IDENTITY pOrigin,
         {
             activeDS.currentState = 5;
             /* Notify the application that it can close the data source */
-            activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ;
+            if (activeDS.windowMessage)
+                PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0);
         }
         twRC = TWRC_SUCCESS;
         activeDS.twCC = TWCC_SUCCESS;
@@ -578,6 +574,8 @@ TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin,
     else
     {
         activeDS.hwndOwner = pUserInterface->hParent;
+        if (! activeDS.windowMessage)
+            activeDS.windowMessage = RegisterWindowMessageA("SANE.DS ACTIVITY MESSAGE");
         if (pUserInterface->ShowUI)
         {
             BOOL rc;
@@ -586,7 +584,8 @@ TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin,
             rc = DoScannerUI();
             if (!rc)
             {
-                activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ;
+                if (activeDS.windowMessage)
+                    PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0);
             }
 #ifdef SONAME_LIBSANE
             else
@@ -599,8 +598,9 @@ TW_UINT16 SANE_EnableDSUserInterface (pTW_IDENTITY pOrigin,
         else
         {
             /* no UI will be displayed, so source is ready to transfer data */
-            activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
             activeDS.currentState = 6; /* Transitions to state 6 directly */
+            if (activeDS.windowMessage)
+                PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_XFERREADY, 0);
         }
 
         activeDS.hwndOwner = pUserInterface->hParent;
diff --git a/dlls/sane.ds/sane_i.h b/dlls/sane.ds/sane_i.h
index 3c123d0..5a3a6d0 100644
--- a/dlls/sane.ds/sane_i.h
+++ b/dlls/sane.ds/sane_i.h
@@ -48,6 +48,7 @@ MAKE_FUNCPTR(sane_strstatus)
 
 #include "windef.h"
 #include "winbase.h"
+#include "winuser.h"
 #include "twain.h"
 
 extern HINSTANCE SANE_instance;
@@ -58,8 +59,7 @@ struct tagActiveDS
     struct tagActiveDS	*next;			/* next active DS */
     TW_IDENTITY		identity;		/* identity */
     TW_UINT16		currentState;		/* current state */
-    TW_EVENT		pendingEvent;		/* pending event to be sent to
-                                                   application */
+    UINT                windowMessage;          /* message to use to send status */
     TW_UINT16		twCC;			/* condition code */
     HWND		hwndOwner;		/* window handle of the app */
     HWND		progressWnd;		/* window handle of the scanning window */
diff --git a/dlls/sane.ds/ui.c b/dlls/sane.ds/ui.c
index 236a91d..31b5152 100644
--- a/dlls/sane.ds/ui.c
+++ b/dlls/sane.ds/ui.c
@@ -996,11 +996,13 @@ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
                         if (psn->lParam == TRUE)
                         {
                             activeDS.currentState = 6;
-                            activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
+                            if (activeDS.windowMessage)
+                                PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_XFERREADY, 0);
                         }
                         break;
                     case PSN_QUERYCANCEL:
-                        activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ;
+                        if (activeDS.windowMessage)
+                            PostMessageA(activeDS.hwndOwner, activeDS.windowMessage, MSG_CLOSEDSREQ, 0);
                         break;
                     case PSN_SETACTIVE:
                         InitializeDialog(hwndDlg);




More information about the wine-cvs mailing list