Sync to Wine-20050628:
[reactos.git] / reactos / lib / shdocvw / events.c
1 /*
2 * Implementation of event-related interfaces for IE Web Browser 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 static HRESULT WINAPI WBCPC_QueryInterface(LPCONNECTIONPOINTCONTAINER iface,
40 REFIID riid, LPVOID *ppobj)
41 {
42 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
43
44 if (ppobj == NULL) return E_POINTER;
45
46 return E_NOINTERFACE;
47 }
48
49 static ULONG WINAPI WBCPC_AddRef(LPCONNECTIONPOINTCONTAINER iface)
50 {
51 SHDOCVW_LockModule();
52
53 return 2; /* non-heap based object */
54 }
55
56 static ULONG WINAPI WBCPC_Release(LPCONNECTIONPOINTCONTAINER iface)
57 {
58 SHDOCVW_UnlockModule();
59
60 return 1; /* non-heap based object */
61 }
62
63 /* Get a list of connection points inside this container. */
64 static HRESULT WINAPI WBCPC_EnumConnectionPoints(LPCONNECTIONPOINTCONTAINER iface,
65 LPENUMCONNECTIONPOINTS *ppEnum)
66 {
67 FIXME("stub: IEnumConnectionPoints = %p\n", *ppEnum);
68 return S_OK;
69 }
70
71 /* Retrieve the connection point in this container associated with the
72 * riid interface. When events occur in the control, the control can
73 * call backwards into its embedding site, through these interfaces.
74 */
75 static HRESULT WINAPI WBCPC_FindConnectionPoint(LPCONNECTIONPOINTCONTAINER iface,
76 REFIID riid, LPCONNECTIONPOINT *ppCP)
77 {
78 TRACE(": IID = %s, IConnectionPoint = %p\n", debugstr_guid(riid), *ppCP);
79
80 /* For now, return the same IConnectionPoint object for both
81 * event interface requests.
82 */
83 if (IsEqualGUID (&IID_INotifyDBEvents, riid))
84 {
85 TRACE("Returning connection point %p for IID_INotifyDBEvents\n",
86 &SHDOCVW_ConnectionPoint);
87 *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
88 return S_OK;
89 }
90 else if (IsEqualGUID (&IID_IPropertyNotifySink, riid))
91 {
92 TRACE("Returning connection point %p for IID_IPropertyNotifySink\n",
93 &SHDOCVW_ConnectionPoint);
94 *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
95 return S_OK;
96 }
97
98 return E_FAIL;
99 }
100
101 /**********************************************************************
102 * IConnectionPointContainer virtual function table for IE Web Browser component
103 */
104
105 static const IConnectionPointContainerVtbl WBCPC_Vtbl =
106 {
107 WBCPC_QueryInterface,
108 WBCPC_AddRef,
109 WBCPC_Release,
110 WBCPC_EnumConnectionPoints,
111 WBCPC_FindConnectionPoint
112 };
113
114 IConnectionPointContainerImpl SHDOCVW_ConnectionPointContainer = {&WBCPC_Vtbl};
115
116
117 /**********************************************************************
118 * Implement the IConnectionPoint interface
119 */
120
121 static HRESULT WINAPI WBCP_QueryInterface(LPCONNECTIONPOINT iface,
122 REFIID riid, LPVOID *ppobj)
123 {
124 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
125
126 if (ppobj == NULL) return E_POINTER;
127
128 return E_NOINTERFACE;
129 }
130
131 static ULONG WINAPI WBCP_AddRef(LPCONNECTIONPOINT iface)
132 {
133 SHDOCVW_LockModule();
134
135 return 2; /* non-heap based object */
136 }
137
138 static ULONG WINAPI WBCP_Release(LPCONNECTIONPOINT iface)
139 {
140 SHDOCVW_UnlockModule();
141
142 return 1; /* non-heap based object */
143 }
144
145 static HRESULT WINAPI WBCP_GetConnectionInterface(LPCONNECTIONPOINT iface, IID* pIId)
146 {
147 FIXME("stub: %s\n", debugstr_guid(pIId));
148 return S_OK;
149 }
150
151 /* Get this connection point's owning container */
152 static HRESULT WINAPI
153 WBCP_GetConnectionPointContainer(LPCONNECTIONPOINT iface,
154 LPCONNECTIONPOINTCONTAINER *ppCPC)
155 {
156 FIXME("stub: IConnectionPointContainer = %p\n", *ppCPC);
157 return S_OK;
158 }
159
160 /* Connect the pUnkSink event-handling implementation (in the control site)
161 * to this connection point. Return a handle to this connection in
162 * pdwCookie (for later use in Unadvise()).
163 */
164 static HRESULT WINAPI WBCP_Advise(LPCONNECTIONPOINT iface,
165 LPUNKNOWN pUnkSink, DWORD *pdwCookie)
166 {
167 static int new_cookie;
168
169 FIXME("stub: IUnknown = %p, connection cookie = %ld\n", pUnkSink, *pdwCookie);
170
171 *pdwCookie = ++new_cookie;
172 TRACE ("Returning cookie = %ld\n", *pdwCookie);
173
174 return S_OK;
175 }
176
177 /* Disconnect this implementation from the connection point. */
178 static HRESULT WINAPI WBCP_Unadvise(LPCONNECTIONPOINT iface,
179 DWORD dwCookie)
180 {
181 FIXME("stub: cookie to disconnect = %lx\n", dwCookie);
182 return S_OK;
183 }
184
185 /* Get a list of connections in this connection point. */
186 static HRESULT WINAPI WBCP_EnumConnections(LPCONNECTIONPOINT iface,
187 LPENUMCONNECTIONS *ppEnum)
188 {
189 FIXME("stub: IEnumConnections = %p\n", *ppEnum);
190 return S_OK;
191 }
192
193 /**********************************************************************
194 * IConnectionPoint virtual function table for IE Web Browser component
195 */
196
197 static const IConnectionPointVtbl WBCP_Vtbl =
198 {
199 WBCP_QueryInterface,
200 WBCP_AddRef,
201 WBCP_Release,
202 WBCP_GetConnectionInterface,
203 WBCP_GetConnectionPointContainer,
204 WBCP_Advise,
205 WBCP_Unadvise,
206 WBCP_EnumConnections
207 };
208
209 static IConnectionPointImpl SHDOCVW_ConnectionPoint = {&WBCP_Vtbl};