ReactOS 0.4.15-dev-8344-g0574987
conpoint.c
Go to the documentation of this file.
1/*
2 * Copyright 2006 Jacek Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "mshtml_private.h"
20
21typedef struct {
22 IEnumConnections IEnumConnections_iface;
23
24 LONG ref;
25
26 unsigned iter;
29
31{
32 return CONTAINING_RECORD(iface, EnumConnections, IEnumConnections_iface);
33}
34
36{
38
39 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
40
42 *ppv = &This->IEnumConnections_iface;
44 *ppv = &This->IEnumConnections_iface;
45 }else {
46 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
47 *ppv = NULL;
48 return E_NOINTERFACE;
49 }
50
51 IUnknown_AddRef((IUnknown*)*ppv);
52 return S_OK;
53}
54
56{
59
60 TRACE("(%p) ref=%d\n", This, ref);
61
62 return ref;
63}
64
66{
69
70 TRACE("(%p) ref=%d\n", This, ref);
71
72 if(!ref) {
73 IConnectionPoint_Release(&This->cp->IConnectionPoint_iface);
75 }
76
77 return ref;
78}
79
80static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *rgcd, ULONG *pcFetched)
81{
83 ULONG fetched = 0;
84
85 TRACE("(%p)->(%d %p %p)\n", This, cConnections, rgcd, pcFetched);
86
87 while(fetched < cConnections && This->iter < This->cp->sinks_size) {
88 if(!This->cp->sinks[This->iter].unk) {
89 This->iter++;
90 continue;
91 }
92
93 rgcd[fetched].pUnk = This->cp->sinks[This->iter].unk;
94 rgcd[fetched].dwCookie = ++This->iter;
95 IUnknown_AddRef(rgcd[fetched].pUnk);
96 fetched++;
97 }
98
99 if(pcFetched)
100 *pcFetched = fetched;
101 return fetched == cConnections ? S_OK : S_FALSE;
102}
103
105{
107 FIXME("(%p)->(%d)\n", This, cConnections);
108 return E_NOTIMPL;
109}
110
112{
114 FIXME("(%p)\n", This);
115 return E_NOTIMPL;
116}
117
119{
121 FIXME("(%p)->(%p)\n", This, ppEnum);
122 return E_NOTIMPL;
123}
124
125static const IEnumConnectionsVtbl EnumConnectionsVtbl = {
133};
134
136{
137 return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
138}
139
142{
144
145 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
146
148 *ppv = &This->IConnectionPoint_iface;
150 *ppv = &This->IConnectionPoint_iface;
151 }else {
152 *ppv = NULL;
153 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
154 return E_NOINTERFACE;
155 }
156
157 IUnknown_AddRef((IUnknown*)*ppv);
158 return S_OK;
159}
160
162{
164 return IConnectionPointContainer_AddRef(&This->container->IConnectionPointContainer_iface);
165}
166
168{
170 return IConnectionPointContainer_Release(&This->container->IConnectionPointContainer_iface);
171}
172
174{
176
177 TRACE("(%p)->(%p)\n", This, pIID);
178
179 if(!pIID)
180 return E_POINTER;
181
182 *pIID = *This->iid;
183 return S_OK;
184}
185
188{
190
191 TRACE("(%p)->(%p)\n", This, ppCPC);
192
193 if(!ppCPC)
194 return E_POINTER;
195
196 *ppCPC = &This->container->IConnectionPointContainer_iface;
197 IConnectionPointContainer_AddRef(*ppCPC);
198 return S_OK;
199}
200
202 DWORD *pdwCookie)
203{
205 IUnknown *sink;
206 DWORD i;
208
209 TRACE("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
210
211 hres = IUnknown_QueryInterface(pUnkSink, This->iid, (void**)&sink);
213 hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&sink);
214 if(FAILED(hres))
216
217 if(This->sinks) {
218 for(i=0; i<This->sinks_size; i++) {
219 if(!This->sinks[i].unk)
220 break;
221 }
222
223 if(i == This->sinks_size)
224 This->sinks = heap_realloc(This->sinks,(++This->sinks_size)*sizeof(*This->sinks));
225 }else {
226 This->sinks = heap_alloc(sizeof(*This->sinks));
227 This->sinks_size = 1;
228 i = 0;
229 }
230
231 This->sinks[i].unk = sink;
232 if(pdwCookie)
233 *pdwCookie = i+1;
234
235 if(!i && This->data && This->data->on_advise)
236 This->data->on_advise(This->container->outer, This->data);
237
238 return S_OK;
239}
240
242{
244 TRACE("(%p)->(%d)\n", This, dwCookie);
245
246 if(!dwCookie || dwCookie > This->sinks_size || !This->sinks[dwCookie-1].unk)
248
249 IUnknown_Release(This->sinks[dwCookie-1].unk);
250 This->sinks[dwCookie-1].unk = NULL;
251
252 return S_OK;
253}
254
256 IEnumConnections **ppEnum)
257{
260
261 TRACE("(%p)->(%p)\n", This, ppEnum);
262
263 ret = heap_alloc(sizeof(*ret));
264 if(!ret)
265 return E_OUTOFMEMORY;
266
267 ret->IEnumConnections_iface.lpVtbl = &EnumConnectionsVtbl;
268 ret->ref = 1;
269 ret->iter = 0;
270
271 IConnectionPoint_AddRef(&This->IConnectionPoint_iface);
272 ret->cp = This;
273
274 *ppEnum = &ret->IEnumConnections_iface;
275 return S_OK;
276}
277
278static const IConnectionPointVtbl ConnectionPointVtbl =
279{
288};
289
291{
292 cp->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
293 cp->container = container;
294 cp->sinks = NULL;
295 cp->sinks_size = 0;
296 cp->iid = riid;
297 cp->data = data;
298}
299
301{
302 DWORD i;
303
304 for(i=0; i<This->sinks_size; i++) {
305 if(This->sinks[i].unk)
306 IUnknown_Release(This->sinks[i].unk);
307 }
308
309 heap_free(This->sinks);
310}
311
313{
314 const cpc_entry_t *iter;
315 unsigned idx, i;
316
317 for(iter = container->cp_entries; iter->riid; iter++) {
318 if(IsEqualGUID(iter->riid, riid))
319 break;
320 }
321 if(!iter->riid)
322 return NULL;
323 idx = iter - container->cp_entries;
324
325 if(!container->cps) {
326 if(!do_create)
327 return NULL;
328
329 while(iter->riid)
330 iter++;
331 container->cps = heap_alloc((iter - container->cp_entries) * sizeof(*container->cps));
332 if(!container->cps)
333 return NULL;
334
335 for(i=0; container->cp_entries[i].riid; i++)
336 ConnectionPoint_Init(container->cps+i, container, container->cp_entries[i].riid, container->cp_entries[i].desc);
337 }
338
339 return container->cps+idx;
340}
341
343{
345 DWORD i;
346
348 if(!cp)
349 return;
350
351 for(i=0; i<cp->sinks_size; i++) {
352 if(cp->sinks[i].propnotif)
353 IPropertyNotifySink_OnChanged(cp->sinks[i].propnotif, dispid);
354 }
355}
356
358{
359 return CONTAINING_RECORD(iface, ConnectionPointContainer, IConnectionPointContainer_iface);
360}
361
363 REFIID riid, void **ppv)
364{
366 return IUnknown_QueryInterface(This->outer, riid, ppv);
367}
368
370{
372 return IUnknown_AddRef(This->outer);
373}
374
376{
378 return IUnknown_Release(This->outer);
379}
380
382 IEnumConnectionPoints **ppEnum)
383{
385 FIXME("(%p)->(%p)\n", This, ppEnum);
386 return E_NOTIMPL;
387}
388
391{
394
395 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppCP);
396
397 if(This->forward_container)
398 return IConnectionPointContainer_FindConnectionPoint(&This->forward_container->IConnectionPointContainer_iface,
399 riid, ppCP);
400
401 cp = get_cp(This, riid, TRUE);
402 if(!cp) {
403 FIXME("unsupported riid %s\n", debugstr_mshtml_guid(riid));
404 *ppCP = NULL;
406 }
407
408 *ppCP = &cp->IConnectionPoint_iface;
409 IConnectionPoint_AddRef(*ppCP);
410 return S_OK;
411}
412
413static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
419};
420
422{
423 This->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
424 This->cp_entries = cp_entries;
425 This->cps = NULL;
426 This->outer = outer;
427 This->forward_container = NULL;
428}
429
431{
432 unsigned i;
433
434 if(!This->cps)
435 return;
436
437 for(i=0; This->cp_entries[i].riid; i++)
439 heap_free(This->cps);
440}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
static HRESULT WINAPI EnumConnections_Skip(IEnumConnections *iface, ULONG cConnections)
Definition: conpoint.c:104
static ConnectionPoint * impl_from_IConnectionPoint(IConnectionPoint *iface)
Definition: conpoint.c:135
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink, DWORD *pdwCookie)
Definition: conpoint.c:201
static ULONG WINAPI EnumConnections_Release(IEnumConnections *iface)
Definition: conpoint.c:65
static EnumConnections * impl_from_IEnumConnections(IEnumConnections *iface)
Definition: conpoint.c:30
static void ConnectionPoint_Destroy(ConnectionPoint *This)
Definition: conpoint.c:300
static ULONG WINAPI EnumConnections_AddRef(IEnumConnections *iface)
Definition: conpoint.c:55
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **ppCP)
Definition: conpoint.c:389
static void ConnectionPoint_Init(ConnectionPoint *cp, ConnectionPointContainer *container, REFIID riid, cp_static_data_t *data)
Definition: conpoint.c:290
void ConnectionPointContainer_Destroy(ConnectionPointContainer *This)
Definition: conpoint.c:430
static ConnectionPointContainer * impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
Definition: conpoint.c:357
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
Definition: conpoint.c:173
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, void **ppv)
Definition: conpoint.c:362
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **ppEnum)
Definition: conpoint.c:381
static HRESULT WINAPI EnumConnections_QueryInterface(IEnumConnections *iface, REFIID riid, void **ppv)
Definition: conpoint.c:35
static const IConnectionPointVtbl ConnectionPointVtbl
Definition: conpoint.c:278
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, LPVOID *ppv)
Definition: conpoint.c:140
static HRESULT WINAPI EnumConnections_Reset(IEnumConnections *iface)
Definition: conpoint.c:111
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
Definition: conpoint.c:241
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl
Definition: conpoint.c:413
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
Definition: conpoint.c:369
static const IEnumConnectionsVtbl EnumConnectionsVtbl
Definition: conpoint.c:125
void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *outer, const cpc_entry_t *cp_entries)
Definition: conpoint.c:421
static ConnectionPoint * get_cp(ConnectionPointContainer *container, REFIID riid, BOOL do_create)
Definition: conpoint.c:312
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface, IConnectionPointContainer **ppCPC)
Definition: conpoint.c:186
void call_property_onchanged(ConnectionPointContainer *container, DISPID dispid)
Definition: conpoint.c:342
static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *rgcd, ULONG *pcFetched)
Definition: conpoint.c:80
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface, IEnumConnections **ppEnum)
Definition: conpoint.c:255
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
Definition: conpoint.c:161
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
Definition: conpoint.c:375
static HRESULT WINAPI EnumConnections_Clone(IEnumConnections *iface, IEnumConnections **ppEnum)
Definition: conpoint.c:118
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
Definition: conpoint.c:167
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
const char * debugstr_mshtml_guid(const GUID *iid)
Definition: main.c:542
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
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
POINT cp
Definition: magnifier.c:59
HRESULT hres
Definition: protocol.c:465
static VARIANTARG static DISPID
Definition: ordinal.c:52
#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 TRACE(s)
Definition: solgame.cpp:4
unsigned iter
Definition: conpoint.c:26
const IID * riid
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365