dlls: Assorted spelling fixes.
[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 "htiframe.h"
38
39 #include "wine/unicode.h"
40 #include "wine/list.h"
41
42 typedef struct ConnectionPoint ConnectionPoint;
43 typedef struct DocHost DocHost;
44
45 typedef struct {
46     IConnectionPointContainer IConnectionPointContainer_iface;
47
48     ConnectionPoint *wbe2;
49     ConnectionPoint *wbe;
50     ConnectionPoint *pns;
51
52     IUnknown *impl;
53 } ConnectionPointContainer;
54
55 typedef struct {
56     IHlinkFrame    IHlinkFrame_iface;
57     ITargetFrame2  ITargetFrame2_iface;
58
59     IUnknown *outer;
60     DocHost *doc_host;
61 } HlinkFrame;
62
63 struct _task_header_t;
64
65 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
66 typedef void (*task_destr_t)(struct _task_header_t*);
67
68 typedef struct _task_header_t {
69     struct list entry;
70     task_proc_t proc;
71     task_destr_t destr;
72 } task_header_t;
73
74 typedef struct _IDocHostContainerVtbl
75 {
76     ULONG (*addref)(DocHost*);
77     ULONG (*release)(DocHost*);
78     void (WINAPI* GetDocObjRect)(DocHost*,RECT*);
79     HRESULT (WINAPI* SetStatusText)(DocHost*,LPCWSTR);
80     void (WINAPI* SetURL)(DocHost*,LPCWSTR);
81     HRESULT (*exec)(DocHost*,const GUID*,DWORD,DWORD,VARIANT*,VARIANT*);
82 } IDocHostContainerVtbl;
83
84 struct DocHost {
85     IOleClientSite      IOleClientSite_iface;
86     IOleInPlaceSiteEx   IOleInPlaceSiteEx_iface;
87     IDocHostUIHandler2  IDocHostUIHandler2_iface;
88     IOleDocumentSite    IOleDocumentSite_iface;
89     IOleControlSite     IOleControlSite_iface;
90     IOleCommandTarget   IOleCommandTarget_iface;
91     IDispatch           IDispatch_iface;
92     IPropertyNotifySink IPropertyNotifySink_iface;
93     IServiceProvider    IServiceProvider_iface;
94
95     /* Interfaces of InPlaceFrame object */
96     IOleInPlaceFrame  IOleInPlaceFrame_iface;
97
98     IDispatch *disp;
99
100     IDispatch *client_disp;
101     IDocHostUIHandler *hostui;
102     IOleInPlaceFrame *frame;
103
104     IUnknown *document;
105     IOleDocumentView *view;
106     IUnknown *doc_navigate;
107
108     const IDocHostContainerVtbl *container_vtbl;
109
110     HWND hwnd;
111     HWND frame_hwnd;
112
113     struct list task_queue;
114
115     LPOLESTR url;
116
117     VARIANT_BOOL silent;
118     VARIANT_BOOL offline;
119     VARIANT_BOOL busy;
120
121     READYSTATE ready_state;
122     READYSTATE doc_state;
123     DWORD prop_notif_cookie;
124     BOOL is_prop_notif;
125
126     ConnectionPointContainer cps;
127 };
128
129 struct WebBrowser {
130     IWebBrowser2             IWebBrowser2_iface;
131     IOleObject               IOleObject_iface;
132     IOleInPlaceObject        IOleInPlaceObject_iface;
133     IOleControl              IOleControl_iface;
134     IPersistStorage          IPersistStorage_iface;
135     IPersistMemory           IPersistMemory_iface;
136     IPersistStreamInit       IPersistStreamInit_iface;
137     IProvideClassInfo2       IProvideClassInfo2_iface;
138     IViewObject2             IViewObject2_iface;
139     IOleInPlaceActiveObject  IOleInPlaceActiveObject_iface;
140     IOleCommandTarget        IOleCommandTarget_iface;
141     IServiceProvider         IServiceProvider_iface;
142     IDataObject              IDataObject_iface;
143     HlinkFrame hlink_frame;
144
145     LONG ref;
146
147     INT version;
148
149     IOleClientSite *client;
150     IOleContainer *container;
151     IOleInPlaceSiteEx *inplace;
152
153     /* window context */
154
155     HWND frame_hwnd;
156     IOleInPlaceUIWindow *uiwindow;
157     RECT pos_rect;
158     RECT clip_rect;
159     OLEINPLACEFRAMEINFO frameinfo;
160     SIZEL extent;
161
162     HWND shell_embedding_hwnd;
163
164     VARIANT_BOOL register_browser;
165     VARIANT_BOOL visible;
166     VARIANT_BOOL menu_bar;
167     VARIANT_BOOL address_bar;
168     VARIANT_BOOL status_bar;
169     VARIANT_BOOL tool_bar;
170     VARIANT_BOOL full_screen;
171     VARIANT_BOOL theater_mode;
172
173     DocHost doc_host;
174 };
175
176 typedef struct {
177     DocHost doc_host;
178
179     LONG ref;
180
181     InternetExplorer *ie;
182 } IEDocHost;
183
184 struct InternetExplorer {
185     IWebBrowser2 IWebBrowser2_iface;
186     HlinkFrame hlink_frame;
187
188     LONG ref;
189
190     HWND frame_hwnd;
191     HWND status_hwnd;
192     HMENU menu;
193     BOOL nohome;
194
195     struct list entry;
196     IEDocHost *doc_host;
197 };
198
199 void WebBrowser_OleObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
200 void WebBrowser_ViewObject_Init(WebBrowser*) DECLSPEC_HIDDEN;
201 void WebBrowser_Persist_Init(WebBrowser*) DECLSPEC_HIDDEN;
202 void WebBrowser_ClassInfo_Init(WebBrowser*) DECLSPEC_HIDDEN;
203
204 void WebBrowser_OleObject_Destroy(WebBrowser*) DECLSPEC_HIDDEN;
205
206 void DocHost_Init(DocHost*,IDispatch*,const IDocHostContainerVtbl*) DECLSPEC_HIDDEN;
207 void DocHost_Release(DocHost*) DECLSPEC_HIDDEN;
208 void DocHost_ClientSite_Init(DocHost*) DECLSPEC_HIDDEN;
209 void DocHost_ClientSite_Release(DocHost*) DECLSPEC_HIDDEN;
210 void DocHost_Frame_Init(DocHost*) DECLSPEC_HIDDEN;
211 void release_dochost_client(DocHost*) DECLSPEC_HIDDEN;
212
213 void HlinkFrame_Init(HlinkFrame*,IUnknown*,DocHost*) DECLSPEC_HIDDEN;
214 BOOL HlinkFrame_QI(HlinkFrame*,REFIID,void**) DECLSPEC_HIDDEN;
215
216 HRESULT ShellBrowser_Create(IShellBrowser**) DECLSPEC_HIDDEN;
217
218 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
219 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
220
221 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*) DECLSPEC_HIDDEN;
222 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
223 HRESULT go_home(DocHost*) DECLSPEC_HIDDEN;
224 HRESULT get_location_url(DocHost*,BSTR*) DECLSPEC_HIDDEN;
225 void handle_navigation_error(DocHost*,HRESULT,BSTR,IHTMLWindow2*) DECLSPEC_HIDDEN;
226 HRESULT dochost_object_available(DocHost*,IUnknown*) DECLSPEC_HIDDEN;
227 void set_doc_state(DocHost*,READYSTATE) DECLSPEC_HIDDEN;
228 void deactivate_document(DocHost*) DECLSPEC_HIDDEN;
229 void create_doc_view_hwnd(DocHost*) DECLSPEC_HIDDEN;
230
231 #define WM_DOCHOSTTASK (WM_USER+0x300)
232 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,task_destr_t,BOOL) DECLSPEC_HIDDEN;
233 void abort_dochost_tasks(DocHost*,task_proc_t) DECLSPEC_HIDDEN;
234 LRESULT process_dochost_tasks(DocHost*) DECLSPEC_HIDDEN;
235
236 void InternetExplorer_WebBrowser_Init(InternetExplorer*) DECLSPEC_HIDDEN;
237 HRESULT update_ie_statustext(InternetExplorer*, LPCWSTR) DECLSPEC_HIDDEN;
238 void released_obj(void) DECLSPEC_HIDDEN;
239
240 void register_iewindow_class(void) DECLSPEC_HIDDEN;
241 void unregister_iewindow_class(void) DECLSPEC_HIDDEN;
242
243 HRESULT get_typeinfo(ITypeInfo**) DECLSPEC_HIDDEN;
244 HRESULT register_class_object(BOOL) DECLSPEC_HIDDEN;
245
246 HRESULT WINAPI CUrlHistory_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
247 HRESULT WINAPI InternetExplorer_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
248 HRESULT WINAPI InternetShortcut_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
249 HRESULT WINAPI TaskbarList_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
250 HRESULT WINAPI WebBrowser_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
251 HRESULT WINAPI WebBrowserV1_Create(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
252
253 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
254
255 extern LONG module_ref DECLSPEC_HIDDEN;
256 extern HINSTANCE ieframe_instance DECLSPEC_HIDDEN;
257
258 static inline void lock_module(void) {
259     InterlockedIncrement(&module_ref);
260 }
261
262 static inline void unlock_module(void) {
263     InterlockedDecrement(&module_ref);
264 }
265
266 static inline void *heap_alloc(size_t len)
267 {
268     return HeapAlloc(GetProcessHeap(), 0, len);
269 }
270
271 static inline void *heap_alloc_zero(size_t len)
272 {
273     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
274 }
275
276 static inline void *heap_realloc(void *mem, size_t len)
277 {
278     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
279 }
280
281 static inline BOOL heap_free(void *mem)
282 {
283     return HeapFree(GetProcessHeap(), 0, mem);
284 }
285
286 static inline LPWSTR heap_strdupW(LPCWSTR str)
287 {
288     LPWSTR ret = NULL;
289
290     if(str) {
291         DWORD size;
292
293         size = (strlenW(str)+1)*sizeof(WCHAR);
294         ret = heap_alloc(size);
295         if(ret)
296             memcpy(ret, str, size);
297     }
298
299     return ret;
300 }
301
302 static inline LPWSTR co_strdupW(LPCWSTR str)
303 {
304     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
305     if (ret)
306         lstrcpyW(ret, str);
307     return ret;
308 }
309
310 static inline LPWSTR co_strdupAtoW(LPCSTR str)
311 {
312     INT len;
313     WCHAR *ret;
314     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
315     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
316     if (ret)
317         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
318     return ret;
319 }
320
321 static inline LPSTR co_strdupWtoA(LPCWSTR str)
322 {
323     INT len;
324     CHAR *ret;
325     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
326     ret = CoTaskMemAlloc(len);
327     if (ret)
328         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
329     return ret;
330 }