2001-01-11 23:32:44 +01:00
|
|
|
/*
|
2005-09-12 12:10:04 +02:00
|
|
|
* Implementation of event-related interfaces for WebBrowser control:
|
2002-05-05 21:40:57 +02:00
|
|
|
*
|
|
|
|
* - IConnectionPointContainer
|
|
|
|
* - IConnectionPoint
|
2001-01-11 23:32:44 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 2001 John R. Sheets (for CodeWeavers)
|
2006-05-17 18:26:30 +02:00
|
|
|
* Copyright 2006 Jacek Caban for CodeWeavers
|
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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 23:32:44 +01:00
|
|
|
*/
|
|
|
|
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2002-03-20 02:02:15 +01:00
|
|
|
#include "wine/debug.h"
|
2002-05-05 21:40:57 +02:00
|
|
|
#include "shdocvw.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-12-02 11:26:32 +01:00
|
|
|
struct ConnectionPoint {
|
2010-11-13 17:48:34 +01:00
|
|
|
IConnectionPoint IConnectionPoint_iface;
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2006-04-18 00:41:43 +02:00
|
|
|
IConnectionPointContainer *container;
|
2005-11-17 12:40:55 +01:00
|
|
|
|
2005-12-02 11:26:32 +01:00
|
|
|
IDispatch **sinks;
|
|
|
|
DWORD sinks_size;
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
IID iid;
|
2005-12-02 11:26:32 +01:00
|
|
|
};
|
2005-11-17 12:40:55 +01:00
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* Implement the IConnectionPointContainer interface
|
|
|
|
*/
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2010-11-13 17:48:34 +01:00
|
|
|
static inline ConnectionPointContainer *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
return (ConnectionPointContainer*)((char*)iface - FIELD_OFFSET(ConnectionPointContainer, IConnectionPointContainer_iface));
|
|
|
|
}
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
|
2006-05-17 18:26:30 +02:00
|
|
|
REFIID riid, LPVOID *ppv)
|
2005-09-12 12:10:04 +02:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
return IUnknown_QueryInterface(This->impl, riid, ppv);
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
return IUnknown_AddRef(This->impl);
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
return IUnknown_Release(This->impl);
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
|
|
|
|
LPENUMCONNECTIONPOINTS *ppEnum)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2005-09-12 12:10:04 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
|
|
|
|
REFIID riid, LPCONNECTIONPOINT *ppCP)
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
|
2005-09-12 12:10:04 +02:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
if(!ppCP) {
|
|
|
|
WARN("ppCP == NULL\n");
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
*ppCP = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
|
|
|
|
TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP);
|
2010-11-13 17:48:34 +01:00
|
|
|
*ppCP = &This->wbe2->IConnectionPoint_iface;
|
2005-11-17 12:40:55 +01:00
|
|
|
}else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
|
|
|
|
TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
|
2010-11-13 17:48:34 +01:00
|
|
|
*ppCP = &This->wbe->IConnectionPoint_iface;
|
2005-11-17 12:40:55 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
|
2010-11-13 17:48:34 +01:00
|
|
|
*ppCP = &This->pns->IConnectionPoint_iface;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
2005-11-17 12:40:55 +01:00
|
|
|
|
|
|
|
if(*ppCP) {
|
|
|
|
IConnectionPoint_AddRef(*ppCP);
|
2002-05-05 21:40:57 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
WARN("Unsupported IID %s\n", debugstr_guid(riid));
|
2006-02-10 14:51:30 +01:00
|
|
|
return CONNECT_E_NOCONNECTION;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2010-11-13 17:48:34 +01:00
|
|
|
#undef impl_from_IConnectionPointContainer
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
2005-09-12 12:10:04 +02:00
|
|
|
ConnectionPointContainer_QueryInterface,
|
|
|
|
ConnectionPointContainer_AddRef,
|
|
|
|
ConnectionPointContainer_Release,
|
|
|
|
ConnectionPointContainer_EnumConnectionPoints,
|
|
|
|
ConnectionPointContainer_FindConnectionPoint
|
2002-05-05 21:40:57 +02:00
|
|
|
};
|
|
|
|
|
2001-01-11 23:32:44 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Implement the IConnectionPoint interface
|
|
|
|
*/
|
|
|
|
|
2010-11-13 17:48:34 +01:00
|
|
|
static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
return (ConnectionPoint*)((char*)iface - FIELD_OFFSET(ConnectionPoint, IConnectionPoint_iface));
|
|
|
|
}
|
2005-11-17 12:40:55 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
*ppv = NULL;
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-11-13 17:48:34 +01:00
|
|
|
*ppv = &This->IConnectionPoint_iface;
|
2005-11-17 12:40:55 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
|
2010-11-13 17:48:34 +01:00
|
|
|
*ppv = &This->IConnectionPoint_iface;
|
2005-11-17 12:40:55 +01:00
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
if(*ppv) {
|
2006-05-17 18:26:30 +02:00
|
|
|
IConnectionPointContainer_AddRef(This->container);
|
2005-11-17 12:40:55 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
return IConnectionPointContainer_AddRef(This->container);
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
return IConnectionPointContainer_Release(This->container);
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2005-11-17 12:40:55 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pIID);
|
|
|
|
|
2008-03-17 22:36:56 +01:00
|
|
|
*pIID = This->iid;
|
2002-05-05 21:40:57 +02:00
|
|
|
return S_OK;
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
|
|
|
|
IConnectionPointContainer **ppCPC)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, ppCPC);
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2006-04-18 00:41:43 +02:00
|
|
|
*ppCPC = This->container;
|
|
|
|
IConnectionPointContainer_AddRef(This->container);
|
2002-05-05 21:40:57 +02:00
|
|
|
return S_OK;
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
|
|
|
|
DWORD *pdwCookie)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2005-12-02 11:26:32 +01:00
|
|
|
IDispatch *disp;
|
|
|
|
DWORD i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(pUnkSink, &This->iid, (void**)&disp);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&disp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->sinks) {
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(!This->sinks[i])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i == This->sinks_size)
|
2007-11-28 00:09:35 +01:00
|
|
|
This->sinks = heap_realloc(This->sinks,
|
2006-05-11 06:45:43 +02:00
|
|
|
(++This->sinks_size)*sizeof(*This->sinks));
|
2005-12-02 11:26:32 +01:00
|
|
|
}else {
|
2007-11-28 00:09:35 +01:00
|
|
|
This->sinks = heap_alloc(sizeof(*This->sinks));
|
2005-12-02 11:26:32 +01:00
|
|
|
This->sinks_size = 1;
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->sinks[i] = disp;
|
|
|
|
*pdwCookie = i+1;
|
|
|
|
|
|
|
|
return S_OK;
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2005-12-02 11:26:32 +01:00
|
|
|
|
2006-10-05 23:49:39 +02:00
|
|
|
TRACE("(%p)->(%d)\n", This, dwCookie);
|
2005-12-02 11:26:32 +01:00
|
|
|
|
|
|
|
if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1])
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
IDispatch_Release(This->sinks[dwCookie-1]);
|
|
|
|
This->sinks[dwCookie-1] = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2001-01-11 23:32:44 +01:00
|
|
|
}
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
|
|
|
|
IEnumConnections **ppEnum)
|
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2005-11-17 12:40:55 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
static const IConnectionPointVtbl ConnectionPointVtbl =
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint_QueryInterface,
|
|
|
|
ConnectionPoint_AddRef,
|
|
|
|
ConnectionPoint_Release,
|
|
|
|
ConnectionPoint_GetConnectionInterface,
|
|
|
|
ConnectionPoint_GetConnectionPointContainer,
|
|
|
|
ConnectionPoint_Advise,
|
|
|
|
ConnectionPoint_Unadvise,
|
|
|
|
ConnectionPoint_EnumConnections
|
2001-01-11 23:32:44 +01:00
|
|
|
};
|
|
|
|
|
2005-12-02 11:26:32 +01:00
|
|
|
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(This->sinks[i])
|
|
|
|
IDispatch_Invoke(This->sinks[i], dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
|
|
|
|
DISPATCH_METHOD, dispparams, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-17 18:26:30 +02:00
|
|
|
static void ConnectionPoint_Create(REFIID riid, ConnectionPoint **cp,
|
|
|
|
IConnectionPointContainer *container)
|
2005-11-17 12:40:55 +01:00
|
|
|
{
|
2007-11-28 00:09:35 +01:00
|
|
|
ConnectionPoint *ret = heap_alloc(sizeof(ConnectionPoint));
|
2005-11-17 12:40:55 +01:00
|
|
|
|
2010-11-13 17:48:34 +01:00
|
|
|
ret->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
|
2005-12-02 11:26:32 +01:00
|
|
|
|
|
|
|
ret->sinks = NULL;
|
|
|
|
ret->sinks_size = 0;
|
2006-05-17 18:26:30 +02:00
|
|
|
ret->container = container;
|
2005-12-02 11:26:32 +01:00
|
|
|
|
2008-03-17 22:36:56 +01:00
|
|
|
ret->iid = *riid;
|
2005-11-17 12:40:55 +01:00
|
|
|
|
2005-12-02 11:26:32 +01:00
|
|
|
*cp = ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ConnectionPoint_Destroy(ConnectionPoint *This)
|
|
|
|
{
|
2008-09-08 20:29:55 +02:00
|
|
|
DWORD i;
|
2005-12-02 11:26:32 +01:00
|
|
|
|
|
|
|
for(i=0; i<This->sinks_size; i++) {
|
|
|
|
if(This->sinks[i])
|
|
|
|
IDispatch_Release(This->sinks[i]);
|
|
|
|
}
|
|
|
|
|
2007-11-28 00:09:35 +01:00
|
|
|
heap_free(This->sinks);
|
|
|
|
heap_free(This);
|
2005-11-17 12:40:55 +01:00
|
|
|
}
|
2005-09-12 12:10:04 +02:00
|
|
|
|
2006-05-17 18:26:30 +02:00
|
|
|
void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *impl)
|
2005-09-12 12:10:04 +02:00
|
|
|
{
|
2010-11-13 17:48:34 +01:00
|
|
|
This->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
|
2005-11-18 13:06:12 +01:00
|
|
|
|
2010-11-13 17:48:34 +01:00
|
|
|
ConnectionPoint_Create(&DIID_DWebBrowserEvents2, &This->wbe2, &This->IConnectionPointContainer_iface);
|
|
|
|
ConnectionPoint_Create(&DIID_DWebBrowserEvents, &This->wbe, &This->IConnectionPointContainer_iface);
|
|
|
|
ConnectionPoint_Create(&IID_IPropertyNotifySink, &This->pns, &This->IConnectionPointContainer_iface);
|
2006-05-17 18:26:30 +02:00
|
|
|
|
|
|
|
This->impl = impl;
|
2005-11-18 13:06:12 +01:00
|
|
|
}
|
2006-04-18 00:41:43 +02:00
|
|
|
|
2006-05-17 18:26:30 +02:00
|
|
|
void ConnectionPointContainer_Destroy(ConnectionPointContainer *This)
|
2006-04-18 00:41:43 +02:00
|
|
|
{
|
2006-05-17 18:26:30 +02:00
|
|
|
ConnectionPoint_Destroy(This->wbe2);
|
|
|
|
ConnectionPoint_Destroy(This->wbe);
|
|
|
|
ConnectionPoint_Destroy(This->pns);
|
2006-04-18 00:41:43 +02:00
|
|
|
}
|