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 #include "inetcomm_private.h"
25 static HINSTANCE instance
;
27 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
29 static IMimeInternational
*international
;
31 TRACE("(%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
35 case DLL_WINE_PREATTACH
:
37 case DLL_PROCESS_ATTACH
:
38 DisableThreadLibraryCalls(hinstDLL
);
40 if (!InternetTransport_RegisterClass(hinstDLL
))
42 MimeInternational_Construct(&international
);
44 case DLL_PROCESS_DETACH
:
45 if (lpvReserved
) break;
46 IMimeInternational_Release(international
);
47 InternetTransport_UnregisterClass(hinstDLL
);
53 /******************************************************************************
58 IClassFactory IClassFactory_iface
;
59 HRESULT (*create_object
)(IUnknown
*, void **);
62 static inline cf
*impl_from_IClassFactory( IClassFactory
*iface
)
64 return CONTAINING_RECORD(iface
, cf
, IClassFactory_iface
);
67 static HRESULT WINAPI
cf_QueryInterface( IClassFactory
*iface
, REFIID riid
, LPVOID
*ppobj
)
69 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
70 IsEqualGUID(riid
, &IID_IClassFactory
))
72 IClassFactory_AddRef( iface
);
77 if (!IsEqualGUID(riid
, &IID_IInternetProtocolInfo
))
78 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
83 static ULONG WINAPI
cf_AddRef( IClassFactory
*iface
)
88 static ULONG WINAPI
cf_Release( IClassFactory
*iface
)
93 static HRESULT WINAPI
cf_CreateInstance( IClassFactory
*iface
, LPUNKNOWN pOuter
,
94 REFIID riid
, LPVOID
*ppobj
)
96 cf
*This
= impl_from_IClassFactory( iface
);
100 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
104 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
105 return CLASS_E_NOAGGREGATION
;
107 r
= This
->create_object( pOuter
, (LPVOID
*) &punk
);
111 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
116 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
117 IUnknown_Release( punk
);
121 static HRESULT WINAPI
cf_LockServer( IClassFactory
*iface
, BOOL dolock
)
123 FIXME("(%p)->(%d),stub!\n",iface
,dolock
);
127 static const struct IClassFactoryVtbl cf_vtbl
=
136 static cf mime_body_cf
= { { &cf_vtbl
}, MimeBody_create
};
137 static cf mime_allocator_cf
= { { &cf_vtbl
}, MimeAllocator_create
};
138 static cf mime_message_cf
= { { &cf_vtbl
}, MimeMessage_create
};
139 static cf mime_security_cf
= { { &cf_vtbl
}, MimeSecurity_create
};
140 static cf virtual_stream_cf
= { { &cf_vtbl
}, VirtualStream_create
};
141 static cf mhtml_protocol_cf
= { { &cf_vtbl
}, MimeHtmlProtocol_create
};
143 /***********************************************************************
144 * DllGetClassObject (INETCOMM.@)
146 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
148 IClassFactory
*cf
= NULL
;
150 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
152 if (IsEqualCLSID(rclsid
, &CLSID_ISMTPTransport
))
153 return SMTPTransportCF_Create(iid
, ppv
);
155 if (IsEqualCLSID(rclsid
, &CLSID_ISMTPTransport2
))
156 return SMTPTransportCF_Create(iid
, ppv
);
158 if (IsEqualCLSID(rclsid
, &CLSID_IIMAPTransport
))
159 return IMAPTransportCF_Create(iid
, ppv
);
161 if (IsEqualCLSID(rclsid
, &CLSID_IPOP3Transport
))
162 return POP3TransportCF_Create(iid
, ppv
);
164 if ( IsEqualCLSID( rclsid
, &CLSID_IMimeSecurity
))
166 cf
= &mime_security_cf
.IClassFactory_iface
;
168 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeMessage
))
170 cf
= &mime_message_cf
.IClassFactory_iface
;
172 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeBody
))
174 cf
= &mime_body_cf
.IClassFactory_iface
;
176 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeAllocator
))
178 cf
= &mime_allocator_cf
.IClassFactory_iface
;
180 else if( IsEqualCLSID( rclsid
, &CLSID_IVirtualStream
))
182 cf
= &virtual_stream_cf
.IClassFactory_iface
;
184 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeHtmlProtocol
))
186 cf
= &mhtml_protocol_cf
.IClassFactory_iface
;
191 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid
),debugstr_guid(iid
));
192 return CLASS_E_CLASSNOTAVAILABLE
;
195 return IClassFactory_QueryInterface( cf
, iid
, ppv
);
198 /***********************************************************************
199 * DllCanUnloadNow (INETCOMM.@)
201 HRESULT WINAPI
DllCanUnloadNow(void)
206 /***********************************************************************
207 * DllRegisterServer (INETCOMM.@)
209 HRESULT WINAPI
DllRegisterServer(void)
211 return __wine_register_resources( instance
);
214 /***********************************************************************
215 * DllUnregisterServer (INETCOMM.@)
217 HRESULT WINAPI
DllUnregisterServer(void)
219 return __wine_unregister_resources( instance
);