Free ConnectionPoint objects (fix memory leak).
[wine] / dlls / shdocvw / client.c
1 /*
2  * Copyright 2005 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "wine/debug.h"
20 #include "shdocvw.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
23
24 #define CLIENTSITE_THIS(iface) DEFINE_THIS(WebBrowser, OleClientSite, iface)
25
26 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
27 {
28     WebBrowser *This = CLIENTSITE_THIS(iface);
29
30     *ppv = NULL;
31
32     if(IsEqualGUID(&IID_IUnknown, riid)) {
33         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
34         *ppv = CLIENTSITE(This);
35     }else if(IsEqualGUID(&IID_IOleClientSite, riid)) {
36         TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppv);
37         *ppv = CLIENTSITE(This);
38     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
39         TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
40         *ppv = INPLACESITE(This);
41     }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
42         TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppv);
43         *ppv = INPLACESITE(This);
44     }else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)) {
45         TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppv);
46         *ppv = DOCHOSTUI(This);
47     }else if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
48         TRACE("(%p)->(IID_IDocHostUIHandler2 %p)\n", This, ppv);
49         *ppv = DOCHOSTUI2(This);
50     }
51
52     if(*ppv) {
53         IWebBrowser2_AddRef(WEBBROWSER(This));
54         return S_OK;
55     }
56
57     WARN("Unsupported intrface %s\n", debugstr_guid(riid));
58
59     return E_NOINTERFACE;
60 }
61
62 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
63 {
64     WebBrowser *This = CLIENTSITE_THIS(iface);
65     return IWebBrowser2_AddRef(WEBBROWSER(This));
66 }
67
68 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
69 {
70     WebBrowser *This = CLIENTSITE_THIS(iface);
71     return IWebBrowser2_Release(WEBBROWSER(This));
72 }
73
74 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
75 {
76     WebBrowser *This = CLIENTSITE_THIS(iface);
77     FIXME("(%p)\n", This);
78     return E_NOTIMPL;
79 }
80
81 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign,
82                                             DWORD dwWhichMoniker, IMoniker **ppmk)
83 {
84     WebBrowser *This = CLIENTSITE_THIS(iface);
85     FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
86     return E_NOTIMPL;
87 }
88
89 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
90 {
91     WebBrowser *This = CLIENTSITE_THIS(iface);
92     FIXME("(%p)->(%p)\n", This, ppContainer);
93     return E_NOTIMPL;
94 }
95
96 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
97 {
98     WebBrowser *This = CLIENTSITE_THIS(iface);
99     FIXME("(%p)\n", This);
100     return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
104 {
105     WebBrowser *This = CLIENTSITE_THIS(iface);
106     FIXME("(%p)->(%x)\n", This, fShow);
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
111 {
112     WebBrowser *This = CLIENTSITE_THIS(iface);
113     FIXME("(%p)\n", This);
114     return E_NOTIMPL;
115 }
116
117 #undef CLIENTSITE_THIS
118
119 static const IOleClientSiteVtbl OleClientSiteVtbl = {
120     ClientSite_QueryInterface,
121     ClientSite_AddRef,
122     ClientSite_Release,
123     ClientSite_SaveObject,
124     ClientSite_GetMoniker,
125     ClientSite_GetContainer,
126     ClientSite_ShowObject,
127     ClientSite_OnShowWindow,
128     ClientSite_RequestNewObjectLayout
129 };
130
131 #define INPLACESITE_THIS(iface) DEFINE_THIS(WebBrowser, OleInPlaceSite, iface)
132
133 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
134 {
135     WebBrowser *This = INPLACESITE_THIS(iface);
136     return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
137 }
138
139 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
140 {
141     WebBrowser *This = INPLACESITE_THIS(iface);
142     return IOleClientSite_AddRef(CLIENTSITE(This));
143 }
144
145 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
146 {
147     WebBrowser *This = INPLACESITE_THIS(iface);
148     return IOleClientSite_Release(CLIENTSITE(This));
149 }
150
151 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
152 {
153     WebBrowser *This = INPLACESITE_THIS(iface);
154     FIXME("(%p)->(%p)\n", This, phwnd);
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
159 {
160     WebBrowser *This = INPLACESITE_THIS(iface);
161     FIXME("(%p)->(%x)\n", This, fEnterMode);
162     return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
166 {
167     WebBrowser *This = INPLACESITE_THIS(iface);
168     FIXME("(%p)\n", This);
169     return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
173 {
174     WebBrowser *This = INPLACESITE_THIS(iface);
175     FIXME("(%p)\n", This);
176     return E_NOTIMPL;
177 }
178
179 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
180 {
181     WebBrowser *This = INPLACESITE_THIS(iface);
182     FIXME("(%p)\n", This);
183     return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
187         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
188         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
189 {
190     WebBrowser *This = INPLACESITE_THIS(iface);
191     FIXME("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
192           lprcClipRect, lpFrameInfo);
193     return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtent)
197 {
198     WebBrowser *This = INPLACESITE_THIS(iface);
199     FIXME("(%p)->({%ld %ld})\n", This, scrollExtent.cx, scrollExtent.cy);
200     return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
204 {
205     WebBrowser *This = INPLACESITE_THIS(iface);
206     FIXME("(%p)->(%x)\n", This, fUndoable);
207     return E_NOTIMPL;
208 }
209
210 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
211 {
212     WebBrowser *This = INPLACESITE_THIS(iface);
213     FIXME("(%p)\n", This);
214     return E_NOTIMPL;
215 }
216
217 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
218 {
219     WebBrowser *This = INPLACESITE_THIS(iface);
220     FIXME("(%p)\n", This);
221     return E_NOTIMPL;
222 }
223
224 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
225 {
226     WebBrowser *This = INPLACESITE_THIS(iface);
227     FIXME("(%p)\n", This);
228     return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface,
232                                                   LPCRECT lprcPosRect)
233 {
234     WebBrowser *This = INPLACESITE_THIS(iface);
235     FIXME("(%p)->(%p)\n", This, lprcPosRect);
236     return E_NOTIMPL;
237 }
238
239 #undef INPLACESITE_THIS
240
241 static const IOleInPlaceSiteVtbl OleInPlaceSiteVtbl = {
242     InPlaceSite_QueryInterface,
243     InPlaceSite_AddRef,
244     InPlaceSite_Release,
245     InPlaceSite_GetWindow,
246     InPlaceSite_ContextSensitiveHelp,
247     InPlaceSite_CanInPlaceActivate,
248     InPlaceSite_OnInPlaceActivate,
249     InPlaceSite_OnUIActivate,
250     InPlaceSite_GetWindowContext,
251     InPlaceSite_Scroll,
252     InPlaceSite_OnUIDeactivate,
253     InPlaceSite_OnInPlaceDeactivate,
254     InPlaceSite_DiscardUndoState,
255     InPlaceSite_DeactivateAndUndo,
256     InPlaceSite_OnPosRectChange
257 };
258
259 void WebBrowser_ClientSite_Init(WebBrowser *This)
260 {
261     This->lpOleClientSiteVtbl   = &OleClientSiteVtbl;
262     This->lpOleInPlaceSiteVtbl  = &OleInPlaceSiteVtbl;
263 }