Added msvcrt/eh.h.
[wine] / dlls / shdocvw / events.c
1 /*
2  * Implementation of event-related interfaces for IE Web Browser control:
3  *
4  *  - IConnectionPointContainer
5  *  - IConnectionPoint
6  *
7  * 2001 John R. Sheets (for CodeWeavers)
8  */
9
10 #include <string.h>
11 #include "debugtools.h"
12 #include "shdocvw.h"
13
14 DEFAULT_DEBUG_CHANNEL(shdocvw);
15
16
17 /**********************************************************************
18  * Implement the IConnectionPointContainer interface
19  */
20
21 static HRESULT WINAPI WBCPC_QueryInterface(LPCONNECTIONPOINTCONTAINER iface,
22                                            REFIID riid, LPVOID *ppobj)
23 {
24     ICOM_THIS(IConnectionPointContainerImpl, iface);
25
26     FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj);
27     return E_NOINTERFACE;
28 }
29
30 static ULONG WINAPI WBCPC_AddRef(LPCONNECTIONPOINTCONTAINER iface)
31 {
32     ICOM_THIS(IConnectionPointContainerImpl, iface);
33
34     TRACE("\n");
35     return ++(This->ref);
36 }
37
38 static ULONG WINAPI WBCPC_Release(LPCONNECTIONPOINTCONTAINER iface)
39 {
40     ICOM_THIS(IConnectionPointContainerImpl, iface);
41
42     /* static class, won't be freed */
43     TRACE("\n");
44     return --(This->ref);
45 }
46
47 /* Get a list of connection points inside this container. */
48 static HRESULT WINAPI WBCPC_EnumConnectionPoints(LPCONNECTIONPOINTCONTAINER iface,
49                                                  LPENUMCONNECTIONPOINTS *ppEnum)
50 {
51     FIXME("stub: IEnumConnectionPoints = %p\n", *ppEnum);
52     return S_OK;
53 }
54
55 /* Retrieve the connection point in this container associated with the
56  * riid interface.  When events occur in the control, the control can
57  * call backwards into its embedding site, through these interfaces.
58  */
59 static HRESULT WINAPI WBCPC_FindConnectionPoint(LPCONNECTIONPOINTCONTAINER iface,
60                                                 REFIID riid, LPCONNECTIONPOINT *ppCP)
61 {
62     TRACE(": IID = %s, IConnectionPoint = %p\n", debugstr_guid(riid), *ppCP);
63
64     /* For now, return the same IConnectionPoint object for both
65      * event interface requests.
66      */
67     if (IsEqualGUID (&IID_INotifyDBEvents, riid))
68     {
69         TRACE("Returning connection point %p for IID_INotifyDBEvents\n",
70               &SHDOCVW_ConnectionPoint);
71         *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
72         return S_OK;
73     }
74     else if (IsEqualGUID (&IID_IPropertyNotifySink, riid))
75     {
76         TRACE("Returning connection point %p for IID_IPropertyNotifySink\n",
77               &SHDOCVW_ConnectionPoint);
78         *ppCP = (LPCONNECTIONPOINT)&SHDOCVW_ConnectionPoint;
79         return S_OK;
80     }
81
82     return E_FAIL;
83 }
84
85 /**********************************************************************
86  * IConnectionPointContainer virtual function table for IE Web Browser component
87  */
88
89 static ICOM_VTABLE(IConnectionPointContainer) WBCPC_Vtbl = 
90 {
91     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
92     WBCPC_QueryInterface,
93     WBCPC_AddRef,
94     WBCPC_Release,
95     WBCPC_EnumConnectionPoints,
96     WBCPC_FindConnectionPoint
97 };
98
99 IConnectionPointContainerImpl SHDOCVW_ConnectionPointContainer = { &WBCPC_Vtbl, 1 };
100
101
102 /**********************************************************************
103  * Implement the IConnectionPoint interface
104  */
105
106 static HRESULT WINAPI WBCP_QueryInterface(LPCONNECTIONPOINT iface,
107                                           REFIID riid, LPVOID *ppobj)
108 {
109     ICOM_THIS(IConnectionPointImpl, iface);
110
111     FIXME("(%p)->(%s,%p),stub!\n", This, debugstr_guid(riid), ppobj);
112     return E_NOINTERFACE;
113 }
114
115 static ULONG WINAPI WBCP_AddRef(LPCONNECTIONPOINT iface)
116 {
117     ICOM_THIS(IConnectionPointImpl, iface);
118
119     TRACE("\n");
120     return ++(This->ref);
121 }
122
123 static ULONG WINAPI WBCP_Release(LPCONNECTIONPOINT iface)
124 {
125     ICOM_THIS(IConnectionPointImpl, iface);
126
127     /* static class, won't be freed */
128     TRACE("\n");
129     return --(This->ref);
130 }
131
132 static HRESULT WINAPI WBCP_GetConnectionInterface(LPCONNECTIONPOINT iface, IID* pIId)
133 {
134     FIXME("stub: %s\n", debugstr_guid(pIId));
135     return S_OK;
136 }
137
138 /* Get this connection point's owning container */
139 static HRESULT WINAPI
140 WBCP_GetConnectionPointContainer(LPCONNECTIONPOINT iface,
141                                  LPCONNECTIONPOINTCONTAINER *ppCPC)
142 {
143     FIXME("stub: IConnectionPointContainer = %p\n", *ppCPC);
144     return S_OK;
145 }
146
147 /* Connect the pUnkSink event-handling implementation (in the control site)
148  * to this connection point.  Return a handle to this connection in
149  * pdwCookie (for later use in Unadvise()).
150  */
151 static HRESULT WINAPI WBCP_Advise(LPCONNECTIONPOINT iface,
152                                   LPUNKNOWN pUnkSink, DWORD *pdwCookie)
153 {
154     static int new_cookie;
155
156     FIXME("stub: IUnknown = %p, connection cookie = %ld\n", pUnkSink, *pdwCookie);
157
158     *pdwCookie = ++new_cookie;
159     TRACE ("Returning cookie = %ld\n", *pdwCookie);
160
161     return S_OK;
162 }
163
164 /* Disconnect this implementation from the connection point. */
165 static HRESULT WINAPI WBCP_Unadvise(LPCONNECTIONPOINT iface,
166                                     DWORD dwCookie)
167 {
168     FIXME("stub: cookie to disconnect = %ld\n", dwCookie);
169     return S_OK;
170 }
171
172 /* Get a list of connections in this connection point. */
173 static HRESULT WINAPI WBCP_EnumConnections(LPCONNECTIONPOINT iface,
174                                            LPENUMCONNECTIONS *ppEnum)
175 {
176     FIXME("stub: IEnumConnections = %p\n", *ppEnum);
177     return S_OK;
178 }
179
180 /**********************************************************************
181  * IConnectionPoint virtual function table for IE Web Browser component
182  */
183
184 static ICOM_VTABLE(IConnectionPoint) WBCP_Vtbl = 
185 {
186     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
187     WBCP_QueryInterface,
188     WBCP_AddRef,
189     WBCP_Release,
190     WBCP_GetConnectionInterface,
191     WBCP_GetConnectionPointContainer,
192     WBCP_Advise,
193     WBCP_Unadvise,
194     WBCP_EnumConnections
195 };
196
197 IConnectionPointImpl SHDOCVW_ConnectionPoint = { &WBCP_Vtbl, 1 };