2fb6dc2e10740737389f5488844875e3ca46c1b4
[reactos.git] / reactos / lib / shdocvw / events.c
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 *
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.
13 *
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.
18 *
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
22 */
23
24 #include <string.h>
25 #include "wine/debug.h"
26 #include "shdocvw.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
29
30 static IConnectionPointImpl SHDOCVW_ConnectionPoint;
31
32 static const GUID IID_INotifyDBEvents =
33 { 0xdb526cc0, 0xd188, 0x11cd, { 0xad, 0x48, 0x00, 0xaa, 0x00, 0x3c, 0x9c, 0xb6 } };
34
35 /**********************************************************************
36 * Implement the IConnectionPointContainer interface
37 */
38
39 #define CONPTCONT_THIS(iface) DEFINE_THIS(WebBrowser, ConnectionPointContainer, iface)
40
41 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
42 REFIID riid, LPVOID *ppobj)
43 {
44 WebBrowser *This = CONPTCONT_THIS(iface);
45 return IWebBrowser_QueryInterface(WEBBROWSER(This), riid, ppobj);
46 }
47
48 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
49 {
50 WebBrowser *This = CONPTCONT_THIS(iface);
51 return IWebBrowser_AddRef(WEBBROWSER(This));
52 }
53
54 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
55 {
56 WebBrowser *This = CONPTCONT_THIS(iface);
57 return IWebBrowser_Release(WEBBROWSER(This));
58 }
59
60 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
61 LPENUMCONNECTIONPOINTS *ppEnum)
62 {
63 WebBrowser *This = CONPTCONT_THIS(iface);
64 FIXME("(%p)->(%p)\n", This, ppEnum);
65 return E_NOTIMPL;
66 }
67
68 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
69 REFIID riid, LPCONNECTIONPOINT *ppCP)
70 {
71 WebBrowser *This = CONPTCONT_THIS(iface);
72
73 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppCP);
74
75 /* For now, return the same IConnectionPoint object for both
76 * event interface requests.
77 */
78 if (IsEqualGUID (&IID_INotifyDBEvents, riid))
79 {
80 TRACE("Returning connection point %p for IID_INotifyDBEvents\n",
81 &SHDOCVW_ConnectionPoint);
82 *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
83 return S_OK;
84 }
85 else if (IsEqualGUID (&IID_IPropertyNotifySink, riid))
86 {
87 TRACE("Returning connection point %p for IID_IPropertyNotifySink\n",
88 &SHDOCVW_ConnectionPoint);
89 *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
90 return S_OK;
91 }
92
93 return E_FAIL;
94 }
95
96 #undef CONPTCONT_THIS
97
98 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
99 {
100 ConnectionPointContainer_QueryInterface,
101 ConnectionPointContainer_AddRef,
102 ConnectionPointContainer_Release,
103 ConnectionPointContainer_EnumConnectionPoints,
104 ConnectionPointContainer_FindConnectionPoint
105 };
106
107
108 /**********************************************************************
109 * Implement the IConnectionPoint interface
110 */
111
112 static HRESULT WINAPI WBCP_QueryInterface(LPCONNECTIONPOINT iface,
113 REFIID riid, LPVOID *ppobj)
114 {
115 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
116
117 if (ppobj == NULL) return E_POINTER;
118
119 return E_NOINTERFACE;
120 }
121
122 static ULONG WINAPI WBCP_AddRef(LPCONNECTIONPOINT iface)
123 {
124 SHDOCVW_LockModule();
125
126 return 2; /* non-heap based object */
127 }
128
129 static ULONG WINAPI WBCP_Release(LPCONNECTIONPOINT iface)
130 {
131 SHDOCVW_UnlockModule();
132
133 return 1; /* non-heap based object */
134 }
135
136 static HRESULT WINAPI WBCP_GetConnectionInterface(LPCONNECTIONPOINT iface, IID* pIId)
137 {
138 FIXME("stub: %s\n", debugstr_guid(pIId));
139 return S_OK;
140 }
141
142 /* Get this connection point's owning container */
143 static HRESULT WINAPI
144 WBCP_GetConnectionPointContainer(LPCONNECTIONPOINT iface,
145 LPCONNECTIONPOINTCONTAINER *ppCPC)
146 {
147 FIXME("stub: IConnectionPointContainer = %p\n", *ppCPC);
148 return S_OK;
149 }
150
151 /* Connect the pUnkSink event-handling implementation (in the control site)
152 * to this connection point. Return a handle to this connection in
153 * pdwCookie (for later use in Unadvise()).
154 */
155 static HRESULT WINAPI WBCP_Advise(LPCONNECTIONPOINT iface,
156 LPUNKNOWN pUnkSink, DWORD *pdwCookie)
157 {
158 static int new_cookie;
159
160 FIXME("stub: IUnknown = %p, connection cookie = %ld\n", pUnkSink, *pdwCookie);
161
162 *pdwCookie = ++new_cookie;
163 TRACE ("Returning cookie = %ld\n", *pdwCookie);
164
165 return S_OK;
166 }
167
168 /* Disconnect this implementation from the connection point. */
169 static HRESULT WINAPI WBCP_Unadvise(LPCONNECTIONPOINT iface,
170 DWORD dwCookie)
171 {
172 FIXME("stub: cookie to disconnect = %lx\n", dwCookie);
173 return S_OK;
174 }
175
176 /* Get a list of connections in this connection point. */
177 static HRESULT WINAPI WBCP_EnumConnections(LPCONNECTIONPOINT iface,
178 LPENUMCONNECTIONS *ppEnum)
179 {
180 FIXME("stub: IEnumConnections = %p\n", *ppEnum);
181 return S_OK;
182 }
183
184 /**********************************************************************
185 * IConnectionPoint virtual function table for IE Web Browser component
186 */
187
188 static const IConnectionPointVtbl WBCP_Vtbl =
189 {
190 WBCP_QueryInterface,
191 WBCP_AddRef,
192 WBCP_Release,
193 WBCP_GetConnectionInterface,
194 WBCP_GetConnectionPointContainer,
195 WBCP_Advise,
196 WBCP_Unadvise,
197 WBCP_EnumConnections
198 };
199
200 static IConnectionPointImpl SHDOCVW_ConnectionPoint = {&WBCP_Vtbl};
201
202 void WebBrowser_Events_Init(WebBrowser *This)
203 {
204 This->lpConnectionPointContainerVtbl = &ConnectionPointContainerVtbl;
205 }