inetcomm: Added MimeHtmlProtocol stub implementation.
[wine.git] / dlls / inetcomm / inetcomm_main.c
blob4cb55226dc01cb2fe12e10161d1edae11eb593a2
1 /*
2 * Internet Messaging APIs
4 * Copyright 2006 Robert Shearman for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "ocidl.h"
31 #include "rpcproxy.h"
32 #include "initguid.h"
33 #include "mimeole.h"
35 #include "inetcomm_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
41 static HINSTANCE instance;
43 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
45 static IMimeInternational *international;
47 TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
49 switch (fdwReason)
51 case DLL_WINE_PREATTACH:
52 return FALSE;
53 case DLL_PROCESS_ATTACH:
54 DisableThreadLibraryCalls(hinstDLL);
55 instance = hinstDLL;
56 if (!InternetTransport_RegisterClass(hinstDLL))
57 return FALSE;
58 MimeInternational_Construct(&international);
59 break;
60 case DLL_PROCESS_DETACH:
61 if (lpvReserved) break;
62 IMimeInternational_Release(international);
63 InternetTransport_UnregisterClass(hinstDLL);
64 break;
66 return TRUE;
69 /******************************************************************************
70 * ClassFactory
72 typedef struct
74 IClassFactory IClassFactory_iface;
75 HRESULT (*create_object)(IUnknown *, void **);
76 } cf;
78 static inline cf *impl_from_IClassFactory( IClassFactory *iface )
80 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
83 static HRESULT WINAPI cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
85 if (IsEqualGUID(riid, &IID_IUnknown) ||
86 IsEqualGUID(riid, &IID_IClassFactory))
88 IClassFactory_AddRef( iface );
89 *ppobj = iface;
90 return S_OK;
93 if (!IsEqualGUID(riid, &IID_IInternetProtocolInfo))
94 FIXME("interface %s not implemented\n", debugstr_guid(riid));
95 *ppobj = NULL;
96 return E_NOINTERFACE;
99 static ULONG WINAPI cf_AddRef( IClassFactory *iface )
101 return 2;
104 static ULONG WINAPI cf_Release( IClassFactory *iface )
106 return 1;
109 static HRESULT WINAPI cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
110 REFIID riid, LPVOID *ppobj )
112 cf *This = impl_from_IClassFactory( iface );
113 HRESULT r;
114 IUnknown *punk;
116 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
118 *ppobj = NULL;
120 r = This->create_object( pOuter, (LPVOID*) &punk );
121 if (FAILED(r))
122 return r;
124 r = IUnknown_QueryInterface( punk, riid, ppobj );
125 IUnknown_Release( punk );
127 return r;
130 static HRESULT WINAPI cf_LockServer( IClassFactory *iface, BOOL dolock)
132 FIXME("(%p)->(%d),stub!\n",iface,dolock);
133 return S_OK;
136 static const struct IClassFactoryVtbl cf_vtbl =
138 cf_QueryInterface,
139 cf_AddRef,
140 cf_Release,
141 cf_CreateInstance,
142 cf_LockServer
145 static cf mime_body_cf = { { &cf_vtbl }, MimeBody_create };
146 static cf mime_allocator_cf = { { &cf_vtbl }, MimeAllocator_create };
147 static cf mime_message_cf = { { &cf_vtbl }, MimeMessage_create };
148 static cf mime_security_cf = { { &cf_vtbl }, MimeSecurity_create };
149 static cf virtual_stream_cf = { { &cf_vtbl }, VirtualStream_create };
150 static cf mhtml_protocol_cf = { { &cf_vtbl }, MimeHtmlProtocol_create };
152 /***********************************************************************
153 * DllGetClassObject (INETCOMM.@)
155 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
157 IClassFactory *cf = NULL;
159 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
161 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport))
162 return SMTPTransportCF_Create(iid, ppv);
164 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport2))
165 return SMTPTransportCF_Create(iid, ppv);
167 if (IsEqualCLSID(rclsid, &CLSID_IIMAPTransport))
168 return IMAPTransportCF_Create(iid, ppv);
170 if (IsEqualCLSID(rclsid, &CLSID_IPOP3Transport))
171 return POP3TransportCF_Create(iid, ppv);
173 if ( IsEqualCLSID( rclsid, &CLSID_IMimeSecurity ))
175 cf = &mime_security_cf.IClassFactory_iface;
177 else if( IsEqualCLSID( rclsid, &CLSID_IMimeMessage ))
179 cf = &mime_message_cf.IClassFactory_iface;
181 else if( IsEqualCLSID( rclsid, &CLSID_IMimeBody ))
183 cf = &mime_body_cf.IClassFactory_iface;
185 else if( IsEqualCLSID( rclsid, &CLSID_IMimeAllocator ))
187 cf = &mime_allocator_cf.IClassFactory_iface;
189 else if( IsEqualCLSID( rclsid, &CLSID_IVirtualStream ))
191 cf = &virtual_stream_cf.IClassFactory_iface;
193 else if( IsEqualCLSID( rclsid, &CLSID_IMimeHtmlProtocol ))
195 cf = &mhtml_protocol_cf.IClassFactory_iface;
198 if ( !cf )
200 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
201 return CLASS_E_CLASSNOTAVAILABLE;
204 return IClassFactory_QueryInterface( cf, iid, ppv );
207 /***********************************************************************
208 * DllCanUnloadNow (INETCOMM.@)
210 HRESULT WINAPI DllCanUnloadNow(void)
212 return S_FALSE;
215 /***********************************************************************
216 * DllRegisterServer (INETCOMM.@)
218 HRESULT WINAPI DllRegisterServer(void)
220 return __wine_register_resources( instance );
223 /***********************************************************************
224 * DllUnregisterServer (INETCOMM.@)
226 HRESULT WINAPI DllUnregisterServer(void)
228 return __wine_unregister_resources( instance );