2006-04-28 19:59:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-04-28 19:59:58 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2007-12-05 02:05:02 +01:00
|
|
|
static const char *debugstr_cp_guid(REFIID riid)
|
|
|
|
{
|
|
|
|
#define X(x) \
|
|
|
|
if(IsEqualGUID(riid, &x)) \
|
|
|
|
return #x
|
|
|
|
|
|
|
|
X(IID_IPropertyNotifySink);
|
|
|
|
X(DIID_HTMLDocumentEvents);
|
|
|
|
X(DIID_HTMLDocumentEvents2);
|
|
|
|
X(DIID_HTMLTableEvents);
|
|
|
|
X(DIID_HTMLTextContainerEvents);
|
|
|
|
|
|
|
|
#undef X
|
|
|
|
|
|
|
|
return debugstr_guid(riid);
|
|
|
|
}
|
|
|
|
|
2006-08-22 16:15:09 +02:00
|
|
|
void call_property_onchanged(ConnectionPoint *This, DISPID dispid)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(This->sinks[i].propnotif)
|
|
|
|
IPropertyNotifySink_OnChanged(This->sinks[i].propnotif, dispid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:02:57 +01:00
|
|
|
static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
|
|
|
|
}
|
2006-04-28 20:01:07 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-04-28 20:01:07 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-03 01:02:57 +01:00
|
|
|
*ppv = &This->IConnectionPoint_iface;
|
2006-04-28 20:01:07 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
|
2011-01-03 01:02:57 +01:00
|
|
|
*ppv = &This->IConnectionPoint_iface;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_AddRef(&This->container->IConnectionPointContainer_iface);
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_Release(&This->container->IConnectionPointContainer_iface);
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-04-28 20:04:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pIID);
|
|
|
|
|
|
|
|
if(!pIID)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2008-03-05 22:35:16 +01:00
|
|
|
*pIID = *This->iid;
|
2006-04-28 20:04:22 +02:00
|
|
|
return S_OK;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
|
|
|
|
IConnectionPointContainer **ppCPC)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-04-28 20:02:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, ppCPC);
|
|
|
|
|
|
|
|
if(!ppCPC)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2011-01-03 01:02:57 +01:00
|
|
|
*ppCPC = &This->container->IConnectionPointContainer_iface;
|
2006-04-28 20:02:14 +02:00
|
|
|
IConnectionPointContainer_AddRef(*ppCPC);
|
|
|
|
return S_OK;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
|
|
|
|
DWORD *pdwCookie)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-06-25 15:48:47 +02:00
|
|
|
IUnknown *sink;
|
|
|
|
DWORD i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
|
|
|
|
|
2007-12-04 13:36:27 +01:00
|
|
|
hres = IUnknown_QueryInterface(pUnkSink, This->iid, (void**)&sink);
|
|
|
|
if(FAILED(hres) && !IsEqualGUID(&IID_IPropertyNotifySink, This->iid))
|
2006-06-25 15:48:47 +02:00
|
|
|
hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&sink);
|
2006-08-17 23:16:56 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
2006-06-25 15:48:47 +02:00
|
|
|
|
|
|
|
if(This->sinks) {
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(!This->sinks[i].unk)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i == This->sinks_size)
|
2007-12-05 21:52:31 +01:00
|
|
|
This->sinks = heap_realloc(This->sinks,(++This->sinks_size)*sizeof(*This->sinks));
|
2006-06-25 15:48:47 +02:00
|
|
|
}else {
|
2007-12-05 21:52:31 +01:00
|
|
|
This->sinks = heap_alloc(sizeof(*This->sinks));
|
2006-06-25 15:48:47 +02:00
|
|
|
This->sinks_size = 1;
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->sinks[i].unk = sink;
|
|
|
|
*pdwCookie = i+1;
|
|
|
|
|
2010-01-04 00:37:47 +01:00
|
|
|
if(!i && This->data && This->data->on_advise)
|
|
|
|
This->data->on_advise(This->container->outer, This->data);
|
|
|
|
|
2006-06-25 15:48:47 +02:00
|
|
|
return S_OK;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, dwCookie);
|
2006-06-25 15:50:18 +02:00
|
|
|
|
|
|
|
if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1].unk)
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
IUnknown_Release(This->sinks[dwCookie-1].unk);
|
|
|
|
This->sinks[dwCookie-1].unk = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
|
|
|
|
IEnumConnections **ppEnum)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-04-28 20:01:07 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IConnectionPointVtbl ConnectionPointVtbl =
|
|
|
|
{
|
|
|
|
ConnectionPoint_QueryInterface,
|
|
|
|
ConnectionPoint_AddRef,
|
|
|
|
ConnectionPoint_Release,
|
|
|
|
ConnectionPoint_GetConnectionInterface,
|
|
|
|
ConnectionPoint_GetConnectionPointContainer,
|
|
|
|
ConnectionPoint_Advise,
|
|
|
|
ConnectionPoint_Unadvise,
|
|
|
|
ConnectionPoint_EnumConnections
|
|
|
|
};
|
|
|
|
|
2009-11-23 19:28:43 +01:00
|
|
|
void ConnectionPoint_Init(ConnectionPoint *cp, ConnectionPointContainer *container, REFIID riid, cp_static_data_t *data)
|
2006-04-28 20:01:07 +02:00
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
cp->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
|
2010-01-04 00:37:09 +01:00
|
|
|
cp->container = container;
|
2007-06-29 02:47:59 +02:00
|
|
|
cp->sinks = NULL;
|
|
|
|
cp->sinks_size = 0;
|
2007-12-04 13:36:27 +01:00
|
|
|
cp->iid = riid;
|
2009-11-23 19:28:43 +01:00
|
|
|
cp->data = data;
|
2007-06-29 02:48:50 +02:00
|
|
|
|
2007-12-04 13:36:27 +01:00
|
|
|
cp->next = container->cp_list;
|
|
|
|
container->cp_list = cp;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-25 15:49:39 +02:00
|
|
|
static void ConnectionPoint_Destroy(ConnectionPoint *This)
|
|
|
|
{
|
2008-10-18 17:08:41 +02:00
|
|
|
DWORD i;
|
2006-06-25 15:49:39 +02:00
|
|
|
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(This->sinks[i].unk)
|
|
|
|
IUnknown_Release(This->sinks[i].unk);
|
|
|
|
}
|
|
|
|
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This->sinks);
|
2006-06-25 15:49:39 +02:00
|
|
|
}
|
|
|
|
|
2011-01-03 01:02:57 +01:00
|
|
|
static inline ConnectionPointContainer *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ConnectionPointContainer, IConnectionPointContainer_iface);
|
|
|
|
}
|
2006-04-28 19:59:58 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2007-06-29 02:49:27 +02:00
|
|
|
return IUnknown_QueryInterface(This->outer, riid, ppv);
|
2006-04-28 19:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2007-06-29 02:49:27 +02:00
|
|
|
return IUnknown_AddRef(This->outer);
|
2006-04-28 19:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2007-06-29 02:49:27 +02:00
|
|
|
return IUnknown_Release(This->outer);
|
2006-04-28 19:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
|
|
|
|
IEnumConnectionPoints **ppEnum)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2006-04-28 19:59:58 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
|
|
|
|
REFIID riid, IConnectionPoint **ppCP)
|
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2007-06-29 02:48:50 +02:00
|
|
|
ConnectionPoint *iter;
|
|
|
|
|
2007-12-05 02:05:02 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_cp_guid(riid), ppCP);
|
2006-04-28 20:01:07 +02:00
|
|
|
|
2009-11-23 19:28:17 +01:00
|
|
|
if(This->forward_container)
|
2011-02-27 05:55:16 +01:00
|
|
|
return IConnectionPointContainer_FindConnectionPoint(&This->forward_container->IConnectionPointContainer_iface,
|
2011-01-03 01:02:57 +01:00
|
|
|
riid, ppCP);
|
2009-11-23 19:28:17 +01:00
|
|
|
|
2006-04-28 20:01:07 +02:00
|
|
|
*ppCP = NULL;
|
|
|
|
|
2007-06-29 02:49:27 +02:00
|
|
|
for(iter = This->cp_list; iter; iter = iter->next) {
|
2007-12-04 13:36:27 +01:00
|
|
|
if(IsEqualGUID(iter->iid, riid))
|
2011-01-03 01:02:57 +01:00
|
|
|
*ppCP = &iter->IConnectionPoint_iface;
|
2006-04-28 20:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppCP) {
|
|
|
|
IConnectionPoint_AddRef(*ppCP);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-12-05 02:05:02 +01:00
|
|
|
FIXME("unsupported riid %s\n", debugstr_cp_guid(riid));
|
2006-04-28 20:01:07 +02:00
|
|
|
return CONNECT_E_NOCONNECTION;
|
2006-04-28 19:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
|
|
|
|
ConnectionPointContainer_QueryInterface,
|
|
|
|
ConnectionPointContainer_AddRef,
|
|
|
|
ConnectionPointContainer_Release,
|
|
|
|
ConnectionPointContainer_EnumConnectionPoints,
|
|
|
|
ConnectionPointContainer_FindConnectionPoint
|
|
|
|
};
|
|
|
|
|
2007-12-04 13:36:27 +01:00
|
|
|
void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *outer)
|
2006-04-28 19:59:58 +02:00
|
|
|
{
|
2011-01-03 01:02:57 +01:00
|
|
|
This->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
|
2007-12-04 13:36:27 +01:00
|
|
|
This->cp_list = NULL;
|
2007-06-29 02:49:27 +02:00
|
|
|
This->outer = outer;
|
2006-04-28 19:59:58 +02:00
|
|
|
}
|
2006-06-25 15:49:39 +02:00
|
|
|
|
2007-06-29 02:49:27 +02:00
|
|
|
void ConnectionPointContainer_Destroy(ConnectionPointContainer *This)
|
2006-06-25 15:49:39 +02:00
|
|
|
{
|
2007-06-29 02:49:27 +02:00
|
|
|
ConnectionPoint *iter = This->cp_list;
|
2007-06-29 02:48:50 +02:00
|
|
|
|
|
|
|
while(iter) {
|
|
|
|
ConnectionPoint_Destroy(iter);
|
|
|
|
iter = iter->next;
|
|
|
|
}
|
2006-06-25 15:49:39 +02:00
|
|
|
}
|