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
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
);
51 case DLL_WINE_PREATTACH
:
53 case DLL_PROCESS_ATTACH
:
54 DisableThreadLibraryCalls(hinstDLL
);
56 if (!InternetTransport_RegisterClass(hinstDLL
))
58 MimeInternational_Construct(&international
);
60 case DLL_PROCESS_DETACH
:
61 if (lpvReserved
) break;
62 IMimeInternational_Release(international
);
63 InternetTransport_UnregisterClass(hinstDLL
);
69 /******************************************************************************
74 IClassFactory IClassFactory_iface
;
75 HRESULT (*create_object
)(IUnknown
*, void **);
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
);
93 if (!IsEqualGUID(riid
, &IID_IInternetProtocolInfo
))
94 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
99 static ULONG WINAPI
cf_AddRef( IClassFactory
*iface
)
104 static ULONG WINAPI
cf_Release( IClassFactory
*iface
)
109 static HRESULT WINAPI
cf_CreateInstance( IClassFactory
*iface
, LPUNKNOWN pOuter
,
110 REFIID riid
, LPVOID
*ppobj
)
112 cf
*This
= impl_from_IClassFactory( iface
);
116 TRACE("%p %s %p\n", pOuter
, debugstr_guid(riid
), ppobj
);
120 if (pOuter
&& !IsEqualGUID(&IID_IUnknown
, riid
))
121 return CLASS_E_NOAGGREGATION
;
123 r
= This
->create_object( pOuter
, (LPVOID
*) &punk
);
127 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
132 r
= IUnknown_QueryInterface( punk
, riid
, ppobj
);
133 IUnknown_Release( punk
);
137 static HRESULT WINAPI
cf_LockServer( IClassFactory
*iface
, BOOL dolock
)
139 FIXME("(%p)->(%d),stub!\n",iface
,dolock
);
143 static const struct IClassFactoryVtbl cf_vtbl
=
152 static cf mime_body_cf
= { { &cf_vtbl
}, MimeBody_create
};
153 static cf mime_allocator_cf
= { { &cf_vtbl
}, MimeAllocator_create
};
154 static cf mime_message_cf
= { { &cf_vtbl
}, MimeMessage_create
};
155 static cf mime_security_cf
= { { &cf_vtbl
}, MimeSecurity_create
};
156 static cf virtual_stream_cf
= { { &cf_vtbl
}, VirtualStream_create
};
157 static cf mhtml_protocol_cf
= { { &cf_vtbl
}, MimeHtmlProtocol_create
};
159 /***********************************************************************
160 * DllGetClassObject (INETCOMM.@)
162 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
164 IClassFactory
*cf
= NULL
;
166 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
168 if (IsEqualCLSID(rclsid
, &CLSID_ISMTPTransport
))
169 return SMTPTransportCF_Create(iid
, ppv
);
171 if (IsEqualCLSID(rclsid
, &CLSID_ISMTPTransport2
))
172 return SMTPTransportCF_Create(iid
, ppv
);
174 if (IsEqualCLSID(rclsid
, &CLSID_IIMAPTransport
))
175 return IMAPTransportCF_Create(iid
, ppv
);
177 if (IsEqualCLSID(rclsid
, &CLSID_IPOP3Transport
))
178 return POP3TransportCF_Create(iid
, ppv
);
180 if ( IsEqualCLSID( rclsid
, &CLSID_IMimeSecurity
))
182 cf
= &mime_security_cf
.IClassFactory_iface
;
184 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeMessage
))
186 cf
= &mime_message_cf
.IClassFactory_iface
;
188 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeBody
))
190 cf
= &mime_body_cf
.IClassFactory_iface
;
192 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeAllocator
))
194 cf
= &mime_allocator_cf
.IClassFactory_iface
;
196 else if( IsEqualCLSID( rclsid
, &CLSID_IVirtualStream
))
198 cf
= &virtual_stream_cf
.IClassFactory_iface
;
200 else if( IsEqualCLSID( rclsid
, &CLSID_IMimeHtmlProtocol
))
202 cf
= &mhtml_protocol_cf
.IClassFactory_iface
;
207 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid
),debugstr_guid(iid
));
208 return CLASS_E_CLASSNOTAVAILABLE
;
211 return IClassFactory_QueryInterface( cf
, iid
, ppv
);
214 /***********************************************************************
215 * DllCanUnloadNow (INETCOMM.@)
217 HRESULT WINAPI
DllCanUnloadNow(void)
222 /***********************************************************************
223 * DllRegisterServer (INETCOMM.@)
225 HRESULT WINAPI
DllRegisterServer(void)
227 return __wine_register_resources( instance
);
230 /***********************************************************************
231 * DllUnregisterServer (INETCOMM.@)
233 HRESULT WINAPI
DllUnregisterServer(void)
235 return __wine_unregister_resources( instance
);