Release 0.9.14.
[wine/multimedia.git] / dlls / mshtml / conpoint.c
blob53841859ccec5dec72cf4c60319d496fa41442df
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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.
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.
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 #define CONPOINT(x) ((IConnectionPoint*) &(x)->lpConnectionPointVtbl);
39 struct ConnectionPoint {
40 const IConnectionPointVtbl *lpConnectionPointVtbl;
42 HTMLDocument *doc;
43 IID iid;
46 #define CONPOINT_THIS(iface) DEFINE_THIS(ConnectionPoint, ConnectionPoint, iface)
48 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
49 REFIID riid, LPVOID *ppv)
51 ConnectionPoint *This = CONPOINT_THIS(iface);
53 *ppv = NULL;
55 if(IsEqualGUID(&IID_IUnknown, riid)) {
56 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
57 *ppv = CONPOINT(This);
58 }else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
59 TRACE("(%p)->(IID_IConnectionPoint %p)\n", This, ppv);
60 *ppv = CONPOINT(This);
63 if(*ppv) {
64 IUnknown_AddRef((IUnknown*)*ppv);
65 return S_OK;
68 WARN("Unsupported interface %s\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
72 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
74 ConnectionPoint *This = CONPOINT_THIS(iface);
75 return IHTMLDocument2_AddRef(HTMLDOC(This->doc));
78 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
80 ConnectionPoint *This = CONPOINT_THIS(iface);
81 return IHTMLDocument2_Release(HTMLDOC(This->doc));
84 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
86 ConnectionPoint *This = CONPOINT_THIS(iface);
88 TRACE("(%p)->(%p)\n", This, pIID);
90 if(!pIID)
91 return E_POINTER;
93 memcpy(pIID, &This->iid, sizeof(IID));
94 return S_OK;
97 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
98 IConnectionPointContainer **ppCPC)
100 ConnectionPoint *This = CONPOINT_THIS(iface);
102 TRACE("(%p)->(%p)\n", This, ppCPC);
104 if(!ppCPC)
105 return E_POINTER;
107 *ppCPC = CONPTCONT(This->doc);
108 IConnectionPointContainer_AddRef(*ppCPC);
109 return S_OK;
112 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
113 DWORD *pdwCookie)
115 ConnectionPoint *This = CONPOINT_THIS(iface);
116 FIXME("(%p)->(%p %p)\n", This, pUnkSink, pdwCookie);
117 return E_NOTIMPL;
120 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
122 ConnectionPoint *This = CONPOINT_THIS(iface);
123 FIXME("(%p)->(%ld)\n", This, dwCookie);
124 return E_NOTIMPL;
127 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
128 IEnumConnections **ppEnum)
130 ConnectionPoint *This = CONPOINT_THIS(iface);
131 FIXME("(%p)->(%p)\n", This, ppEnum);
132 return E_NOTIMPL;
135 #undef CONPOINT_THIS
137 static const IConnectionPointVtbl ConnectionPointVtbl =
139 ConnectionPoint_QueryInterface,
140 ConnectionPoint_AddRef,
141 ConnectionPoint_Release,
142 ConnectionPoint_GetConnectionInterface,
143 ConnectionPoint_GetConnectionPointContainer,
144 ConnectionPoint_Advise,
145 ConnectionPoint_Unadvise,
146 ConnectionPoint_EnumConnections
149 static void ConnectionPoint_Create(HTMLDocument *doc, REFIID riid, ConnectionPoint **cp)
151 ConnectionPoint *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ConnectionPoint));
153 ret->lpConnectionPointVtbl = &ConnectionPointVtbl;
154 ret->doc = doc;
155 memcpy(&ret->iid, riid, sizeof(IID));
157 *cp = ret;
160 #define CONPTCONT_THIS(iface) DEFINE_THIS(HTMLDocument, ConnectionPointContainer, iface)
162 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
163 REFIID riid, void **ppv)
165 HTMLDocument *This = CONPTCONT_THIS(iface);
166 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
169 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
171 HTMLDocument *This = CONPTCONT_THIS(iface);
172 return IHTMLDocument2_AddRef(HTMLDOC(This));
175 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
177 HTMLDocument *This = CONPTCONT_THIS(iface);
178 return IHTMLDocument2_Release(HTMLDOC(This));
181 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
182 IEnumConnectionPoints **ppEnum)
184 HTMLDocument *This = CONPTCONT_THIS(iface);
185 FIXME("(%p)->(%p)\n", This, ppEnum);
186 return E_NOTIMPL;
189 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
190 REFIID riid, IConnectionPoint **ppCP)
192 HTMLDocument *This = CONPTCONT_THIS(iface);
194 *ppCP = NULL;
196 if(IsEqualGUID(&DIID_HTMLDocumentEvents, riid)) {
197 TRACE("(%p)->(DIID_HTMLDocumentEvents %p)\n", This, ppCP);
198 *ppCP = CONPOINT(This->cp_htmldocevents);
199 }else if(IsEqualGUID(&DIID_HTMLDocumentEvents2, riid)) {
200 TRACE("(%p)->(DIID_HTMLDocumentEvents2 %p)\n", This, ppCP);
201 *ppCP = CONPOINT(This->cp_htmldocevents2);
204 if(*ppCP) {
205 IConnectionPoint_AddRef(*ppCP);
206 return S_OK;
209 FIXME("(%p)->(%s %p) unsupported riid\n", This, debugstr_guid(riid), ppCP);
210 return CONNECT_E_NOCONNECTION;
213 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
214 ConnectionPointContainer_QueryInterface,
215 ConnectionPointContainer_AddRef,
216 ConnectionPointContainer_Release,
217 ConnectionPointContainer_EnumConnectionPoints,
218 ConnectionPointContainer_FindConnectionPoint
221 #undef CONPTCONT_THIS
223 void HTMLDocument_ConnectionPoints_Init(HTMLDocument *This)
225 This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
227 ConnectionPoint_Create(This, &DIID_HTMLDocumentEvents, &This->cp_htmldocevents);
228 ConnectionPoint_Create(This, &DIID_HTMLDocumentEvents2, &This->cp_htmldocevents2);