storage.dll16: COM cleanup in storage.c.
[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);
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
84 typedef struct _task_header_t {
85     task_proc_t proc;
86 } task_header_t;
87
88 typedef struct _IDocHostContainerVtbl
89 {
90     ULONG (*addref)(DocHost*);
91     ULONG (*release)(DocHost*);
92     void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
93     HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
94     void (WINAPI* SetURL)(DocHost*,LPCWSTR);
95     HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
96 } IDocHostContainerVtbl;
97
98 struct DocHost {
99     IOleClientSite      IOleClientSite_iface;
100     IOleInPlaceSite     IOleInPlaceSite_iface;
101     IDocHostUIHandler2  IDocHostUIHandler2_iface;
102     IOleDocumentSite    IOleDocumentSite_iface;
103     IOleControlSite     IOleControlSite_iface;
104     IOleCommandTarget   IOleCommandTarget_iface;
105     IDispatch           IDispatch_iface;
106     IPropertyNotifySink IPropertyNotifySink_iface;
107     IServiceProvider    IServiceProvider_iface;
108
109     /* Interfaces of InPlaceFrame object */
110     IOleInPlaceFrame  IOleInPlaceFrame_iface;
111
112     IDispatch *disp;
113
114     IDispatch *client_disp;
115     IDocHostUIHandler *hostui;
116     IOleInPlaceFrame *frame;
117
118     IUnknown *document;
119     IOleDocumentView *view;
120     IUnknown *doc_navigate;
121
122     const IDocHostContainerVtbl *container_vtbl;
123
124     HWND hwnd;
125     HWND frame_hwnd;
126
127     LPOLESTR url;
128
129     VARIANT_BOOL silent;
130     VARIANT_BOOL offline;
131     VARIANT_BOOL busy;
132
133     READYSTATE ready_state;
134     READYSTATE doc_state;
135     DWORD prop_notif_cookie;
136     BOOL is_prop_notif;
137
138     ConnectionPointContainer cps;
139 };
140
141 struct WebBrowser {
142     IWebBrowser2             IWebBrowser2_iface;
143     IOleObject               IOleObject_iface;
144     IOleInPlaceObject        IOleInPlaceObject_iface;
145     IOleControl              IOleControl_iface;
146     IPersistStorage          IPersistStorage_iface;
147     IPersistMemory           IPersistMemory_iface;
148     IPersistStreamInit       IPersistStreamInit_iface;
149     IProvideClassInfo2       IProvideClassInfo2_iface;
150     IViewObject2             IViewObject2_iface;
151     IOleInPlaceActiveObject  IOleInPlaceActiveObject_iface;
152     IOleCommandTarget        IOleCommandTarget_iface;
153     IServiceProvider         IServiceProvider_iface;
154     IDataObject              IDataObject_iface;
155     HlinkFrame hlink_frame;
156
157     LONG ref;
158
159     INT version;
160
161     IOleClientSite *client;
162     IOleContainer *container;
163     IOleInPlaceSite *inplace;
164
165     /* window context */
166
167     HWND frame_hwnd;
168     IOleInPlaceUIWindow *uiwindow;
169     RECT pos_rect;
170     RECT clip_rect;
171     OLEINPLACEFRAMEINFO frameinfo;
172     SIZEL extent;
173
174     HWND shell_embedding_hwnd;
175
176     VARIANT_BOOL register_browser;
177     VARIANT_BOOL visible;
178     VARIANT_BOOL menu_bar;
179     VARIANT_BOOL address_bar;
180     VARIANT_BOOL status_bar;
181     VARIANT_BOOL tool_bar;
182     VARIANT_BOOL full_screen;
183     VARIANT_BOOL theater_mode;
184
185     DocHost doc_host;
186 };
187
188 typedef struct {
189     DocHost doc_host;
190
191     LONG ref;
192
193     InternetExplorer *ie;
194 } IEDocHost;
195
196 struct InternetExplorer {
197     IWebBrowser2 IWebBrowser2_iface;
198     HlinkFrame hlink_frame;
199
200     LONG ref;
201
202     HWND frame_hwnd;
203     HWND status_hwnd;
204     HMENU menu;
205     BOOL nohome;
206
207     struct list entry;
208     IEDocHost *doc_host;
209 };
210
211 void WebBrowser_OleObject_Init(WebBrowser*);
212 void WebBrowser_ViewObject_Init(WebBrowser*);
213 void WebBrowser_Persist_Init(WebBrowser*);
214 void WebBrowser_ClassInfo_Init(WebBrowser*);
215
216 void WebBrowser_OleObject_Destroy(WebBrowser*);
217
218 void DocHost_Init(DocHost*,IDispatch*,const IDocHostContainerVtbl*);
219 void DocHost_ClientSite_Init(DocHost*);
220 void DocHost_Frame_Init(DocHost*);
221 void release_dochost_client(DocHost*);
222
223 void DocHost_Release(DocHost*);
224 void DocHost_ClientSite_Release(DocHost*);
225
226 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
227 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
228
229 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*);
230 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**);
231
232 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
233 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
234
235 void create_doc_view_hwnd(DocHost*);
236 void deactivate_document(DocHost*);
237 HRESULT dochost_object_available(DocHost*,IUnknown*);
238 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
239 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
240 HRESULT go_home(DocHost*);
241 void set_doc_state(DocHost*,READYSTATE);
242 HRESULT get_location_url(DocHost*,BSTR*);
243
244 #define WM_DOCHOSTTASK (WM_USER+0x300)
245 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
246 LRESULT  process_dochost_task(DocHost*,LPARAM);
247
248 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
249 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
250
251 void released_obj(void);
252
253 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
254
255 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**);
256
257 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**);
258
259 /**********************************************************************
260  * Dll lifetime tracking declaration for shdocvw.dll
261  */
262 extern LONG SHDOCVW_refCount;
263 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
264 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
265
266 extern HINSTANCE shdocvw_hinstance;
267 extern void register_iewindow_class(void);
268 extern void unregister_iewindow_class(void);
269 extern HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR);
270
271 HRESULT register_class_object(BOOL);
272 HRESULT get_typeinfo(ITypeInfo**);
273 DWORD register_iexplore(BOOL);
274
275 const char *debugstr_variant(const VARIANT*);
276
277 /* memory allocation functions */
278
279 static inline void *heap_alloc(size_t len)
280 {
281     return HeapAlloc(GetProcessHeap(), 0, len);
282 }
283
284 static inline void *heap_alloc_zero(size_t len)
285 {
286     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
287 }
288
289 static inline void *heap_realloc(void *mem, size_t len)
290 {
291     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
292 }
293
294 static inline BOOL heap_free(void *mem)
295 {
296     return HeapFree(GetProcessHeap(), 0, mem);
297 }
298
299 static inline LPWSTR heap_strdupW(LPCWSTR str)
300 {
301     LPWSTR ret = NULL;
302
303     if(str) {
304         DWORD size;
305
306         size = (strlenW(str)+1)*sizeof(WCHAR);
307         ret = heap_alloc(size);
308         memcpy(ret, str, size);
309     }
310
311     return ret;
312 }
313
314 static inline LPWSTR co_strdupW(LPCWSTR str)
315 {
316     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
317     if (ret)
318         lstrcpyW(ret, str);
319     return ret;
320 }
321
322 static inline LPWSTR co_strdupAtoW(LPCSTR str)
323 {
324     INT len;
325     WCHAR *ret;
326     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
327     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
328     if (ret)
329         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
330     return ret;
331 }
332
333 static inline LPSTR co_strdupWtoA(LPCWSTR str)
334 {
335     INT len;
336     CHAR *ret;
337     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
338     ret = CoTaskMemAlloc(len);
339     if (ret)
340         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
341     return ret;
342 }
343
344 #endif /* __WINE_SHDOCVW_H */