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

main.c
Go to the documentation of this file.
00001 /*
00002  * WUAPI implementation
00003  *
00004  * Copyright 2008 Hans Leidekker
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #define COBJMACROS
00022 
00023 #include "config.h"
00024 #include <stdarg.h>
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "winuser.h"
00029 #include "ole2.h"
00030 #include "wuapi.h"
00031 
00032 #include "wine/debug.h"
00033 #include "wuapi_private.h"
00034 
00035 WINE_DEFAULT_DEBUG_CHANNEL(wuapi);
00036 
00037 typedef HRESULT (*fnCreateInstance)( IUnknown *pUnkOuter, LPVOID *ppObj );
00038 
00039 typedef struct _wucf
00040 {
00041     const struct IClassFactoryVtbl *vtbl;
00042     fnCreateInstance pfnCreateInstance;
00043 } wucf;
00044 
00045 static inline wucf *impl_from_IClassFactory( IClassFactory *iface )
00046 {
00047     return (wucf *)((char *)iface - FIELD_OFFSET( wucf, vtbl ));
00048 }
00049 
00050 static HRESULT WINAPI wucf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
00051 {
00052     if (IsEqualGUID(riid, &IID_IUnknown) ||
00053         IsEqualGUID(riid, &IID_IClassFactory))
00054     {
00055         IClassFactory_AddRef( iface );
00056         *ppobj = iface;
00057         return S_OK;
00058     }
00059     FIXME("interface %s not implemented\n", debugstr_guid(riid));
00060     return E_NOINTERFACE;
00061 }
00062 
00063 static ULONG WINAPI wucf_AddRef( IClassFactory *iface )
00064 {
00065     return 2;
00066 }
00067 
00068 static ULONG WINAPI wucf_Release( IClassFactory *iface )
00069 {
00070     return 1;
00071 }
00072 
00073 static HRESULT WINAPI wucf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
00074                                            REFIID riid, LPVOID *ppobj )
00075 {
00076     wucf *This = impl_from_IClassFactory( iface );
00077     HRESULT r;
00078     IUnknown *punk;
00079 
00080     TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
00081 
00082     *ppobj = NULL;
00083 
00084     if (pOuter)
00085         return CLASS_E_NOAGGREGATION;
00086 
00087     r = This->pfnCreateInstance( pOuter, (LPVOID *)&punk );
00088     if (FAILED(r))
00089         return r;
00090 
00091     r = IUnknown_QueryInterface( punk, riid, ppobj );
00092     if (FAILED(r))
00093         return r;
00094 
00095     IUnknown_Release( punk );
00096     return r;
00097 }
00098 
00099 static HRESULT WINAPI wucf_LockServer( IClassFactory *iface, BOOL dolock )
00100 {
00101     FIXME("(%p)->(%d)\n", iface, dolock);
00102     return S_OK;
00103 }
00104 
00105 static const struct IClassFactoryVtbl wucf_vtbl =
00106 {
00107     wucf_QueryInterface,
00108     wucf_AddRef,
00109     wucf_Release,
00110     wucf_CreateInstance,
00111     wucf_LockServer
00112 };
00113 
00114 static wucf sessioncf = { &wucf_vtbl, UpdateSession_create };
00115 static wucf updatescf = { &wucf_vtbl, AutomaticUpdates_create };
00116 
00117 BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID lpv )
00118 {
00119     switch(reason)
00120     {
00121     case DLL_WINE_PREATTACH:
00122         return FALSE;  /* prefer native version */
00123     case DLL_PROCESS_ATTACH:
00124         DisableThreadLibraryCalls( hinst );
00125         break;
00126     case DLL_PROCESS_DETACH:
00127         break;
00128     }
00129     return TRUE;
00130 }
00131 
00132 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
00133 {
00134     IClassFactory *cf = NULL;
00135 
00136     TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
00137 
00138     if (IsEqualGUID( rclsid, &CLSID_UpdateSession ))
00139     {
00140        cf = (IClassFactory *)&sessioncf.vtbl;
00141     }
00142     else if (IsEqualGUID( rclsid, &CLSID_AutomaticUpdates ))
00143     {
00144        cf = (IClassFactory *)&updatescf.vtbl;
00145     }
00146     if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
00147     return IClassFactory_QueryInterface( cf, iid, ppv );
00148 }
00149 
00150 HRESULT WINAPI DllCanUnloadNow( void )
00151 {
00152     return S_FALSE;
00153 }

Generated on Sat May 26 2012 04:15:45 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.