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