ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

omnavigator.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2008 Jacek Caban for CodeWeavers
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #include <stdarg.h>
00020 
00021 #define COBJMACROS
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "winuser.h"
00026 #include "ole2.h"
00027 
00028 #include "wine/debug.h"
00029 
00030 #include "mshtml_private.h"
00031 
00032 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
00033 
00034 typedef struct {
00035     DispatchEx dispex;
00036     const IOmNavigatorVtbl  *lpIOmNavigatorVtbl;
00037 
00038     LONG ref;
00039 } OmNavigator;
00040 
00041 #define OMNAVIGATOR(x)  ((IOmNavigator*) &(x)->lpIOmNavigatorVtbl)
00042 
00043 #define OMNAVIGATOR_THIS(iface) DEFINE_THIS(OmNavigator, IOmNavigator, iface)
00044 
00045 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
00046 {
00047     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00048 
00049     *ppv = NULL;
00050 
00051     if(IsEqualGUID(&IID_IUnknown, riid)) {
00052         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
00053         *ppv = OMNAVIGATOR(This);
00054     }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
00055         TRACE("(%p)->(IID_IOmNavigator %p)\n", This, ppv);
00056         *ppv = OMNAVIGATOR(This);
00057     }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
00058         return *ppv ? S_OK : E_NOINTERFACE;
00059     }
00060 
00061     if(*ppv) {
00062         IUnknown_AddRef((IUnknown*)*ppv);
00063         return S_OK;
00064     }
00065 
00066     WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
00067     return E_NOINTERFACE;
00068 }
00069 
00070 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
00071 {
00072     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00073     LONG ref = InterlockedIncrement(&This->ref);
00074 
00075     TRACE("(%p) ref=%d\n", This, ref);
00076 
00077     return ref;
00078 }
00079 
00080 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
00081 {
00082     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00083     LONG ref = InterlockedDecrement(&This->ref);
00084 
00085     TRACE("(%p) ref=%d\n", This, ref);
00086 
00087     if(!ref) {
00088         release_dispex(&This->dispex);
00089         heap_free(This);
00090     }
00091 
00092     return ref;
00093 }
00094 
00095 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
00096 {
00097     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00098     FIXME("(%p)->(%p)\n", This, pctinfo);
00099     return E_NOTIMPL;
00100 }
00101 
00102 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
00103                                               LCID lcid, ITypeInfo **ppTInfo)
00104 {
00105     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00106 
00107     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
00108 }
00109 
00110 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
00111                                                 LPOLESTR *rgszNames, UINT cNames,
00112                                                 LCID lcid, DISPID *rgDispId)
00113 {
00114     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00115 
00116     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
00117 }
00118 
00119 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
00120                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
00121                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
00122 {
00123     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00124 
00125     return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
00126             pVarResult, pExcepInfo, puArgErr);
00127 }
00128 
00129 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
00130 {
00131     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00132 
00133     static const WCHAR mozillaW[] = {'M','o','z','i','l','l','a',0};
00134 
00135     TRACE("(%p)->(%p)\n", This, p);
00136 
00137     *p = SysAllocString(mozillaW);
00138     return S_OK;
00139 }
00140 
00141 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
00142 {
00143     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00144 
00145     static const WCHAR app_nameW[] =
00146         {'M','i','c','r','o','s','o','f','t',' ',
00147          'I','n','t','e','r','n','e','t',' ',
00148          'E','x','p','l','o','r','e','r',0};
00149 
00150     TRACE("(%p)->(%p)\n", This, p);
00151 
00152     *p = SysAllocString(app_nameW);
00153     if(!*p)
00154         return E_OUTOFMEMORY;
00155 
00156     return S_OK;
00157 }
00158 
00159 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
00160 {
00161     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00162 
00163     char user_agent[512];
00164     DWORD size;
00165     HRESULT hres;
00166 
00167     TRACE("(%p)->(%p)\n", This, p);
00168 
00169     size = sizeof(user_agent);
00170     hres = ObtainUserAgentString(0, user_agent, &size);
00171     if(FAILED(hres))
00172         return hres;
00173 
00174     if(strncmp(user_agent, "Mozilla/", 8)) {
00175         FIXME("Unsupported user agent\n");
00176         return E_FAIL;
00177     }
00178 
00179     size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
00180     *p = SysAllocStringLen(NULL, size-1);
00181     if(!*p)
00182         return E_OUTOFMEMORY;
00183 
00184     MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
00185     return S_OK;
00186 }
00187 
00188 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
00189 {
00190     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00191     char user_agent[512];
00192     DWORD size;
00193     HRESULT hres;
00194 
00195     TRACE("(%p)->(%p)\n", This, p);
00196 
00197     size = sizeof(user_agent);
00198     hres = ObtainUserAgentString(0, user_agent, &size);
00199     if(FAILED(hres))
00200         return hres;
00201 
00202     size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
00203     *p = SysAllocStringLen(NULL, size-1);
00204     if(!*p)
00205         return E_OUTOFMEMORY;
00206 
00207     MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
00208     return S_OK;
00209 }
00210 
00211 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
00212 {
00213     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00214     FIXME("(%p)->(%p)\n", This, enabled);
00215     return E_NOTIMPL;
00216 }
00217 
00218 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
00219 {
00220     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00221     FIXME("(%p)->(%p)\n", This, enabled);
00222     return E_NOTIMPL;
00223 }
00224 
00225 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
00226 {
00227     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00228     FIXME("(%p)->(%p)\n", This, p);
00229     return E_NOTIMPL;
00230 }
00231 
00232 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
00233 {
00234     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00235     FIXME("(%p)->(%p)\n", This, p);
00236     return E_NOTIMPL;
00237 }
00238 
00239 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
00240 {
00241     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00242     FIXME("(%p)->(%p)\n", This, p);
00243     return E_NOTIMPL;
00244 }
00245 
00246 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
00247 {
00248     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00249     FIXME("(%p)->(%p)\n", This, p);
00250     return E_NOTIMPL;
00251 }
00252 
00253 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
00254 {
00255     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00256 
00257     static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
00258 
00259     TRACE("(%p)->(%p)\n", This, String);
00260 
00261     if(!String)
00262         return E_INVALIDARG;
00263 
00264     *String = SysAllocString(objectW);
00265     return *String ? S_OK : E_OUTOFMEMORY;
00266 }
00267 
00268 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
00269 {
00270     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00271     FIXME("(%p)->(%p)\n", This, p);
00272     return E_NOTIMPL;
00273 }
00274 
00275 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
00276 {
00277     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00278     FIXME("(%p)->(%p)\n", This, p);
00279     return E_NOTIMPL;
00280 }
00281 
00282 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
00283 {
00284     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00285     FIXME("(%p)->(%p)\n", This, p);
00286     return E_NOTIMPL;
00287 }
00288 
00289 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
00290 {
00291     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00292     FIXME("(%p)->(%p)\n", This, p);
00293     return E_NOTIMPL;
00294 }
00295 
00296 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
00297 {
00298     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00299 
00300 #ifdef _WIN64
00301     static const WCHAR platformW[] = {'W','i','n','6','4',0};
00302 #else
00303     static const WCHAR platformW[] = {'W','i','n','3','2',0};
00304 #endif
00305 
00306     TRACE("(%p)->(%p)\n", This, p);
00307 
00308     *p = SysAllocString(platformW);
00309     return S_OK;
00310 }
00311 
00312 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
00313 {
00314     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00315     FIXME("(%p)->(%p)\n", This, p);
00316     return E_NOTIMPL;
00317 }
00318 
00319 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
00320 {
00321     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00322     FIXME("(%p)->(%p)\n", This, p);
00323     return E_NOTIMPL;
00324 }
00325 
00326 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
00327 {
00328     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00329     FIXME("(%p)->(%p)\n", This, p);
00330     return E_NOTIMPL;
00331 }
00332 
00333 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
00334 {
00335     OmNavigator *This = OMNAVIGATOR_THIS(iface);
00336     FIXME("(%p)->(%p)\n", This, p);
00337     return E_NOTIMPL;
00338 }
00339 
00340 #undef OMNAVIGATOR_THIS
00341 
00342 static const IOmNavigatorVtbl OmNavigatorVtbl = {
00343     OmNavigator_QueryInterface,
00344     OmNavigator_AddRef,
00345     OmNavigator_Release,
00346     OmNavigator_GetTypeInfoCount,
00347     OmNavigator_GetTypeInfo,
00348     OmNavigator_GetIDsOfNames,
00349     OmNavigator_Invoke,
00350     OmNavigator_get_appCodeName,
00351     OmNavigator_get_appName,
00352     OmNavigator_get_appVersion,
00353     OmNavigator_get_userAgent,
00354     OmNavigator_javaEnabled,
00355     OmNavigator_taintEnabled,
00356     OmNavigator_get_mimeTypes,
00357     OmNavigator_get_plugins,
00358     OmNavigator_get_cookieEnabled,
00359     OmNavigator_get_opsProfile,
00360     OmNavigator_toString,
00361     OmNavigator_get_cpuClass,
00362     OmNavigator_get_systemLanguage,
00363     OmNavigator_get_browserLanguage,
00364     OmNavigator_get_userLanguage,
00365     OmNavigator_get_platform,
00366     OmNavigator_get_appMinorVersion,
00367     OmNavigator_get_connectionSpeed,
00368     OmNavigator_get_onLine,
00369     OmNavigator_get_userProfile
00370 };
00371 
00372 static const tid_t OmNavigator_iface_tids[] = {
00373     IOmNavigator_tid,
00374     0
00375 };
00376 static dispex_static_data_t OmNavigator_dispex = {
00377     NULL,
00378     DispHTMLNavigator_tid,
00379     NULL,
00380     OmNavigator_iface_tids
00381 };
00382 
00383 IOmNavigator *OmNavigator_Create(void)
00384 {
00385     OmNavigator *ret;
00386 
00387     ret = heap_alloc_zero(sizeof(*ret));
00388     ret->lpIOmNavigatorVtbl = &OmNavigatorVtbl;
00389     ret->ref = 1;
00390 
00391     init_dispex(&ret->dispex, (IUnknown*)OMNAVIGATOR(ret), &OmNavigator_dispex);
00392 
00393     return OMNAVIGATOR(ret);
00394 }

Generated on Sun May 27 2012 04:25:07 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.