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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct HTMLPluginsCollection HTMLPluginsCollection;
38 IOmNavigator IOmNavigator_iface;
42 HTMLPluginsCollection *plugins;
45 static inline OmNavigator *impl_from_IOmNavigator(IOmNavigator *iface)
47 return CONTAINING_RECORD(iface, OmNavigator, IOmNavigator_iface);
50 struct HTMLPluginsCollection {
52 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
56 OmNavigator *navigator;
59 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
61 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
64 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
66 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
68 if(IsEqualGUID(&IID_IUnknown, riid)) {
69 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
70 *ppv = &This->IHTMLPluginsCollection_iface;
71 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
72 TRACE("(%p)->(IID_IHTMLPluginCollection %p)\n", This, ppv);
73 *ppv = &This->IHTMLPluginsCollection_iface;
74 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
75 return *ppv ? S_OK : E_NOINTERFACE;
78 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
82 IUnknown_AddRef((IUnknown*)*ppv);
86 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
88 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
89 LONG ref = InterlockedIncrement(&This->ref);
91 TRACE("(%p) ref=%d\n", This, ref);
96 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
98 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
99 LONG ref = InterlockedDecrement(&This->ref);
101 TRACE("(%p) ref=%d\n", This, ref);
105 This->navigator->plugins = NULL;
106 release_dispex(&This->dispex);
113 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
115 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
116 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
119 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
120 LCID lcid, ITypeInfo **ppTInfo)
122 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
123 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
126 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
127 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
129 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
130 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
134 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
135 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
136 EXCEPINFO *pExcepInfo, UINT *puArgErr)
138 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
139 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
140 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
143 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
145 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
146 FIXME("(%p)->(%p)\n", This, p);
150 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
152 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
153 FIXME("(%p)->(%x)\n", This, reload);
157 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
158 HTMLPluginsCollection_QueryInterface,
159 HTMLPluginsCollection_AddRef,
160 HTMLPluginsCollection_Release,
161 HTMLPluginsCollection_GetTypeInfoCount,
162 HTMLPluginsCollection_GetTypeInfo,
163 HTMLPluginsCollection_GetIDsOfNames,
164 HTMLPluginsCollection_Invoke,
165 HTMLPluginsCollection_get_length,
166 HTMLPluginsCollection_refresh
169 static const tid_t HTMLPluginsCollection_iface_tids[] = {
170 IHTMLPluginsCollection_tid,
173 static dispex_static_data_t HTMLPluginsCollection_dispex = {
177 HTMLPluginsCollection_iface_tids
180 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
182 HTMLPluginsCollection *col;
184 col = heap_alloc_zero(sizeof(*col));
186 return E_OUTOFMEMORY;
188 col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl;
190 col->navigator = navigator;
192 init_dispex(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface,
193 &HTMLPluginsCollection_dispex);
199 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
201 OmNavigator *This = impl_from_IOmNavigator(iface);
205 if(IsEqualGUID(&IID_IUnknown, riid)) {
206 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
207 *ppv = &This->IOmNavigator_iface;
208 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
209 TRACE("(%p)->(IID_IOmNavigator %p)\n", This, ppv);
210 *ppv = &This->IOmNavigator_iface;
211 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
212 return *ppv ? S_OK : E_NOINTERFACE;
216 IUnknown_AddRef((IUnknown*)*ppv);
220 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
221 return E_NOINTERFACE;
224 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
226 OmNavigator *This = impl_from_IOmNavigator(iface);
227 LONG ref = InterlockedIncrement(&This->ref);
229 TRACE("(%p) ref=%d\n", This, ref);
234 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
236 OmNavigator *This = impl_from_IOmNavigator(iface);
237 LONG ref = InterlockedDecrement(&This->ref);
239 TRACE("(%p) ref=%d\n", This, ref);
243 This->plugins->navigator = NULL;
244 IHTMLPluginsCollection_Release(&This->plugins->IHTMLPluginsCollection_iface);
246 release_dispex(&This->dispex);
253 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
255 OmNavigator *This = impl_from_IOmNavigator(iface);
256 FIXME("(%p)->(%p)\n", This, pctinfo);
260 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
261 LCID lcid, ITypeInfo **ppTInfo)
263 OmNavigator *This = impl_from_IOmNavigator(iface);
265 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
268 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
269 LPOLESTR *rgszNames, UINT cNames,
270 LCID lcid, DISPID *rgDispId)
272 OmNavigator *This = impl_from_IOmNavigator(iface);
274 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
278 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
279 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
280 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
282 OmNavigator *This = impl_from_IOmNavigator(iface);
284 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
285 pDispParams, pVarResult, pExcepInfo, puArgErr);
288 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
290 OmNavigator *This = impl_from_IOmNavigator(iface);
292 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
294 TRACE("(%p)->(%p)\n", This, p);
296 *p = SysAllocString(mozillaW);
300 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
302 OmNavigator *This = impl_from_IOmNavigator(iface);
304 static const WCHAR app_nameW[] =
305 {'M','i','c','r','o','s','o','f','t',' ',
306 'I','n','t','e','r','n','e','t',' ',
307 'E','x','p','l','o','r','e','r',0};
309 TRACE("(%p)->(%p)\n", This, p);
311 *p = SysAllocString(app_nameW);
313 return E_OUTOFMEMORY;
318 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
320 OmNavigator *This = impl_from_IOmNavigator(iface);
322 char user_agent[512];
326 TRACE("(%p)->(%p)\n", This, p);
328 size = sizeof(user_agent);
329 hres = ObtainUserAgentString(0, user_agent, &size);
333 if(strncmp(user_agent, "Mozilla/", 8)) {
334 FIXME("Unsupported user agent\n");
338 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
339 *p = SysAllocStringLen(NULL, size-1);
341 return E_OUTOFMEMORY;
343 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
347 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
349 OmNavigator *This = impl_from_IOmNavigator(iface);
350 char user_agent[512];
354 TRACE("(%p)->(%p)\n", This, p);
356 size = sizeof(user_agent);
357 hres = ObtainUserAgentString(0, user_agent, &size);
361 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
362 *p = SysAllocStringLen(NULL, size-1);
364 return E_OUTOFMEMORY;
366 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
370 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
372 OmNavigator *This = impl_from_IOmNavigator(iface);
374 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
376 *enabled = VARIANT_FALSE;
380 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
382 OmNavigator *This = impl_from_IOmNavigator(iface);
383 FIXME("(%p)->(%p)\n", This, enabled);
387 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
389 OmNavigator *This = impl_from_IOmNavigator(iface);
390 FIXME("(%p)->(%p)\n", This, p);
394 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
396 OmNavigator *This = impl_from_IOmNavigator(iface);
398 TRACE("(%p)->(%p)\n", This, p);
403 hres = create_plugins_collection(This, &This->plugins);
407 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
410 *p = &This->plugins->IHTMLPluginsCollection_iface;
414 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
416 OmNavigator *This = impl_from_IOmNavigator(iface);
417 FIXME("(%p)->(%p)\n", This, p);
421 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
423 OmNavigator *This = impl_from_IOmNavigator(iface);
424 FIXME("(%p)->(%p)\n", This, p);
428 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
430 OmNavigator *This = impl_from_IOmNavigator(iface);
432 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
434 TRACE("(%p)->(%p)\n", This, String);
439 *String = SysAllocString(objectW);
440 return *String ? S_OK : E_OUTOFMEMORY;
443 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
445 OmNavigator *This = impl_from_IOmNavigator(iface);
446 FIXME("(%p)->(%p)\n", This, p);
450 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
452 OmNavigator *This = impl_from_IOmNavigator(iface);
453 FIXME("(%p)->(%p)\n", This, p);
457 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
459 OmNavigator *This = impl_from_IOmNavigator(iface);
460 FIXME("(%p)->(%p)\n", This, p);
464 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
466 OmNavigator *This = impl_from_IOmNavigator(iface);
467 FIXME("(%p)->(%p)\n", This, p);
471 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
473 OmNavigator *This = impl_from_IOmNavigator(iface);
476 static const WCHAR platformW[] = {'W','i','n','6','4',0};
478 static const WCHAR platformW[] = {'W','i','n','3','2',0};
481 TRACE("(%p)->(%p)\n", This, p);
483 *p = SysAllocString(platformW);
487 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
489 OmNavigator *This = impl_from_IOmNavigator(iface);
490 FIXME("(%p)->(%p)\n", This, p);
494 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
496 OmNavigator *This = impl_from_IOmNavigator(iface);
497 FIXME("(%p)->(%p)\n", This, p);
501 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
503 OmNavigator *This = impl_from_IOmNavigator(iface);
504 FIXME("(%p)->(%p)\n", This, p);
508 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
510 OmNavigator *This = impl_from_IOmNavigator(iface);
511 FIXME("(%p)->(%p)\n", This, p);
515 static const IOmNavigatorVtbl OmNavigatorVtbl = {
516 OmNavigator_QueryInterface,
519 OmNavigator_GetTypeInfoCount,
520 OmNavigator_GetTypeInfo,
521 OmNavigator_GetIDsOfNames,
523 OmNavigator_get_appCodeName,
524 OmNavigator_get_appName,
525 OmNavigator_get_appVersion,
526 OmNavigator_get_userAgent,
527 OmNavigator_javaEnabled,
528 OmNavigator_taintEnabled,
529 OmNavigator_get_mimeTypes,
530 OmNavigator_get_plugins,
531 OmNavigator_get_cookieEnabled,
532 OmNavigator_get_opsProfile,
533 OmNavigator_toString,
534 OmNavigator_get_cpuClass,
535 OmNavigator_get_systemLanguage,
536 OmNavigator_get_browserLanguage,
537 OmNavigator_get_userLanguage,
538 OmNavigator_get_platform,
539 OmNavigator_get_appMinorVersion,
540 OmNavigator_get_connectionSpeed,
541 OmNavigator_get_onLine,
542 OmNavigator_get_userProfile
545 static const tid_t OmNavigator_iface_tids[] = {
549 static dispex_static_data_t OmNavigator_dispex = {
551 DispHTMLNavigator_tid,
553 OmNavigator_iface_tids
556 IOmNavigator *OmNavigator_Create(void)
560 ret = heap_alloc_zero(sizeof(*ret));
561 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
564 init_dispex(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex);
566 return &ret->IOmNavigator_iface;