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