d3dx9: Improve the scoring for fallback formats.
[wine/multimedia.git] / dlls / mshtml / omnavigator.c
blob932d1c1c2e4944c80074792c18eb008cfca4fdf8
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 NULL,
168 HTMLDOMImplementation_iface_tids
171 HRESULT create_dom_implementation(IHTMLDOMImplementation **ret)
173 HTMLDOMImplementation *dom_implementation;
175 dom_implementation = heap_alloc_zero(sizeof(*dom_implementation));
176 if(!dom_implementation)
177 return E_OUTOFMEMORY;
179 dom_implementation->IHTMLDOMImplementation_iface.lpVtbl = &HTMLDOMImplementationVtbl;
180 dom_implementation->ref = 1;
182 init_dispex(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface,
183 &HTMLDOMImplementation_dispex);
185 *ret = &dom_implementation->IHTMLDOMImplementation_iface;
186 return S_OK;
189 static inline OmHistory *impl_from_IOmHistory(IOmHistory *iface)
191 return CONTAINING_RECORD(iface, OmHistory, IOmHistory_iface);
194 static HRESULT WINAPI OmHistory_QueryInterface(IOmHistory *iface, REFIID riid, void **ppv)
196 OmHistory *This = impl_from_IOmHistory(iface);
198 *ppv = NULL;
200 if(IsEqualGUID(&IID_IUnknown, riid)) {
201 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
202 *ppv = &This->IOmHistory_iface;
203 }else if(IsEqualGUID(&IID_IOmHistory, riid)) {
204 TRACE("(%p)->(IID_IOmHistory %p)\n", This, ppv);
205 *ppv = &This->IOmHistory_iface;
206 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
207 return *ppv ? S_OK : E_NOINTERFACE;
210 if(*ppv) {
211 IUnknown_AddRef((IUnknown*)*ppv);
212 return S_OK;
215 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
216 return E_NOINTERFACE;
219 static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface)
221 OmHistory *This = impl_from_IOmHistory(iface);
222 LONG ref = InterlockedIncrement(&This->ref);
224 TRACE("(%p) ref=%d\n", This, ref);
226 return ref;
229 static ULONG WINAPI OmHistory_Release(IOmHistory *iface)
231 OmHistory *This = impl_from_IOmHistory(iface);
232 LONG ref = InterlockedDecrement(&This->ref);
234 TRACE("(%p) ref=%d\n", This, ref);
236 if(!ref) {
237 release_dispex(&This->dispex);
238 heap_free(This);
241 return ref;
244 static HRESULT WINAPI OmHistory_GetTypeInfoCount(IOmHistory *iface, UINT *pctinfo)
246 OmHistory *This = impl_from_IOmHistory(iface);
247 FIXME("(%p)->(%p)\n", This, pctinfo);
248 return E_NOTIMPL;
251 static HRESULT WINAPI OmHistory_GetTypeInfo(IOmHistory *iface, UINT iTInfo,
252 LCID lcid, ITypeInfo **ppTInfo)
254 OmHistory *This = impl_from_IOmHistory(iface);
256 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
259 static HRESULT WINAPI OmHistory_GetIDsOfNames(IOmHistory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
260 LCID lcid, DISPID *rgDispId)
262 OmHistory *This = impl_from_IOmHistory(iface);
264 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
265 lcid, rgDispId);
268 static HRESULT WINAPI OmHistory_Invoke(IOmHistory *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
269 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
271 OmHistory *This = impl_from_IOmHistory(iface);
273 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
274 pDispParams, pVarResult, pExcepInfo, puArgErr);
277 static HRESULT WINAPI OmHistory_get_length(IOmHistory *iface, short *p)
279 OmHistory *This = impl_from_IOmHistory(iface);
281 TRACE("(%p)->(%p)\n", This, p);
283 if(!This->window || !This->window->base.outer_window->doc_obj
284 || !This->window->base.outer_window->doc_obj->travel_log) {
285 *p = 0;
286 }else {
287 *p = ITravelLog_CountEntries(This->window->base.outer_window->doc_obj->travel_log,
288 This->window->base.outer_window->doc_obj->browser_service);
290 return S_OK;
293 static HRESULT WINAPI OmHistory_back(IOmHistory *iface, VARIANT *pvargdistance)
295 OmHistory *This = impl_from_IOmHistory(iface);
296 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
297 return E_NOTIMPL;
300 static HRESULT WINAPI OmHistory_forward(IOmHistory *iface, VARIANT *pvargdistance)
302 OmHistory *This = impl_from_IOmHistory(iface);
303 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
304 return E_NOTIMPL;
307 static HRESULT WINAPI OmHistory_go(IOmHistory *iface, VARIANT *pvargdistance)
309 OmHistory *This = impl_from_IOmHistory(iface);
310 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
311 return E_NOTIMPL;
314 static const IOmHistoryVtbl OmHistoryVtbl = {
315 OmHistory_QueryInterface,
316 OmHistory_AddRef,
317 OmHistory_Release,
318 OmHistory_GetTypeInfoCount,
319 OmHistory_GetTypeInfo,
320 OmHistory_GetIDsOfNames,
321 OmHistory_Invoke,
322 OmHistory_get_length,
323 OmHistory_back,
324 OmHistory_forward,
325 OmHistory_go
328 static const tid_t OmHistory_iface_tids[] = {
329 IOmHistory_tid,
332 static dispex_static_data_t OmHistory_dispex = {
333 NULL,
334 DispHTMLHistory_tid,
335 NULL,
336 OmHistory_iface_tids
340 HRESULT create_history(HTMLInnerWindow *window, OmHistory **ret)
342 OmHistory *history;
344 history = heap_alloc_zero(sizeof(*history));
345 if(!history)
346 return E_OUTOFMEMORY;
348 init_dispex(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex);
349 history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl;
350 history->ref = 1;
352 history->window = window;
354 *ret = history;
355 return S_OK;
358 struct HTMLPluginsCollection {
359 DispatchEx dispex;
360 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
362 LONG ref;
364 OmNavigator *navigator;
367 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
369 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
372 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
374 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
376 if(IsEqualGUID(&IID_IUnknown, riid)) {
377 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
378 *ppv = &This->IHTMLPluginsCollection_iface;
379 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
380 TRACE("(%p)->(IID_IHTMLPluginCollection %p)\n", This, ppv);
381 *ppv = &This->IHTMLPluginsCollection_iface;
382 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
383 return *ppv ? S_OK : E_NOINTERFACE;
384 }else {
385 *ppv = NULL;
386 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
387 return E_NOINTERFACE;
390 IUnknown_AddRef((IUnknown*)*ppv);
391 return S_OK;
394 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
396 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
397 LONG ref = InterlockedIncrement(&This->ref);
399 TRACE("(%p) ref=%d\n", This, ref);
401 return ref;
404 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
406 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
407 LONG ref = InterlockedDecrement(&This->ref);
409 TRACE("(%p) ref=%d\n", This, ref);
411 if(!ref) {
412 if(This->navigator)
413 This->navigator->plugins = NULL;
414 release_dispex(&This->dispex);
415 heap_free(This);
418 return ref;
421 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
423 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
424 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
427 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
428 LCID lcid, ITypeInfo **ppTInfo)
430 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
431 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
434 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
435 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
437 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
438 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
439 lcid, rgDispId);
442 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
443 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
444 EXCEPINFO *pExcepInfo, UINT *puArgErr)
446 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
447 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
448 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
451 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
453 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
455 TRACE("(%p)->(%p)\n", This, p);
457 /* IE always returns 0 here */
458 *p = 0;
459 return S_OK;
462 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
464 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
465 FIXME("(%p)->(%x)\n", This, reload);
466 return E_NOTIMPL;
469 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
470 HTMLPluginsCollection_QueryInterface,
471 HTMLPluginsCollection_AddRef,
472 HTMLPluginsCollection_Release,
473 HTMLPluginsCollection_GetTypeInfoCount,
474 HTMLPluginsCollection_GetTypeInfo,
475 HTMLPluginsCollection_GetIDsOfNames,
476 HTMLPluginsCollection_Invoke,
477 HTMLPluginsCollection_get_length,
478 HTMLPluginsCollection_refresh
481 static const tid_t HTMLPluginsCollection_iface_tids[] = {
482 IHTMLPluginsCollection_tid,
485 static dispex_static_data_t HTMLPluginsCollection_dispex = {
486 NULL,
487 DispCPlugins_tid,
488 NULL,
489 HTMLPluginsCollection_iface_tids
492 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
494 HTMLPluginsCollection *col;
496 col = heap_alloc_zero(sizeof(*col));
497 if(!col)
498 return E_OUTOFMEMORY;
500 col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl;
501 col->ref = 1;
502 col->navigator = navigator;
504 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface,
505 &HTMLPluginsCollection_dispex);
507 *ret = col;
508 return S_OK;
511 struct HTMLMimeTypesCollection {
512 DispatchEx dispex;
513 IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface;
515 LONG ref;
517 OmNavigator *navigator;
520 static inline HTMLMimeTypesCollection *impl_from_IHTMLMimeTypesCollection(IHTMLMimeTypesCollection *iface)
522 return CONTAINING_RECORD(iface, HTMLMimeTypesCollection, IHTMLMimeTypesCollection_iface);
525 static HRESULT WINAPI HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesCollection *iface, REFIID riid, void **ppv)
527 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
529 if(IsEqualGUID(&IID_IUnknown, riid)) {
530 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
531 *ppv = &This->IHTMLMimeTypesCollection_iface;
532 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection, riid)) {
533 TRACE("(%p)->(IID_IHTMLMimeTypesCollection %p)\n", This, ppv);
534 *ppv = &This->IHTMLMimeTypesCollection_iface;
535 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
536 return *ppv ? S_OK : E_NOINTERFACE;
537 }else {
538 *ppv = NULL;
539 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
540 return E_NOINTERFACE;
543 IUnknown_AddRef((IUnknown*)*ppv);
544 return S_OK;
547 static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *iface)
549 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
550 LONG ref = InterlockedIncrement(&This->ref);
552 TRACE("(%p) ref=%d\n", This, ref);
554 return ref;
557 static ULONG WINAPI HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection *iface)
559 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
560 LONG ref = InterlockedDecrement(&This->ref);
562 TRACE("(%p) ref=%d\n", This, ref);
564 if(!ref) {
565 if(This->navigator)
566 This->navigator->mime_types = NULL;
567 release_dispex(&This->dispex);
568 heap_free(This);
571 return ref;
574 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfoCount(IHTMLMimeTypesCollection *iface, UINT *pctinfo)
576 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
577 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
580 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfo(IHTMLMimeTypesCollection *iface, UINT iTInfo,
581 LCID lcid, ITypeInfo **ppTInfo)
583 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
584 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
587 static HRESULT WINAPI HTMLMimeTypesCollection_GetIDsOfNames(IHTMLMimeTypesCollection *iface, REFIID riid,
588 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
590 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
591 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
592 lcid, rgDispId);
595 static HRESULT WINAPI HTMLMimeTypesCollection_Invoke(IHTMLMimeTypesCollection *iface, DISPID dispIdMember,
596 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
597 EXCEPINFO *pExcepInfo, UINT *puArgErr)
599 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
600 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
601 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
604 static HRESULT WINAPI HTMLMimeTypesCollection_get_length(IHTMLMimeTypesCollection *iface, LONG *p)
606 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
608 TRACE("(%p)->(%p)\n", This, p);
610 /* This is just a stub for compatibility with other browser in IE */
611 *p = 0;
612 return S_OK;
615 static const IHTMLMimeTypesCollectionVtbl HTMLMimeTypesCollectionVtbl = {
616 HTMLMimeTypesCollection_QueryInterface,
617 HTMLMimeTypesCollection_AddRef,
618 HTMLMimeTypesCollection_Release,
619 HTMLMimeTypesCollection_GetTypeInfoCount,
620 HTMLMimeTypesCollection_GetTypeInfo,
621 HTMLMimeTypesCollection_GetIDsOfNames,
622 HTMLMimeTypesCollection_Invoke,
623 HTMLMimeTypesCollection_get_length
626 static const tid_t HTMLMimeTypesCollection_iface_tids[] = {
627 IHTMLMimeTypesCollection_tid,
630 static dispex_static_data_t HTMLMimeTypesCollection_dispex = {
631 NULL,
632 IHTMLMimeTypesCollection_tid,
633 NULL,
634 HTMLMimeTypesCollection_iface_tids
637 static HRESULT create_mime_types_collection(OmNavigator *navigator, HTMLMimeTypesCollection **ret)
639 HTMLMimeTypesCollection *col;
641 col = heap_alloc_zero(sizeof(*col));
642 if(!col)
643 return E_OUTOFMEMORY;
645 col->IHTMLMimeTypesCollection_iface.lpVtbl = &HTMLMimeTypesCollectionVtbl;
646 col->ref = 1;
647 col->navigator = navigator;
649 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLMimeTypesCollection_iface,
650 &HTMLMimeTypesCollection_dispex);
652 *ret = col;
653 return S_OK;
656 static inline OmNavigator *impl_from_IOmNavigator(IOmNavigator *iface)
658 return CONTAINING_RECORD(iface, OmNavigator, IOmNavigator_iface);
661 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
663 OmNavigator *This = impl_from_IOmNavigator(iface);
665 *ppv = NULL;
667 if(IsEqualGUID(&IID_IUnknown, riid)) {
668 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
669 *ppv = &This->IOmNavigator_iface;
670 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
671 TRACE("(%p)->(IID_IOmNavigator %p)\n", This, ppv);
672 *ppv = &This->IOmNavigator_iface;
673 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
674 return *ppv ? S_OK : E_NOINTERFACE;
677 if(*ppv) {
678 IUnknown_AddRef((IUnknown*)*ppv);
679 return S_OK;
682 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
683 return E_NOINTERFACE;
686 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
688 OmNavigator *This = impl_from_IOmNavigator(iface);
689 LONG ref = InterlockedIncrement(&This->ref);
691 TRACE("(%p) ref=%d\n", This, ref);
693 return ref;
696 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
698 OmNavigator *This = impl_from_IOmNavigator(iface);
699 LONG ref = InterlockedDecrement(&This->ref);
701 TRACE("(%p) ref=%d\n", This, ref);
703 if(!ref) {
704 if(This->plugins)
705 This->plugins->navigator = NULL;
706 if(This->mime_types)
707 This->mime_types->navigator = NULL;
708 release_dispex(&This->dispex);
709 heap_free(This);
712 return ref;
715 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
717 OmNavigator *This = impl_from_IOmNavigator(iface);
718 FIXME("(%p)->(%p)\n", This, pctinfo);
719 return E_NOTIMPL;
722 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
723 LCID lcid, ITypeInfo **ppTInfo)
725 OmNavigator *This = impl_from_IOmNavigator(iface);
727 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
730 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
731 LPOLESTR *rgszNames, UINT cNames,
732 LCID lcid, DISPID *rgDispId)
734 OmNavigator *This = impl_from_IOmNavigator(iface);
736 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
737 lcid, rgDispId);
740 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
741 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
742 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
744 OmNavigator *This = impl_from_IOmNavigator(iface);
746 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
747 pDispParams, pVarResult, pExcepInfo, puArgErr);
750 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
752 OmNavigator *This = impl_from_IOmNavigator(iface);
754 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
756 TRACE("(%p)->(%p)\n", This, p);
758 *p = SysAllocString(mozillaW);
759 return S_OK;
762 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
764 OmNavigator *This = impl_from_IOmNavigator(iface);
766 static const WCHAR app_nameW[] =
767 {'M','i','c','r','o','s','o','f','t',' ',
768 'I','n','t','e','r','n','e','t',' ',
769 'E','x','p','l','o','r','e','r',0};
771 TRACE("(%p)->(%p)\n", This, p);
773 *p = SysAllocString(app_nameW);
774 if(!*p)
775 return E_OUTOFMEMORY;
777 return S_OK;
780 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
782 OmNavigator *This = impl_from_IOmNavigator(iface);
784 char user_agent[512];
785 DWORD size;
786 HRESULT hres;
788 TRACE("(%p)->(%p)\n", This, p);
790 size = sizeof(user_agent);
791 hres = ObtainUserAgentString(0, user_agent, &size);
792 if(FAILED(hres))
793 return hres;
795 if(strncmp(user_agent, "Mozilla/", 8)) {
796 FIXME("Unsupported user agent\n");
797 return E_FAIL;
800 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
801 *p = SysAllocStringLen(NULL, size-1);
802 if(!*p)
803 return E_OUTOFMEMORY;
805 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
806 return S_OK;
809 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
811 OmNavigator *This = impl_from_IOmNavigator(iface);
812 char user_agent[512];
813 DWORD size;
814 HRESULT hres;
816 TRACE("(%p)->(%p)\n", This, p);
818 size = sizeof(user_agent);
819 hres = ObtainUserAgentString(0, user_agent, &size);
820 if(FAILED(hres))
821 return hres;
823 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
824 *p = SysAllocStringLen(NULL, size-1);
825 if(!*p)
826 return E_OUTOFMEMORY;
828 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
829 return S_OK;
832 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
834 OmNavigator *This = impl_from_IOmNavigator(iface);
836 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
838 *enabled = VARIANT_TRUE;
839 return S_OK;
842 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
844 OmNavigator *This = impl_from_IOmNavigator(iface);
845 FIXME("(%p)->(%p)\n", This, enabled);
846 return E_NOTIMPL;
849 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
851 OmNavigator *This = impl_from_IOmNavigator(iface);
853 TRACE("(%p)->(%p)\n", This, p);
855 if(!This->mime_types) {
856 HRESULT hres;
858 hres = create_mime_types_collection(This, &This->mime_types);
859 if(FAILED(hres))
860 return hres;
861 }else {
862 IHTMLMimeTypesCollection_AddRef(&This->mime_types->IHTMLMimeTypesCollection_iface);
865 *p = &This->mime_types->IHTMLMimeTypesCollection_iface;
866 return S_OK;
869 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
871 OmNavigator *This = impl_from_IOmNavigator(iface);
873 TRACE("(%p)->(%p)\n", This, p);
875 if(!This->plugins) {
876 HRESULT hres;
878 hres = create_plugins_collection(This, &This->plugins);
879 if(FAILED(hres))
880 return hres;
881 }else {
882 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
885 *p = &This->plugins->IHTMLPluginsCollection_iface;
886 return S_OK;
889 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
891 OmNavigator *This = impl_from_IOmNavigator(iface);
893 WARN("(%p)->(%p) semi-stub\n", This, p);
895 *p = VARIANT_TRUE;
896 return S_OK;
899 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
901 OmNavigator *This = impl_from_IOmNavigator(iface);
902 FIXME("(%p)->(%p)\n", This, p);
903 return E_NOTIMPL;
906 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
908 OmNavigator *This = impl_from_IOmNavigator(iface);
910 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
912 TRACE("(%p)->(%p)\n", This, String);
914 if(!String)
915 return E_INVALIDARG;
917 *String = SysAllocString(objectW);
918 return *String ? S_OK : E_OUTOFMEMORY;
921 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
923 OmNavigator *This = impl_from_IOmNavigator(iface);
925 static const WCHAR cpu_classW[] =
926 #ifdef _WIN64
927 {'x','6','4',0};
928 #else
929 {'x','8','6',0};
930 #endif
932 TRACE("(%p)->(%p)\n", This, p);
934 *p = SysAllocString(cpu_classW);
935 return *p ? S_OK : E_OUTOFMEMORY;
938 static HRESULT get_language_string(LCID lcid, BSTR *p)
940 BSTR ret;
941 int len;
943 len = LCIDToLocaleName(lcid, NULL, 0, 0);
944 if(!len) {
945 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
946 return E_FAIL;
949 ret = SysAllocStringLen(NULL, len-1);
950 if(!ret)
951 return E_OUTOFMEMORY;
953 len = LCIDToLocaleName(lcid, ret, len, 0);
954 if(!len) {
955 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
956 SysFreeString(ret);
957 return E_FAIL;
960 *p = ret;
961 return S_OK;
964 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
966 OmNavigator *This = impl_from_IOmNavigator(iface);
968 TRACE("(%p)->(%p)\n", This, p);
970 return get_language_string(LOCALE_SYSTEM_DEFAULT, p);
973 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
975 OmNavigator *This = impl_from_IOmNavigator(iface);
977 TRACE("(%p)->(%p)\n", This, p);
979 return get_language_string(GetUserDefaultUILanguage(), p);
982 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
984 OmNavigator *This = impl_from_IOmNavigator(iface);
986 TRACE("(%p)->(%p)\n", This, p);
988 return get_language_string(LOCALE_USER_DEFAULT, p);
991 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
993 OmNavigator *This = impl_from_IOmNavigator(iface);
995 #ifdef _WIN64
996 static const WCHAR platformW[] = {'W','i','n','6','4',0};
997 #else
998 static const WCHAR platformW[] = {'W','i','n','3','2',0};
999 #endif
1001 TRACE("(%p)->(%p)\n", This, p);
1003 *p = SysAllocString(platformW);
1004 return S_OK;
1007 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
1009 OmNavigator *This = impl_from_IOmNavigator(iface);
1011 static const WCHAR zeroW[] = {'0',0};
1013 TRACE("(%p)->(%p)\n", This, p);
1015 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
1016 *p = SysAllocString(zeroW);
1017 return S_OK;
1020 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
1022 OmNavigator *This = impl_from_IOmNavigator(iface);
1023 FIXME("(%p)->(%p)\n", This, p);
1024 return E_NOTIMPL;
1027 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
1029 OmNavigator *This = impl_from_IOmNavigator(iface);
1031 WARN("(%p)->(%p) semi-stub, returning true\n", This, p);
1033 *p = VARIANT_TRUE;
1034 return S_OK;
1037 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
1039 OmNavigator *This = impl_from_IOmNavigator(iface);
1040 FIXME("(%p)->(%p)\n", This, p);
1041 return E_NOTIMPL;
1044 static const IOmNavigatorVtbl OmNavigatorVtbl = {
1045 OmNavigator_QueryInterface,
1046 OmNavigator_AddRef,
1047 OmNavigator_Release,
1048 OmNavigator_GetTypeInfoCount,
1049 OmNavigator_GetTypeInfo,
1050 OmNavigator_GetIDsOfNames,
1051 OmNavigator_Invoke,
1052 OmNavigator_get_appCodeName,
1053 OmNavigator_get_appName,
1054 OmNavigator_get_appVersion,
1055 OmNavigator_get_userAgent,
1056 OmNavigator_javaEnabled,
1057 OmNavigator_taintEnabled,
1058 OmNavigator_get_mimeTypes,
1059 OmNavigator_get_plugins,
1060 OmNavigator_get_cookieEnabled,
1061 OmNavigator_get_opsProfile,
1062 OmNavigator_toString,
1063 OmNavigator_get_cpuClass,
1064 OmNavigator_get_systemLanguage,
1065 OmNavigator_get_browserLanguage,
1066 OmNavigator_get_userLanguage,
1067 OmNavigator_get_platform,
1068 OmNavigator_get_appMinorVersion,
1069 OmNavigator_get_connectionSpeed,
1070 OmNavigator_get_onLine,
1071 OmNavigator_get_userProfile
1074 static const tid_t OmNavigator_iface_tids[] = {
1075 IOmNavigator_tid,
1078 static dispex_static_data_t OmNavigator_dispex = {
1079 NULL,
1080 DispHTMLNavigator_tid,
1081 NULL,
1082 OmNavigator_iface_tids
1085 IOmNavigator *OmNavigator_Create(void)
1087 OmNavigator *ret;
1089 ret = heap_alloc_zero(sizeof(*ret));
1090 if(!ret)
1091 return NULL;
1093 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
1094 ret->ref = 1;
1096 init_dispex(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex);
1098 return &ret->IOmNavigator_iface;