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