ReactOS  0.4.14-dev-593-g1793dcc
inetcomm_main.c
Go to the documentation of this file.
1 /*
2  * Internet Messaging APIs
3  *
4  * Copyright 2006 Robert Shearman for CodeWeavers
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #define COBJMACROS
22 
23 #include <stdarg.h>
24 
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"
34 
35 #include "inetcomm_private.h"
36 
37 #include "wine/debug.h"
38 
40 
42 
44 {
45  static IMimeInternational *international;
46 
47  TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
48 
49  switch (fdwReason)
50  {
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);
64  break;
65  }
66  return TRUE;
67 }
68 
69 /******************************************************************************
70  * ClassFactory
71  */
72 typedef struct
73 {
75  HRESULT (*create_object)(IUnknown *, void **);
76 } cf;
77 
78 static inline cf *impl_from_IClassFactory( IClassFactory *iface )
79 {
80  return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
81 }
82 
84 {
85  if (IsEqualGUID(riid, &IID_IUnknown) ||
87  {
88  IClassFactory_AddRef( iface );
89  *ppobj = iface;
90  return S_OK;
91  }
92 
93  if (!IsEqualGUID(riid, &IID_IInternetProtocolInfo))
94  FIXME("interface %s not implemented\n", debugstr_guid(riid));
95  *ppobj = NULL;
96  return E_NOINTERFACE;
97 }
98 
100 {
101  return 2;
102 }
103 
105 {
106  return 1;
107 }
108 
110  REFIID riid, LPVOID *ppobj )
111 {
112  cf *This = impl_from_IClassFactory( iface );
113  HRESULT r;
114  IUnknown *punk;
115 
116  TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
117 
118  *ppobj = NULL;
119 
120  if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
121  return CLASS_E_NOAGGREGATION;
122 
123  r = This->create_object( pOuter, (LPVOID*) &punk );
124  if (FAILED(r))
125  return r;
126 
127  if (IsEqualGUID(&IID_IUnknown, riid)) {
128  *ppobj = punk;
129  return S_OK;
130  }
131 
132  r = IUnknown_QueryInterface( punk, riid, ppobj );
133  IUnknown_Release( punk );
134  return r;
135 }
136 
138 {
139  FIXME("(%p)->(%d),stub!\n",iface,dolock);
140  return S_OK;
141 }
142 
143 static const struct IClassFactoryVtbl cf_vtbl =
144 {
146  cf_AddRef,
147  cf_Release,
150 };
151 
158 
159 /***********************************************************************
160  * DllGetClassObject (INETCOMM.@)
161  */
163 {
164  IClassFactory *cf = NULL;
165 
166  TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
167 
168  if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport))
169  return SMTPTransportCF_Create(iid, ppv);
170 
171  if (IsEqualCLSID(rclsid, &CLSID_ISMTPTransport2))
172  return SMTPTransportCF_Create(iid, ppv);
173 
174  if (IsEqualCLSID(rclsid, &CLSID_IIMAPTransport))
175  return IMAPTransportCF_Create(iid, ppv);
176 
177  if (IsEqualCLSID(rclsid, &CLSID_IPOP3Transport))
178  return POP3TransportCF_Create(iid, ppv);
179 
180  if ( IsEqualCLSID( rclsid, &CLSID_IMimeSecurity ))
181  {
183  }
184  else if( IsEqualCLSID( rclsid, &CLSID_IMimeMessage ))
185  {
187  }
188  else if( IsEqualCLSID( rclsid, &CLSID_IMimeBody ))
189  {
191  }
192  else if( IsEqualCLSID( rclsid, &CLSID_IMimeAllocator ))
193  {
195  }
196  else if( IsEqualCLSID( rclsid, &CLSID_IVirtualStream ))
197  {
199  }
200  else if( IsEqualCLSID( rclsid, &CLSID_IMimeHtmlProtocol ))
201  {
203  }
204 
205  if ( !cf )
206  {
207  FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
209  }
210 
211  return IClassFactory_QueryInterface( cf, iid, ppv );
212 }
213 
214 /***********************************************************************
215  * DllCanUnloadNow (INETCOMM.@)
216  */
218 {
219  return S_FALSE;
220 }
221 
222 /***********************************************************************
223  * DllRegisterServer (INETCOMM.@)
224  */
226 {
228 }
229 
230 /***********************************************************************
231  * DllUnregisterServer (INETCOMM.@)
232  */
234 {
236 }
static IClassFactory * cf
#define HRESULT
Definition: msvc.h:7
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
IClassFactory IClassFactory_iface
Definition: inetcomm_main.c:74
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
HRESULT MimeHtmlProtocol_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: protocol.c:729
static cf mime_message_cf
REFIID riid
Definition: precomp.h:44
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define REFCLSID
Definition: guiddef.h:117
HRESULT POP3TransportCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
void InternetTransport_UnregisterClass(HINSTANCE hInstance) DECLSPEC_HIDDEN
static cf mime_security_cf
HRESULT MimeSecurity_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: mimeole.c:3310
HRESULT IMAPTransportCF_Create(REFIID riid, LPVOID *ppv)
HRESULT MimeInternational_Construct(IMimeInternational **internat) DECLSPEC_HIDDEN
Definition: mimeintl.c:525
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static cf mime_allocator_cf
static IN DWORD IN LPVOID lpvReserved
static ULONG WINAPI cf_AddRef(IClassFactory *iface)
Definition: inetcomm_main.c:99
HRESULT WINAPI DllRegisterServer(void)
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPUNKNOWN
Definition: ndr_ole.c:49
static HRESULT WINAPI cf_LockServer(IClassFactory *iface, BOOL dolock)
#define FIXME(fmt,...)
Definition: debug.h:110
static cf mhtml_protocol_cf
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
static HINSTANCE instance
Definition: inetcomm_main.c:41
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static cf mime_body_cf
static HRESULT WINAPI cf_CreateInstance(IClassFactory *iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
#define DLL_PROCESS_DETACH
Definition: compat.h:119
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI DllCanUnloadNow(void)
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT MimeBody_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: mimeole.c:1920
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: inetcomm_main.c:43
HRESULT VirtualStream_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: mimeole.c:3535
HRESULT MimeAllocator_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: mimeole.c:3522
static cf virtual_stream_cf
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
HRESULT WINAPI DllUnregisterServer(void)
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static const struct IClassFactoryVtbl cf_vtbl
static HRESULT WINAPI cf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppobj)
Definition: inetcomm_main.c:83
BOOL InternetTransport_RegisterClass(HINSTANCE hInstance) DECLSPEC_HIDDEN
unsigned int ULONG
Definition: retypes.h:1
static ULONG WINAPI cf_Release(IClassFactory *iface)
HRESULT create_object(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:731
HRESULT SMTPTransportCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN
WINE_DEFAULT_DEBUG_CHANNEL(inetcomm)
static cf * impl_from_IClassFactory(IClassFactory *iface)
Definition: inetcomm_main.c:78
const GUID IID_IClassFactory
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
HRESULT MimeMessage_create(IUnknown *outer, void **obj) DECLSPEC_HIDDEN
Definition: mimeole.c:3085