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 const IOmNavigatorVtbl *lpIOmNavigatorVtbl;
42 HTMLPluginsCollection *plugins;
46 #define OMNAVIGATOR(x) ((IOmNavigator*) &(x)->lpIOmNavigatorVtbl)
48 struct HTMLPluginsCollection {
50 const IHTMLPluginsCollectionVtbl *lpIHTMLPluginsCollectionVtbl;
54 OmNavigator *navigator;
57 #define HTMLPLUGINSCOL(x) ((IHTMLPluginsCollection*) &(x)->lpIHTMLPluginsCollectionVtbl)
59 #define HTMLPLUGINCOL_THIS(iface) DEFINE_THIS(HTMLPluginsCollection, IHTMLPluginsCollection, iface)
61 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
63 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
65 if(IsEqualGUID(&IID_IUnknown, riid)) {
66 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
67 *ppv = HTMLPLUGINSCOL(This);
68 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
69 TRACE("(%p)->(IID_IHTMLPluginCollection %p)\n", This, ppv);
70 *ppv = HTMLPLUGINSCOL(This);
71 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
72 return *ppv ? S_OK : E_NOINTERFACE;
75 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
79 IUnknown_AddRef((IUnknown*)*ppv);
83 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
85 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
86 LONG ref = InterlockedIncrement(&This->ref);
88 TRACE("(%p) ref=%d\n", This, ref);
93 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
95 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
96 LONG ref = InterlockedDecrement(&This->ref);
98 TRACE("(%p) ref=%d\n", This, ref);
102 This->navigator->plugins = NULL;
103 release_dispex(&This->dispex);
110 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
112 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
113 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
116 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
117 LCID lcid, ITypeInfo **ppTInfo)
119 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
120 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
123 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
124 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
126 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
127 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
130 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
131 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
132 EXCEPINFO *pExcepInfo, UINT *puArgErr)
134 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
135 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
136 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
139 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
141 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
142 FIXME("(%p)->(%p)\n", This, p);
146 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
148 HTMLPluginsCollection *This = HTMLPLUGINCOL_THIS(iface);
149 FIXME("(%p)->(%x)\n", This, reload);
153 #undef HTMLPLUGINSCOL_THIS
155 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
156 HTMLPluginsCollection_QueryInterface,
157 HTMLPluginsCollection_AddRef,
158 HTMLPluginsCollection_Release,
159 HTMLPluginsCollection_GetTypeInfoCount,
160 HTMLPluginsCollection_GetTypeInfo,
161 HTMLPluginsCollection_GetIDsOfNames,
162 HTMLPluginsCollection_Invoke,
163 HTMLPluginsCollection_get_length,
164 HTMLPluginsCollection_refresh
167 static const tid_t HTMLPluginsCollection_iface_tids[] = {
168 IHTMLPluginsCollection_tid,
171 static dispex_static_data_t HTMLPluginsCollection_dispex = {
175 HTMLPluginsCollection_iface_tids
178 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
180 HTMLPluginsCollection *col;
182 col = heap_alloc_zero(sizeof(*col));
184 return E_OUTOFMEMORY;
186 col->lpIHTMLPluginsCollectionVtbl = &HTMLPluginsCollectionVtbl;
188 col->navigator = navigator;
190 init_dispex(&col->dispex, (IUnknown*)HTMLPLUGINSCOL(col), &HTMLPluginsCollection_dispex);
196 #define OMNAVIGATOR_THIS(iface) DEFINE_THIS(OmNavigator, IOmNavigator, iface)
198 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
200 OmNavigator *This = OMNAVIGATOR_THIS(iface);
204 if(IsEqualGUID(&IID_IUnknown, riid)) {
205 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
206 *ppv = OMNAVIGATOR(This);
207 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
208 TRACE("(%p)->(IID_IOmNavigator %p)\n", This, ppv);
209 *ppv = OMNAVIGATOR(This);
210 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
211 return *ppv ? S_OK : E_NOINTERFACE;
215 IUnknown_AddRef((IUnknown*)*ppv);
219 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
220 return E_NOINTERFACE;
223 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
225 OmNavigator *This = OMNAVIGATOR_THIS(iface);
226 LONG ref = InterlockedIncrement(&This->ref);
228 TRACE("(%p) ref=%d\n", This, ref);
233 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
235 OmNavigator *This = OMNAVIGATOR_THIS(iface);
236 LONG ref = InterlockedDecrement(&This->ref);
238 TRACE("(%p) ref=%d\n", This, ref);
242 This->plugins->navigator = NULL;
243 IHTMLPluginsCollection_Release(HTMLPLUGINSCOL(This->plugins));
245 release_dispex(&This->dispex);
252 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
254 OmNavigator *This = OMNAVIGATOR_THIS(iface);
255 FIXME("(%p)->(%p)\n", This, pctinfo);
259 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
260 LCID lcid, ITypeInfo **ppTInfo)
262 OmNavigator *This = OMNAVIGATOR_THIS(iface);
264 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
267 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
268 LPOLESTR *rgszNames, UINT cNames,
269 LCID lcid, DISPID *rgDispId)
271 OmNavigator *This = OMNAVIGATOR_THIS(iface);
273 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
276 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
277 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
278 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
280 OmNavigator *This = OMNAVIGATOR_THIS(iface);
282 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
283 pVarResult, pExcepInfo, puArgErr);
286 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
288 OmNavigator *This = OMNAVIGATOR_THIS(iface);
290 static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
292 TRACE("(%p)->(%p)\n", This, p);
294 *p = SysAllocString(mozillaW);
298 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
300 OmNavigator *This = OMNAVIGATOR_THIS(iface);
302 static const WCHAR app_nameW[] =
303 {'M','i','c','r','o','s','o','f','t',' ',
304 'I','n','t','e','r','n','e','t',' ',
305 'E','x','p','l','o','r','e','r',0};
307 TRACE("(%p)->(%p)\n", This, p);
309 *p = SysAllocString(app_nameW);
311 return E_OUTOFMEMORY;
316 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
318 OmNavigator *This = OMNAVIGATOR_THIS(iface);
320 char user_agent[512];
324 TRACE("(%p)->(%p)\n", This, p);
326 size = sizeof(user_agent);
327 hres = ObtainUserAgentString(0, user_agent, &size);
331 if(strncmp(user_agent, "Mozilla/", 8)) {
332 FIXME("Unsupported user agent\n");
336 size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
337 *p = SysAllocStringLen(NULL, size-1);
339 return E_OUTOFMEMORY;
341 MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
345 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
347 OmNavigator *This = OMNAVIGATOR_THIS(iface);
348 char user_agent[512];
352 TRACE("(%p)->(%p)\n", This, p);
354 size = sizeof(user_agent);
355 hres = ObtainUserAgentString(0, user_agent, &size);
359 size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
360 *p = SysAllocStringLen(NULL, size-1);
362 return E_OUTOFMEMORY;
364 MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
368 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
370 OmNavigator *This = OMNAVIGATOR_THIS(iface);
371 FIXME("(%p)->(%p)\n", This, enabled);
375 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
377 OmNavigator *This = OMNAVIGATOR_THIS(iface);
378 FIXME("(%p)->(%p)\n", This, enabled);
382 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
384 OmNavigator *This = OMNAVIGATOR_THIS(iface);
385 FIXME("(%p)->(%p)\n", This, p);
389 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
391 OmNavigator *This = OMNAVIGATOR_THIS(iface);
393 TRACE("(%p)->(%p)\n", This, p);
398 hres = create_plugins_collection(This, &This->plugins);
402 IHTMLPluginsCollection_AddRef(HTMLPLUGINSCOL(This->plugins));
405 *p = HTMLPLUGINSCOL(This->plugins);
409 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
411 OmNavigator *This = OMNAVIGATOR_THIS(iface);
412 FIXME("(%p)->(%p)\n", This, p);
416 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
418 OmNavigator *This = OMNAVIGATOR_THIS(iface);
419 FIXME("(%p)->(%p)\n", This, p);
423 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
425 OmNavigator *This = OMNAVIGATOR_THIS(iface);
427 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
429 TRACE("(%p)->(%p)\n", This, String);
434 *String = SysAllocString(objectW);
435 return *String ? S_OK : E_OUTOFMEMORY;
438 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
440 OmNavigator *This = OMNAVIGATOR_THIS(iface);
441 FIXME("(%p)->(%p)\n", This, p);
445 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
447 OmNavigator *This = OMNAVIGATOR_THIS(iface);
448 FIXME("(%p)->(%p)\n", This, p);
452 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
454 OmNavigator *This = OMNAVIGATOR_THIS(iface);
455 FIXME("(%p)->(%p)\n", This, p);
459 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
461 OmNavigator *This = OMNAVIGATOR_THIS(iface);
462 FIXME("(%p)->(%p)\n", This, p);
466 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
468 OmNavigator *This = OMNAVIGATOR_THIS(iface);
471 static const WCHAR platformW[] = {'W','i','n','6','4',0};
473 static const WCHAR platformW[] = {'W','i','n','3','2',0};
476 TRACE("(%p)->(%p)\n", This, p);
478 *p = SysAllocString(platformW);
482 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
484 OmNavigator *This = OMNAVIGATOR_THIS(iface);
485 FIXME("(%p)->(%p)\n", This, p);
489 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
491 OmNavigator *This = OMNAVIGATOR_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, p);
496 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
498 OmNavigator *This = OMNAVIGATOR_THIS(iface);
499 FIXME("(%p)->(%p)\n", This, p);
503 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
505 OmNavigator *This = OMNAVIGATOR_THIS(iface);
506 FIXME("(%p)->(%p)\n", This, p);
510 #undef OMNAVIGATOR_THIS
512 static const IOmNavigatorVtbl OmNavigatorVtbl = {
513 OmNavigator_QueryInterface,
516 OmNavigator_GetTypeInfoCount,
517 OmNavigator_GetTypeInfo,
518 OmNavigator_GetIDsOfNames,
520 OmNavigator_get_appCodeName,
521 OmNavigator_get_appName,
522 OmNavigator_get_appVersion,
523 OmNavigator_get_userAgent,
524 OmNavigator_javaEnabled,
525 OmNavigator_taintEnabled,
526 OmNavigator_get_mimeTypes,
527 OmNavigator_get_plugins,
528 OmNavigator_get_cookieEnabled,
529 OmNavigator_get_opsProfile,
530 OmNavigator_toString,
531 OmNavigator_get_cpuClass,
532 OmNavigator_get_systemLanguage,
533 OmNavigator_get_browserLanguage,
534 OmNavigator_get_userLanguage,
535 OmNavigator_get_platform,
536 OmNavigator_get_appMinorVersion,
537 OmNavigator_get_connectionSpeed,
538 OmNavigator_get_onLine,
539 OmNavigator_get_userProfile
542 static const tid_t OmNavigator_iface_tids[] = {
546 static dispex_static_data_t OmNavigator_dispex = {
548 DispHTMLNavigator_tid,
550 OmNavigator_iface_tids
553 IOmNavigator *OmNavigator_Create(void)
557 ret = heap_alloc_zero(sizeof(*ret));
558 ret->lpIOmNavigatorVtbl = &OmNavigatorVtbl;
561 init_dispex(&ret->dispex, (IUnknown*)OMNAVIGATOR(ret), &OmNavigator_dispex);
563 return OMNAVIGATOR(ret);