1c2c66affSColin Finck /*
2c2c66affSColin Finck * MAPI basics
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2001, 2009 CodeWeavers Inc.
5c2c66affSColin Finck *
6c2c66affSColin Finck * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck * License as published by the Free Software Foundation; either
9c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck *
11c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14c2c66affSColin Finck * Lesser General Public License for more details.
15c2c66affSColin Finck *
16c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck */
20c2c66affSColin Finck
21*4dd96d42SAmine Khaldi #include <stdarg.h>
22*4dd96d42SAmine Khaldi
23*4dd96d42SAmine Khaldi #include "windef.h"
24*4dd96d42SAmine Khaldi #include "winbase.h"
25*4dd96d42SAmine Khaldi #include "winerror.h"
26*4dd96d42SAmine Khaldi #include "objbase.h"
27*4dd96d42SAmine Khaldi #include "initguid.h"
28*4dd96d42SAmine Khaldi #include "mapix.h"
29*4dd96d42SAmine Khaldi #include "mapiform.h"
30*4dd96d42SAmine Khaldi #include "mapi.h"
31*4dd96d42SAmine Khaldi #include "wine/debug.h"
32*4dd96d42SAmine Khaldi #include "util.h"
33*4dd96d42SAmine Khaldi
34*4dd96d42SAmine Khaldi WINE_DEFAULT_DEBUG_CHANNEL(mapi);
35c2c66affSColin Finck
36c2c66affSColin Finck DECLSPEC_HIDDEN LONG MAPI_ObjectCount = 0;
37c2c66affSColin Finck DECLSPEC_HIDDEN HINSTANCE hInstMAPI32;
38c2c66affSColin Finck
39c2c66affSColin Finck /***********************************************************************
40c2c66affSColin Finck * DllMain (MAPI32.init)
41c2c66affSColin Finck */
DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID fImpLoad)42c2c66affSColin Finck BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
43c2c66affSColin Finck {
44c2c66affSColin Finck TRACE("(%p,%d,%p)\n", hinstDLL, fdwReason, fImpLoad);
45c2c66affSColin Finck
46c2c66affSColin Finck switch (fdwReason)
47c2c66affSColin Finck {
48c2c66affSColin Finck case DLL_PROCESS_ATTACH:
49c2c66affSColin Finck hInstMAPI32 = hinstDLL;
50c2c66affSColin Finck DisableThreadLibraryCalls(hinstDLL);
51c2c66affSColin Finck load_mapi_providers();
52c2c66affSColin Finck break;
53c2c66affSColin Finck case DLL_PROCESS_DETACH:
54c2c66affSColin Finck if (fImpLoad) break;
55c2c66affSColin Finck TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount);
56c2c66affSColin Finck unload_mapi_providers();
57c2c66affSColin Finck break;
58c2c66affSColin Finck }
59c2c66affSColin Finck return TRUE;
60c2c66affSColin Finck }
61c2c66affSColin Finck
62c2c66affSColin Finck /***********************************************************************
63c2c66affSColin Finck * DllGetClassObject (MAPI32.27)
64c2c66affSColin Finck */
DllGetClassObject(REFCLSID rclsid,REFIID iid,LPVOID * ppv)65c2c66affSColin Finck HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
66c2c66affSColin Finck {
67c2c66affSColin Finck if (mapiFunctions.DllGetClassObject)
68c2c66affSColin Finck {
69c2c66affSColin Finck HRESULT ret = mapiFunctions.DllGetClassObject(rclsid, iid, ppv);
70c2c66affSColin Finck
71c2c66affSColin Finck TRACE("ret: %x\n", ret);
72c2c66affSColin Finck return ret;
73c2c66affSColin Finck }
74c2c66affSColin Finck
75c2c66affSColin Finck FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
76c2c66affSColin Finck
77c2c66affSColin Finck *ppv = NULL;
78c2c66affSColin Finck return CLASS_E_CLASSNOTAVAILABLE;
79c2c66affSColin Finck }
80c2c66affSColin Finck
81c2c66affSColin Finck /***********************************************************************
82c2c66affSColin Finck * DllCanUnloadNow (MAPI32.28)
83c2c66affSColin Finck *
84c2c66affSColin Finck * Determine if this dll can be unloaded from the callers address space.
85c2c66affSColin Finck *
86c2c66affSColin Finck * PARAMS
87c2c66affSColin Finck * None.
88c2c66affSColin Finck *
89c2c66affSColin Finck * RETURNS
90c2c66affSColin Finck * S_OK, if the dll can be unloaded,
91c2c66affSColin Finck * S_FALSE, otherwise.
92c2c66affSColin Finck */
DllCanUnloadNow(void)93c2c66affSColin Finck HRESULT WINAPI DllCanUnloadNow(void)
94c2c66affSColin Finck {
95c2c66affSColin Finck HRESULT ret = S_OK;
96c2c66affSColin Finck
97c2c66affSColin Finck if (mapiFunctions.DllCanUnloadNow)
98c2c66affSColin Finck {
99c2c66affSColin Finck ret = mapiFunctions.DllCanUnloadNow();
100c2c66affSColin Finck TRACE("(): provider returns %d\n", ret);
101c2c66affSColin Finck }
102c2c66affSColin Finck
103c2c66affSColin Finck return MAPI_ObjectCount == 0 ? ret : S_FALSE;
104c2c66affSColin Finck }
105c2c66affSColin Finck
106c2c66affSColin Finck /***********************************************************************
107c2c66affSColin Finck * MAPIInitialize
108c2c66affSColin Finck *
109c2c66affSColin Finck * Initialises the MAPI library. In our case, we pass through to the
110c2c66affSColin Finck * loaded Extended MAPI provider.
111c2c66affSColin Finck */
MAPIInitialize(LPVOID init)112c2c66affSColin Finck HRESULT WINAPI MAPIInitialize(LPVOID init)
113c2c66affSColin Finck {
114c2c66affSColin Finck TRACE("(%p)\n", init);
115c2c66affSColin Finck
116c2c66affSColin Finck if (mapiFunctions.MAPIInitialize)
117c2c66affSColin Finck return mapiFunctions.MAPIInitialize(init);
118c2c66affSColin Finck
119c2c66affSColin Finck return MAPI_E_NOT_INITIALIZED;
120c2c66affSColin Finck }
121c2c66affSColin Finck
122c2c66affSColin Finck /***********************************************************************
123c2c66affSColin Finck * MAPILogon
124c2c66affSColin Finck *
125c2c66affSColin Finck * Logs on to a MAPI provider. If available, we pass this through to a
126c2c66affSColin Finck * Simple MAPI provider. Otherwise, we maintain basic functionality
127c2c66affSColin Finck * ourselves.
128c2c66affSColin Finck */
MAPILogon(ULONG_PTR uiparam,LPSTR profile,LPSTR password,FLAGS flags,ULONG reserved,LPLHANDLE session)129c2c66affSColin Finck ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password,
130c2c66affSColin Finck FLAGS flags, ULONG reserved, LPLHANDLE session)
131c2c66affSColin Finck {
132c2c66affSColin Finck TRACE("(0x%08lx %s %p 0x%08x 0x%08x %p)\n", uiparam,
133c2c66affSColin Finck debugstr_a(profile), password, flags, reserved, session);
134c2c66affSColin Finck
135c2c66affSColin Finck if (mapiFunctions.MAPILogon)
136c2c66affSColin Finck return mapiFunctions.MAPILogon(uiparam, profile, password, flags, reserved, session);
137c2c66affSColin Finck
138c2c66affSColin Finck if (session) *session = 1;
139c2c66affSColin Finck return SUCCESS_SUCCESS;
140c2c66affSColin Finck }
141c2c66affSColin Finck
142c2c66affSColin Finck /***********************************************************************
143c2c66affSColin Finck * MAPILogoff
144c2c66affSColin Finck *
145c2c66affSColin Finck * Logs off from a MAPI provider. If available, we pass this through to a
146c2c66affSColin Finck * Simple MAPI provider. Otherwise, we maintain basic functionality
147c2c66affSColin Finck * ourselves.
148c2c66affSColin Finck */
MAPILogoff(LHANDLE session,ULONG_PTR uiparam,FLAGS flags,ULONG reserved)149c2c66affSColin Finck ULONG WINAPI MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags,
150c2c66affSColin Finck ULONG reserved )
151c2c66affSColin Finck {
152c2c66affSColin Finck TRACE("(0x%08lx 0x%08lx 0x%08x 0x%08x)\n", session,
153c2c66affSColin Finck uiparam, flags, reserved);
154c2c66affSColin Finck
155c2c66affSColin Finck if (mapiFunctions.MAPILogoff)
156c2c66affSColin Finck return mapiFunctions.MAPILogoff(session, uiparam, flags, reserved);
157c2c66affSColin Finck
158c2c66affSColin Finck return SUCCESS_SUCCESS;
159c2c66affSColin Finck }
160c2c66affSColin Finck
161c2c66affSColin Finck /***********************************************************************
162c2c66affSColin Finck * MAPILogonEx
163c2c66affSColin Finck *
164c2c66affSColin Finck * Logs on to a MAPI provider. If available, we pass this through to an
165c2c66affSColin Finck * Extended MAPI provider. Otherwise, we return an error.
166c2c66affSColin Finck */
MAPILogonEx(ULONG_PTR uiparam,LPWSTR profile,LPWSTR password,ULONG flags,LPMAPISESSION * session)167c2c66affSColin Finck HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
168c2c66affSColin Finck LPWSTR password, ULONG flags, LPMAPISESSION *session)
169c2c66affSColin Finck {
170c2c66affSColin Finck TRACE("(0x%08lx %s %p 0x%08x %p)\n", uiparam,
171c2c66affSColin Finck debugstr_w(profile), password, flags, session);
172c2c66affSColin Finck
173c2c66affSColin Finck if (mapiFunctions.MAPILogonEx)
174c2c66affSColin Finck return mapiFunctions.MAPILogonEx(uiparam, profile, password, flags, session);
175c2c66affSColin Finck
176c2c66affSColin Finck return E_FAIL;
177c2c66affSColin Finck }
178c2c66affSColin Finck
MAPIOpenLocalFormContainer(LPVOID * ppfcnt)179c2c66affSColin Finck HRESULT WINAPI MAPIOpenLocalFormContainer(LPVOID *ppfcnt)
180c2c66affSColin Finck {
181c2c66affSColin Finck if (mapiFunctions.MAPIOpenLocalFormContainer)
182c2c66affSColin Finck return mapiFunctions.MAPIOpenLocalFormContainer(ppfcnt);
183c2c66affSColin Finck
184c2c66affSColin Finck FIXME("(%p) Stub\n", ppfcnt);
185c2c66affSColin Finck return E_FAIL;
186c2c66affSColin Finck }
187c2c66affSColin Finck
188c2c66affSColin Finck /***********************************************************************
189c2c66affSColin Finck * MAPIUninitialize
190c2c66affSColin Finck *
191c2c66affSColin Finck * Uninitialises the MAPI library. In our case, we pass through to the
192c2c66affSColin Finck * loaded Extended MAPI provider.
193c2c66affSColin Finck *
194c2c66affSColin Finck */
MAPIUninitialize(void)195c2c66affSColin Finck VOID WINAPI MAPIUninitialize(void)
196c2c66affSColin Finck {
197c2c66affSColin Finck TRACE("()\n");
198c2c66affSColin Finck
199c2c66affSColin Finck /* Try to uninitialise the Extended MAPI library */
200c2c66affSColin Finck if (mapiFunctions.MAPIUninitialize)
201c2c66affSColin Finck mapiFunctions.MAPIUninitialize();
202c2c66affSColin Finck }
203c2c66affSColin Finck
MAPIAdminProfiles(ULONG ulFlags,LPPROFADMIN * lppProfAdmin)204c2c66affSColin Finck HRESULT WINAPI MAPIAdminProfiles(ULONG ulFlags, LPPROFADMIN *lppProfAdmin)
205c2c66affSColin Finck {
206c2c66affSColin Finck if (mapiFunctions.MAPIAdminProfiles)
207c2c66affSColin Finck return mapiFunctions.MAPIAdminProfiles(ulFlags, lppProfAdmin);
208c2c66affSColin Finck
209c2c66affSColin Finck FIXME("(%u, %p): stub\n", ulFlags, lppProfAdmin);
210c2c66affSColin Finck *lppProfAdmin = NULL;
211c2c66affSColin Finck return E_FAIL;
212c2c66affSColin Finck }
213c2c66affSColin Finck
MAPIAddress(LHANDLE session,ULONG_PTR uiparam,LPSTR caption,ULONG editfields,LPSTR labels,ULONG nRecips,lpMapiRecipDesc lpRecips,FLAGS flags,ULONG reserved,LPULONG newRecips,lpMapiRecipDesc * lppNewRecips)214c2c66affSColin Finck ULONG WINAPI MAPIAddress(LHANDLE session, ULONG_PTR uiparam, LPSTR caption,
215c2c66affSColin Finck ULONG editfields, LPSTR labels, ULONG nRecips, lpMapiRecipDesc lpRecips,
216c2c66affSColin Finck FLAGS flags, ULONG reserved, LPULONG newRecips, lpMapiRecipDesc * lppNewRecips)
217c2c66affSColin Finck {
218c2c66affSColin Finck if (mapiFunctions.MAPIAddress)
219c2c66affSColin Finck return mapiFunctions.MAPIAddress(session, uiparam, caption, editfields, labels,
220c2c66affSColin Finck nRecips, lpRecips, flags, reserved, newRecips, lppNewRecips);
221c2c66affSColin Finck
222c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
223c2c66affSColin Finck }
224c2c66affSColin Finck
MAPIDeleteMail(LHANDLE session,ULONG_PTR uiparam,LPSTR msg_id,FLAGS flags,ULONG reserved)225c2c66affSColin Finck ULONG WINAPI MAPIDeleteMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
226c2c66affSColin Finck FLAGS flags, ULONG reserved)
227c2c66affSColin Finck {
228c2c66affSColin Finck if (mapiFunctions.MAPIDeleteMail)
229c2c66affSColin Finck return mapiFunctions.MAPIDeleteMail(session, uiparam, msg_id, flags, reserved);
230c2c66affSColin Finck
231c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
232c2c66affSColin Finck }
233c2c66affSColin Finck
MAPIDetails(LHANDLE session,ULONG_PTR uiparam,lpMapiRecipDesc recip,FLAGS flags,ULONG reserved)234c2c66affSColin Finck ULONG WINAPI MAPIDetails(LHANDLE session, ULONG_PTR uiparam, lpMapiRecipDesc recip,
235c2c66affSColin Finck FLAGS flags, ULONG reserved)
236c2c66affSColin Finck {
237c2c66affSColin Finck if (mapiFunctions.MAPIDetails)
238c2c66affSColin Finck return mapiFunctions.MAPIDetails(session, uiparam, recip, flags, reserved);
239c2c66affSColin Finck
240c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
241c2c66affSColin Finck }
242c2c66affSColin Finck
MAPIFindNext(LHANDLE session,ULONG_PTR uiparam,LPSTR msg_type,LPSTR seed_msg_id,FLAGS flags,ULONG reserved,LPSTR msg_id)243c2c66affSColin Finck ULONG WINAPI MAPIFindNext(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_type,
244c2c66affSColin Finck LPSTR seed_msg_id, FLAGS flags, ULONG reserved, LPSTR msg_id)
245c2c66affSColin Finck {
246c2c66affSColin Finck if (mapiFunctions.MAPIFindNext)
247c2c66affSColin Finck return mapiFunctions.MAPIFindNext(session, uiparam, msg_type, seed_msg_id, flags, reserved, msg_id);
248c2c66affSColin Finck
249c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
250c2c66affSColin Finck }
251c2c66affSColin Finck
MAPIReadMail(LHANDLE session,ULONG_PTR uiparam,LPSTR msg_id,FLAGS flags,ULONG reserved,lpMapiMessage msg)252c2c66affSColin Finck ULONG WINAPI MAPIReadMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
253c2c66affSColin Finck FLAGS flags, ULONG reserved, lpMapiMessage msg)
254c2c66affSColin Finck {
255c2c66affSColin Finck if (mapiFunctions.MAPIReadMail)
256c2c66affSColin Finck return mapiFunctions.MAPIReadMail(session, uiparam, msg_id, flags, reserved, msg);
257c2c66affSColin Finck
258c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
259c2c66affSColin Finck }
260c2c66affSColin Finck
MAPIResolveName(LHANDLE session,ULONG_PTR uiparam,LPSTR name,FLAGS flags,ULONG reserved,lpMapiRecipDesc * recip)261c2c66affSColin Finck ULONG WINAPI MAPIResolveName(LHANDLE session, ULONG_PTR uiparam, LPSTR name,
262c2c66affSColin Finck FLAGS flags, ULONG reserved, lpMapiRecipDesc *recip)
263c2c66affSColin Finck {
264c2c66affSColin Finck if (mapiFunctions.MAPIResolveName)
265c2c66affSColin Finck return mapiFunctions.MAPIResolveName(session, uiparam, name, flags, reserved, recip);
266c2c66affSColin Finck
267c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
268c2c66affSColin Finck }
269c2c66affSColin Finck
MAPISaveMail(LHANDLE session,ULONG_PTR uiparam,lpMapiMessage msg,FLAGS flags,ULONG reserved,LPSTR msg_id)270c2c66affSColin Finck ULONG WINAPI MAPISaveMail(LHANDLE session, ULONG_PTR uiparam, lpMapiMessage msg,
271c2c66affSColin Finck FLAGS flags, ULONG reserved, LPSTR msg_id)
272c2c66affSColin Finck {
273c2c66affSColin Finck if (mapiFunctions.MAPISaveMail)
274c2c66affSColin Finck return mapiFunctions.MAPISaveMail(session, uiparam, msg, flags, reserved, msg_id);
275c2c66affSColin Finck
276c2c66affSColin Finck return MAPI_E_NOT_SUPPORTED;
277c2c66affSColin Finck }
278