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)
|
|
|
|
*
|
|
|
|
* 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
|
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-11-17 12:40:55 +01:00
|
|
|
typedef struct {
|
|
|
|
const IConnectionPointVtbl *lpConnectionPointVtbl;
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
WebBrowser *webbrowser;
|
|
|
|
|
|
|
|
IID iid;
|
|
|
|
} ConnectionPoint;
|
|
|
|
|
|
|
|
#define CONPOINT(x) ((IConnectionPoint*) &(x)->lpConnectionPointVtbl)
|
2003-09-09 21:39:31 +02:00
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* Implement the IConnectionPointContainer interface
|
|
|
|
*/
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
#define CONPTCONT_THIS(iface) DEFINE_THIS(WebBrowser, ConnectionPointContainer, iface)
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
|
|
|
|
REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
WebBrowser *This = CONPTCONT_THIS(iface);
|
|
|
|
return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
|
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
|
|
|
{
|
2005-09-12 12:10:04 +02:00
|
|
|
WebBrowser *This = CONPTCONT_THIS(iface);
|
|
|
|
return IWebBrowser_AddRef(WEBBROWSER(This));
|
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
|
|
|
{
|
2005-09-12 12:10:04 +02:00
|
|
|
WebBrowser *This = CONPTCONT_THIS(iface);
|
|
|
|
return IWebBrowser_Release(WEBBROWSER(This));
|
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
|
|
|
{
|
2005-09-12 12:10:04 +02:00
|
|
|
WebBrowser *This = CONPTCONT_THIS(iface);
|
|
|
|
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
|
|
|
{
|
2005-09-12 12:10:04 +02:00
|
|
|
WebBrowser *This = CONPTCONT_THIS(iface);
|
|
|
|
|
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);
|
|
|
|
*ppCP = This->cp_wbe2;
|
|
|
|
}else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
|
|
|
|
TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
|
|
|
|
*ppCP = This->cp_wbe;
|
|
|
|
}else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
|
|
|
|
*ppCP = This->cp_pns;
|
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));
|
|
|
|
return E_NOINTERFACE;
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
2005-09-12 12:10:04 +02:00
|
|
|
#undef CONPTCONT_THIS
|
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
|
|
|
|
*/
|
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
#define CONPOINT_THIS(iface) DEFINE_THIS(ConnectionPoint, ConnectionPoint, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
2001-01-11 23:32:44 +01:00
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(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);
|
|
|
|
*ppv = CONPOINT(This);
|
|
|
|
}else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
|
|
|
|
*ppv = CONPOINT(This);
|
|
|
|
}
|
2001-01-11 23:32:44 +01:00
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
if(*ppv) {
|
|
|
|
IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser));
|
|
|
|
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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
return IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser));
|
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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
return IWebBrowser2_Release(WEBBROWSER(This->webbrowser));
|
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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pIID);
|
|
|
|
|
|
|
|
memcpy(pIID, &This->iid, sizeof(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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(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
|
|
|
|
2005-11-17 12:40:55 +01:00
|
|
|
*ppCPC = CONPTCONT(This->webbrowser);
|
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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
|
|
|
|
return E_NOTIMPL;
|
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
|
|
|
{
|
2005-11-17 12:40:55 +01:00
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%ld)\n", This, dwCookie);
|
|
|
|
return E_NOTIMPL;
|
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)
|
|
|
|
{
|
|
|
|
ConnectionPoint *This = CONPOINT_THIS(iface);
|
|
|
|
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
|
|
|
#undef CONPOINT_THIS
|
|
|
|
|
|
|
|
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-11-17 12:40:55 +01:00
|
|
|
static void ConnectionPoint_Create(WebBrowser *wb, REFIID riid, IConnectionPoint **cp)
|
|
|
|
{
|
|
|
|
ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
|
|
|
|
|
|
|
|
ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
|
|
|
|
ret->webbrowser = wb;
|
|
|
|
memcpy(&ret->iid, riid, sizeof(IID));
|
|
|
|
|
|
|
|
*cp = CONPOINT(ret);
|
|
|
|
}
|
2005-09-12 12:10:04 +02:00
|
|
|
|
|
|
|
void WebBrowser_Events_Init(WebBrowser *This)
|
|
|
|
{
|
|
|
|
This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
|
2005-11-17 12:40:55 +01:00
|
|
|
|
|
|
|
ConnectionPoint_Create(This, &DIID_DWebBrowserEvents2, &This->cp_wbe2);
|
|
|
|
ConnectionPoint_Create(This, &DIID_DWebBrowserEvents, &This->cp_wbe);
|
|
|
|
ConnectionPoint_Create(This, &IID_IPropertyNotifySink, &This->cp_pns);
|
2005-09-12 12:10:04 +02:00
|
|
|
}
|
2005-11-18 13:06:12 +01:00
|
|
|
|
|
|
|
void WebBrowser_Events_Destroy(WebBrowser *This)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->cp_wbe2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->cp_wbe);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->cp_pns);
|
|
|
|
}
|