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