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