1998-11-22 19:06:33 +01:00
|
|
|
/*
|
|
|
|
* OLE2 COM objects
|
|
|
|
*
|
|
|
|
* Copyright 1998 Eric Kohl
|
1999-05-02 11:27:08 +02:00
|
|
|
* Copyright 1999 Francis Beaudet
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-02-28 13:27:56 +01:00
|
|
|
#include <string.h>
|
2004-10-07 05:06:48 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-02-28 20:14:33 +01:00
|
|
|
#include "winbase.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
1998-11-22 19:06:33 +01:00
|
|
|
#include "winerror.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-12-05 21:33:07 +01:00
|
|
|
#include "ole2.h"
|
2000-08-03 06:22:35 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
#define INITIAL_SINKS 10
|
1998-11-22 19:06:33 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl Implementation
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
typedef struct OleAdviseHolderImpl
|
1999-03-10 19:03:53 +01:00
|
|
|
{
|
2005-06-06 21:50:35 +02:00
|
|
|
const IOleAdviseHolderVtbl *lpVtbl;
|
1999-03-10 19:03:53 +01:00
|
|
|
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
DWORD maxSinks;
|
|
|
|
IAdviseSink** arrayOfSinks;
|
|
|
|
|
|
|
|
} OleAdviseHolderImpl;
|
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
static HRESULT EnumOleSTATDATA_Construct(OleAdviseHolderImpl *pOleAdviseHolder, ULONG index, IEnumSTATDATA **ppenum);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const IEnumSTATDATAVtbl *lpvtbl;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
ULONG index;
|
|
|
|
OleAdviseHolderImpl *pOleAdviseHolder;
|
|
|
|
} EnumOleSTATDATA;
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumOleSTATDATA_QueryInterface(
|
|
|
|
IEnumSTATDATA *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IEnumSTATDATA))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumOleSTATDATA_AddRef(
|
|
|
|
IEnumSTATDATA *iface)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
TRACE("()\n");
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI EnumOleSTATDATA_Release(
|
|
|
|
IEnumSTATDATA *iface)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
LONG refs = InterlockedDecrement(&This->ref);
|
|
|
|
TRACE("()\n");
|
|
|
|
if (!refs)
|
|
|
|
{
|
|
|
|
IOleAdviseHolder_Release((IOleAdviseHolder *)This->pOleAdviseHolder);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumOleSTATDATA_Next(
|
|
|
|
IEnumSTATDATA *iface, ULONG celt, LPSTATDATA rgelt,
|
|
|
|
ULONG *pceltFetched)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%ld, %p, %p)\n", celt, rgelt, pceltFetched);
|
|
|
|
|
|
|
|
if (pceltFetched)
|
|
|
|
*pceltFetched = 0;
|
|
|
|
|
|
|
|
for (; celt; celt--, rgelt++)
|
|
|
|
{
|
|
|
|
while ((This->index < This->pOleAdviseHolder->maxSinks) &&
|
|
|
|
!This->pOleAdviseHolder->arrayOfSinks[This->index])
|
|
|
|
{
|
|
|
|
This->index++;
|
|
|
|
}
|
|
|
|
if (This->index >= This->pOleAdviseHolder->maxSinks)
|
|
|
|
{
|
|
|
|
hr = S_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&rgelt->formatetc, 0, sizeof(rgelt->formatetc));
|
|
|
|
rgelt->advf = 0;
|
|
|
|
rgelt->pAdvSink = This->pOleAdviseHolder->arrayOfSinks[This->index];
|
|
|
|
IAdviseSink_AddRef(rgelt->pAdvSink);
|
|
|
|
rgelt->dwConnection = This->index;
|
|
|
|
|
|
|
|
if (pceltFetched)
|
2006-03-02 18:03:32 +01:00
|
|
|
(*pceltFetched)++;
|
2006-01-11 12:09:32 +01:00
|
|
|
This->index++;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumOleSTATDATA_Skip(
|
|
|
|
IEnumSTATDATA *iface, ULONG celt)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
|
|
|
|
TRACE("(%ld)\n", celt);
|
|
|
|
|
|
|
|
for (; celt; celt--)
|
|
|
|
{
|
|
|
|
while ((This->index < This->pOleAdviseHolder->maxSinks) &&
|
|
|
|
!This->pOleAdviseHolder->arrayOfSinks[This->index])
|
|
|
|
{
|
|
|
|
This->index++;
|
|
|
|
}
|
|
|
|
if (This->index >= This->pOleAdviseHolder->maxSinks)
|
|
|
|
return S_FALSE;
|
|
|
|
This->index++;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumOleSTATDATA_Reset(
|
|
|
|
IEnumSTATDATA *iface)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
This->index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI EnumOleSTATDATA_Clone(
|
|
|
|
IEnumSTATDATA *iface,
|
|
|
|
IEnumSTATDATA **ppenum)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = (EnumOleSTATDATA *)iface;
|
|
|
|
return EnumOleSTATDATA_Construct(This->pOleAdviseHolder, This->index, ppenum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IEnumSTATDATAVtbl EnumOleSTATDATA_VTable =
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA_QueryInterface,
|
|
|
|
EnumOleSTATDATA_AddRef,
|
|
|
|
EnumOleSTATDATA_Release,
|
|
|
|
EnumOleSTATDATA_Next,
|
|
|
|
EnumOleSTATDATA_Skip,
|
|
|
|
EnumOleSTATDATA_Reset,
|
|
|
|
EnumOleSTATDATA_Clone
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT EnumOleSTATDATA_Construct(OleAdviseHolderImpl *pOleAdviseHolder, ULONG index, IEnumSTATDATA **ppenum)
|
|
|
|
{
|
|
|
|
EnumOleSTATDATA *This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
This->lpvtbl = &EnumOleSTATDATA_VTable;
|
|
|
|
This->ref = 1;
|
|
|
|
This->index = index;
|
|
|
|
This->pOleAdviseHolder = pOleAdviseHolder;
|
|
|
|
IOleAdviseHolder_AddRef((IOleAdviseHolder *)pOleAdviseHolder);
|
|
|
|
*ppenum = (IEnumSTATDATA *)&This->lpvtbl;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-22 19:06:33 +01:00
|
|
|
/**************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_Destructor
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static void OleAdviseHolderImpl_Destructor(
|
|
|
|
OleAdviseHolderImpl* ptrToDestroy)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD index;
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("%p\n", ptrToDestroy);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
for (index = 0; index < ptrToDestroy->maxSinks; index++)
|
|
|
|
{
|
|
|
|
if (ptrToDestroy->arrayOfSinks[index]!=0)
|
|
|
|
{
|
|
|
|
IAdviseSink_Release(ptrToDestroy->arrayOfSinks[index]);
|
|
|
|
ptrToDestroy->arrayOfSinks[index] = NULL;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
ptrToDestroy->arrayOfSinks);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
ptrToDestroy);
|
|
|
|
}
|
1998-11-22 19:06:33 +01:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* OleAdviseHolderImpl_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI OleAdviseHolderImpl_QueryInterface(
|
|
|
|
LPOLEADVISEHOLDER iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
REFIID riid,
|
1999-05-02 11:27:08 +02:00
|
|
|
LPVOID* ppvObj)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (ppvObj==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
2002-06-01 01:06:46 +02:00
|
|
|
*ppvObj = This;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
else if(IsEqualIID(riid, &IID_IOleAdviseHolder))
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
|
|
|
/* IOleAdviseHolder */
|
|
|
|
*ppvObj = (IOleAdviseHolder*) This;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvObj == NULL)
|
1998-11-22 19:06:33 +01:00
|
|
|
return E_NOINTERFACE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* A successful QI always increments the reference count.
|
|
|
|
*/
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObj);
|
|
|
|
|
|
|
|
return S_OK;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_AddRef
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static ULONG WINAPI OleAdviseHolderImpl_AddRef(
|
|
|
|
LPOLEADVISEHOLDER iface)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
2005-01-09 18:29:21 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref=%ld)\n", This, ref - 1);
|
|
|
|
|
|
|
|
return ref;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_Release
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static ULONG WINAPI OleAdviseHolderImpl_Release(
|
|
|
|
LPOLEADVISEHOLDER iface)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("(%p)->(ref=%ld)\n", This, This->ref);
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref == 0) OleAdviseHolderImpl_Destructor(This);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_Advise
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI OleAdviseHolderImpl_Advise(
|
|
|
|
LPOLEADVISEHOLDER iface,
|
|
|
|
IAdviseSink* pAdvise,
|
|
|
|
DWORD* pdwConnection)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD index;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p)->(%p, %p)\n", This, pAdvise, pdwConnection);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pdwConnection==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
*pdwConnection = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a free spot in the array.
|
|
|
|
*/
|
|
|
|
for (index = 0; index < This->maxSinks; index++)
|
|
|
|
{
|
|
|
|
if (This->arrayOfSinks[index]==NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the array is full, we need to grow it.
|
|
|
|
*/
|
|
|
|
if (index == This->maxSinks)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
This->maxSinks+=INITIAL_SINKS;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
This->arrayOfSinks = HeapReAlloc(GetProcessHeap(),
|
1999-05-02 11:27:08 +02:00
|
|
|
0,
|
|
|
|
This->arrayOfSinks,
|
|
|
|
This->maxSinks*sizeof(IAdviseSink*));
|
|
|
|
|
|
|
|
for (i=index;i < This->maxSinks; i++)
|
2002-06-01 01:06:46 +02:00
|
|
|
This->arrayOfSinks[i]=0;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Store the new sink
|
|
|
|
*/
|
|
|
|
This->arrayOfSinks[index] = pAdvise;
|
|
|
|
|
|
|
|
if (This->arrayOfSinks[index]!=NULL)
|
|
|
|
IAdviseSink_AddRef(This->arrayOfSinks[index]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the index as the cookie.
|
1999-05-08 12:55:32 +02:00
|
|
|
* Since 0 is not a valid cookie, we will increment by
|
|
|
|
* 1 the index in the table.
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
1999-05-08 12:55:32 +02:00
|
|
|
*pdwConnection = index+1;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
return S_OK;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_Unadvise
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI OleAdviseHolderImpl_Unadvise(
|
2002-06-01 01:06:46 +02:00
|
|
|
LPOLEADVISEHOLDER iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD dwConnection)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p)->(%lu)\n", This, dwConnection);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
1999-05-08 12:55:32 +02:00
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* So we don't return 0 as a cookie, the index was
|
1999-05-08 12:55:32 +02:00
|
|
|
* incremented by 1 in OleAdviseHolderImpl_Advise
|
|
|
|
* we have to compensate.
|
|
|
|
*/
|
|
|
|
dwConnection--;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Check for invalid cookies.
|
|
|
|
*/
|
2002-06-22 00:25:17 +02:00
|
|
|
if (dwConnection >= This->maxSinks)
|
1999-05-02 11:27:08 +02:00
|
|
|
return OLE_E_NOCONNECTION;
|
|
|
|
|
|
|
|
if (This->arrayOfSinks[dwConnection] == NULL)
|
|
|
|
return OLE_E_NOCONNECTION;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the sink and mark the spot in the list as free.
|
|
|
|
*/
|
|
|
|
IAdviseSink_Release(This->arrayOfSinks[dwConnection]);
|
|
|
|
This->arrayOfSinks[dwConnection] = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_EnumAdvise
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
1999-05-02 11:27:08 +02:00
|
|
|
OleAdviseHolderImpl_EnumAdvise (LPOLEADVISEHOLDER iface, IEnumSTATDATA **ppenumAdvise)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
|
2006-01-11 12:09:32 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppenumAdvise);
|
1998-11-22 19:06:33 +01:00
|
|
|
|
|
|
|
*ppenumAdvise = NULL;
|
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
return EnumOleSTATDATA_Construct(This, 0, ppenumAdvise);
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_SendOnRename
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
1999-05-02 11:27:08 +02:00
|
|
|
OleAdviseHolderImpl_SendOnRename (LPOLEADVISEHOLDER iface, IMoniker *pmk)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2006-01-11 12:09:32 +01:00
|
|
|
IEnumSTATDATA *pEnum;
|
|
|
|
HRESULT hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
TRACE("(%p)->(%p)\n", iface, pmk);
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
hr = IOleAdviseHolder_EnumAdvise(iface, &pEnum);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
STATDATA statdata;
|
|
|
|
while (IEnumSTATDATA_Next(pEnum, 1, &statdata, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IAdviseSink_OnRename(statdata.pAdvSink, pmk);
|
|
|
|
|
|
|
|
IAdviseSink_Release(statdata.pAdvSink);
|
|
|
|
}
|
|
|
|
IEnumSTATDATA_Release(pEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_SendOnSave
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
1999-05-02 11:27:08 +02:00
|
|
|
OleAdviseHolderImpl_SendOnSave (LPOLEADVISEHOLDER iface)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2006-01-11 12:09:32 +01:00
|
|
|
IEnumSTATDATA *pEnum;
|
|
|
|
HRESULT hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
|
|
|
hr = IOleAdviseHolder_EnumAdvise(iface, &pEnum);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
STATDATA statdata;
|
|
|
|
while (IEnumSTATDATA_Next(pEnum, 1, &statdata, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IAdviseSink_OnSave(statdata.pAdvSink);
|
|
|
|
|
|
|
|
IAdviseSink_Release(statdata.pAdvSink);
|
|
|
|
}
|
|
|
|
IEnumSTATDATA_Release(pEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-05-02 11:27:08 +02:00
|
|
|
* OleAdviseHolderImpl_SendOnClose
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
1999-05-02 11:27:08 +02:00
|
|
|
OleAdviseHolderImpl_SendOnClose (LPOLEADVISEHOLDER iface)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
2006-01-11 12:09:32 +01:00
|
|
|
IEnumSTATDATA *pEnum;
|
|
|
|
HRESULT hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
TRACE("(%p)->()\n", iface);
|
1998-11-22 19:06:33 +01:00
|
|
|
|
2006-01-11 12:09:32 +01:00
|
|
|
hr = IOleAdviseHolder_EnumAdvise(iface, &pEnum);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
STATDATA statdata;
|
|
|
|
while (IEnumSTATDATA_Next(pEnum, 1, &statdata, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IAdviseSink_OnClose(statdata.pAdvSink);
|
|
|
|
|
|
|
|
IAdviseSink_Release(statdata.pAdvSink);
|
|
|
|
}
|
|
|
|
IEnumSTATDATA_Release(pEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|
|
|
|
|
2005-05-23 18:31:13 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* OleAdviseHolderImpl_VTable
|
|
|
|
*/
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IOleAdviseHolderVtbl oahvt =
|
2005-05-23 18:31:13 +02:00
|
|
|
{
|
|
|
|
OleAdviseHolderImpl_QueryInterface,
|
|
|
|
OleAdviseHolderImpl_AddRef,
|
|
|
|
OleAdviseHolderImpl_Release,
|
|
|
|
OleAdviseHolderImpl_Advise,
|
|
|
|
OleAdviseHolderImpl_Unadvise,
|
|
|
|
OleAdviseHolderImpl_EnumAdvise,
|
|
|
|
OleAdviseHolderImpl_SendOnRename,
|
|
|
|
OleAdviseHolderImpl_SendOnSave,
|
|
|
|
OleAdviseHolderImpl_SendOnClose
|
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* OleAdviseHolderImpl_Constructor
|
|
|
|
*/
|
|
|
|
|
2005-06-21 22:53:13 +02:00
|
|
|
static LPOLEADVISEHOLDER OleAdviseHolderImpl_Constructor(void)
|
2005-05-23 18:31:13 +02:00
|
|
|
{
|
|
|
|
OleAdviseHolderImpl* lpoah;
|
|
|
|
DWORD index;
|
|
|
|
|
|
|
|
lpoah = HeapAlloc(GetProcessHeap(), 0, sizeof(OleAdviseHolderImpl));
|
|
|
|
|
|
|
|
lpoah->lpVtbl = &oahvt;
|
|
|
|
lpoah->ref = 1;
|
|
|
|
lpoah->maxSinks = INITIAL_SINKS;
|
|
|
|
lpoah->arrayOfSinks = HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
lpoah->maxSinks * sizeof(IAdviseSink*));
|
|
|
|
|
|
|
|
for (index = 0; index < lpoah->maxSinks; index++)
|
|
|
|
lpoah->arrayOfSinks[index]=0;
|
|
|
|
|
|
|
|
TRACE("returning %p\n", lpoah);
|
|
|
|
return (LPOLEADVISEHOLDER)lpoah;
|
|
|
|
}
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* DataAdviseHolder Implementation
|
|
|
|
*/
|
2000-07-08 13:46:54 +02:00
|
|
|
typedef struct DataAdviseConnection {
|
|
|
|
IAdviseSink *sink;
|
|
|
|
FORMATETC fmat;
|
|
|
|
DWORD advf;
|
2005-11-28 11:16:58 +01:00
|
|
|
DWORD remote_connection;
|
2002-06-01 01:06:46 +02:00
|
|
|
} DataAdviseConnection;
|
2000-07-08 13:46:54 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
typedef struct DataAdviseHolder
|
|
|
|
{
|
2005-06-06 21:50:35 +02:00
|
|
|
const IDataAdviseHolderVtbl *lpVtbl;
|
1999-05-02 11:27:08 +02:00
|
|
|
|
2005-07-05 13:02:54 +02:00
|
|
|
LONG ref;
|
2000-07-08 13:46:54 +02:00
|
|
|
DWORD maxCons;
|
|
|
|
DataAdviseConnection* Connections;
|
1999-05-02 11:27:08 +02:00
|
|
|
} DataAdviseHolder;
|
|
|
|
|
2005-11-28 11:16:58 +01:00
|
|
|
/* this connection has also has been advised to the delegate data object */
|
|
|
|
#define WINE_ADVF_REMOTE 0x80000000
|
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DataAdviseHolder_Destructor
|
|
|
|
*/
|
2000-07-08 13:46:54 +02:00
|
|
|
static void DataAdviseHolder_Destructor(DataAdviseHolder* ptrToDestroy)
|
1999-05-02 11:27:08 +02:00
|
|
|
{
|
2000-07-08 13:46:54 +02:00
|
|
|
DWORD index;
|
|
|
|
TRACE("%p\n", ptrToDestroy);
|
|
|
|
|
|
|
|
for (index = 0; index < ptrToDestroy->maxCons; index++)
|
|
|
|
{
|
|
|
|
if (ptrToDestroy->Connections[index].sink != NULL)
|
|
|
|
{
|
|
|
|
IAdviseSink_Release(ptrToDestroy->Connections[index].sink);
|
|
|
|
ptrToDestroy->Connections[index].sink = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, ptrToDestroy->Connections);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptrToDestroy);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataAdviseHolder_QueryInterface (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI DataAdviseHolder_QueryInterface(
|
|
|
|
IDataAdviseHolder* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Perform a sanity check on the parameters.
|
|
|
|
*/
|
|
|
|
if ( (This==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Initialize the return parameter.
|
|
|
|
*/
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare the riid with the interface IDs implemented by this object.
|
|
|
|
*/
|
|
|
|
if ( (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) ||
|
|
|
|
(memcmp(&IID_IDataAdviseHolder, riid, sizeof(IID_IDataAdviseHolder)) == 0) )
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Check that we obtained an interface.
|
|
|
|
*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Query Interface always increases the reference count by one when it is
|
2002-06-01 01:06:46 +02:00
|
|
|
* successful.
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataAdviseHolder_AddRef (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataAdviseHolder_AddRef(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataAdviseHolder* iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p) (ref=%ld)\n", This, This->ref);
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* DataAdviseHolder_Release (IUnknown)
|
|
|
|
*
|
|
|
|
* See Windows documentation for more details on IUnknown methods.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static ULONG WINAPI DataAdviseHolder_Release(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataAdviseHolder* iface)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2000-07-08 13:46:54 +02:00
|
|
|
TRACE("(%p) (ref=%ld)\n", This, This->ref);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Decrease the reference count on this object.
|
|
|
|
*/
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reference count goes down to 0, perform suicide.
|
|
|
|
*/
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref==0) DataAdviseHolder_Destructor(This);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
/************************************************************************
|
|
|
|
* DataAdviseHolder_Advise
|
|
|
|
*
|
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
static HRESULT WINAPI DataAdviseHolder_Advise(
|
|
|
|
IDataAdviseHolder* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
IDataObject* pDataObject,
|
|
|
|
FORMATETC* pFetc,
|
|
|
|
DWORD advf,
|
|
|
|
IAdviseSink* pAdvise,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD* pdwConnection)
|
|
|
|
{
|
2000-07-08 13:46:54 +02:00
|
|
|
DWORD index;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p, %08lx, %p, %p)\n", This, pDataObject, pFetc, advf,
|
|
|
|
pAdvise, pdwConnection);
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if (pdwConnection==NULL)
|
|
|
|
return E_POINTER;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
*pdwConnection = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a free spot in the array.
|
|
|
|
*/
|
|
|
|
for (index = 0; index < This->maxCons; index++)
|
|
|
|
{
|
|
|
|
if (This->Connections[index].sink == NULL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the array is full, we need to grow it.
|
|
|
|
*/
|
|
|
|
if (index == This->maxCons)
|
|
|
|
{
|
|
|
|
This->maxCons+=INITIAL_SINKS;
|
|
|
|
This->Connections = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
This->Connections,
|
|
|
|
This->maxCons*sizeof(DataAdviseConnection));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Store the new sink
|
|
|
|
*/
|
|
|
|
This->Connections[index].sink = pAdvise;
|
|
|
|
memcpy(&(This->Connections[index].fmat), pFetc, sizeof(FORMATETC));
|
2005-11-28 11:16:58 +01:00
|
|
|
This->Connections[index].advf = advf & ~WINE_ADVF_REMOTE;
|
2000-07-08 13:46:54 +02:00
|
|
|
|
|
|
|
if (This->Connections[index].sink != NULL) {
|
|
|
|
IAdviseSink_AddRef(This->Connections[index].sink);
|
|
|
|
if(advf & ADVF_PRIMEFIRST) {
|
2005-05-23 18:31:13 +02:00
|
|
|
IDataAdviseHolder_SendOnDataChange(iface, pDataObject, 0, advf);
|
2000-07-08 13:46:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Return the index as the cookie.
|
|
|
|
* Since 0 is not a valid cookie, we will increment by
|
|
|
|
* 1 the index in the table.
|
|
|
|
*/
|
|
|
|
*pdwConnection = index+1;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DataAdviseHolder_Unadvise
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataAdviseHolder_Unadvise(
|
1999-05-02 11:27:08 +02:00
|
|
|
IDataAdviseHolder* iface,
|
|
|
|
DWORD dwConnection)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%lu)\n", This, dwConnection);
|
|
|
|
|
|
|
|
/*
|
2002-06-01 01:06:46 +02:00
|
|
|
* So we don't return 0 as a cookie, the index was
|
2000-07-08 13:46:54 +02:00
|
|
|
* incremented by 1 in OleAdviseHolderImpl_Advise
|
|
|
|
* we have to compensate.
|
|
|
|
*/
|
|
|
|
dwConnection--;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
/*
|
|
|
|
* Check for invalid cookies.
|
|
|
|
*/
|
2002-06-22 00:25:17 +02:00
|
|
|
if (dwConnection >= This->maxCons)
|
2000-07-08 13:46:54 +02:00
|
|
|
return OLE_E_NOCONNECTION;
|
|
|
|
|
|
|
|
if (This->Connections[dwConnection].sink == NULL)
|
|
|
|
return OLE_E_NOCONNECTION;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release the sink and mark the spot in the list as free.
|
|
|
|
*/
|
|
|
|
IAdviseSink_Release(This->Connections[dwConnection].sink);
|
|
|
|
memset(&(This->Connections[dwConnection]), 0, sizeof(DataAdviseConnection));
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataAdviseHolder_EnumAdvise(
|
|
|
|
IDataAdviseHolder* iface,
|
1999-05-02 11:27:08 +02:00
|
|
|
IEnumSTATDATA** ppenumAdvise)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppenumAdvise);
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2000-07-08 13:46:54 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DataAdviseHolder_SendOnDataChange
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HRESULT WINAPI DataAdviseHolder_SendOnDataChange(
|
|
|
|
IDataAdviseHolder* iface,
|
|
|
|
IDataObject* pDataObject,
|
|
|
|
DWORD dwReserved,
|
1999-05-02 11:27:08 +02:00
|
|
|
DWORD advf)
|
|
|
|
{
|
2004-09-09 23:03:58 +02:00
|
|
|
DataAdviseHolder *This = (DataAdviseHolder *)iface;
|
2000-07-08 13:46:54 +02:00
|
|
|
DWORD index;
|
|
|
|
STGMEDIUM stg;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%08lx,%08lx)\n", This, pDataObject, dwReserved, advf);
|
|
|
|
|
|
|
|
for(index = 0; index < This->maxCons; index++) {
|
|
|
|
if(This->Connections[index].sink != NULL) {
|
|
|
|
if(!(This->Connections[index].advf & ADVF_NODATA)) {
|
|
|
|
TRACE("Calling IDataObject_GetData\n");
|
|
|
|
res = IDataObject_GetData(pDataObject,
|
|
|
|
&(This->Connections[index].fmat),
|
|
|
|
&stg);
|
|
|
|
TRACE("returns %08lx\n", res);
|
|
|
|
}
|
|
|
|
TRACE("Calling IAdviseSink_OnDataChange\n");
|
|
|
|
IAdviseSink_OnDataChange(This->Connections[index].sink,
|
|
|
|
&(This->Connections[index].fmat),
|
|
|
|
&stg);
|
|
|
|
TRACE("Done IAdviseSink_OnDataChange\n");
|
|
|
|
if(This->Connections[index].advf & ADVF_ONLYONCE) {
|
|
|
|
TRACE("Removing connection\n");
|
|
|
|
DataAdviseHolder_Unadvise(iface, index+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return S_OK;
|
1999-05-02 11:27:08 +02:00
|
|
|
}
|
|
|
|
|
2005-05-23 18:31:13 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* DataAdviseHolderImpl_VTable
|
|
|
|
*/
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IDataAdviseHolderVtbl DataAdviseHolderImpl_VTable =
|
2005-05-23 18:31:13 +02:00
|
|
|
{
|
|
|
|
DataAdviseHolder_QueryInterface,
|
|
|
|
DataAdviseHolder_AddRef,
|
|
|
|
DataAdviseHolder_Release,
|
|
|
|
DataAdviseHolder_Advise,
|
|
|
|
DataAdviseHolder_Unadvise,
|
|
|
|
DataAdviseHolder_EnumAdvise,
|
|
|
|
DataAdviseHolder_SendOnDataChange
|
|
|
|
};
|
|
|
|
|
2005-11-28 11:16:58 +01:00
|
|
|
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 */
|
|
|
|
}
|
|
|
|
|
2005-05-23 18:31:13 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DataAdviseHolder_Constructor
|
|
|
|
*/
|
2005-06-21 22:53:13 +02:00
|
|
|
static IDataAdviseHolder* DataAdviseHolder_Constructor(void)
|
2005-05-23 18:31:13 +02:00
|
|
|
{
|
|
|
|
DataAdviseHolder* newHolder;
|
|
|
|
|
|
|
|
newHolder = HeapAlloc(GetProcessHeap(), 0, sizeof(DataAdviseHolder));
|
|
|
|
|
|
|
|
newHolder->lpVtbl = &DataAdviseHolderImpl_VTable;
|
|
|
|
newHolder->ref = 1;
|
|
|
|
newHolder->maxCons = INITIAL_SINKS;
|
|
|
|
newHolder->Connections = HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
newHolder->maxCons *
|
|
|
|
sizeof(DataAdviseConnection));
|
|
|
|
|
|
|
|
TRACE("returning %p\n", newHolder);
|
|
|
|
return (IDataAdviseHolder*)newHolder;
|
|
|
|
}
|
|
|
|
|
1998-11-22 19:06:33 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* API functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CreateOleAdviseHolder [OLE32.@]
|
1998-11-22 19:06:33 +01:00
|
|
|
*/
|
1999-05-02 11:27:08 +02:00
|
|
|
HRESULT WINAPI CreateOleAdviseHolder(
|
|
|
|
LPOLEADVISEHOLDER *ppOAHolder)
|
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n", ppOAHolder);
|
1999-05-02 11:27:08 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check,
|
|
|
|
*/
|
|
|
|
if (ppOAHolder==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppOAHolder = OleAdviseHolderImpl_Constructor ();
|
|
|
|
|
|
|
|
if (*ppOAHolder != NULL)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-11 05:06:25 +02:00
|
|
|
* CreateDataAdviseHolder [OLE32.@]
|
1999-05-02 11:27:08 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateDataAdviseHolder(
|
|
|
|
LPDATAADVISEHOLDER* ppDAHolder)
|
1998-11-22 19:06:33 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n", ppDAHolder);
|
1998-11-22 19:06:33 +01:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
/*
|
|
|
|
* Sanity check,
|
|
|
|
*/
|
|
|
|
if (ppDAHolder==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppDAHolder = DataAdviseHolder_Constructor();
|
|
|
|
|
|
|
|
if (*ppDAHolder != NULL)
|
|
|
|
return S_OK;
|
1998-11-22 19:06:33 +01:00
|
|
|
|
1999-05-02 11:27:08 +02:00
|
|
|
return E_OUTOFMEMORY;
|
1998-11-22 19:06:33 +01:00
|
|
|
}
|