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(DISPATCHEX(&This
->dispex
), 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(DISPATCHEX(&This
->dispex
), 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(DISPATCHEX(&This
->dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
133 static HRESULT WINAPI
HTMLPluginsCollection_Invoke(IHTMLPluginsCollection
*iface
, DISPID dispIdMember
,
134 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
135 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
137 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
138 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
,
139 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
142 static HRESULT WINAPI
HTMLPluginsCollection_get_length(IHTMLPluginsCollection
*iface
, LONG
*p
)
144 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
145 FIXME("(%p)->(%p)\n", This
, p
);
149 static HRESULT WINAPI
HTMLPluginsCollection_refresh(IHTMLPluginsCollection
*iface
, VARIANT_BOOL reload
)
151 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
152 FIXME("(%p)->(%x)\n", This
, reload
);
156 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl
= {
157 HTMLPluginsCollection_QueryInterface
,
158 HTMLPluginsCollection_AddRef
,
159 HTMLPluginsCollection_Release
,
160 HTMLPluginsCollection_GetTypeInfoCount
,
161 HTMLPluginsCollection_GetTypeInfo
,
162 HTMLPluginsCollection_GetIDsOfNames
,
163 HTMLPluginsCollection_Invoke
,
164 HTMLPluginsCollection_get_length
,
165 HTMLPluginsCollection_refresh
168 static const tid_t HTMLPluginsCollection_iface_tids
[] = {
169 IHTMLPluginsCollection_tid
,
172 static dispex_static_data_t HTMLPluginsCollection_dispex
= {
176 HTMLPluginsCollection_iface_tids
179 static HRESULT
create_plugins_collection(OmNavigator
*navigator
, HTMLPluginsCollection
**ret
)
181 HTMLPluginsCollection
*col
;
183 col
= heap_alloc_zero(sizeof(*col
));
185 return E_OUTOFMEMORY
;
187 col
->IHTMLPluginsCollection_iface
.lpVtbl
= &HTMLPluginsCollectionVtbl
;
189 col
->navigator
= navigator
;
191 init_dispex(&col
->dispex
, (IUnknown
*)&col
->IHTMLPluginsCollection_iface
,
192 &HTMLPluginsCollection_dispex
);
198 static HRESULT WINAPI
OmNavigator_QueryInterface(IOmNavigator
*iface
, REFIID riid
, void **ppv
)
200 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
204 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
205 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
206 *ppv
= &This
->IOmNavigator_iface
;
207 }else if(IsEqualGUID(&IID_IOmNavigator
, riid
)) {
208 TRACE("(%p)->(IID_IOmNavigator %p)\n", This
, ppv
);
209 *ppv
= &This
->IOmNavigator_iface
;
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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(iface
);
236 LONG ref
= InterlockedDecrement(&This
->ref
);
238 TRACE("(%p) ref=%d\n", This
, ref
);
242 This
->plugins
->navigator
= NULL
;
243 IHTMLPluginsCollection_Release(&This
->plugins
->IHTMLPluginsCollection_iface
);
245 release_dispex(&This
->dispex
);
252 static HRESULT WINAPI
OmNavigator_GetTypeInfoCount(IOmNavigator
*iface
, UINT
*pctinfo
)
254 OmNavigator
*This
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(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
= impl_from_IOmNavigator(iface
);
372 FIXME("(%p)->(%p) semi-stub\n", This
, enabled
);
374 *enabled
= VARIANT_FALSE
;
378 static HRESULT WINAPI
OmNavigator_taintEnabled(IOmNavigator
*iface
, VARIANT_BOOL
*enabled
)
380 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
381 FIXME("(%p)->(%p)\n", This
, enabled
);
385 static HRESULT WINAPI
OmNavigator_get_mimeTypes(IOmNavigator
*iface
, IHTMLMimeTypesCollection
**p
)
387 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
388 FIXME("(%p)->(%p)\n", This
, p
);
392 static HRESULT WINAPI
OmNavigator_get_plugins(IOmNavigator
*iface
, IHTMLPluginsCollection
**p
)
394 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
396 TRACE("(%p)->(%p)\n", This
, p
);
401 hres
= create_plugins_collection(This
, &This
->plugins
);
405 IHTMLPluginsCollection_AddRef(&This
->plugins
->IHTMLPluginsCollection_iface
);
408 *p
= &This
->plugins
->IHTMLPluginsCollection_iface
;
412 static HRESULT WINAPI
OmNavigator_get_cookieEnabled(IOmNavigator
*iface
, VARIANT_BOOL
*p
)
414 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
415 FIXME("(%p)->(%p)\n", This
, p
);
419 static HRESULT WINAPI
OmNavigator_get_opsProfile(IOmNavigator
*iface
, IHTMLOpsProfile
**p
)
421 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
422 FIXME("(%p)->(%p)\n", This
, p
);
426 static HRESULT WINAPI
OmNavigator_toString(IOmNavigator
*iface
, BSTR
*String
)
428 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
430 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
432 TRACE("(%p)->(%p)\n", This
, String
);
437 *String
= SysAllocString(objectW
);
438 return *String
? S_OK
: E_OUTOFMEMORY
;
441 static HRESULT WINAPI
OmNavigator_get_cpuClass(IOmNavigator
*iface
, BSTR
*p
)
443 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
444 FIXME("(%p)->(%p)\n", This
, p
);
448 static HRESULT WINAPI
OmNavigator_get_systemLanguage(IOmNavigator
*iface
, BSTR
*p
)
450 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
451 FIXME("(%p)->(%p)\n", This
, p
);
455 static HRESULT WINAPI
OmNavigator_get_browserLanguage(IOmNavigator
*iface
, BSTR
*p
)
457 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
458 FIXME("(%p)->(%p)\n", This
, p
);
462 static HRESULT WINAPI
OmNavigator_get_userLanguage(IOmNavigator
*iface
, BSTR
*p
)
464 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
465 FIXME("(%p)->(%p)\n", This
, p
);
469 static HRESULT WINAPI
OmNavigator_get_platform(IOmNavigator
*iface
, BSTR
*p
)
471 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
474 static const WCHAR platformW
[] = {'W','i','n','6','4',0};
476 static const WCHAR platformW
[] = {'W','i','n','3','2',0};
479 TRACE("(%p)->(%p)\n", This
, p
);
481 *p
= SysAllocString(platformW
);
485 static HRESULT WINAPI
OmNavigator_get_appMinorVersion(IOmNavigator
*iface
, BSTR
*p
)
487 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
488 FIXME("(%p)->(%p)\n", This
, p
);
492 static HRESULT WINAPI
OmNavigator_get_connectionSpeed(IOmNavigator
*iface
, LONG
*p
)
494 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
495 FIXME("(%p)->(%p)\n", This
, p
);
499 static HRESULT WINAPI
OmNavigator_get_onLine(IOmNavigator
*iface
, VARIANT_BOOL
*p
)
501 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
502 FIXME("(%p)->(%p)\n", This
, p
);
506 static HRESULT WINAPI
OmNavigator_get_userProfile(IOmNavigator
*iface
, IHTMLOpsProfile
**p
)
508 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
509 FIXME("(%p)->(%p)\n", This
, p
);
513 static const IOmNavigatorVtbl OmNavigatorVtbl
= {
514 OmNavigator_QueryInterface
,
517 OmNavigator_GetTypeInfoCount
,
518 OmNavigator_GetTypeInfo
,
519 OmNavigator_GetIDsOfNames
,
521 OmNavigator_get_appCodeName
,
522 OmNavigator_get_appName
,
523 OmNavigator_get_appVersion
,
524 OmNavigator_get_userAgent
,
525 OmNavigator_javaEnabled
,
526 OmNavigator_taintEnabled
,
527 OmNavigator_get_mimeTypes
,
528 OmNavigator_get_plugins
,
529 OmNavigator_get_cookieEnabled
,
530 OmNavigator_get_opsProfile
,
531 OmNavigator_toString
,
532 OmNavigator_get_cpuClass
,
533 OmNavigator_get_systemLanguage
,
534 OmNavigator_get_browserLanguage
,
535 OmNavigator_get_userLanguage
,
536 OmNavigator_get_platform
,
537 OmNavigator_get_appMinorVersion
,
538 OmNavigator_get_connectionSpeed
,
539 OmNavigator_get_onLine
,
540 OmNavigator_get_userProfile
543 static const tid_t OmNavigator_iface_tids
[] = {
547 static dispex_static_data_t OmNavigator_dispex
= {
549 DispHTMLNavigator_tid
,
551 OmNavigator_iface_tids
554 IOmNavigator
*OmNavigator_Create(void)
558 ret
= heap_alloc_zero(sizeof(*ret
));
559 ret
->IOmNavigator_iface
.lpVtbl
= &OmNavigatorVtbl
;
562 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IOmNavigator_iface
, &OmNavigator_dispex
);
564 return &ret
->IOmNavigator_iface
;