include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / inetcomm / inetcomm_main.c
blobad02f210d9a2b736efae64df946c2139fd8e451e
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 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
43 static IMimeInternational *international;
45 TRACE("(%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
47 switch (fdwReason)
49 case DLL_PROCESS_ATTACH:
50 DisableThreadLibraryCalls(hinstDLL);
51 if (!InternetTransport_RegisterClass(hinstDLL))
52 return FALSE;
53 MimeInternational_Construct(&international);
54 break;
55 case DLL_PROCESS_DETACH:
56 if (lpvReserved) break;
57 IMimeInternational_Release(international);
58 InternetTransport_UnregisterClass(hinstDLL);
59 break;
61 return TRUE;
64 /******************************************************************************
65 * ClassFactory
67 typedef struct
69 IClassFactory IClassFactory_iface;
70 HRESULT (*create_object)(IUnknown *, void **);
71 } cf;
73 static inline cf *impl_from_IClassFactory( IClassFactory *iface )
75 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
78 static HRESULT WINAPI cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
80 if (IsEqualGUID(riid, &IID_IUnknown) ||
81 IsEqualGUID(riid, &IID_IClassFactory))
83 IClassFactory_AddRef( iface );
84 *ppobj = iface;
85 return S_OK;
88 if (!IsEqualGUID(riid, &IID_IInternetProtocolInfo))
89 FIXME("interface %s not implemented\n", debugstr_guid(riid));
90 *ppobj = NULL;
91 return E_NOINTERFACE;
94 static ULONG WINAPI cf_AddRef( IClassFactory *iface )
96 return 2;
99 static ULONG WINAPI cf_Release( IClassFactory *iface )
101 return 1;
104 static HRESULT WINAPI cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
105 REFIID riid, LPVOID *ppobj )
107 cf *This = impl_from_IClassFactory( iface );
108 HRESULT r;
109 IUnknown *punk;
111 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
113 *ppobj = NULL;
115 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
116 return CLASS_E_NOAGGREGATION;
118 r = This->create_object( pOuter, (LPVOID*) &punk );
119 if (FAILED(r))
120 return r;
122 if (IsEqualGUID(&IID_IUnknown, riid)) {
123 *ppobj = punk;
124 return S_OK;
127 r = IUnknown_QueryInterface( punk, riid, ppobj );
128 IUnknown_Release( punk );
129 return r;
132 static HRESULT WINAPI cf_LockServer( IClassFactory *iface, BOOL dolock)
134 FIXME("(%p)->(%d),stub!\n",iface,dolock);
135 return S_OK;
138 static const struct IClassFactoryVtbl cf_vtbl =
140 cf_QueryInterface,
141 cf_AddRef,
142 cf_Release,
143 cf_CreateInstance,
144 cf_LockServer
147 static cf mime_body_cf = { { &cf_vtbl }, MimeBody_create };
148 static cf mime_allocator_cf = { { &cf_vtbl }, MimeAllocator_create };
149 static cf mime_message_cf = { { &cf_vtbl }, MimeMessage_create };
150 static cf mime_security_cf = { { &cf_vtbl }, MimeSecurity_create };
151 static cf virtual_stream_cf = { { &cf_vtbl }, VirtualStream_create };
152 static cf mhtml_protocol_cf = { { &cf_vtbl }, MimeHtmlProtocol_create };
154 /***********************************************************************
155 * DllGetClassObject (INETCOMM.@)
157 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
159 IClassFactory *cf = NULL;
161 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
163 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport))
164 return SMTPTransportCF_Create(iid, ppv);
166 if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport2))
167 return SMTPTransportCF_Create(iid, ppv);
169 if (IsEqualCLSID(rclsid, &CLSID_IIMAPTransport))
170 return IMAPTransportCF_Create(iid, ppv);
172 if (IsEqualCLSID(rclsid, &CLSID_IPOP3Transport))
173 return POP3TransportCF_Create(iid, ppv);
175 if ( IsEqualCLSID( rclsid, &CLSID_IMimeSecurity ))
177 cf = &mime_security_cf.IClassFactory_iface;
179 else if( IsEqualCLSID( rclsid, &CLSID_IMimeMessage ))
181 cf = &mime_message_cf.IClassFactory_iface;
183 else if( IsEqualCLSID( rclsid, &CLSID_IMimeBody ))
185 cf = &mime_body_cf.IClassFactory_iface;
187 else if( IsEqualCLSID( rclsid, &CLSID_IMimeAllocator ))
189 cf = &mime_allocator_cf.IClassFactory_iface;
191 else if( IsEqualCLSID( rclsid, &CLSID_IVirtualStream ))
193 cf = &virtual_stream_cf.IClassFactory_iface;
195 else if( IsEqualCLSID( rclsid, &CLSID_IMimeHtmlProtocol ))
197 cf = &mhtml_protocol_cf.IClassFactory_iface;
200 if ( !cf )
202 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
203 return CLASS_E_CLASSNOTAVAILABLE;
206 return IClassFactory_QueryInterface( cf, iid, ppv );