wined3d: Add support for WINED3DFMT_R8G8_SINT format.
[wine.git] / dlls / mshtml / omnavigator.c
blob86383d00854873d162f7c34028f072276ec08298
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 IHTMLDOMImplementation IHTMLDOMImplementation_iface;
51 LONG ref;
52 } HTMLDOMImplementation;
54 static inline HTMLDOMImplementation *impl_from_IHTMLDOMImplementation(IHTMLDOMImplementation *iface)
56 return CONTAINING_RECORD(iface, HTMLDOMImplementation, IHTMLDOMImplementation_iface);
59 static HRESULT WINAPI HTMLDOMImplementation_QueryInterface(IHTMLDOMImplementation *iface, REFIID riid, void **ppv)
61 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
63 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
65 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IHTMLDOMImplementation, riid)) {
66 *ppv = &This->IHTMLDOMImplementation_iface;
67 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
68 return *ppv ? S_OK : E_NOINTERFACE;
69 }else {
70 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
71 *ppv = NULL;
72 return E_NOINTERFACE;
75 IUnknown_AddRef((IUnknown*)*ppv);
76 return S_OK;
79 static ULONG WINAPI HTMLDOMImplementation_AddRef(IHTMLDOMImplementation *iface)
81 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
82 LONG ref = InterlockedIncrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
86 return ref;
89 static ULONG WINAPI HTMLDOMImplementation_Release(IHTMLDOMImplementation *iface)
91 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
92 LONG ref = InterlockedDecrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, ref);
96 if(!ref) {
97 release_dispex(&This->dispex);
98 heap_free(This);
101 return ref;
104 static HRESULT WINAPI HTMLDOMImplementation_GetTypeInfoCount(IHTMLDOMImplementation *iface, UINT *pctinfo)
106 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
108 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
111 static HRESULT WINAPI HTMLDOMImplementation_GetTypeInfo(IHTMLDOMImplementation *iface, UINT iTInfo,
112 LCID lcid, ITypeInfo **ppTInfo)
114 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
116 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
119 static HRESULT WINAPI HTMLDOMImplementation_GetIDsOfNames(IHTMLDOMImplementation *iface, REFIID riid,
120 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
122 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
124 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
125 cNames, lcid, rgDispId);
128 static HRESULT WINAPI HTMLDOMImplementation_Invoke(IHTMLDOMImplementation *iface, DISPID dispIdMember,
129 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
130 EXCEPINFO *pExcepInfo, UINT *puArgErr)
132 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
134 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
135 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
138 static HRESULT WINAPI HTMLDOMImplementation_hasFeature(IHTMLDOMImplementation *iface, BSTR feature,
139 VARIANT version, VARIANT_BOOL *pfHasFeature)
141 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
143 FIXME("(%p)->(%s %s %p) returning false\n", This, debugstr_w(feature), debugstr_variant(&version), pfHasFeature);
145 *pfHasFeature = VARIANT_FALSE;
146 return S_OK;
149 static const IHTMLDOMImplementationVtbl HTMLDOMImplementationVtbl = {
150 HTMLDOMImplementation_QueryInterface,
151 HTMLDOMImplementation_AddRef,
152 HTMLDOMImplementation_Release,
153 HTMLDOMImplementation_GetTypeInfoCount,
154 HTMLDOMImplementation_GetTypeInfo,
155 HTMLDOMImplementation_GetIDsOfNames,
156 HTMLDOMImplementation_Invoke,
157 HTMLDOMImplementation_hasFeature
160 static const tid_t HTMLDOMImplementation_iface_tids[] = {
161 IHTMLDOMImplementation_tid,
164 static dispex_static_data_t HTMLDOMImplementation_dispex = {
165 NULL,
166 IHTMLDOMImplementation_tid,
167 HTMLDOMImplementation_iface_tids
170 HRESULT create_dom_implementation(IHTMLDOMImplementation **ret)
172 HTMLDOMImplementation *dom_implementation;
174 dom_implementation = heap_alloc_zero(sizeof(*dom_implementation));
175 if(!dom_implementation)
176 return E_OUTOFMEMORY;
178 dom_implementation->IHTMLDOMImplementation_iface.lpVtbl = &HTMLDOMImplementationVtbl;
179 dom_implementation->ref = 1;
181 init_dispex(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface,
182 &HTMLDOMImplementation_dispex);
184 *ret = &dom_implementation->IHTMLDOMImplementation_iface;
185 return S_OK;
188 static inline OmHistory *impl_from_IOmHistory(IOmHistory *iface)
190 return CONTAINING_RECORD(iface, OmHistory, IOmHistory_iface);
193 static HRESULT WINAPI OmHistory_QueryInterface(IOmHistory *iface, REFIID riid, void **ppv)
195 OmHistory *This = impl_from_IOmHistory(iface);
197 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
199 if(IsEqualGUID(&IID_IUnknown, riid)) {
200 *ppv = &This->IOmHistory_iface;
201 }else if(IsEqualGUID(&IID_IOmHistory, riid)) {
202 *ppv = &This->IOmHistory_iface;
203 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
204 return *ppv ? S_OK : E_NOINTERFACE;
205 }else {
206 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
207 *ppv = NULL;
208 return E_NOINTERFACE;
211 IUnknown_AddRef((IUnknown*)*ppv);
212 return S_OK;
215 static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface)
217 OmHistory *This = impl_from_IOmHistory(iface);
218 LONG ref = InterlockedIncrement(&This->ref);
220 TRACE("(%p) ref=%d\n", This, ref);
222 return ref;
225 static ULONG WINAPI OmHistory_Release(IOmHistory *iface)
227 OmHistory *This = impl_from_IOmHistory(iface);
228 LONG ref = InterlockedDecrement(&This->ref);
230 TRACE("(%p) ref=%d\n", This, ref);
232 if(!ref) {
233 release_dispex(&This->dispex);
234 heap_free(This);
237 return ref;
240 static HRESULT WINAPI OmHistory_GetTypeInfoCount(IOmHistory *iface, UINT *pctinfo)
242 OmHistory *This = impl_from_IOmHistory(iface);
243 FIXME("(%p)->(%p)\n", This, pctinfo);
244 return E_NOTIMPL;
247 static HRESULT WINAPI OmHistory_GetTypeInfo(IOmHistory *iface, UINT iTInfo,
248 LCID lcid, ITypeInfo **ppTInfo)
250 OmHistory *This = impl_from_IOmHistory(iface);
252 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
255 static HRESULT WINAPI OmHistory_GetIDsOfNames(IOmHistory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
256 LCID lcid, DISPID *rgDispId)
258 OmHistory *This = impl_from_IOmHistory(iface);
260 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
261 lcid, rgDispId);
264 static HRESULT WINAPI OmHistory_Invoke(IOmHistory *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
265 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
267 OmHistory *This = impl_from_IOmHistory(iface);
269 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
270 pDispParams, pVarResult, pExcepInfo, puArgErr);
273 static HRESULT WINAPI OmHistory_get_length(IOmHistory *iface, short *p)
275 OmHistory *This = impl_from_IOmHistory(iface);
277 TRACE("(%p)->(%p)\n", This, p);
279 if(!This->window || !This->window->base.outer_window->doc_obj
280 || !This->window->base.outer_window->doc_obj->travel_log) {
281 *p = 0;
282 }else {
283 *p = ITravelLog_CountEntries(This->window->base.outer_window->doc_obj->travel_log,
284 This->window->base.outer_window->doc_obj->browser_service);
286 return S_OK;
289 static HRESULT WINAPI OmHistory_back(IOmHistory *iface, VARIANT *pvargdistance)
291 OmHistory *This = impl_from_IOmHistory(iface);
292 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
293 return E_NOTIMPL;
296 static HRESULT WINAPI OmHistory_forward(IOmHistory *iface, VARIANT *pvargdistance)
298 OmHistory *This = impl_from_IOmHistory(iface);
299 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
300 return E_NOTIMPL;
303 static HRESULT WINAPI OmHistory_go(IOmHistory *iface, VARIANT *pvargdistance)
305 OmHistory *This = impl_from_IOmHistory(iface);
306 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
307 return E_NOTIMPL;
310 static const IOmHistoryVtbl OmHistoryVtbl = {
311 OmHistory_QueryInterface,
312 OmHistory_AddRef,
313 OmHistory_Release,
314 OmHistory_GetTypeInfoCount,
315 OmHistory_GetTypeInfo,
316 OmHistory_GetIDsOfNames,
317 OmHistory_Invoke,
318 OmHistory_get_length,
319 OmHistory_back,
320 OmHistory_forward,
321 OmHistory_go
324 static const tid_t OmHistory_iface_tids[] = {
325 IOmHistory_tid,
328 static dispex_static_data_t OmHistory_dispex = {
329 NULL,
330 DispHTMLHistory_tid,
331 OmHistory_iface_tids
335 HRESULT create_history(HTMLInnerWindow *window, OmHistory **ret)
337 OmHistory *history;
339 history = heap_alloc_zero(sizeof(*history));
340 if(!history)
341 return E_OUTOFMEMORY;
343 init_dispex(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex);
344 history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl;
345 history->ref = 1;
347 history->window = window;
349 *ret = history;
350 return S_OK;
353 struct HTMLPluginsCollection {
354 DispatchEx dispex;
355 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
357 LONG ref;
359 OmNavigator *navigator;
362 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
364 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
367 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
369 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
371 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
373 if(IsEqualGUID(&IID_IUnknown, riid)) {
374 *ppv = &This->IHTMLPluginsCollection_iface;
375 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
376 *ppv = &This->IHTMLPluginsCollection_iface;
377 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
378 return *ppv ? S_OK : E_NOINTERFACE;
379 }else {
380 *ppv = NULL;
381 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
382 return E_NOINTERFACE;
385 IUnknown_AddRef((IUnknown*)*ppv);
386 return S_OK;
389 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
391 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
392 LONG ref = InterlockedIncrement(&This->ref);
394 TRACE("(%p) ref=%d\n", This, ref);
396 return ref;
399 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
401 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
402 LONG ref = InterlockedDecrement(&This->ref);
404 TRACE("(%p) ref=%d\n", This, ref);
406 if(!ref) {
407 if(This->navigator)
408 This->navigator->plugins = NULL;
409 release_dispex(&This->dispex);
410 heap_free(This);
413 return ref;
416 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
418 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
419 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
422 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
423 LCID lcid, ITypeInfo **ppTInfo)
425 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
426 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
429 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
430 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
432 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
433 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
434 lcid, rgDispId);
437 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
438 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
439 EXCEPINFO *pExcepInfo, UINT *puArgErr)
441 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
442 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
443 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
446 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
448 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
450 TRACE("(%p)->(%p)\n", This, p);
452 /* IE always returns 0 here */
453 *p = 0;
454 return S_OK;
457 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
459 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
461 TRACE("(%p)->(%x)\n", This, reload);
463 /* Nothing to do here. */
464 return S_OK;
467 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
468 HTMLPluginsCollection_QueryInterface,
469 HTMLPluginsCollection_AddRef,
470 HTMLPluginsCollection_Release,
471 HTMLPluginsCollection_GetTypeInfoCount,
472 HTMLPluginsCollection_GetTypeInfo,
473 HTMLPluginsCollection_GetIDsOfNames,
474 HTMLPluginsCollection_Invoke,
475 HTMLPluginsCollection_get_length,
476 HTMLPluginsCollection_refresh
479 static const tid_t HTMLPluginsCollection_iface_tids[] = {
480 IHTMLPluginsCollection_tid,
483 static dispex_static_data_t HTMLPluginsCollection_dispex = {
484 NULL,
485 DispCPlugins_tid,
486 HTMLPluginsCollection_iface_tids
489 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
491 HTMLPluginsCollection *col;
493 col = heap_alloc_zero(sizeof(*col));
494 if(!col)
495 return E_OUTOFMEMORY;
497 col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl;
498 col->ref = 1;
499 col->navigator = navigator;
501 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface,
502 &HTMLPluginsCollection_dispex);
504 *ret = col;
505 return S_OK;
508 struct HTMLMimeTypesCollection {
509 DispatchEx dispex;
510 IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface;
512 LONG ref;
514 OmNavigator *navigator;
517 static inline HTMLMimeTypesCollection *impl_from_IHTMLMimeTypesCollection(IHTMLMimeTypesCollection *iface)
519 return CONTAINING_RECORD(iface, HTMLMimeTypesCollection, IHTMLMimeTypesCollection_iface);
522 static HRESULT WINAPI HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesCollection *iface, REFIID riid, void **ppv)
524 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
526 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
528 if(IsEqualGUID(&IID_IUnknown, riid)) {
529 *ppv = &This->IHTMLMimeTypesCollection_iface;
530 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection, riid)) {
531 *ppv = &This->IHTMLMimeTypesCollection_iface;
532 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
533 return *ppv ? S_OK : E_NOINTERFACE;
534 }else {
535 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
536 *ppv = NULL;
537 return E_NOINTERFACE;
540 IUnknown_AddRef((IUnknown*)*ppv);
541 return S_OK;
544 static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *iface)
546 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
547 LONG ref = InterlockedIncrement(&This->ref);
549 TRACE("(%p) ref=%d\n", This, ref);
551 return ref;
554 static ULONG WINAPI HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection *iface)
556 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
557 LONG ref = InterlockedDecrement(&This->ref);
559 TRACE("(%p) ref=%d\n", This, ref);
561 if(!ref) {
562 if(This->navigator)
563 This->navigator->mime_types = NULL;
564 release_dispex(&This->dispex);
565 heap_free(This);
568 return ref;
571 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfoCount(IHTMLMimeTypesCollection *iface, UINT *pctinfo)
573 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
574 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
577 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfo(IHTMLMimeTypesCollection *iface, UINT iTInfo,
578 LCID lcid, ITypeInfo **ppTInfo)
580 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
581 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
584 static HRESULT WINAPI HTMLMimeTypesCollection_GetIDsOfNames(IHTMLMimeTypesCollection *iface, REFIID riid,
585 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
587 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
588 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
589 lcid, rgDispId);
592 static HRESULT WINAPI HTMLMimeTypesCollection_Invoke(IHTMLMimeTypesCollection *iface, DISPID dispIdMember,
593 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
594 EXCEPINFO *pExcepInfo, UINT *puArgErr)
596 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
597 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
598 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
601 static HRESULT WINAPI HTMLMimeTypesCollection_get_length(IHTMLMimeTypesCollection *iface, LONG *p)
603 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
605 TRACE("(%p)->(%p)\n", This, p);
607 /* This is just a stub for compatibility with other browser in IE */
608 *p = 0;
609 return S_OK;
612 static const IHTMLMimeTypesCollectionVtbl HTMLMimeTypesCollectionVtbl = {
613 HTMLMimeTypesCollection_QueryInterface,
614 HTMLMimeTypesCollection_AddRef,
615 HTMLMimeTypesCollection_Release,
616 HTMLMimeTypesCollection_GetTypeInfoCount,
617 HTMLMimeTypesCollection_GetTypeInfo,
618 HTMLMimeTypesCollection_GetIDsOfNames,
619 HTMLMimeTypesCollection_Invoke,
620 HTMLMimeTypesCollection_get_length
623 static const tid_t HTMLMimeTypesCollection_iface_tids[] = {
624 IHTMLMimeTypesCollection_tid,
627 static dispex_static_data_t HTMLMimeTypesCollection_dispex = {
628 NULL,
629 IHTMLMimeTypesCollection_tid,
630 HTMLMimeTypesCollection_iface_tids
633 static HRESULT create_mime_types_collection(OmNavigator *navigator, HTMLMimeTypesCollection **ret)
635 HTMLMimeTypesCollection *col;
637 col = heap_alloc_zero(sizeof(*col));
638 if(!col)
639 return E_OUTOFMEMORY;
641 col->IHTMLMimeTypesCollection_iface.lpVtbl = &HTMLMimeTypesCollectionVtbl;
642 col->ref = 1;
643 col->navigator = navigator;
645 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLMimeTypesCollection_iface,
646 &HTMLMimeTypesCollection_dispex);
648 *ret = col;
649 return S_OK;
652 static inline OmNavigator *impl_from_IOmNavigator(IOmNavigator *iface)
654 return CONTAINING_RECORD(iface, OmNavigator, IOmNavigator_iface);
657 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
659 OmNavigator *This = impl_from_IOmNavigator(iface);
661 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
663 if(IsEqualGUID(&IID_IUnknown, riid)) {
664 *ppv = &This->IOmNavigator_iface;
665 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
666 *ppv = &This->IOmNavigator_iface;
667 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
668 return *ppv ? S_OK : E_NOINTERFACE;
669 }else {
670 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
671 *ppv = NULL;
672 return E_NOINTERFACE;
675 IUnknown_AddRef((IUnknown*)*ppv);
676 return S_OK;
679 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
681 OmNavigator *This = impl_from_IOmNavigator(iface);
682 LONG ref = InterlockedIncrement(&This->ref);
684 TRACE("(%p) ref=%d\n", This, ref);
686 return ref;
689 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
691 OmNavigator *This = impl_from_IOmNavigator(iface);
692 LONG ref = InterlockedDecrement(&This->ref);
694 TRACE("(%p) ref=%d\n", This, ref);
696 if(!ref) {
697 if(This->plugins)
698 This->plugins->navigator = NULL;
699 if(This->mime_types)
700 This->mime_types->navigator = NULL;
701 release_dispex(&This->dispex);
702 heap_free(This);
705 return ref;
708 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
710 OmNavigator *This = impl_from_IOmNavigator(iface);
711 FIXME("(%p)->(%p)\n", This, pctinfo);
712 return E_NOTIMPL;
715 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
716 LCID lcid, ITypeInfo **ppTInfo)
718 OmNavigator *This = impl_from_IOmNavigator(iface);
720 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
723 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
724 LPOLESTR *rgszNames, UINT cNames,
725 LCID lcid, DISPID *rgDispId)
727 OmNavigator *This = impl_from_IOmNavigator(iface);
729 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
730 lcid, rgDispId);
733 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
734 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
735 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
737 OmNavigator *This = impl_from_IOmNavigator(iface);
739 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
740 pDispParams, pVarResult, pExcepInfo, puArgErr);
743 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
745 OmNavigator *This = impl_from_IOmNavigator(iface);
747 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
749 TRACE("(%p)->(%p)\n", This, p);
751 *p = SysAllocString(mozillaW);
752 return S_OK;
755 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
757 OmNavigator *This = impl_from_IOmNavigator(iface);
759 static const WCHAR app_nameW[] =
760 {'M','i','c','r','o','s','o','f','t',' ',
761 'I','n','t','e','r','n','e','t',' ',
762 'E','x','p','l','o','r','e','r',0};
764 TRACE("(%p)->(%p)\n", This, p);
766 *p = SysAllocString(app_nameW);
767 if(!*p)
768 return E_OUTOFMEMORY;
770 return S_OK;
773 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
775 OmNavigator *This = impl_from_IOmNavigator(iface);
777 char user_agent[512];
778 DWORD size;
779 HRESULT hres;
781 TRACE("(%p)->(%p)\n", This, p);
783 size = sizeof(user_agent);
784 hres = ObtainUserAgentString(0, user_agent, &size);
785 if(FAILED(hres))
786 return hres;
788 if(strncmp(user_agent, "Mozilla/", 8)) {
789 FIXME("Unsupported user agent\n");
790 return E_FAIL;
793 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
794 *p = SysAllocStringLen(NULL, size-1);
795 if(!*p)
796 return E_OUTOFMEMORY;
798 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
799 return S_OK;
802 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
804 OmNavigator *This = impl_from_IOmNavigator(iface);
805 char user_agent[512];
806 DWORD size;
807 HRESULT hres;
809 TRACE("(%p)->(%p)\n", This, p);
811 size = sizeof(user_agent);
812 hres = ObtainUserAgentString(0, user_agent, &size);
813 if(FAILED(hres))
814 return hres;
816 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
817 *p = SysAllocStringLen(NULL, size-1);
818 if(!*p)
819 return E_OUTOFMEMORY;
821 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
822 return S_OK;
825 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
827 OmNavigator *This = impl_from_IOmNavigator(iface);
829 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
831 *enabled = VARIANT_TRUE;
832 return S_OK;
835 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
837 OmNavigator *This = impl_from_IOmNavigator(iface);
838 FIXME("(%p)->(%p)\n", This, enabled);
839 return E_NOTIMPL;
842 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
844 OmNavigator *This = impl_from_IOmNavigator(iface);
846 TRACE("(%p)->(%p)\n", This, p);
848 if(!This->mime_types) {
849 HRESULT hres;
851 hres = create_mime_types_collection(This, &This->mime_types);
852 if(FAILED(hres))
853 return hres;
854 }else {
855 IHTMLMimeTypesCollection_AddRef(&This->mime_types->IHTMLMimeTypesCollection_iface);
858 *p = &This->mime_types->IHTMLMimeTypesCollection_iface;
859 return S_OK;
862 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
864 OmNavigator *This = impl_from_IOmNavigator(iface);
866 TRACE("(%p)->(%p)\n", This, p);
868 if(!This->plugins) {
869 HRESULT hres;
871 hres = create_plugins_collection(This, &This->plugins);
872 if(FAILED(hres))
873 return hres;
874 }else {
875 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
878 *p = &This->plugins->IHTMLPluginsCollection_iface;
879 return S_OK;
882 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
884 OmNavigator *This = impl_from_IOmNavigator(iface);
886 WARN("(%p)->(%p) semi-stub\n", This, p);
888 *p = VARIANT_TRUE;
889 return S_OK;
892 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
894 OmNavigator *This = impl_from_IOmNavigator(iface);
895 FIXME("(%p)->(%p)\n", This, p);
896 return E_NOTIMPL;
899 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
901 OmNavigator *This = impl_from_IOmNavigator(iface);
903 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
905 TRACE("(%p)->(%p)\n", This, String);
907 if(!String)
908 return E_INVALIDARG;
910 *String = SysAllocString(objectW);
911 return *String ? S_OK : E_OUTOFMEMORY;
914 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
916 OmNavigator *This = impl_from_IOmNavigator(iface);
918 static const WCHAR cpu_classW[] =
919 #ifdef _WIN64
920 {'x','6','4',0};
921 #else
922 {'x','8','6',0};
923 #endif
925 TRACE("(%p)->(%p)\n", This, p);
927 *p = SysAllocString(cpu_classW);
928 return *p ? S_OK : E_OUTOFMEMORY;
931 static HRESULT get_language_string(LCID lcid, BSTR *p)
933 BSTR ret;
934 int len;
936 len = LCIDToLocaleName(lcid, NULL, 0, 0);
937 if(!len) {
938 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
939 return E_FAIL;
942 ret = SysAllocStringLen(NULL, len-1);
943 if(!ret)
944 return E_OUTOFMEMORY;
946 len = LCIDToLocaleName(lcid, ret, len, 0);
947 if(!len) {
948 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
949 SysFreeString(ret);
950 return E_FAIL;
953 *p = ret;
954 return S_OK;
957 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
959 OmNavigator *This = impl_from_IOmNavigator(iface);
961 TRACE("(%p)->(%p)\n", This, p);
963 return get_language_string(LOCALE_SYSTEM_DEFAULT, p);
966 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
968 OmNavigator *This = impl_from_IOmNavigator(iface);
970 TRACE("(%p)->(%p)\n", This, p);
972 return get_language_string(GetUserDefaultUILanguage(), p);
975 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
977 OmNavigator *This = impl_from_IOmNavigator(iface);
979 TRACE("(%p)->(%p)\n", This, p);
981 return get_language_string(LOCALE_USER_DEFAULT, p);
984 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
986 OmNavigator *This = impl_from_IOmNavigator(iface);
988 #ifdef _WIN64
989 static const WCHAR platformW[] = {'W','i','n','6','4',0};
990 #else
991 static const WCHAR platformW[] = {'W','i','n','3','2',0};
992 #endif
994 TRACE("(%p)->(%p)\n", This, p);
996 *p = SysAllocString(platformW);
997 return S_OK;
1000 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
1002 OmNavigator *This = impl_from_IOmNavigator(iface);
1004 static const WCHAR zeroW[] = {'0',0};
1006 TRACE("(%p)->(%p)\n", This, p);
1008 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
1009 *p = SysAllocString(zeroW);
1010 return S_OK;
1013 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
1015 OmNavigator *This = impl_from_IOmNavigator(iface);
1016 FIXME("(%p)->(%p)\n", This, p);
1017 return E_NOTIMPL;
1020 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
1022 OmNavigator *This = impl_from_IOmNavigator(iface);
1024 WARN("(%p)->(%p) semi-stub, returning true\n", This, p);
1026 *p = VARIANT_TRUE;
1027 return S_OK;
1030 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
1032 OmNavigator *This = impl_from_IOmNavigator(iface);
1033 FIXME("(%p)->(%p)\n", This, p);
1034 return E_NOTIMPL;
1037 static const IOmNavigatorVtbl OmNavigatorVtbl = {
1038 OmNavigator_QueryInterface,
1039 OmNavigator_AddRef,
1040 OmNavigator_Release,
1041 OmNavigator_GetTypeInfoCount,
1042 OmNavigator_GetTypeInfo,
1043 OmNavigator_GetIDsOfNames,
1044 OmNavigator_Invoke,
1045 OmNavigator_get_appCodeName,
1046 OmNavigator_get_appName,
1047 OmNavigator_get_appVersion,
1048 OmNavigator_get_userAgent,
1049 OmNavigator_javaEnabled,
1050 OmNavigator_taintEnabled,
1051 OmNavigator_get_mimeTypes,
1052 OmNavigator_get_plugins,
1053 OmNavigator_get_cookieEnabled,
1054 OmNavigator_get_opsProfile,
1055 OmNavigator_toString,
1056 OmNavigator_get_cpuClass,
1057 OmNavigator_get_systemLanguage,
1058 OmNavigator_get_browserLanguage,
1059 OmNavigator_get_userLanguage,
1060 OmNavigator_get_platform,
1061 OmNavigator_get_appMinorVersion,
1062 OmNavigator_get_connectionSpeed,
1063 OmNavigator_get_onLine,
1064 OmNavigator_get_userProfile
1067 static const tid_t OmNavigator_iface_tids[] = {
1068 IOmNavigator_tid,
1071 static dispex_static_data_t OmNavigator_dispex = {
1072 NULL,
1073 DispHTMLNavigator_tid,
1074 OmNavigator_iface_tids
1077 IOmNavigator *OmNavigator_Create(void)
1079 OmNavigator *ret;
1081 ret = heap_alloc_zero(sizeof(*ret));
1082 if(!ret)
1083 return NULL;
1085 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
1086 ret->ref = 1;
1088 init_dispex(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex);
1090 return &ret->IOmNavigator_iface;