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

inetcomm_main.c
Go to the documentation of this file.
00001 /*
00002  * Internet Messaging APIs
00003  *
00004  * Copyright 2006 Robert Shearman for CodeWeavers
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 <stdarg.h>
00024 
00025 #include "windef.h"
00026 #include "winbase.h"
00027 #include "winnt.h"
00028 #include "winuser.h"
00029 #include "ole2.h"
00030 #include "ocidl.h"
00031 #include "rpcproxy.h"
00032 #include "initguid.h"
00033 #include "mimeole.h"
00034 
00035 #include "inetcomm_private.h"
00036 
00037 #include "wine/debug.h"
00038 
00039 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
00040 
00041 static HINSTANCE instance;
00042 
00043 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
00044 {
00045     static IMimeInternational *international;
00046 
00047     TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
00048 
00049     switch (fdwReason)
00050     {
00051     case DLL_WINE_PREATTACH:
00052         return FALSE;
00053     case DLL_PROCESS_ATTACH:
00054         DisableThreadLibraryCalls(hinstDLL);
00055         instance = hinstDLL;
00056         if (!InternetTransport_RegisterClass(hinstDLL))
00057             return FALSE;
00058         MimeInternational_Construct(&international);
00059         break;
00060     case DLL_PROCESS_DETACH:
00061         IMimeInternational_Release(international);
00062         InternetTransport_UnregisterClass(hinstDLL);
00063         break;
00064     default:
00065         break;
00066     }
00067     return TRUE;
00068 }
00069 
00070 /******************************************************************************
00071  * ClassFactory
00072  */
00073 typedef struct
00074 {
00075     IClassFactory IClassFactory_iface;
00076     HRESULT (*create_object)(IUnknown *, void **);
00077 } cf;
00078 
00079 static inline cf *impl_from_IClassFactory( IClassFactory *iface )
00080 {
00081     return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
00082 }
00083 
00084 static HRESULT WINAPI cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
00085 {
00086     if (IsEqualGUID(riid, &IID_IUnknown) ||
00087         IsEqualGUID(riid, &IID_IClassFactory))
00088     {
00089         IClassFactory_AddRef( iface );
00090         *ppobj = iface;
00091         return S_OK;
00092     }
00093 
00094     FIXME("interface %s not implemented\n", debugstr_guid(riid));
00095     return E_NOINTERFACE;
00096 }
00097 
00098 static ULONG WINAPI cf_AddRef( IClassFactory *iface )
00099 {
00100     return 2;
00101 }
00102 
00103 static ULONG WINAPI cf_Release( IClassFactory *iface )
00104 {
00105     return 1;
00106 }
00107 
00108 static HRESULT WINAPI cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
00109                                          REFIID riid, LPVOID *ppobj )
00110 {
00111     cf *This = impl_from_IClassFactory( iface );
00112     HRESULT r;
00113     IUnknown *punk;
00114 
00115     TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
00116 
00117     *ppobj = NULL;
00118 
00119     r = This->create_object( pOuter, (LPVOID*) &punk );
00120     if (FAILED(r))
00121         return r;
00122 
00123     r = IUnknown_QueryInterface( punk, riid, ppobj );
00124     IUnknown_Release( punk );
00125 
00126     return r;
00127 }
00128 
00129 static HRESULT WINAPI cf_LockServer( IClassFactory *iface, BOOL dolock)
00130 {
00131     FIXME("(%p)->(%d),stub!\n",iface,dolock);
00132     return S_OK;
00133 }
00134 
00135 static const struct IClassFactoryVtbl cf_vtbl =
00136 {
00137     cf_QueryInterface,
00138     cf_AddRef,
00139     cf_Release,
00140     cf_CreateInstance,
00141     cf_LockServer
00142 };
00143 
00144 static cf mime_body_cf      = { { &cf_vtbl }, MimeBody_create };
00145 static cf mime_allocator_cf = { { &cf_vtbl }, MimeAllocator_create };
00146 static cf mime_message_cf   = { { &cf_vtbl }, MimeMessage_create };
00147 static cf mime_security_cf  = { { &cf_vtbl }, MimeSecurity_create };
00148 static cf virtual_stream_cf = { { &cf_vtbl }, VirtualStream_create };
00149 
00150 /***********************************************************************
00151  *              DllGetClassObject (INETCOMM.@)
00152  */
00153 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
00154 {
00155     IClassFactory *cf = NULL;
00156 
00157     TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
00158 
00159     if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport))
00160         return SMTPTransportCF_Create(iid, ppv);
00161 
00162     if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport2))
00163         return SMTPTransportCF_Create(iid, ppv);
00164 
00165     if (IsEqualCLSID(rclsid, &CLSID_IIMAPTransport))
00166         return IMAPTransportCF_Create(iid, ppv);
00167 
00168     if (IsEqualCLSID(rclsid, &CLSID_IPOP3Transport))
00169         return POP3TransportCF_Create(iid, ppv);
00170 
00171     if ( IsEqualCLSID( rclsid, &CLSID_IMimeSecurity ))
00172     {
00173         cf = &mime_security_cf.IClassFactory_iface;
00174     }
00175     else if( IsEqualCLSID( rclsid, &CLSID_IMimeMessage ))
00176     {
00177         cf = &mime_message_cf.IClassFactory_iface;
00178     }
00179     else if( IsEqualCLSID( rclsid, &CLSID_IMimeBody ))
00180     {
00181         cf = &mime_body_cf.IClassFactory_iface;
00182     }
00183     else if( IsEqualCLSID( rclsid, &CLSID_IMimeAllocator ))
00184     {
00185         cf = &mime_allocator_cf.IClassFactory_iface;
00186     }
00187     else if( IsEqualCLSID( rclsid, &CLSID_IVirtualStream ))
00188     {
00189         cf = &virtual_stream_cf.IClassFactory_iface;
00190     }
00191 
00192     if ( !cf )
00193     {
00194         FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
00195         return CLASS_E_CLASSNOTAVAILABLE;
00196     }
00197 
00198     return IClassFactory_QueryInterface( cf, iid, ppv );
00199 }
00200 
00201 /***********************************************************************
00202  *              DllCanUnloadNow (INETCOMM.@)
00203  */
00204 HRESULT WINAPI DllCanUnloadNow(void)
00205 {
00206     return S_FALSE;
00207 }
00208 
00209 /***********************************************************************
00210  *      DllRegisterServer (INETCOMM.@)
00211  */
00212 HRESULT WINAPI DllRegisterServer(void)
00213 {
00214     return __wine_register_resources( instance );
00215 }
00216 
00217 /***********************************************************************
00218  *      DllUnregisterServer (INETCOMM.@)
00219  */
00220 HRESULT WINAPI DllUnregisterServer(void)
00221 {
00222     return __wine_unregister_resources( instance );
00223 }

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