msi/tests: Fix a source test comment.
[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
44 /**********************************************************************
45  * Shell Instance Objects
46  */
47 extern HRESULT SHDOCVW_GetShellInstanceObjectClassObject(REFCLSID rclsid, 
48     REFIID riid, LPVOID *ppvClassObj);
49
50 /**********************************************************************
51  * WebBrowser declaration for SHDOCVW.DLL
52  */
53
54 typedef struct ConnectionPoint ConnectionPoint;
55 typedef struct DocHost DocHost;
56
57 typedef struct {
58     const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
59
60     ConnectionPoint *wbe2;
61     ConnectionPoint *wbe;
62     ConnectionPoint *pns;
63
64     IUnknown *impl;
65 } ConnectionPointContainer;
66
67 struct _task_header_t;
68
69 typedef void (*task_proc_t)(DocHost*, struct _task_header_t*);
70
71 typedef struct _task_header_t {
72     task_proc_t proc;
73 } task_header_t;
74
75 struct DocHost {
76     const IOleClientSiteVtbl      *lpOleClientSiteVtbl;
77     const IOleInPlaceSiteVtbl     *lpOleInPlaceSiteVtbl;
78     const IDocHostUIHandler2Vtbl  *lpDocHostUIHandlerVtbl;
79     const IOleDocumentSiteVtbl    *lpOleDocumentSiteVtbl;
80     const IOleCommandTargetVtbl   *lpOleCommandTargetVtbl;
81     const IDispatchVtbl           *lpDispatchVtbl;
82     const IPropertyNotifySinkVtbl *lpIPropertyNotifySinkVtbl;
83     const IServiceProviderVtbl    *lpServiceProviderVtbl;
84
85     /* Interfaces of InPlaceFrame object */
86     const IOleInPlaceFrameVtbl          *lpOleInPlaceFrameVtbl;
87
88     IDispatch *disp;
89
90     IDispatch *client_disp;
91     IDocHostUIHandler *hostui;
92     IOleInPlaceFrame *frame;
93
94     IUnknown *document;
95     IOleDocumentView *view;
96     IUnknown *doc_navigate;
97
98     HWND hwnd;
99     HWND frame_hwnd;
100
101     LPOLESTR url;
102
103     VARIANT_BOOL silent;
104     VARIANT_BOOL offline;
105     VARIANT_BOOL busy;
106
107     READYSTATE ready_state;
108     READYSTATE doc_state;
109     DWORD prop_notif_cookie;
110     BOOL is_prop_notif;
111
112     ConnectionPointContainer cps;
113 };
114
115 struct WebBrowser {
116     /* Interfaces available via WebBrowser object */
117
118     const IWebBrowser2Vtbl              *lpWebBrowser2Vtbl;
119     const IOleObjectVtbl                *lpOleObjectVtbl;
120     const IOleInPlaceObjectVtbl         *lpOleInPlaceObjectVtbl;
121     const IOleControlVtbl               *lpOleControlVtbl;
122     const IPersistStorageVtbl           *lpPersistStorageVtbl;
123     const IPersistMemoryVtbl            *lpPersistMemoryVtbl;
124     const IPersistStreamInitVtbl        *lpPersistStreamInitVtbl;
125     const IProvideClassInfo2Vtbl        *lpProvideClassInfoVtbl;
126     const IViewObject2Vtbl              *lpViewObjectVtbl;
127     const IOleInPlaceActiveObjectVtbl   *lpOleInPlaceActiveObjectVtbl;
128     const IOleCommandTargetVtbl         *lpOleCommandTargetVtbl;
129     const IHlinkFrameVtbl               *lpHlinkFrameVtbl;
130     const ITargetFrame2Vtbl             *lpITargetFrame2Vtbl;
131     const IServiceProviderVtbl          *lpServiceProviderVtbl;
132     const IDataObjectVtbl               *lpDataObjectVtbl;
133
134     LONG ref;
135
136     INT version;
137
138     IOleClientSite *client;
139     IOleContainer *container;
140     IOleInPlaceSite *inplace;
141
142     /* window context */
143
144     HWND frame_hwnd;
145     IOleInPlaceUIWindow *uiwindow;
146     RECT pos_rect;
147     RECT clip_rect;
148     OLEINPLACEFRAMEINFO frameinfo;
149     SIZEL extent;
150
151     HWND shell_embedding_hwnd;
152
153     VARIANT_BOOL register_browser;
154     VARIANT_BOOL visible;
155     VARIANT_BOOL menu_bar;
156     VARIANT_BOOL address_bar;
157     VARIANT_BOOL status_bar;
158     VARIANT_BOOL tool_bar;
159     VARIANT_BOOL full_screen;
160     VARIANT_BOOL theater_mode;
161
162     DocHost doc_host;
163 };
164
165 struct InternetExplorer {
166     const IWebBrowser2Vtbl *lpWebBrowser2Vtbl;
167
168     LONG ref;
169
170     HWND frame_hwnd;
171
172     DocHost doc_host;
173 };
174
175 #define WEBBROWSER(x)   ((IWebBrowser*)                 &(x)->lpWebBrowser2Vtbl)
176 #define WEBBROWSER2(x)  ((IWebBrowser2*)                &(x)->lpWebBrowser2Vtbl)
177 #define OLEOBJ(x)       ((IOleObject*)                  &(x)->lpOleObjectVtbl)
178 #define INPLACEOBJ(x)   ((IOleInPlaceObject*)           &(x)->lpOleInPlaceObjectVtbl)
179 #define CONTROL(x)      ((IOleControl*)                 &(x)->lpOleControlVtbl)
180 #define PERSTORAGE(x)   ((IPersistStorage*)             &(x)->lpPersistStorageVtbl)
181 #define PERMEMORY(x)    ((IPersistMemory*)              &(x)->lpPersistMemoryVtbl)
182 #define PERSTRINIT(x)   ((IPersistStreamInit*)          &(x)->lpPersistStreamInitVtbl)
183 #define CLASSINFO(x)    ((IProvideClassInfo2*)          &(x)->lpProvideClassInfoVtbl)
184 #define CONPTCONT(x)    ((IConnectionPointContainer*)   &(x)->lpConnectionPointContainerVtbl)
185 #define VIEWOBJ(x)      ((IViewObject*)                 &(x)->lpViewObjectVtbl);
186 #define VIEWOBJ2(x)     ((IViewObject2*)                &(x)->lpViewObjectVtbl);
187 #define ACTIVEOBJ(x)    ((IOleInPlaceActiveObject*)     &(x)->lpOleInPlaceActiveObjectVtbl)
188 #define OLECMD(x)       ((IOleCommandTarget*)           &(x)->lpOleCommandTargetVtbl)
189 #define HLINKFRAME(x)   ((IHlinkFrame*)                 &(x)->lpHlinkFrameVtbl)
190 #define DATAOBJECT(x)   ((IDataObject*)                 &(x)->lpDataObjectVtbl)
191 #define TARGETFRAME2(x) ((ITargetFrame2*)               &(x)->lpITargetFrame2Vtbl)
192
193 #define CLIENTSITE(x)   ((IOleClientSite*)              &(x)->lpOleClientSiteVtbl)
194 #define INPLACESITE(x)  ((IOleInPlaceSite*)             &(x)->lpOleInPlaceSiteVtbl)
195 #define DOCHOSTUI(x)    ((IDocHostUIHandler*)           &(x)->lpDocHostUIHandlerVtbl)
196 #define DOCHOSTUI2(x)   ((IDocHostUIHandler2*)          &(x)->lpDocHostUIHandlerVtbl)
197 #define DOCSITE(x)      ((IOleDocumentSite*)            &(x)->lpOleDocumentSiteVtbl)
198 #define CLDISP(x)       ((IDispatch*)                   &(x)->lpDispatchVtbl)
199 #define PROPNOTIF(x)    ((IPropertyNotifySink*)         &(x)->lpIPropertyNotifySinkVtbl)
200 #define SERVPROV(x)     ((IServiceProvider*)            &(x)->lpServiceProviderVtbl)
201
202 #define INPLACEFRAME(x) ((IOleInPlaceFrame*)            &(x)->lpOleInPlaceFrameVtbl)
203
204 void WebBrowser_OleObject_Init(WebBrowser*);
205 void WebBrowser_ViewObject_Init(WebBrowser*);
206 void WebBrowser_DataObject_Init(WebBrowser*);
207 void WebBrowser_Persist_Init(WebBrowser*);
208 void WebBrowser_ClassInfo_Init(WebBrowser*);
209 void WebBrowser_HlinkFrame_Init(WebBrowser*);
210
211 void WebBrowser_OleObject_Destroy(WebBrowser*);
212
213 void DocHost_Init(DocHost*,IDispatch*);
214 void DocHost_ClientSite_Init(DocHost*);
215 void DocHost_Frame_Init(DocHost*);
216 void release_dochost_client(DocHost*);
217
218 void DocHost_Release(DocHost*);
219 void DocHost_ClientSite_Release(DocHost*);
220
221 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
222 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
223
224 HRESULT WebBrowserV1_Create(IUnknown*,REFIID,void**);
225 HRESULT WebBrowserV2_Create(IUnknown*,REFIID,void**);
226
227 void create_doc_view_hwnd(DocHost*);
228 void deactivate_document(DocHost*);
229 HRESULT dochost_object_available(DocHost*,IUnknown*);
230 void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
231 HRESULT navigate_url(DocHost*,LPCWSTR,const VARIANT*,const VARIANT*,VARIANT*,VARIANT*);
232 HRESULT go_home(DocHost*);
233 void set_doc_state(DocHost*,READYSTATE);
234
235 #define WM_DOCHOSTTASK (WM_USER+0x300)
236 void push_dochost_task(DocHost*,task_header_t*,task_proc_t,BOOL);
237 LRESULT  process_dochost_task(DocHost*,LPARAM);
238
239 HRESULT InternetExplorer_Create(IUnknown*,REFIID,void**);
240 void InternetExplorer_WebBrowser_Init(InternetExplorer*);
241
242 HRESULT CUrlHistory_Create(IUnknown*,REFIID,void**);
243
244 HRESULT InternetShortcut_Create(IUnknown*,REFIID,void**);
245
246 HRESULT TaskbarList_Create(IUnknown*,REFIID,void**);
247
248 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
249
250 /**********************************************************************
251  * Dll lifetime tracking declaration for shdocvw.dll
252  */
253 extern LONG SHDOCVW_refCount;
254 static inline void SHDOCVW_LockModule(void) { InterlockedIncrement( &SHDOCVW_refCount ); }
255 static inline void SHDOCVW_UnlockModule(void) { InterlockedDecrement( &SHDOCVW_refCount ); }
256
257 extern HINSTANCE shdocvw_hinstance;
258 extern void register_iewindow_class(void);
259 extern void unregister_iewindow_class(void);
260
261 HRESULT register_class_object(BOOL);
262 HRESULT get_typeinfo(ITypeInfo**);
263 DWORD register_iexplore(BOOL);
264
265 const char *debugstr_variant(const VARIANT*);
266
267 /* memory allocation functions */
268
269 static inline void *heap_alloc(size_t len)
270 {
271     return HeapAlloc(GetProcessHeap(), 0, len);
272 }
273
274 static inline void *heap_alloc_zero(size_t len)
275 {
276     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
277 }
278
279 static inline void *heap_realloc(void *mem, size_t len)
280 {
281     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
282 }
283
284 static inline BOOL heap_free(void *mem)
285 {
286     return HeapFree(GetProcessHeap(), 0, mem);
287 }
288
289 static inline LPWSTR heap_strdupW(LPCWSTR str)
290 {
291     LPWSTR ret = NULL;
292
293     if(str) {
294         DWORD size;
295
296         size = (strlenW(str)+1)*sizeof(WCHAR);
297         ret = heap_alloc(size);
298         memcpy(ret, str, size);
299     }
300
301     return ret;
302 }
303
304 static inline LPWSTR co_strdupW(LPCWSTR str)
305 {
306     WCHAR *ret = CoTaskMemAlloc((strlenW(str) + 1)*sizeof(WCHAR));
307     if (ret)
308         lstrcpyW(ret, str);
309     return ret;
310 }
311
312 static inline LPWSTR co_strdupAtoW(LPCSTR str)
313 {
314     INT len;
315     WCHAR *ret;
316     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
317     ret = CoTaskMemAlloc(len*sizeof(WCHAR));
318     if (ret)
319         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
320     return ret;
321 }
322
323 static inline LPSTR co_strdupWtoA(LPCWSTR str)
324 {
325     INT len;
326     CHAR *ret;
327     len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, 0, 0);
328     ret = CoTaskMemAlloc(len);
329     if (ret)
330         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, 0, 0);
331     return ret;
332 }
333
334 #endif /* __WINE_SHDOCVW_H */