msi: Write-strings warnings fix.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "docobj.h"
20 #include "mshtml.h"
21 #include "mshtmhst.h"
22 #include "hlink.h"
23
24 #ifdef INIT_GUID
25 #include "initguid.h"
26 #endif
27
28 #include "nsiface.h"
29
30 #define NS_OK                     ((nsresult)0x00000000L)
31 #define NS_ERROR_FAILURE          ((nsresult)0x80004005L)
32 #define NS_NOINTERFACE            ((nsresult)0x80004002L)
33 #define NS_ERROR_NOT_IMPLEMENTED  ((nsresult)0x80004001L)
34 #define NS_ERROR_INVALID_ARG      ((nsresult)0x80070057L) 
35 #define NS_ERROR_UNEXPECTED       ((nsresult)0x8000ffffL)
36 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
37
38 #define NS_FAILED(res) ((res) & 0x80000000)
39 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
40
41 #define NSAPI WINAPI
42
43 #define NS_ELEMENT_NODE   1
44 #define NS_DOCUMENT_NODE  9
45
46 typedef struct HTMLDOMNode HTMLDOMNode;
47 typedef struct ConnectionPoint ConnectionPoint;
48 typedef struct BSCallback BSCallback;
49
50 typedef enum {
51     UNKNOWN_USERMODE,
52     BROWSEMODE,
53     EDITMODE        
54 } USERMODE;
55
56 struct HTMLDocument {
57     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
58     const IHTMLDocument3Vtbl              *lpHTMLDocument3Vtbl;
59     const IPersistMonikerVtbl             *lpPersistMonikerVtbl;
60     const IPersistFileVtbl                *lpPersistFileVtbl;
61     const IMonikerPropVtbl                *lpMonikerPropVtbl;
62     const IOleObjectVtbl                  *lpOleObjectVtbl;
63     const IOleDocumentVtbl                *lpOleDocumentVtbl;
64     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
65     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
66     const IViewObject2Vtbl                *lpViewObject2Vtbl;
67     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
68     const IServiceProviderVtbl            *lpServiceProviderVtbl;
69     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
70     const IOleControlVtbl                 *lpOleControlVtbl;
71     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
72     const IConnectionPointContainerVtbl   *lpConnectionPointContainerVtbl;
73     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
74
75     LONG ref;
76
77     NSContainer *nscontainer;
78
79     IOleClientSite *client;
80     IDocHostUIHandler *hostui;
81     IOleInPlaceSite *ipsite;
82     IOleInPlaceFrame *frame;
83
84     HWND hwnd;
85     HWND tooltips_hwnd;
86
87     USERMODE usermode;
88     BOOL in_place_active;
89     BOOL ui_active;
90     BOOL window_active;
91     BOOL has_key_path;
92     BOOL container_locked;
93
94     ConnectionPoint *cp_htmldocevents;
95     ConnectionPoint *cp_htmldocevents2;
96     ConnectionPoint *cp_propnotif;
97
98     HTMLDOMNode *nodes;
99 };
100
101 struct NSContainer {
102     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
103     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
104     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
105     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
106     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
107     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
108     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
109     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
110
111     nsIWebBrowser *webbrowser;
112     nsIWebNavigation *navigation;
113     nsIBaseWindow *window;
114     nsIWebBrowserFocus *focus;
115
116     LONG ref;
117
118     NSContainer *parent;
119     HTMLDocument *doc;
120
121     HWND hwnd;
122
123     BSCallback *bscallback; /* hack */
124 };
125
126 typedef struct {
127     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
128     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
129
130     LONG ref;
131
132     nsIChannel *channel;
133     nsIHttpChannel *http_channel;
134     nsIWineURI *uri;
135     nsIInputStream *post_data_stream;
136     nsILoadGroup *load_group;
137     nsIInterfaceRequestor *notif_callback;
138     nsLoadFlags load_flags;
139     nsIURI *original_uri;
140     char *content;
141 } nsChannel;
142
143 typedef struct {
144     const nsIInputStreamVtbl *lpInputStreamVtbl;
145
146     LONG ref;
147
148     char buf[1024];
149     DWORD buf_size;
150 } nsProtocolStream;
151
152 struct BSCallback {
153     const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
154     const IServiceProviderVtbl    *lpServiceProviderVtbl;
155     const IHttpNegotiate2Vtbl     *lpHttpNegotiate2Vtbl;
156     const IInternetBindInfoVtbl   *lpInternetBindInfoVtbl;
157
158     LONG ref;
159
160     LPWSTR headers;
161     HGLOBAL post_data;
162     ULONG post_data_len;
163     ULONG readed;
164
165     nsChannel *nschannel;
166     nsIStreamListener *nslistener;
167     nsISupports *nscontext;
168
169     nsProtocolStream *nsstream;
170 };
171
172 struct HTMLDOMNode {
173     const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
174
175     void (*destructor)(IUnknown*);
176
177     enum {
178         NT_UNKNOWN,
179         NT_HTMLELEM
180     } node_type;
181
182     union {
183         IUnknown *unk;
184         IHTMLElement *elem;
185     } impl;
186
187     nsIDOMNode *nsnode;
188     HTMLDocument *doc;
189
190     HTMLDOMNode *next;
191 };
192
193 typedef struct {
194     const IHTMLElementVtbl *lpHTMLElementVtbl;
195     const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
196
197     void (*destructor)(IUnknown*);
198
199     nsIDOMHTMLElement *nselem;
200     HTMLDOMNode *node;
201
202     IUnknown *impl;
203 } HTMLElement;
204
205 typedef struct {
206     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
207
208     HTMLElement *element;
209 } HTMLTextContainer;
210
211 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
212 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
213 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
214 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
215 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
216 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
217 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
218 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
219 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
220 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
221 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
222 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
223 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
224 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
225 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
226 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
227 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
228 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
229 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
230 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
231 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
232
233 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
234 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
235 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
236 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
237 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
238 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
239 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
240 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
241
242 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
243 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
244 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
245
246 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
247 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
248 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
249
250 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
251 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
252 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
253
254 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
255
256 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
257
258 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
259 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
260
261 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
262 void HTMLDocument_Persist_Init(HTMLDocument*);
263 void HTMLDocument_OleCmd_Init(HTMLDocument*);
264 void HTMLDocument_OleObj_Init(HTMLDocument*);
265 void HTMLDocument_View_Init(HTMLDocument*);
266 void HTMLDocument_Window_Init(HTMLDocument*);
267 void HTMLDocument_Service_Init(HTMLDocument*);
268 void HTMLDocument_Hlink_Init(HTMLDocument*);
269 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
270
271 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
272
273 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
274 void NSContainer_Release(NSContainer*);
275
276 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
277 void HTMLDocument_ShowContextMenu(HTMLDocument*,DWORD,POINT*);
278
279 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
280 void hide_tooltip(HTMLDocument*);
281
282 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
283
284 void close_gecko(void);
285 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
286 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
287
288 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
289
290 nsIURI *get_nsIURI(LPCWSTR);
291
292 void *nsalloc(size_t);
293 void nsfree(void*);
294
295 void nsACString_Init(nsACString*,const char*);
296 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
297 void nsACString_Finish(nsACString*);
298
299 void nsAString_Init(nsAString*,const PRUnichar*);
300 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
301 void nsAString_Finish(nsAString*);
302
303 nsIInputStream *create_nsstream(const char*,PRInt32);
304
305 BSCallback *create_bscallback(HTMLDocument*,LPCOLESTR);
306 HRESULT start_binding(BSCallback*,IMoniker*);
307
308 IHlink *Hlink_Create(void);
309 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
310 IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*);
311
312 void HTMLElement_Create(HTMLDOMNode*);
313 void HTMLBodyElement_Create(HTMLElement*);
314 void HTMLInputElement_Create(HTMLElement*);
315 void HTMLSelectElement_Create(HTMLElement*);
316 void HTMLTextAreaElement_Create(HTMLElement*);
317
318 void HTMLElement2_Init(HTMLElement*);
319
320 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
321
322 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
323 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
324
325 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
326 void release_nodes(HTMLDocument*);
327
328 void install_wine_gecko(void);
329
330 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
331 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
332 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
333 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
334 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
335
336 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
337
338 extern LONG module_ref;
339 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
340 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
341
342 /* memory allocation functions */
343
344 static inline void *mshtml_alloc(size_t len)
345 {
346     return HeapAlloc(GetProcessHeap(), 0, len);
347 }
348
349 static inline void *mshtml_realloc(void *mem, size_t len)
350 {
351     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
352 }
353
354 static inline BOOL mshtml_free(void *mem)
355 {
356     return HeapFree(GetProcessHeap(), 0, mem);
357 }
358
359 extern HINSTANCE hInst;