gdi32: Clip solid pen regions to the DIB rectangle to avoid overflows.
[wine.git] / dlls / mshtml / omnavigator.c
blob73bb0bbc5d074c6efc22b71a360692df7ccc282b
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct HTMLPluginsCollection HTMLPluginsCollection;
35 typedef struct HTMLMimeTypesCollection HTMLMimeTypesCollection;
37 typedef struct {
38 DispatchEx dispex;
39 IOmNavigator IOmNavigator_iface;
41 LONG ref;
43 HTMLPluginsCollection *plugins;
44 HTMLMimeTypesCollection *mime_types;
45 } OmNavigator;
47 typedef struct {
48 DispatchEx dispex;
49 IOmHistory IOmHistory_iface;
51 LONG ref;
52 } OmHistory;
54 static inline OmHistory *impl_from_IOmHistory(IOmHistory *iface)
56 return CONTAINING_RECORD(iface, OmHistory, IOmHistory_iface);
59 static HRESULT WINAPI OmHistory_QueryInterface(IOmHistory *iface, REFIID riid, void **ppv)
61 OmHistory *This = impl_from_IOmHistory(iface);
63 *ppv = NULL;
65 if(IsEqualGUID(&IID_IUnknown, riid)) {
66 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
67 *ppv = &This->IOmHistory_iface;
68 }else if(IsEqualGUID(&IID_IOmHistory, riid)) {
69 TRACE("(%p)->(IID_IOmHistory %p)\n", This, ppv);
70 *ppv = &This->IOmHistory_iface;
71 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
72 return *ppv ? S_OK : E_NOINTERFACE;
75 if(*ppv) {
76 IUnknown_AddRef((IUnknown*)*ppv);
77 return S_OK;
80 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
81 return E_NOINTERFACE;
84 static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface)
86 OmHistory *This = impl_from_IOmHistory(iface);
87 LONG ref = InterlockedIncrement(&This->ref);
89 TRACE("(%p) ref=%d\n", This, ref);
91 return ref;
94 static ULONG WINAPI OmHistory_Release(IOmHistory *iface)
96 OmHistory *This = impl_from_IOmHistory(iface);
97 LONG ref = InterlockedDecrement(&This->ref);
99 TRACE("(%p) ref=%d\n", This, ref);
101 if(!ref) {
102 release_dispex(&This->dispex);
103 heap_free(This);
106 return ref;
109 static HRESULT WINAPI OmHistory_GetTypeInfoCount(IOmHistory *iface, UINT *pctinfo)
111 OmHistory *This = impl_from_IOmHistory(iface);
112 FIXME("(%p)->(%p)\n", This, pctinfo);
113 return E_NOTIMPL;
116 static HRESULT WINAPI OmHistory_GetTypeInfo(IOmHistory *iface, UINT iTInfo,
117 LCID lcid, ITypeInfo **ppTInfo)
119 OmHistory *This = impl_from_IOmHistory(iface);
121 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
124 static HRESULT WINAPI OmHistory_GetIDsOfNames(IOmHistory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
125 LCID lcid, DISPID *rgDispId)
127 OmHistory *This = impl_from_IOmHistory(iface);
129 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
130 lcid, rgDispId);
133 static HRESULT WINAPI OmHistory_Invoke(IOmHistory *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
134 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
136 OmHistory *This = impl_from_IOmHistory(iface);
138 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
139 pDispParams, pVarResult, pExcepInfo, puArgErr);
142 static HRESULT WINAPI OmHistory_get_length(IOmHistory *iface, short *p)
144 OmHistory *This = impl_from_IOmHistory(iface);
145 FIXME("(%p)->(%p)\n", This, p);
146 return E_NOTIMPL;
149 static HRESULT WINAPI OmHistory_back(IOmHistory *iface, VARIANT *pvargdistance)
151 OmHistory *This = impl_from_IOmHistory(iface);
152 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
153 return E_NOTIMPL;
156 static HRESULT WINAPI OmHistory_forward(IOmHistory *iface, VARIANT *pvargdistance)
158 OmHistory *This = impl_from_IOmHistory(iface);
159 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
160 return E_NOTIMPL;
163 static HRESULT WINAPI OmHistory_go(IOmHistory *iface, VARIANT *pvargdistance)
165 OmHistory *This = impl_from_IOmHistory(iface);
166 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
167 return E_NOTIMPL;
170 static const IOmHistoryVtbl OmHistoryVtbl = {
171 OmHistory_QueryInterface,
172 OmHistory_AddRef,
173 OmHistory_Release,
174 OmHistory_GetTypeInfoCount,
175 OmHistory_GetTypeInfo,
176 OmHistory_GetIDsOfNames,
177 OmHistory_Invoke,
178 OmHistory_get_length,
179 OmHistory_back,
180 OmHistory_forward,
181 OmHistory_go
184 static const tid_t OmHistory_iface_tids[] = {
185 IOmHistory_tid,
188 static dispex_static_data_t OmHistory_dispex = {
189 NULL,
190 DispHTMLHistory_tid,
191 NULL,
192 OmHistory_iface_tids
196 HRESULT create_history(IOmHistory **ret)
198 OmHistory *history;
200 history = heap_alloc_zero(sizeof(*history));
201 if(!history)
202 return E_OUTOFMEMORY;
204 init_dispex(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex);
205 history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl;
206 history->ref = 1;
208 *ret = &history->IOmHistory_iface;
209 return S_OK;
212 struct HTMLPluginsCollection {
213 DispatchEx dispex;
214 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
216 LONG ref;
218 OmNavigator *navigator;
221 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
223 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
226 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
228 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
230 if(IsEqualGUID(&IID_IUnknown, riid)) {
231 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
232 *ppv = &This->IHTMLPluginsCollection_iface;
233 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
234 TRACE("(%p)->(IID_IHTMLPluginCollection %p)\n", This, ppv);
235 *ppv = &This->IHTMLPluginsCollection_iface;
236 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
237 return *ppv ? S_OK : E_NOINTERFACE;
238 }else {
239 *ppv = NULL;
240 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
241 return E_NOINTERFACE;
244 IUnknown_AddRef((IUnknown*)*ppv);
245 return S_OK;
248 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
250 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
251 LONG ref = InterlockedIncrement(&This->ref);
253 TRACE("(%p) ref=%d\n", This, ref);
255 return ref;
258 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
260 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
261 LONG ref = InterlockedDecrement(&This->ref);
263 TRACE("(%p) ref=%d\n", This, ref);
265 if(!ref) {
266 if(This->navigator)
267 This->navigator->plugins = NULL;
268 release_dispex(&This->dispex);
269 heap_free(This);
272 return ref;
275 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
277 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
278 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
281 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
282 LCID lcid, ITypeInfo **ppTInfo)
284 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
285 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
288 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
289 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
291 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
292 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
293 lcid, rgDispId);
296 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
297 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
298 EXCEPINFO *pExcepInfo, UINT *puArgErr)
300 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
301 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
302 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
305 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
307 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
309 TRACE("(%p)->(%p)\n", This, p);
311 /* IE always returns 0 here */
312 *p = 0;
313 return S_OK;
316 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
318 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
319 FIXME("(%p)->(%x)\n", This, reload);
320 return E_NOTIMPL;
323 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
324 HTMLPluginsCollection_QueryInterface,
325 HTMLPluginsCollection_AddRef,
326 HTMLPluginsCollection_Release,
327 HTMLPluginsCollection_GetTypeInfoCount,
328 HTMLPluginsCollection_GetTypeInfo,
329 HTMLPluginsCollection_GetIDsOfNames,
330 HTMLPluginsCollection_Invoke,
331 HTMLPluginsCollection_get_length,
332 HTMLPluginsCollection_refresh
335 static const tid_t HTMLPluginsCollection_iface_tids[] = {
336 IHTMLPluginsCollection_tid,
339 static dispex_static_data_t HTMLPluginsCollection_dispex = {
340 NULL,
341 DispCPlugins_tid,
342 NULL,
343 HTMLPluginsCollection_iface_tids
346 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
348 HTMLPluginsCollection *col;
350 col = heap_alloc_zero(sizeof(*col));
351 if(!col)
352 return E_OUTOFMEMORY;
354 col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl;
355 col->ref = 1;
356 col->navigator = navigator;
358 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface,
359 &HTMLPluginsCollection_dispex);
361 *ret = col;
362 return S_OK;
365 struct HTMLMimeTypesCollection {
366 DispatchEx dispex;
367 IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface;
369 LONG ref;
371 OmNavigator *navigator;
374 static inline HTMLMimeTypesCollection *impl_from_IHTMLMimeTypesCollection(IHTMLMimeTypesCollection *iface)
376 return CONTAINING_RECORD(iface, HTMLMimeTypesCollection, IHTMLMimeTypesCollection_iface);
379 static HRESULT WINAPI HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesCollection *iface, REFIID riid, void **ppv)
381 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
383 if(IsEqualGUID(&IID_IUnknown, riid)) {
384 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
385 *ppv = &This->IHTMLMimeTypesCollection_iface;
386 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection, riid)) {
387 TRACE("(%p)->(IID_IHTMLMimeTypesCollection %p)\n", This, ppv);
388 *ppv = &This->IHTMLMimeTypesCollection_iface;
389 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
390 return *ppv ? S_OK : E_NOINTERFACE;
391 }else {
392 *ppv = NULL;
393 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
394 return E_NOINTERFACE;
397 IUnknown_AddRef((IUnknown*)*ppv);
398 return S_OK;
401 static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *iface)
403 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
404 LONG ref = InterlockedIncrement(&This->ref);
406 TRACE("(%p) ref=%d\n", This, ref);
408 return ref;
411 static ULONG WINAPI HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection *iface)
413 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
414 LONG ref = InterlockedDecrement(&This->ref);
416 TRACE("(%p) ref=%d\n", This, ref);
418 if(!ref) {
419 if(This->navigator)
420 This->navigator->mime_types = NULL;
421 release_dispex(&This->dispex);
422 heap_free(This);
425 return ref;
428 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfoCount(IHTMLMimeTypesCollection *iface, UINT *pctinfo)
430 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
431 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
434 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfo(IHTMLMimeTypesCollection *iface, UINT iTInfo,
435 LCID lcid, ITypeInfo **ppTInfo)
437 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
438 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
441 static HRESULT WINAPI HTMLMimeTypesCollection_GetIDsOfNames(IHTMLMimeTypesCollection *iface, REFIID riid,
442 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
444 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
445 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
446 lcid, rgDispId);
449 static HRESULT WINAPI HTMLMimeTypesCollection_Invoke(IHTMLMimeTypesCollection *iface, DISPID dispIdMember,
450 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
451 EXCEPINFO *pExcepInfo, UINT *puArgErr)
453 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
454 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
455 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
458 static HRESULT WINAPI HTMLMimeTypesCollection_get_length(IHTMLMimeTypesCollection *iface, LONG *p)
460 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
462 TRACE("(%p)->(%p)\n", This, p);
464 /* This is just a stub for compatibility with other browser in IE */
465 *p = 0;
466 return S_OK;
469 static const IHTMLMimeTypesCollectionVtbl HTMLMimeTypesCollectionVtbl = {
470 HTMLMimeTypesCollection_QueryInterface,
471 HTMLMimeTypesCollection_AddRef,
472 HTMLMimeTypesCollection_Release,
473 HTMLMimeTypesCollection_GetTypeInfoCount,
474 HTMLMimeTypesCollection_GetTypeInfo,
475 HTMLMimeTypesCollection_GetIDsOfNames,
476 HTMLMimeTypesCollection_Invoke,
477 HTMLMimeTypesCollection_get_length
480 static const tid_t HTMLMimeTypesCollection_iface_tids[] = {
481 IHTMLMimeTypesCollection_tid,
484 static dispex_static_data_t HTMLMimeTypesCollection_dispex = {
485 NULL,
486 IHTMLMimeTypesCollection_tid,
487 NULL,
488 HTMLMimeTypesCollection_iface_tids
491 static HRESULT create_mime_types_collection(OmNavigator *navigator, HTMLMimeTypesCollection **ret)
493 HTMLMimeTypesCollection *col;
495 col = heap_alloc_zero(sizeof(*col));
496 if(!col)
497 return E_OUTOFMEMORY;
499 col->IHTMLMimeTypesCollection_iface.lpVtbl = &HTMLMimeTypesCollectionVtbl;
500 col->ref = 1;
501 col->navigator = navigator;
503 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLMimeTypesCollection_iface,
504 &HTMLMimeTypesCollection_dispex);
506 *ret = col;
507 return S_OK;
510 static inline OmNavigator *impl_from_IOmNavigator(IOmNavigator *iface)
512 return CONTAINING_RECORD(iface, OmNavigator, IOmNavigator_iface);
515 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
517 OmNavigator *This = impl_from_IOmNavigator(iface);
519 *ppv = NULL;
521 if(IsEqualGUID(&IID_IUnknown, riid)) {
522 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
523 *ppv = &This->IOmNavigator_iface;
524 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
525 TRACE("(%p)->(IID_IOmNavigator %p)\n", This, ppv);
526 *ppv = &This->IOmNavigator_iface;
527 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
528 return *ppv ? S_OK : E_NOINTERFACE;
531 if(*ppv) {
532 IUnknown_AddRef((IUnknown*)*ppv);
533 return S_OK;
536 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
537 return E_NOINTERFACE;
540 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
542 OmNavigator *This = impl_from_IOmNavigator(iface);
543 LONG ref = InterlockedIncrement(&This->ref);
545 TRACE("(%p) ref=%d\n", This, ref);
547 return ref;
550 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
552 OmNavigator *This = impl_from_IOmNavigator(iface);
553 LONG ref = InterlockedDecrement(&This->ref);
555 TRACE("(%p) ref=%d\n", This, ref);
557 if(!ref) {
558 if(This->plugins)
559 This->plugins->navigator = NULL;
560 if(This->mime_types)
561 This->mime_types->navigator = NULL;
562 release_dispex(&This->dispex);
563 heap_free(This);
566 return ref;
569 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
571 OmNavigator *This = impl_from_IOmNavigator(iface);
572 FIXME("(%p)->(%p)\n", This, pctinfo);
573 return E_NOTIMPL;
576 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
577 LCID lcid, ITypeInfo **ppTInfo)
579 OmNavigator *This = impl_from_IOmNavigator(iface);
581 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
584 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
585 LPOLESTR *rgszNames, UINT cNames,
586 LCID lcid, DISPID *rgDispId)
588 OmNavigator *This = impl_from_IOmNavigator(iface);
590 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
591 lcid, rgDispId);
594 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
595 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
596 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
598 OmNavigator *This = impl_from_IOmNavigator(iface);
600 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
601 pDispParams, pVarResult, pExcepInfo, puArgErr);
604 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
606 OmNavigator *This = impl_from_IOmNavigator(iface);
608 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
610 TRACE("(%p)->(%p)\n", This, p);
612 *p = SysAllocString(mozillaW);
613 return S_OK;
616 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
618 OmNavigator *This = impl_from_IOmNavigator(iface);
620 static const WCHAR app_nameW[] =
621 {'M','i','c','r','o','s','o','f','t',' ',
622 'I','n','t','e','r','n','e','t',' ',
623 'E','x','p','l','o','r','e','r',0};
625 TRACE("(%p)->(%p)\n", This, p);
627 *p = SysAllocString(app_nameW);
628 if(!*p)
629 return E_OUTOFMEMORY;
631 return S_OK;
634 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
636 OmNavigator *This = impl_from_IOmNavigator(iface);
638 char user_agent[512];
639 DWORD size;
640 HRESULT hres;
642 TRACE("(%p)->(%p)\n", This, p);
644 size = sizeof(user_agent);
645 hres = ObtainUserAgentString(0, user_agent, &size);
646 if(FAILED(hres))
647 return hres;
649 if(strncmp(user_agent, "Mozilla/", 8)) {
650 FIXME("Unsupported user agent\n");
651 return E_FAIL;
654 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
655 *p = SysAllocStringLen(NULL, size-1);
656 if(!*p)
657 return E_OUTOFMEMORY;
659 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
660 return S_OK;
663 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
665 OmNavigator *This = impl_from_IOmNavigator(iface);
666 char user_agent[512];
667 DWORD size;
668 HRESULT hres;
670 TRACE("(%p)->(%p)\n", This, p);
672 size = sizeof(user_agent);
673 hres = ObtainUserAgentString(0, user_agent, &size);
674 if(FAILED(hres))
675 return hres;
677 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
678 *p = SysAllocStringLen(NULL, size-1);
679 if(!*p)
680 return E_OUTOFMEMORY;
682 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
683 return S_OK;
686 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
688 OmNavigator *This = impl_from_IOmNavigator(iface);
690 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
692 *enabled = VARIANT_TRUE;
693 return S_OK;
696 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
698 OmNavigator *This = impl_from_IOmNavigator(iface);
699 FIXME("(%p)->(%p)\n", This, enabled);
700 return E_NOTIMPL;
703 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
705 OmNavigator *This = impl_from_IOmNavigator(iface);
707 TRACE("(%p)->(%p)\n", This, p);
709 if(!This->mime_types) {
710 HRESULT hres;
712 hres = create_mime_types_collection(This, &This->mime_types);
713 if(FAILED(hres))
714 return hres;
715 }else {
716 IHTMLMimeTypesCollection_AddRef(&This->mime_types->IHTMLMimeTypesCollection_iface);
719 *p = &This->mime_types->IHTMLMimeTypesCollection_iface;
720 return S_OK;
723 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
725 OmNavigator *This = impl_from_IOmNavigator(iface);
727 TRACE("(%p)->(%p)\n", This, p);
729 if(!This->plugins) {
730 HRESULT hres;
732 hres = create_plugins_collection(This, &This->plugins);
733 if(FAILED(hres))
734 return hres;
735 }else {
736 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
739 *p = &This->plugins->IHTMLPluginsCollection_iface;
740 return S_OK;
743 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
745 OmNavigator *This = impl_from_IOmNavigator(iface);
747 WARN("(%p)->(%p) semi-stub\n", This, p);
749 *p = VARIANT_TRUE;
750 return S_OK;
753 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
755 OmNavigator *This = impl_from_IOmNavigator(iface);
756 FIXME("(%p)->(%p)\n", This, p);
757 return E_NOTIMPL;
760 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
762 OmNavigator *This = impl_from_IOmNavigator(iface);
764 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
766 TRACE("(%p)->(%p)\n", This, String);
768 if(!String)
769 return E_INVALIDARG;
771 *String = SysAllocString(objectW);
772 return *String ? S_OK : E_OUTOFMEMORY;
775 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
777 OmNavigator *This = impl_from_IOmNavigator(iface);
779 static const WCHAR cpu_classW[] =
780 #ifdef _WIN64
781 {'x','6','4',0};
782 #else
783 {'x','8','6',0};
784 #endif
786 TRACE("(%p)->(%p)\n", This, p);
788 *p = SysAllocString(cpu_classW);
789 return *p ? S_OK : E_OUTOFMEMORY;
792 static HRESULT get_language_string(LCID lcid, BSTR *p)
794 BSTR ret;
795 int len;
797 len = LCIDToLocaleName(lcid, NULL, 0, 0);
798 if(!len) {
799 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
800 return E_FAIL;
803 ret = SysAllocStringLen(NULL, len-1);
804 if(!ret)
805 return E_OUTOFMEMORY;
807 len = LCIDToLocaleName(lcid, ret, len, 0);
808 if(!len) {
809 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
810 SysFreeString(ret);
811 return E_FAIL;
814 *p = ret;
815 return S_OK;
818 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
820 OmNavigator *This = impl_from_IOmNavigator(iface);
822 TRACE("(%p)->(%p)\n", This, p);
824 return get_language_string(LOCALE_SYSTEM_DEFAULT, p);
827 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
829 OmNavigator *This = impl_from_IOmNavigator(iface);
831 TRACE("(%p)->(%p)\n", This, p);
833 return get_language_string(GetUserDefaultUILanguage(), p);
836 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
838 OmNavigator *This = impl_from_IOmNavigator(iface);
840 TRACE("(%p)->(%p)\n", This, p);
842 return get_language_string(LOCALE_USER_DEFAULT, p);
845 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
847 OmNavigator *This = impl_from_IOmNavigator(iface);
849 #ifdef _WIN64
850 static const WCHAR platformW[] = {'W','i','n','6','4',0};
851 #else
852 static const WCHAR platformW[] = {'W','i','n','3','2',0};
853 #endif
855 TRACE("(%p)->(%p)\n", This, p);
857 *p = SysAllocString(platformW);
858 return S_OK;
861 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
863 OmNavigator *This = impl_from_IOmNavigator(iface);
865 static const WCHAR zeroW[] = {'0',0};
867 TRACE("(%p)->(%p)\n", This, p);
869 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
870 *p = SysAllocString(zeroW);
871 return S_OK;
874 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
876 OmNavigator *This = impl_from_IOmNavigator(iface);
877 FIXME("(%p)->(%p)\n", This, p);
878 return E_NOTIMPL;
881 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
883 OmNavigator *This = impl_from_IOmNavigator(iface);
884 FIXME("(%p)->(%p)\n", This, p);
885 return E_NOTIMPL;
888 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
890 OmNavigator *This = impl_from_IOmNavigator(iface);
891 FIXME("(%p)->(%p)\n", This, p);
892 return E_NOTIMPL;
895 static const IOmNavigatorVtbl OmNavigatorVtbl = {
896 OmNavigator_QueryInterface,
897 OmNavigator_AddRef,
898 OmNavigator_Release,
899 OmNavigator_GetTypeInfoCount,
900 OmNavigator_GetTypeInfo,
901 OmNavigator_GetIDsOfNames,
902 OmNavigator_Invoke,
903 OmNavigator_get_appCodeName,
904 OmNavigator_get_appName,
905 OmNavigator_get_appVersion,
906 OmNavigator_get_userAgent,
907 OmNavigator_javaEnabled,
908 OmNavigator_taintEnabled,
909 OmNavigator_get_mimeTypes,
910 OmNavigator_get_plugins,
911 OmNavigator_get_cookieEnabled,
912 OmNavigator_get_opsProfile,
913 OmNavigator_toString,
914 OmNavigator_get_cpuClass,
915 OmNavigator_get_systemLanguage,
916 OmNavigator_get_browserLanguage,
917 OmNavigator_get_userLanguage,
918 OmNavigator_get_platform,
919 OmNavigator_get_appMinorVersion,
920 OmNavigator_get_connectionSpeed,
921 OmNavigator_get_onLine,
922 OmNavigator_get_userProfile
925 static const tid_t OmNavigator_iface_tids[] = {
926 IOmNavigator_tid,
929 static dispex_static_data_t OmNavigator_dispex = {
930 NULL,
931 DispHTMLNavigator_tid,
932 NULL,
933 OmNavigator_iface_tids
936 IOmNavigator *OmNavigator_Create(void)
938 OmNavigator *ret;
940 ret = heap_alloc_zero(sizeof(*ret));
941 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
942 ret->ref = 1;
944 init_dispex(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex);
946 return &ret->IOmNavigator_iface;