We should always allocate in NdrConformantStringUnmarshal if the
[wine.git] / dlls / shdocvw / events.c
blob184b694e6b4219a687d87afc7cc264a37086de0e
1 /*
2 * Implementation of event-related interfaces for WebBrowser control:
4 * - IConnectionPointContainer
5 * - IConnectionPoint
7 * Copyright 2001 John R. Sheets (for CodeWeavers)
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <string.h>
25 #include "wine/debug.h"
26 #include "shdocvw.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
30 typedef struct {
31 const IConnectionPointVtbl *lpConnectionPointVtbl;
33 WebBrowser *webbrowser;
35 IID iid;
36 } ConnectionPoint;
38 #define CONPOINT(x) ((IConnectionPoint*) &(x)->lpConnectionPointVtbl)
40 /**********************************************************************
41 * Implement the IConnectionPointContainer interface
44 #define CONPTCONT_THIS(iface) DEFINE_THIS(WebBrowser, ConnectionPointContainer, iface)
46 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
47 REFIID riid, LPVOID *ppobj)
49 WebBrowser *This = CONPTCONT_THIS(iface);
50 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
53 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
55 WebBrowser *This = CONPTCONT_THIS(iface);
56 return IWebBrowser_AddRef(WEBBROWSER(This));
59 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
61 WebBrowser *This = CONPTCONT_THIS(iface);
62 return IWebBrowser_Release(WEBBROWSER(This));
65 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
66 LPENUMCONNECTIONPOINTS *ppEnum)
68 WebBrowser *This = CONPTCONT_THIS(iface);
69 FIXME("(%p)->(%p)\n", This, ppEnum);
70 return E_NOTIMPL;
73 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
74 REFIID riid, LPCONNECTIONPOINT *ppCP)
76 WebBrowser *This = CONPTCONT_THIS(iface);
78 if(!ppCP) {
79 WARN("ppCP == NULL\n");
80 return E_POINTER;
83 *ppCP = NULL;
85 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
86 TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP);
87 *ppCP = This->cp_wbe2;
88 }else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
89 TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
90 *ppCP = This->cp_wbe;
91 }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
92 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
93 *ppCP = This->cp_pns;
96 if(*ppCP) {
97 IConnectionPoint_AddRef(*ppCP);
98 return S_OK;
101 WARN("Unsupported IID %s\n", debugstr_guid(riid));
102 return E_NOINTERFACE;
105 #undef CONPTCONT_THIS
107 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
109 ConnectionPointContainer_QueryInterface,
110 ConnectionPointContainer_AddRef,
111 ConnectionPointContainer_Release,
112 ConnectionPointContainer_EnumConnectionPoints,
113 ConnectionPointContainer_FindConnectionPoint
117 /**********************************************************************
118 * Implement the IConnectionPoint interface
121 #define CONPOINT_THIS(iface) DEFINE_THIS(ConnectionPoint, ConnectionPoint, iface)
123 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
124 REFIID riid, LPVOID *ppv)
126 ConnectionPoint *This = CONPOINT_THIS(iface);
128 *ppv = NULL;
130 if(IsEqualGUID(&IID_IUnknown, riid)) {
131 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
132 *ppv = CONPOINT(This);
133 }else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
134 TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
135 *ppv = CONPOINT(This);
138 if(*ppv) {
139 IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser));
140 return S_OK;
143 WARN("Unsupported interface %s\n", debugstr_guid(riid));
144 return E_NOINTERFACE;
147 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
149 ConnectionPoint *This = CONPOINT_THIS(iface);
150 return IWebBrowser2_AddRef(WEBBROWSER(This->webbrowser));
153 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
155 ConnectionPoint *This = CONPOINT_THIS(iface);
156 return IWebBrowser2_Release(WEBBROWSER(This->webbrowser));
159 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
161 ConnectionPoint *This = CONPOINT_THIS(iface);
163 TRACE("(%p)->(%p)\n", This, pIID);
165 memcpy(pIID, &This->iid, sizeof(IID));
166 return S_OK;
169 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
170 IConnectionPointContainer **ppCPC)
172 ConnectionPoint *This = CONPOINT_THIS(iface);
174 TRACE("(%p)->(%p)\n", This, ppCPC);
176 *ppCPC = CONPTCONT(This->webbrowser);
177 return S_OK;
180 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
181 DWORD *pdwCookie)
183 ConnectionPoint *This = CONPOINT_THIS(iface);
184 FIXME("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
185 return E_NOTIMPL;
188 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
190 ConnectionPoint *This = CONPOINT_THIS(iface);
191 FIXME("(%p)->(%ld)\n", This, dwCookie);
192 return E_NOTIMPL;
195 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
196 IEnumConnections **ppEnum)
198 ConnectionPoint *This = CONPOINT_THIS(iface);
199 FIXME("(%p)->(%p)\n", This, ppEnum);
200 return E_NOTIMPL;
203 #undef CONPOINT_THIS
205 static const IConnectionPointVtbl ConnectionPointVtbl =
207 ConnectionPoint_QueryInterface,
208 ConnectionPoint_AddRef,
209 ConnectionPoint_Release,
210 ConnectionPoint_GetConnectionInterface,
211 ConnectionPoint_GetConnectionPointContainer,
212 ConnectionPoint_Advise,
213 ConnectionPoint_Unadvise,
214 ConnectionPoint_EnumConnections
217 static void ConnectionPoint_Create(WebBrowser *wb, REFIID riid, IConnectionPoint **cp)
219 ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
221 ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
222 ret->webbrowser = wb;
223 memcpy(&ret->iid, riid, sizeof(IID));
225 *cp = CONPOINT(ret);
228 void WebBrowser_Events_Init(WebBrowser *This)
230 This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
232 ConnectionPoint_Create(This, &DIID_DWebBrowserEvents2, &This->cp_wbe2);
233 ConnectionPoint_Create(This, &DIID_DWebBrowserEvents, &This->cp_wbe);
234 ConnectionPoint_Create(This, &IID_IPropertyNotifySink, &This->cp_pns);
237 void WebBrowser_Events_Destroy(WebBrowser *This)
239 HeapFree(GetProcessHeap(), 0, This->cp_wbe2);
240 HeapFree(GetProcessHeap(), 0, This->cp_wbe);
241 HeapFree(GetProcessHeap(), 0, This->cp_pns);