mfplay: Implement GetCharacteristics().
[wine/zf.git] / dlls / inetcomm / inetcomm_main.c
blobe9029ffb98b992ebb094b9c8bd508fc6d861dc22
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_PROCESS_ATTACH:
52 DisableThreadLibraryCalls(hinstDLL);
53 instance = hinstDLL;
54 if (!InternetTransport_RegisterClass(hinstDLL))
55 return FALSE;
56 MimeInternational_Construct(&international);
57 break;
58 case DLL_PROCESS_DETACH:
59 if (lpvReserved) break;
60 IMimeInternational_Release(international);
61 InternetTransport_UnregisterClass(hinstDLL);
62 break;
64 return TRUE;
67 /******************************************************************************
68 * ClassFactory
70 typedef struct
72 IClassFactory IClassFactory_iface;
73 HRESULT (*create_object)(IUnknown *, void **);
74 } cf;
76 static inline cf *impl_from_IClassFactory( IClassFactory *iface )
78 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
81 static HRESULT WINAPI cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
83 if (IsEqualGUID(riid, &IID_IUnknown) ||
84 IsEqualGUID(riid, &IID_IClassFactory))
86 IClassFactory_AddRef( iface );
87 *ppobj = iface;
88 return S_OK;
91 if (!IsEqualGUID(riid, &IID_IInternetProtocolInfo))
92 FIXME("interface %s not implemented\n", debugstr_guid(riid));
93 *ppobj = NULL;
94 return E_NOINTERFACE;
97 static ULONG WINAPI cf_AddRef( IClassFactory *iface )
99 return 2;
102 static ULONG WINAPI cf_Release( IClassFactory *iface )
104 return 1;
107 static HRESULT WINAPI cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
108 REFIID riid, LPVOID *ppobj )
110 cf *This = impl_from_IClassFactory( iface );
111 HRESULT r;
112 IUnknown *punk;
114 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
116 *ppobj = NULL;
118 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
119 return CLASS_E_NOAGGREGATION;
121 r = This->create_object( pOuter, (LPVOID*) &punk );
122 if (FAILED(r))
123 return r;
125 if (IsEqualGUID(&IID_IUnknown, riid)) {
126 *ppobj = punk;
127 return S_OK;
130 r = IUnknown_QueryInterface( punk, riid, ppobj );
131 IUnknown_Release( punk );
132 return r;
135 static HRESULT WINAPI cf_LockServer( IClassFactory *iface, BOOL dolock)
137 FIXME("(%p)->(%d),stub!\n",iface,dolock);
138 return S_OK;
141 static const struct IClassFactoryVtbl cf_vtbl =
143 cf_QueryInterface,
144 cf_AddRef,
145 cf_Release,
146 cf_CreateInstance,
147 cf_LockServer
150 static cf mime_body_cf = { { &cf_vtbl }, MimeBody_create };
151 static cf mime_allocator_cf = { { &cf_vtbl }, MimeAllocator_create };
152 static cf mime_message_cf = { { &cf_vtbl }, MimeMessage_create };
153 static cf mime_security_cf = { { &cf_vtbl }, MimeSecurity_create };
154 static cf virtual_stream_cf = { { &cf_vtbl }, VirtualStream_create };
155 static cf mhtml_protocol_cf = { { &cf_vtbl }, MimeHtmlProtocol_create };
157 /***********************************************************************
158 * DllGetClassObject (INETCOMM.@)
160 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
162 IClassFactory *cf = NULL;
164 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
166 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport))
167 return SMTPTransportCF_Create(iid, ppv);
169 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport2))
170 return SMTPTransportCF_Create(iid, ppv);
172 if (IsEqualCLSID(rclsid, &CLSID_IIMAPTransport))
173 return IMAPTransportCF_Create(iid, ppv);
175 if (IsEqualCLSID(rclsid, &CLSID_IPOP3Transport))
176 return POP3TransportCF_Create(iid, ppv);
178 if ( IsEqualCLSID( rclsid, &CLSID_IMimeSecurity ))
180 cf = &mime_security_cf.IClassFactory_iface;
182 else if( IsEqualCLSID( rclsid, &CLSID_IMimeMessage ))
184 cf = &mime_message_cf.IClassFactory_iface;
186 else if( IsEqualCLSID( rclsid, &CLSID_IMimeBody ))
188 cf = &mime_body_cf.IClassFactory_iface;
190 else if( IsEqualCLSID( rclsid, &CLSID_IMimeAllocator ))
192 cf = &mime_allocator_cf.IClassFactory_iface;
194 else if( IsEqualCLSID( rclsid, &CLSID_IVirtualStream ))
196 cf = &virtual_stream_cf.IClassFactory_iface;
198 else if( IsEqualCLSID( rclsid, &CLSID_IMimeHtmlProtocol ))
200 cf = &mhtml_protocol_cf.IClassFactory_iface;
203 if ( !cf )
205 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
206 return CLASS_E_CLASSNOTAVAILABLE;
209 return IClassFactory_QueryInterface( cf, iid, ppv );
212 /***********************************************************************
213 * DllCanUnloadNow (INETCOMM.@)
215 HRESULT WINAPI DllCanUnloadNow(void)
217 return S_FALSE;
220 /***********************************************************************
221 * DllRegisterServer (INETCOMM.@)
223 HRESULT WINAPI DllRegisterServer(void)
225 return __wine_register_resources( instance );
228 /***********************************************************************
229 * DllUnregisterServer (INETCOMM.@)
231 HRESULT WINAPI DllUnregisterServer(void)
233 return __wine_unregister_resources( instance );