msvcirt: Add implementation of streambuf::unbuffered.
[wine.git] / dlls / mshtml / omnavigator.c
blobc70fac675a1680525840faa424c1d7ca57054390
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 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
200 if(IsEqualGUID(&IID_IUnknown, riid)) {
201 *ppv = &This->IOmHistory_iface;
202 }else if(IsEqualGUID(&IID_IOmHistory, riid)) {
203 *ppv = &This->IOmHistory_iface;
204 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
205 return *ppv ? S_OK : E_NOINTERFACE;
206 }else {
207 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
208 *ppv = NULL;
209 return E_NOINTERFACE;
212 IUnknown_AddRef((IUnknown*)*ppv);
213 return S_OK;
216 static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface)
218 OmHistory *This = impl_from_IOmHistory(iface);
219 LONG ref = InterlockedIncrement(&This->ref);
221 TRACE("(%p) ref=%d\n", This, ref);
223 return ref;
226 static ULONG WINAPI OmHistory_Release(IOmHistory *iface)
228 OmHistory *This = impl_from_IOmHistory(iface);
229 LONG ref = InterlockedDecrement(&This->ref);
231 TRACE("(%p) ref=%d\n", This, ref);
233 if(!ref) {
234 release_dispex(&This->dispex);
235 heap_free(This);
238 return ref;
241 static HRESULT WINAPI OmHistory_GetTypeInfoCount(IOmHistory *iface, UINT *pctinfo)
243 OmHistory *This = impl_from_IOmHistory(iface);
244 FIXME("(%p)->(%p)\n", This, pctinfo);
245 return E_NOTIMPL;
248 static HRESULT WINAPI OmHistory_GetTypeInfo(IOmHistory *iface, UINT iTInfo,
249 LCID lcid, ITypeInfo **ppTInfo)
251 OmHistory *This = impl_from_IOmHistory(iface);
253 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
256 static HRESULT WINAPI OmHistory_GetIDsOfNames(IOmHistory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
257 LCID lcid, DISPID *rgDispId)
259 OmHistory *This = impl_from_IOmHistory(iface);
261 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
262 lcid, rgDispId);
265 static HRESULT WINAPI OmHistory_Invoke(IOmHistory *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
266 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
268 OmHistory *This = impl_from_IOmHistory(iface);
270 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
271 pDispParams, pVarResult, pExcepInfo, puArgErr);
274 static HRESULT WINAPI OmHistory_get_length(IOmHistory *iface, short *p)
276 OmHistory *This = impl_from_IOmHistory(iface);
278 TRACE("(%p)->(%p)\n", This, p);
280 if(!This->window || !This->window->base.outer_window->doc_obj
281 || !This->window->base.outer_window->doc_obj->travel_log) {
282 *p = 0;
283 }else {
284 *p = ITravelLog_CountEntries(This->window->base.outer_window->doc_obj->travel_log,
285 This->window->base.outer_window->doc_obj->browser_service);
287 return S_OK;
290 static HRESULT WINAPI OmHistory_back(IOmHistory *iface, VARIANT *pvargdistance)
292 OmHistory *This = impl_from_IOmHistory(iface);
293 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
294 return E_NOTIMPL;
297 static HRESULT WINAPI OmHistory_forward(IOmHistory *iface, VARIANT *pvargdistance)
299 OmHistory *This = impl_from_IOmHistory(iface);
300 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
301 return E_NOTIMPL;
304 static HRESULT WINAPI OmHistory_go(IOmHistory *iface, VARIANT *pvargdistance)
306 OmHistory *This = impl_from_IOmHistory(iface);
307 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
308 return E_NOTIMPL;
311 static const IOmHistoryVtbl OmHistoryVtbl = {
312 OmHistory_QueryInterface,
313 OmHistory_AddRef,
314 OmHistory_Release,
315 OmHistory_GetTypeInfoCount,
316 OmHistory_GetTypeInfo,
317 OmHistory_GetIDsOfNames,
318 OmHistory_Invoke,
319 OmHistory_get_length,
320 OmHistory_back,
321 OmHistory_forward,
322 OmHistory_go
325 static const tid_t OmHistory_iface_tids[] = {
326 IOmHistory_tid,
329 static dispex_static_data_t OmHistory_dispex = {
330 NULL,
331 DispHTMLHistory_tid,
332 NULL,
333 OmHistory_iface_tids
337 HRESULT create_history(HTMLInnerWindow *window, OmHistory **ret)
339 OmHistory *history;
341 history = heap_alloc_zero(sizeof(*history));
342 if(!history)
343 return E_OUTOFMEMORY;
345 init_dispex(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex);
346 history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl;
347 history->ref = 1;
349 history->window = window;
351 *ret = history;
352 return S_OK;
355 struct HTMLPluginsCollection {
356 DispatchEx dispex;
357 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
359 LONG ref;
361 OmNavigator *navigator;
364 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
366 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
369 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
371 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
373 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
375 if(IsEqualGUID(&IID_IUnknown, riid)) {
376 *ppv = &This->IHTMLPluginsCollection_iface;
377 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
378 *ppv = &This->IHTMLPluginsCollection_iface;
379 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
380 return *ppv ? S_OK : E_NOINTERFACE;
381 }else {
382 *ppv = NULL;
383 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
384 return E_NOINTERFACE;
387 IUnknown_AddRef((IUnknown*)*ppv);
388 return S_OK;
391 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
393 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
394 LONG ref = InterlockedIncrement(&This->ref);
396 TRACE("(%p) ref=%d\n", This, ref);
398 return ref;
401 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
403 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
404 LONG ref = InterlockedDecrement(&This->ref);
406 TRACE("(%p) ref=%d\n", This, ref);
408 if(!ref) {
409 if(This->navigator)
410 This->navigator->plugins = NULL;
411 release_dispex(&This->dispex);
412 heap_free(This);
415 return ref;
418 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
420 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
421 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
424 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
425 LCID lcid, ITypeInfo **ppTInfo)
427 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
428 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
431 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
432 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
434 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
435 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
436 lcid, rgDispId);
439 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
440 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
441 EXCEPINFO *pExcepInfo, UINT *puArgErr)
443 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
444 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
445 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
448 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
450 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
452 TRACE("(%p)->(%p)\n", This, p);
454 /* IE always returns 0 here */
455 *p = 0;
456 return S_OK;
459 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
461 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
463 TRACE("(%p)->(%x)\n", This, reload);
465 /* Nothing to do here. */
466 return S_OK;
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 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
531 if(IsEqualGUID(&IID_IUnknown, riid)) {
532 *ppv = &This->IHTMLMimeTypesCollection_iface;
533 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection, riid)) {
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 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
539 *ppv = NULL;
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 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
667 if(IsEqualGUID(&IID_IUnknown, riid)) {
668 *ppv = &This->IOmNavigator_iface;
669 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
670 *ppv = &This->IOmNavigator_iface;
671 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
672 return *ppv ? S_OK : E_NOINTERFACE;
673 }else {
674 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
675 *ppv = NULL;
676 return E_NOINTERFACE;
679 IUnknown_AddRef((IUnknown*)*ppv);
680 return S_OK;
683 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
685 OmNavigator *This = impl_from_IOmNavigator(iface);
686 LONG ref = InterlockedIncrement(&This->ref);
688 TRACE("(%p) ref=%d\n", This, ref);
690 return ref;
693 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
695 OmNavigator *This = impl_from_IOmNavigator(iface);
696 LONG ref = InterlockedDecrement(&This->ref);
698 TRACE("(%p) ref=%d\n", This, ref);
700 if(!ref) {
701 if(This->plugins)
702 This->plugins->navigator = NULL;
703 if(This->mime_types)
704 This->mime_types->navigator = NULL;
705 release_dispex(&This->dispex);
706 heap_free(This);
709 return ref;
712 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
714 OmNavigator *This = impl_from_IOmNavigator(iface);
715 FIXME("(%p)->(%p)\n", This, pctinfo);
716 return E_NOTIMPL;
719 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
720 LCID lcid, ITypeInfo **ppTInfo)
722 OmNavigator *This = impl_from_IOmNavigator(iface);
724 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
727 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
728 LPOLESTR *rgszNames, UINT cNames,
729 LCID lcid, DISPID *rgDispId)
731 OmNavigator *This = impl_from_IOmNavigator(iface);
733 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
734 lcid, rgDispId);
737 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
738 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
739 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
741 OmNavigator *This = impl_from_IOmNavigator(iface);
743 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
744 pDispParams, pVarResult, pExcepInfo, puArgErr);
747 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
749 OmNavigator *This = impl_from_IOmNavigator(iface);
751 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
753 TRACE("(%p)->(%p)\n", This, p);
755 *p = SysAllocString(mozillaW);
756 return S_OK;
759 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
761 OmNavigator *This = impl_from_IOmNavigator(iface);
763 static const WCHAR app_nameW[] =
764 {'M','i','c','r','o','s','o','f','t',' ',
765 'I','n','t','e','r','n','e','t',' ',
766 'E','x','p','l','o','r','e','r',0};
768 TRACE("(%p)->(%p)\n", This, p);
770 *p = SysAllocString(app_nameW);
771 if(!*p)
772 return E_OUTOFMEMORY;
774 return S_OK;
777 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
779 OmNavigator *This = impl_from_IOmNavigator(iface);
781 char user_agent[512];
782 DWORD size;
783 HRESULT hres;
785 TRACE("(%p)->(%p)\n", This, p);
787 size = sizeof(user_agent);
788 hres = ObtainUserAgentString(0, user_agent, &size);
789 if(FAILED(hres))
790 return hres;
792 if(strncmp(user_agent, "Mozilla/", 8)) {
793 FIXME("Unsupported user agent\n");
794 return E_FAIL;
797 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
798 *p = SysAllocStringLen(NULL, size-1);
799 if(!*p)
800 return E_OUTOFMEMORY;
802 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
803 return S_OK;
806 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
808 OmNavigator *This = impl_from_IOmNavigator(iface);
809 char user_agent[512];
810 DWORD size;
811 HRESULT hres;
813 TRACE("(%p)->(%p)\n", This, p);
815 size = sizeof(user_agent);
816 hres = ObtainUserAgentString(0, user_agent, &size);
817 if(FAILED(hres))
818 return hres;
820 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
821 *p = SysAllocStringLen(NULL, size-1);
822 if(!*p)
823 return E_OUTOFMEMORY;
825 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
826 return S_OK;
829 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
831 OmNavigator *This = impl_from_IOmNavigator(iface);
833 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
835 *enabled = VARIANT_TRUE;
836 return S_OK;
839 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
841 OmNavigator *This = impl_from_IOmNavigator(iface);
842 FIXME("(%p)->(%p)\n", This, enabled);
843 return E_NOTIMPL;
846 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
848 OmNavigator *This = impl_from_IOmNavigator(iface);
850 TRACE("(%p)->(%p)\n", This, p);
852 if(!This->mime_types) {
853 HRESULT hres;
855 hres = create_mime_types_collection(This, &This->mime_types);
856 if(FAILED(hres))
857 return hres;
858 }else {
859 IHTMLMimeTypesCollection_AddRef(&This->mime_types->IHTMLMimeTypesCollection_iface);
862 *p = &This->mime_types->IHTMLMimeTypesCollection_iface;
863 return S_OK;
866 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
868 OmNavigator *This = impl_from_IOmNavigator(iface);
870 TRACE("(%p)->(%p)\n", This, p);
872 if(!This->plugins) {
873 HRESULT hres;
875 hres = create_plugins_collection(This, &This->plugins);
876 if(FAILED(hres))
877 return hres;
878 }else {
879 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
882 *p = &This->plugins->IHTMLPluginsCollection_iface;
883 return S_OK;
886 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
888 OmNavigator *This = impl_from_IOmNavigator(iface);
890 WARN("(%p)->(%p) semi-stub\n", This, p);
892 *p = VARIANT_TRUE;
893 return S_OK;
896 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
898 OmNavigator *This = impl_from_IOmNavigator(iface);
899 FIXME("(%p)->(%p)\n", This, p);
900 return E_NOTIMPL;
903 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
905 OmNavigator *This = impl_from_IOmNavigator(iface);
907 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
909 TRACE("(%p)->(%p)\n", This, String);
911 if(!String)
912 return E_INVALIDARG;
914 *String = SysAllocString(objectW);
915 return *String ? S_OK : E_OUTOFMEMORY;
918 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
920 OmNavigator *This = impl_from_IOmNavigator(iface);
922 static const WCHAR cpu_classW[] =
923 #ifdef _WIN64
924 {'x','6','4',0};
925 #else
926 {'x','8','6',0};
927 #endif
929 TRACE("(%p)->(%p)\n", This, p);
931 *p = SysAllocString(cpu_classW);
932 return *p ? S_OK : E_OUTOFMEMORY;
935 static HRESULT get_language_string(LCID lcid, BSTR *p)
937 BSTR ret;
938 int len;
940 len = LCIDToLocaleName(lcid, NULL, 0, 0);
941 if(!len) {
942 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
943 return E_FAIL;
946 ret = SysAllocStringLen(NULL, len-1);
947 if(!ret)
948 return E_OUTOFMEMORY;
950 len = LCIDToLocaleName(lcid, ret, len, 0);
951 if(!len) {
952 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
953 SysFreeString(ret);
954 return E_FAIL;
957 *p = ret;
958 return S_OK;
961 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
963 OmNavigator *This = impl_from_IOmNavigator(iface);
965 TRACE("(%p)->(%p)\n", This, p);
967 return get_language_string(LOCALE_SYSTEM_DEFAULT, p);
970 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
972 OmNavigator *This = impl_from_IOmNavigator(iface);
974 TRACE("(%p)->(%p)\n", This, p);
976 return get_language_string(GetUserDefaultUILanguage(), p);
979 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
981 OmNavigator *This = impl_from_IOmNavigator(iface);
983 TRACE("(%p)->(%p)\n", This, p);
985 return get_language_string(LOCALE_USER_DEFAULT, p);
988 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
990 OmNavigator *This = impl_from_IOmNavigator(iface);
992 #ifdef _WIN64
993 static const WCHAR platformW[] = {'W','i','n','6','4',0};
994 #else
995 static const WCHAR platformW[] = {'W','i','n','3','2',0};
996 #endif
998 TRACE("(%p)->(%p)\n", This, p);
1000 *p = SysAllocString(platformW);
1001 return S_OK;
1004 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
1006 OmNavigator *This = impl_from_IOmNavigator(iface);
1008 static const WCHAR zeroW[] = {'0',0};
1010 TRACE("(%p)->(%p)\n", This, p);
1012 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
1013 *p = SysAllocString(zeroW);
1014 return S_OK;
1017 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
1019 OmNavigator *This = impl_from_IOmNavigator(iface);
1020 FIXME("(%p)->(%p)\n", This, p);
1021 return E_NOTIMPL;
1024 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
1026 OmNavigator *This = impl_from_IOmNavigator(iface);
1028 WARN("(%p)->(%p) semi-stub, returning true\n", This, p);
1030 *p = VARIANT_TRUE;
1031 return S_OK;
1034 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
1036 OmNavigator *This = impl_from_IOmNavigator(iface);
1037 FIXME("(%p)->(%p)\n", This, p);
1038 return E_NOTIMPL;
1041 static const IOmNavigatorVtbl OmNavigatorVtbl = {
1042 OmNavigator_QueryInterface,
1043 OmNavigator_AddRef,
1044 OmNavigator_Release,
1045 OmNavigator_GetTypeInfoCount,
1046 OmNavigator_GetTypeInfo,
1047 OmNavigator_GetIDsOfNames,
1048 OmNavigator_Invoke,
1049 OmNavigator_get_appCodeName,
1050 OmNavigator_get_appName,
1051 OmNavigator_get_appVersion,
1052 OmNavigator_get_userAgent,
1053 OmNavigator_javaEnabled,
1054 OmNavigator_taintEnabled,
1055 OmNavigator_get_mimeTypes,
1056 OmNavigator_get_plugins,
1057 OmNavigator_get_cookieEnabled,
1058 OmNavigator_get_opsProfile,
1059 OmNavigator_toString,
1060 OmNavigator_get_cpuClass,
1061 OmNavigator_get_systemLanguage,
1062 OmNavigator_get_browserLanguage,
1063 OmNavigator_get_userLanguage,
1064 OmNavigator_get_platform,
1065 OmNavigator_get_appMinorVersion,
1066 OmNavigator_get_connectionSpeed,
1067 OmNavigator_get_onLine,
1068 OmNavigator_get_userProfile
1071 static const tid_t OmNavigator_iface_tids[] = {
1072 IOmNavigator_tid,
1075 static dispex_static_data_t OmNavigator_dispex = {
1076 NULL,
1077 DispHTMLNavigator_tid,
1078 NULL,
1079 OmNavigator_iface_tids
1082 IOmNavigator *OmNavigator_Create(void)
1084 OmNavigator *ret;
1086 ret = heap_alloc_zero(sizeof(*ret));
1087 if(!ret)
1088 return NULL;
1090 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
1091 ret->ref = 1;
1093 init_dispex(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex);
1095 return &ret->IOmNavigator_iface;