wine/dlls/ole32 compobj_private.h defaulthandl ...

Alexandre Julliard julliard at wine.codeweavers.com
Mon Nov 28 05:04:19 CST 2005


ChangeSet ID:	21476
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/28 05:04:19

Modified files:
	dlls/ole32     : compobj_private.h defaulthandler.c oleobj.c 

Log message:
	Robert Shearman <rob at codeweavers.com>
	Delegate advises to the remote object to enable the client to receive
	data change notifications.

Patch: http://cvs.winehq.org/patch.py?id=21476

Old revision  New revision  Changes     Path
 1.59          1.60          +4 -0       wine/dlls/ole32/compobj_private.h
 1.37          1.38          +20 -1      wine/dlls/ole32/defaulthandler.c
 1.27          1.28          +32 -1      wine/dlls/ole32/oleobj.c

Index: wine/dlls/ole32/compobj_private.h
diff -u -p wine/dlls/ole32/compobj_private.h:1.59 wine/dlls/ole32/compobj_private.h:1.60
--- wine/dlls/ole32/compobj_private.h:1.59	28 Nov 2005 11: 4:19 -0000
+++ wine/dlls/ole32/compobj_private.h	28 Nov 2005 11: 4:19 -0000
@@ -263,4 +263,8 @@ extern HINSTANCE OLE32_hInstance; /* FIX
 
 #define CHARS_IN_GUID 39 /* including NULL */
 
+/* Exported non-interface Data Advise Holder functions */
+HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate);
+void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface);
+
 #endif /* __WINE_OLE_COMPOBJ_H */
Index: wine/dlls/ole32/defaulthandler.c
diff -u -p wine/dlls/ole32/defaulthandler.c:1.37 wine/dlls/ole32/defaulthandler.c:1.38
--- wine/dlls/ole32/defaulthandler.c:1.37	28 Nov 2005 11: 4:19 -0000
+++ wine/dlls/ole32/defaulthandler.c	28 Nov 2005 11: 4:19 -0000
@@ -55,8 +55,11 @@
 #include "winbase.h"
 #include "winuser.h"
 #include "winerror.h"
-#include "wine/unicode.h"
 #include "ole2.h"
+
+#include "compobj_private.h"
+
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
@@ -108,6 +111,8 @@ struct DefaultHandler
   IOleObject *pOleDelegate;
   /* IPersistStorage delegate */
   IPersistStorage *pPSDelegate;
+  /* IDataObject delegate */
+  IDataObject *pDataDelegate;
 
   /* connection cookie for the advise on the delegate OLE object */
   DWORD dwAdvConn;
@@ -411,6 +416,12 @@ static void WINAPI DefaultHandler_Stop(D
 
   /* FIXME: call IOleCache_OnStop */
 
+  DataAdviseHolder_OnDisconnect(This->dataAdviseHolder);
+  if (This->pDataDelegate)
+  {
+     IDataObject_Release(This->pDataDelegate);
+     This->pDataDelegate = NULL;
+  }
   if (This->pPSDelegate)
   {
      IPersistStorage_Release(This->pPSDelegate);
@@ -1284,6 +1295,13 @@ static HRESULT WINAPI DefaultHandler_Run
    * - IOleCache_OnRun
    */
 
+  if (SUCCEEDED(hr))
+    hr = IOleObject_QueryInterface(This->pOleDelegate, &IID_IDataObject,
+                                   (void **)&This->pDataDelegate);
+
+  if (SUCCEEDED(hr) && This->dataAdviseHolder)
+    hr = DataAdviseHolder_OnConnect(This->dataAdviseHolder, This->pDataDelegate);
+
   if (FAILED(hr))
     DefaultHandler_Stop(This);
 
@@ -1558,6 +1576,7 @@ static DefaultHandler* DefaultHandler_Co
   This->containerObj = NULL;
   This->pOleDelegate = NULL;
   This->pPSDelegate = NULL;
+  This->pDataDelegate = NULL;
 
   This->dwAdvConn = 0;
 
Index: wine/dlls/ole32/oleobj.c
diff -u -p wine/dlls/ole32/oleobj.c:1.27 wine/dlls/ole32/oleobj.c:1.28
--- wine/dlls/ole32/oleobj.c:1.27	28 Nov 2005 11: 4:19 -0000
+++ wine/dlls/ole32/oleobj.c	28 Nov 2005 11: 4:19 -0000
@@ -351,6 +351,7 @@ typedef struct DataAdviseConnection {
   IAdviseSink *sink;
   FORMATETC fmat;
   DWORD advf;
+  DWORD remote_connection;
 } DataAdviseConnection;
 
 typedef struct DataAdviseHolder
@@ -362,6 +363,9 @@ typedef struct DataAdviseHolder
   DataAdviseConnection* Connections;
 } DataAdviseHolder;
 
+/* this connection has also has been advised to the delegate data object */
+#define WINE_ADVF_REMOTE 0x80000000
+
 /******************************************************************************
  * DataAdviseHolder_Destructor
  */
@@ -520,7 +524,7 @@ static HRESULT WINAPI DataAdviseHolder_A
    */
   This->Connections[index].sink = pAdvise;
   memcpy(&(This->Connections[index].fmat), pFetc, sizeof(FORMATETC));
-  This->Connections[index].advf = advf;
+  This->Connections[index].advf = advf & ~WINE_ADVF_REMOTE;
 
   if (This->Connections[index].sink != NULL) {
     IAdviseSink_AddRef(This->Connections[index].sink);
@@ -636,6 +640,33 @@ static const IDataAdviseHolderVtbl DataA
   DataAdviseHolder_SendOnDataChange
 };
 
+HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate)
+{
+  DataAdviseHolder *This = (DataAdviseHolder *)iface;
+  DWORD index;
+  HRESULT hr = S_OK;
+
+  for(index = 0; index < This->maxCons; index++)
+  {
+    if(This->Connections[index].sink != NULL)
+    {
+      hr = IDataObject_DAdvise(pDelegate, &This->Connections[index].fmat,
+                               This->Connections[index].advf,
+                               This->Connections[index].sink,
+                               &This->Connections[index].remote_connection);
+      if (FAILED(hr)) break;
+      This->Connections[index].advf |= WINE_ADVF_REMOTE;
+    }
+  }
+  /* FIXME: store pDelegate somewhere */
+  return hr;
+}
+
+void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface)
+{
+    /* FIXME: Unadvise all remote interfaces */
+}
+
 /******************************************************************************
  * DataAdviseHolder_Constructor
  */



More information about the wine-cvs mailing list