Commit b9d77540 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Delegate advises to the remote object to enable the client to receive

data change notifications.
parent fc17683f
......@@ -263,4 +263,8 @@ extern HINSTANCE OLE32_hInstance; /* FIXME: make static */
#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 */
......@@ -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(DefaultHandler *This)
/* 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_Construct(
This->containerObj = NULL;
This->pOleDelegate = NULL;
This->pPSDelegate = NULL;
This->pDataDelegate = NULL;
This->dwAdvConn = 0;
......
......@@ -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_Advise(
*/
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 DataAdviseHolderImpl_VTable =
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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment