shdocvw: Use task destructors for releasing task params.
[wine] / dlls / shdocvw / shdocvw.h
1 /*
2  * Header includes for shdocvw.dll
3  *
4  * Copyright 2001 John R. Sheets (for CodeWeavers)
5  * Copyright 2005-2006 Jacek Caban for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef __WINE_SHDOCVW_H
23 #define __WINE_SHDOCVW_H
24
25 #define COBJMACROS
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33
34 #include "ole2.h"
35 #include "olectl.h"
36 #include "shlobj.h"
37 #include "exdisp.h"
38 #include "mshtmhst.h"
39 #include "hlink.h"
40 #include "htiframe.h"
41
42 #include "wine/unicode.h"
43 #include "wine/list.h"
44 #include "resource.h"
45
46
47 #define WM_UPDATEADDRBAR    (WM_APP+1)
48
49 /**********************************************************************
50  * Shell Instance Objects
51  */
52 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid, 
53     REFIID riid, LPVOID *ppvClassObj) DECLSPEC_HIDDEN;
54
55 /**********************************************************************
56  * WebBrowser declaration for SHDOCVW.DLL
57  */
58
59 typedef struct ConnectionPoint ConnectionPoint;
60 typedef struct DocHost DocHost;
61
62 typedef struct {
63     IConnectionPointContainer IConnectionPointContainer_iface;
64
65     ConnectionPoint *wbe2;
66     ConnectionPoint *wbe;
67     ConnectionPoint *pns;
68
69     IUnknown *impl;
70 } ConnectionPointContainer;
71
72 typedef struct {
73     IHlinkFrame    IHlinkFrame_iface;
74     ITargetFrame2  ITargetFrame2_iface;
75
76     IUnknown *outer;
77     DocHost *doc_host;
78 } HlinkFrame;
79
80 struct _task_header_t;
81
82 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
83 typedef void (*task_destr_t)(struct _task_header_t*);
84
85 typedef struct _task_header_t {
86     task_proc_t proc;
87     task_destr_t destr;
88 } task_header_t;
89
90 typedef struct _IDocHostContainerVtbl
91 {
92     ULONG (*addref)(DocHost*);
93     ULONG (*release)(DocHost*);
94     void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
95     HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
96     void (WINAPI* SetURL)(DocHost*,LPCWSTR);
97     HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
98 } IDocHostContainerVtbl;
99
100 struct DocHost {
101     IOleClientSite      IOleClientSite_iface;
102     IOleInPlaceSite     IOleInPlaceSite_iface;
103     IDocHostUIHandler2  IDocHostUIHandler2_iface;
104     IOleDocumentSite    IOleDocumentSite_iface;
105     IOleControlSite     IOleControlSite_iface;
106     IOleCommandTarget   IOleCommandTarget_iface;
107     IDispatch           IDispatch_iface;
108     IPropertyNotifySink IPropertyNotifySink_iface;
109     IServiceProvider    IServiceProvider_iface;
110
111     /* Interfaces of InPlaceFrame object */
112     IOleInPlaceFrame  IOleInPlaceFrame_iface;
113
114     IDispatch *disp;
115
116     IDispatch *client_disp;
117     IDocHostUIHandler *hostui;
118     IOleInPlaceFrame *frame;
119
120     IUnknown *document;
121     IOleDocumentView *view;
122     IUnknown *doc_navigate;
123
124     const IDocHostContainerVtbl *container_vtbl;
125
126     HWND hwnd;
127     HWND frame_hwnd;
128
129     LPOLESTR url;
130
131     VARIANT_BOOL silent;
132     VARIANT_BOOL offline;
133     VARIANT_BOOL busy;
134
135     READYSTATE ready_state;
136     READYSTATE doc_state;
137     DWORD prop_notif_cookie;
138     BOOL is_prop_notif;
139
140     ConnectionPointContainer cps;
141 };
142
143 struct WebBrowser {
144     IWebBrowser2             IWebBrowser2_iface;
145     IOleObject               IOleObject_iface;
146     IOleInPlaceObject        IOleInPlaceObject_iface;
147     IOleControl              IOleControl_iface;
148     IPersistStorage          IPersistStorage_iface;
149     IPersistMemory           IPersistMemory_iface;
150     IPersistStreamInit       IPersistStreamInit_iface;
151     IProvideClassInfo2       IProvideClassInfo2_iface;
152     IViewObject2             IViewObject2_iface;
153     IOleInPlaceActiveObject  IOleInPlaceActiveObject_iface;
154     IOleCommandTarget        IOleCommandTarget_iface;
155     IServiceProvider         IServiceProvider_iface;
156     IDataObject              IDataObject_iface;
157     HlinkFrame hlink_frame;
158
159     LONG ref;
160
161     INT version;
162
163     IOleClientSite *client;
164     IOleContainer *container;
165     IOleInPlaceSite *inplace;
166
167     /* window context */
168
169     HWND frame_hwnd;
170     IOleInPlaceUIWindow *uiwindow;
171     RECT pos_rect;
172     RECT clip_rect;
173     OLEINPLACEFRAMEINFO frameinfo;
174     SIZEL extent;
175
176     HWND shell_embedding_hwnd;
177
178     VARIANT_BOOL register_browser;
179     VARIANT_BOOL visible;
180     VARIANT_BOOL menu_bar;
181     VARIANT_BOOL address_bar;
182     VARIANT_BOOL status_bar;
183     VARIANT_BOOL tool_bar;
184     VARIANT_BOOL full_screen;
185     VARIANT_BOOL theater_mode;
186
187     DocHost doc_host;
188 };
189
190 typedef struct {
191     DocHost doc_host;
192
193     LONG ref;
194
195     InternetExplorer *ie;
196 } IEDocHost;
197
198 struct InternetExplorer {
199     IWebBrowser2 IWebBrowser2_iface;
200     HlinkFrame hlink_frame;
201
202     LONG ref;
203
204     HWND frame_hwnd;
205     HWND status_hwnd;
206     HMENU menu;
207     BOOL nohome;
208
209     struct list entry;
210     IEDocHost *doc_host;
211 };
212
213 void WebBrowser_OleObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
214 void WebBrowser_ViewObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
215 void WebBrowser_Persist_Init(WebBrowser*) DECLSPEC_HIDDEN;
216 void WebBrowser_ClassInfo_Init(WebBrowser*) DECLSPEC_HIDDEN;
217
218 void WebBrowser_OleObject_Destroy(WebBrowser*) DECLSPEC_HIDDEN;
219
220 void DocHost_Init(DocHost*,IDispatch*,const IDocHostContainerVtbl*) DECLSPEC_HIDDEN;
221 void DocHost_ClientSite_Init(DocHost*) DECLSPEC_HIDDEN;
222 void DocHost_Frame_Init(DocHost*) DECLSPEC_HIDDEN;
223 void release_dochost_client(DocHost*) DECLSPEC_HIDDEN;
224
225 void DocHost_Release(DocHost*) DECLSPEC_HIDDEN;
226 void DocHost_ClientSite_Release(DocHost*) DECLSPEC_HIDDEN;
227
228 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
229 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
230
231 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*) DECLSPEC_HIDDEN;
232 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**) DECLSPEC_HIDDEN;
233
234 HRESULT ShellBrowser_Create(IShellBrowser**) DECLSPEC_HIDDEN;
235 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
236 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
237
238 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
239 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
240 HRESULT dochost_object_available(DocHost*,IUnknown*) DECLSPEC_HIDDEN;
241 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
242 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
243 HRESULT go_home(DocHost*) DECLSPEC_HIDDEN;
244 void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
245 HRESULT get_location_url(DocHost*,BSTR*) DECLSPEC_HIDDEN;
246 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*) DECLSPEC_HIDDEN;
247
248 #define WM_DOCHOSTTASK (WM_USER+0x300)
249 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,task_destr_t,BOOL) DECLSPEC_HIDDEN;
250 LRESULT  process_dochost_task(DocHost*,LPARAM) DECLSPEC_HIDDEN;
251
252 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
253 void InternetExplorer_WebBrowser_Init(InternetExplorer*) DECLSPEC_HIDDEN;
254
255 void released_obj(void) DECLSPEC_HIDDEN;
256
257 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
258
259 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
260
261 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
262
263 /**********************************************************************
264  * Dll lifetime tracking declaration for shdocvw.dll
265  */
266 extern LONG SHDOCVW_refCount DECLSPEC_HIDDEN;
267 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
268 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
269
270 extern HINSTANCE shdocvw_hinstance DECLSPEC_HIDDEN;
271 extern void register_iewindow_class(void) DECLSPEC_HIDDEN;
272 extern void unregister_iewindow_class(void) DECLSPEC_HIDDEN;
273 extern HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR) DECLSPEC_HIDDEN;
274
275 HRESULT register_class_object(BOOL) DECLSPEC_HIDDEN;
276 HRESULT get_typeinfo(ITypeInfo**) DECLSPEC_HIDDEN;
277 DWORD register_iexplore(BOOL) DECLSPEC_HIDDEN;
278
279 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
280
281 /* memory allocation functions */
282
283 static inline void *heap_alloc(size_t len)
284 {
285     return HeapAlloc(GetProcessHeap(), 0, len);
286 }
287
288 static inline void *heap_alloc_zero(size_t len)
289 {
290     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
291 }
292
293 static inline void *heap_realloc(void *mem, size_t len)
294 {
295     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
296 }
297
298 static inline BOOL heap_free(void *mem)
299 {
300     return HeapFree(GetProcessHeap(), 0, mem);
301 }
302
303 static inline LPWSTR heap_strdupW(LPCWSTR str)
304 {
305     LPWSTR ret = NULL;
306
307     if(str) {
308         DWORD size;
309
310         size = (strlenW(str)+1)*sizeof(WCHAR);
311         ret = heap_alloc(size);
312         memcpy(ret, str, size);
313     }
314
315     return ret;
316 }
317
318 static inline LPWSTR co_strdupW(LPCWSTR str)
319 {
320     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
321     if (ret)
322         lstrcpyW(ret, str);
323     return ret;
324 }
325
326 static inline LPWSTR co_strdupAtoW(LPCSTR str)
327 {
328     INT len;
329     WCHAR *ret;
330     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
331     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
332     if (ret)
333         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
334     return ret;
335 }
336
337 static inline LPSTR co_strdupWtoA(LPCWSTR str)
338 {
339     INT len;
340     CHAR *ret;
341     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
342     ret = CoTaskMemAlloc(len);
343     if (ret)
344         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
345     return ret;
346 }
347
348 #endif /* __WINE_SHDOCVW_H */