ReactOS 0.4.17-dev-1190-g4c812f4
events.c
Go to the documentation of this file.
1/*
2 * Implementation of event-related interfaces for WebBrowser control:
3 *
4 * - IConnectionPointContainer
5 * - IConnectionPoint
6 *
7 * Copyright 2001 John R. Sheets (for CodeWeavers)
8 * Copyright 2006 Jacek Caban for CodeWeavers
9 *
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.
14 *
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.
19 *
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
23 */
24
25#include <string.h>
26
27#include "ieframe.h"
28
29#include "wine/debug.h"
30
32
35
37
40
42};
43
44/**********************************************************************
45 * Implement the IConnectionPointContainer interface
46 */
47
49{
50 return CONTAINING_RECORD(iface, ConnectionPointContainer, IConnectionPointContainer_iface);
51}
52
55{
57 return IUnknown_QueryInterface(This->impl, riid, ppv);
58}
59
61{
63 return IUnknown_AddRef(This->impl);
64}
65
67{
69 return IUnknown_Release(This->impl);
70}
71
73 LPENUMCONNECTIONPOINTS *ppEnum)
74{
76 FIXME("(%p)->(%p)\n", This, ppEnum);
77 return E_NOTIMPL;
78}
79
81 REFIID riid, LPCONNECTIONPOINT *ppCP)
82{
84
85 if(!ppCP) {
86 WARN("ppCP == NULL\n");
87 return E_POINTER;
88 }
89
90 *ppCP = NULL;
91
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;
99 TRACE("(%p)->(IID_IPropertyNotifySink %p)\n", This, ppCP);
100 *ppCP = &This->pns->IConnectionPoint_iface;
101 }
102
103 if(*ppCP) {
104 IConnectionPoint_AddRef(*ppCP);
105 return S_OK;
106 }
107
108 WARN("Unsupported IID %s\n", debugstr_guid(riid));
110}
111
112static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
113{
119};
120
121
122/**********************************************************************
123 * Implement the IConnectionPoint interface
124 */
125
127{
128 return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
129}
130
131typedef struct {
133
135
139
141{
142 return CONTAINING_RECORD(iface, EnumConnections, IEnumConnections_iface);
143}
144
146{
148
150 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
151 *ppv = &This->IEnumConnections_iface;
153 TRACE("(%p)->(IID_IEnumConnections %p)\n", This, ppv);
154 *ppv = &This->IEnumConnections_iface;
155 }else {
156 WARN("Unsupported interface %s\n", debugstr_guid(riid));
157 *ppv = NULL;
158 return E_NOINTERFACE;
159 }
160
161 IUnknown_AddRef((IUnknown*)*ppv);
162 return S_OK;
163}
164
166{
169
170 TRACE("(%p) ref=%ld\n", This, ref);
171
172 return ref;
173}
174
176{
179
180 TRACE("(%p) ref=%ld\n", This, ref);
181
182 if(!ref) {
183 IConnectionPoint_Release(&This->cp->IConnectionPoint_iface);
184 free(This);
185 }
186
187 return ref;
188}
189
190static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *pgcd, ULONG *pcFetched)
191{
193 ULONG cnt = 0;
194
195 TRACE("(%p)->(%lu %p %p)\n", This, cConnections, pgcd, pcFetched);
196
197 while(cConnections--) {
198 while(This->iter < This->cp->sinks_size && !This->cp->sinks[This->iter])
199 This->iter++;
200 if(This->iter == This->cp->sinks_size)
201 break;
202
203 pgcd[cnt].pUnk = (IUnknown*)This->cp->sinks[This->iter];
204 pgcd[cnt].dwCookie = cnt+1;
205 This->iter++;
206 cnt++;
207 }
208
209 if(pcFetched)
210 *pcFetched = cnt;
211 return cnt ? S_OK : S_FALSE;
212}
213
215{
217 FIXME("(%p)->(%lu)\n", This, cConnections);
218 return E_NOTIMPL;
219}
220
222{
224 FIXME("(%p)\n", This);
225 return E_NOTIMPL;
226}
227
229{
231 FIXME("(%p)->(%p)\n", This, ppEnum);
232 return E_NOTIMPL;
233}
234
235static const IEnumConnectionsVtbl EnumConnectionsVtbl = {
243};
244
247{
249
250 *ppv = NULL;
251
253 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
254 *ppv = &This->IConnectionPoint_iface;
256 TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
257 *ppv = &This->IConnectionPoint_iface;
258 }
259
260 if(*ppv) {
261 IConnectionPointContainer_AddRef(This->container);
262 return S_OK;
263 }
264
265 WARN("Unsupported interface %s\n", debugstr_guid(riid));
266 return E_NOINTERFACE;
267}
268
270{
272 return IConnectionPointContainer_AddRef(This->container);
273}
274
276{
278 return IConnectionPointContainer_Release(This->container);
279}
280
282{
284
285 TRACE("(%p)->(%p)\n", This, pIID);
286
287 *pIID = This->iid;
288 return S_OK;
289}
290
293{
295
296 TRACE("(%p)->(%p)\n", This, ppCPC);
297
298 *ppCPC = This->container;
299 IConnectionPointContainer_AddRef(This->container);
300 return S_OK;
301}
302
304 DWORD *pdwCookie)
305{
307 IDispatch *disp;
308 DWORD i;
310
311 TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
312
313 hres = IUnknown_QueryInterface(pUnkSink, &This->iid, (void**)&disp);
314 if(FAILED(hres)) {
315 hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&disp);
316 if(FAILED(hres))
318 }
319
320 if(This->sinks) {
321 for(i=0; i<This->sinks_size; i++) {
322 if(!This->sinks[i])
323 break;
324 }
325
326 if(i == This->sinks_size)
327 This->sinks = realloc(This->sinks, (++This->sinks_size) * sizeof(*This->sinks));
328 }else {
329 This->sinks = malloc(sizeof(*This->sinks));
330 This->sinks_size = 1;
331 i = 0;
332 }
333
334 This->sinks[i] = disp;
335 *pdwCookie = i+1;
336
337 return S_OK;
338}
339
341{
343
344 TRACE("(%p)->(%ld)\n", This, dwCookie);
345
346 if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1])
348
349 IDispatch_Release(This->sinks[dwCookie-1]);
350 This->sinks[dwCookie-1] = NULL;
351
352 return S_OK;
353}
354
356 IEnumConnections **ppEnum)
357{
360
361 TRACE("(%p)->(%p)\n", This, ppEnum);
362
363 ret = malloc(sizeof(*ret));
364 if(!ret)
365 return E_OUTOFMEMORY;
366
367 ret->IEnumConnections_iface.lpVtbl = &EnumConnectionsVtbl;
368 ret->ref = 1;
369 ret->iter = 0;
370
371 IConnectionPoint_AddRef(&This->IConnectionPoint_iface);
372 ret->cp = This;
373
374 *ppEnum = &ret->IEnumConnections_iface;
375 return S_OK;
376}
377
378static const IConnectionPointVtbl ConnectionPointVtbl =
379{
388};
389
390void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
391{
392 DWORD i;
393
394 for(i=0; i<This->sinks_size; i++) {
395 if(This->sinks[i])
396 IDispatch_Invoke(This->sinks[i], dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
397 DISPATCH_METHOD, dispparams, NULL, NULL, NULL);
398 }
399}
400
403{
405
406 ret->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
407
408 ret->sinks = NULL;
409 ret->sinks_size = 0;
410 ret->container = container;
411
412 ret->iid = *riid;
413
414 *cp = ret;
415}
416
418{
419 DWORD i;
420
421 for(i=0; i<This->sinks_size; i++) {
422 if(This->sinks[i])
423 IDispatch_Release(This->sinks[i]);
424 }
425
426 free(This->sinks);
427 free(This);
428}
429
431{
432 This->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
433
434 ConnectionPoint_Create(&DIID_DWebBrowserEvents2, &This->wbe2, &This->IConnectionPointContainer_iface);
435 ConnectionPoint_Create(&DIID_DWebBrowserEvents, &This->wbe, &This->IConnectionPointContainer_iface);
436 ConnectionPoint_Create(&IID_IPropertyNotifySink, &This->pns, &This->IConnectionPointContainer_iface);
437
438 This->impl = impl;
439}
440
442{
446}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
static HRESULT WINAPI EnumConnections_Skip(IEnumConnections *iface, ULONG cConnections)
Definition: events.c:214
static ConnectionPoint * impl_from_IConnectionPoint(IConnectionPoint *iface)
Definition: events.c:126
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink, DWORD *pdwCookie)
Definition: events.c:303
static ULONG WINAPI EnumConnections_Release(IEnumConnections *iface)
Definition: events.c:175
static EnumConnections * impl_from_IEnumConnections(IEnumConnections *iface)
Definition: events.c:140
static void ConnectionPoint_Destroy(ConnectionPoint *This)
Definition: events.c:417
static ULONG WINAPI EnumConnections_AddRef(IEnumConnections *iface)
Definition: events.c:165
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams)
Definition: events.c:390
void ConnectionPointContainer_Destroy(ConnectionPointContainer *This)
Definition: events.c:441
static ConnectionPointContainer * impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
Definition: events.c:48
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
Definition: events.c:281
static HRESULT WINAPI EnumConnections_QueryInterface(IEnumConnections *iface, REFIID riid, void **ppv)
Definition: events.c:145
static const IConnectionPointVtbl ConnectionPointVtbl
Definition: events.c:378
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, LPVOID *ppv)
Definition: events.c:245
static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *pgcd, ULONG *pcFetched)
Definition: events.c:190
static HRESULT WINAPI EnumConnections_Reset(IEnumConnections *iface)
Definition: events.c:221
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
Definition: events.c:340
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, LPVOID *ppv)
Definition: events.c:53
void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *impl)
Definition: events.c:430
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl
Definition: events.c:112
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
Definition: events.c:60
static const IEnumConnectionsVtbl EnumConnectionsVtbl
Definition: events.c:235
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface, LPENUMCONNECTIONPOINTS *ppEnum)
Definition: events.c:72
static void ConnectionPoint_Create(REFIID riid, ConnectionPoint **cp, IConnectionPointContainer *container)
Definition: events.c:401
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, LPCONNECTIONPOINT *ppCP)
Definition: events.c:80
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface, IConnectionPointContainer **ppCPC)
Definition: events.c:291
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface, IEnumConnections **ppEnum)
Definition: events.c:355
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
Definition: events.c:269
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
Definition: events.c:66
static HRESULT WINAPI EnumConnections_Clone(IEnumConnections *iface, IEnumConnections **ppEnum)
Definition: events.c:228
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
Definition: events.c:275
return ret
Definition: mutex.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
POINT cp
Definition: magnifier.c:59
HRESULT hres
Definition: protocol.c:432
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define LOCALE_SYSTEM_DEFAULT
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define CONNECT_E_CANNOTCONNECT
Definition: olectl.h:253
#define CONNECT_E_NOCONNECTION
Definition: olectl.h:251
const GUID IID_IEnumConnections
const GUID IID_IConnectionPoint
const GUID IID_IPropertyNotifySink
const GUID IID_IDispatch
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
#define TRACE(s)
Definition: solgame.cpp:4
DWORD sinks_size
Definition: events.c:39
IConnectionPoint IConnectionPoint_iface
Definition: events.c:34
IDispatch ** sinks
Definition: events.c:38
IConnectionPointContainer * container
Definition: events.c:36
ConnectionPoint * cp
Definition: events.c:136
DWORD iter
Definition: events.c:137
IEnumConnections IEnumConnections_iface
Definition: events.c:132
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ size_t cnt
Definition: wcstombs.cpp:43
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480