po: Remove English strings from the Polish shell folder path translations.
[wine/multimedia.git] / dlls / ieframe / events.c
blob5a426ab5e5886c355068166c00401c7666557c84
1 /*
2 * Implementation of event-related interfaces for WebBrowser control:
4 * - IConnectionPointContainer
5 * - IConnectionPoint
7 * Copyright 2001 John R. Sheets (for CodeWeavers)
8 * Copyright 2006 Jacek Caban for CodeWeavers
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <string.h>
27 #include "ieframe.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
33 struct ConnectionPoint {
34 IConnectionPoint IConnectionPoint_iface;
36 IConnectionPointContainer *container;
38 IDispatch **sinks;
39 DWORD sinks_size;
41 IID iid;
44 /**********************************************************************
45 * Implement the IConnectionPointContainer interface
48 static inline ConnectionPointContainer *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
50 return CONTAINING_RECORD(iface, ConnectionPointContainer, IConnectionPointContainer_iface);
53 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
54 REFIID riid, LPVOID *ppv)
56 ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
57 return IUnknown_QueryInterface(This->impl, riid, ppv);
60 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
62 ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
63 return IUnknown_AddRef(This->impl);
66 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
68 ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
69 return IUnknown_Release(This->impl);
72 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
73 LPENUMCONNECTIONPOINTS *ppEnum)
75 ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
76 FIXME("(%p)->(%p)\n", This, ppEnum);
77 return E_NOTIMPL;
80 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
81 REFIID riid, LPCONNECTIONPOINT *ppCP)
83 ConnectionPointContainer *This = impl_from_IConnectionPointContainer(iface);
85 if(!ppCP) {
86 WARN("ppCP == NULL\n");
87 return E_POINTER;
90 *ppCP = NULL;
92 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
93 TRACE("(%p)->(DIID_DWebBrowserEvents2 %p)\n", This, ppCP);
94 *ppCP = &This->wbe2->IConnectionPoint_iface;
95 }else if(IsEqualGUID(&DIID_DWebBrowserEvents, riid)) {
96 TRACE("(%p)->(DIID_DWebBrowserEvents %p)\n", This, ppCP);
97 *ppCP = &This->wbe->IConnectionPoint_iface;
98 }else if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
99 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
100 *ppCP = &This->pns->IConnectionPoint_iface;
103 if(*ppCP) {
104 IConnectionPoint_AddRef(*ppCP);
105 return S_OK;
108 WARN("Unsupported IID %s\n", debugstr_guid(riid));
109 return CONNECT_E_NOCONNECTION;
112 #undef impl_from_IConnectionPointContainer
114 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
116 ConnectionPointContainer_QueryInterface,
117 ConnectionPointContainer_AddRef,
118 ConnectionPointContainer_Release,
119 ConnectionPointContainer_EnumConnectionPoints,
120 ConnectionPointContainer_FindConnectionPoint
124 /**********************************************************************
125 * Implement the IConnectionPoint interface
128 static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
130 return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
133 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
134 REFIID riid, LPVOID *ppv)
136 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
138 *ppv = NULL;
140 if(IsEqualGUID(&IID_IUnknown, riid)) {
141 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
142 *ppv = &This->IConnectionPoint_iface;
143 }else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
144 TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
145 *ppv = &This->IConnectionPoint_iface;
148 if(*ppv) {
149 IConnectionPointContainer_AddRef(This->container);
150 return S_OK;
153 WARN("Unsupported interface %s\n", debugstr_guid(riid));
154 return E_NOINTERFACE;
157 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
159 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
160 return IConnectionPointContainer_AddRef(This->container);
163 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
165 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
166 return IConnectionPointContainer_Release(This->container);
169 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
171 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
173 TRACE("(%p)->(%p)\n", This, pIID);
175 *pIID = This->iid;
176 return S_OK;
179 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
180 IConnectionPointContainer **ppCPC)
182 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
184 TRACE("(%p)->(%p)\n", This, ppCPC);
186 *ppCPC = This->container;
187 IConnectionPointContainer_AddRef(This->container);
188 return S_OK;
191 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
192 DWORD *pdwCookie)
194 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
195 IDispatch *disp;
196 DWORD i;
197 HRESULT hres;
199 TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
201 hres = IUnknown_QueryInterface(pUnkSink, &This->iid, (void**)&disp);
202 if(FAILED(hres)) {
203 hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&disp);
204 if(FAILED(hres))
205 return CONNECT_E_CANNOTCONNECT;
208 if(This->sinks) {
209 for(i=0; i<This->sinks_size; i++) {
210 if(!This->sinks[i])
211 break;
214 if(i == This->sinks_size)
215 This->sinks = heap_realloc(This->sinks,
216 (++This->sinks_size)*sizeof(*This->sinks));
217 }else {
218 This->sinks = heap_alloc(sizeof(*This->sinks));
219 This->sinks_size = 1;
220 i = 0;
223 This->sinks[i] = disp;
224 *pdwCookie = i+1;
226 return S_OK;
229 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
231 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
233 TRACE("(%p)->(%d)\n", This, dwCookie);
235 if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1])
236 return CONNECT_E_NOCONNECTION;
238 IDispatch_Release(This->sinks[dwCookie-1]);
239 This->sinks[dwCookie-1] = NULL;
241 return S_OK;
244 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
245 IEnumConnections **ppEnum)
247 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
248 FIXME("(%p)->(%p)\n", This, ppEnum);
249 return E_NOTIMPL;
252 static const IConnectionPointVtbl ConnectionPointVtbl =
254 ConnectionPoint_QueryInterface,
255 ConnectionPoint_AddRef,
256 ConnectionPoint_Release,
257 ConnectionPoint_GetConnectionInterface,
258 ConnectionPoint_GetConnectionPointContainer,
259 ConnectionPoint_Advise,
260 ConnectionPoint_Unadvise,
261 ConnectionPoint_EnumConnections
264 void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
266 DWORD i;
268 for(i=0; i<This->sinks_size; i++) {
269 if(This->sinks[i])
270 IDispatch_Invoke(This->sinks[i], dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
271 DISPATCH_METHOD, dispparams, NULL, NULL, NULL);
275 static void ConnectionPoint_Create(REFIID riid, ConnectionPoint **cp,
276 IConnectionPointContainer *container)
278 ConnectionPoint *ret = heap_alloc(sizeof(ConnectionPoint));
280 ret->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
282 ret->sinks = NULL;
283 ret->sinks_size = 0;
284 ret->container = container;
286 ret->iid = *riid;
288 *cp = ret;
291 static void ConnectionPoint_Destroy(ConnectionPoint *This)
293 DWORD i;
295 for(i=0; i<This->sinks_size; i++) {
296 if(This->sinks[i])
297 IDispatch_Release(This->sinks[i]);
300 heap_free(This->sinks);
301 heap_free(This);
304 void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *impl)
306 This->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
308 ConnectionPoint_Create(&DIID_DWebBrowserEvents2, &This->wbe2, &This->IConnectionPointContainer_iface);
309 ConnectionPoint_Create(&DIID_DWebBrowserEvents, &This->wbe, &This->IConnectionPointContainer_iface);
310 ConnectionPoint_Create(&IID_IPropertyNotifySink, &This->pns, &This->IConnectionPointContainer_iface);
312 This->impl = impl;
315 void ConnectionPointContainer_Destroy(ConnectionPointContainer *This)
317 ConnectionPoint_Destroy(This->wbe2);
318 ConnectionPoint_Destroy(This->wbe);
319 ConnectionPoint_Destroy(This->pns);