ntoskrnl.exe: Reimplement KeSetTimerEx() on top of thread pool.
[wine.git] / dlls / mapi32 / mapi32_main.c
blobac830626795866f245d20e477044ba65b6fb2e3b
1 /*
2 * MAPI basics
4 * Copyright 2001, 2009 CodeWeavers Inc.
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 <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "objbase.h"
27 #include "initguid.h"
28 #include "mapix.h"
29 #include "mapiform.h"
30 #include "mapi.h"
31 #include "wine/debug.h"
32 #include "util.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
36 DECLSPEC_HIDDEN LONG MAPI_ObjectCount = 0;
37 DECLSPEC_HIDDEN HINSTANCE hInstMAPI32;
39 /***********************************************************************
40 * DllMain (MAPI32.init)
42 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
44 TRACE("(%p,%d,%p)\n", hinstDLL, fdwReason, fImpLoad);
46 switch (fdwReason)
48 case DLL_PROCESS_ATTACH:
49 hInstMAPI32 = hinstDLL;
50 DisableThreadLibraryCalls(hinstDLL);
51 load_mapi_providers();
52 break;
53 case DLL_PROCESS_DETACH:
54 if (fImpLoad) break;
55 TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount);
56 unload_mapi_providers();
57 break;
59 return TRUE;
62 /***********************************************************************
63 * DllGetClassObject (MAPI32.27)
65 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
67 if (mapiFunctions.DllGetClassObject)
69 HRESULT ret = mapiFunctions.DllGetClassObject(rclsid, iid, ppv);
71 TRACE("ret: %x\n", ret);
72 return ret;
75 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
77 *ppv = NULL;
78 return CLASS_E_CLASSNOTAVAILABLE;
81 /***********************************************************************
82 * DllCanUnloadNow (MAPI32.28)
84 * Determine if this dll can be unloaded from the callers address space.
86 * PARAMS
87 * None.
89 * RETURNS
90 * S_OK, if the dll can be unloaded,
91 * S_FALSE, otherwise.
93 HRESULT WINAPI DllCanUnloadNow(void)
95 HRESULT ret = S_OK;
97 if (mapiFunctions.DllCanUnloadNow)
99 ret = mapiFunctions.DllCanUnloadNow();
100 TRACE("(): provider returns %d\n", ret);
103 return MAPI_ObjectCount == 0 ? ret : S_FALSE;
106 /***********************************************************************
107 * MAPIInitialize
109 * Initialises the MAPI library. In our case, we pass through to the
110 * loaded Extended MAPI provider.
112 HRESULT WINAPI MAPIInitialize(LPVOID init)
114 TRACE("(%p)\n", init);
116 if (mapiFunctions.MAPIInitialize)
117 return mapiFunctions.MAPIInitialize(init);
119 return MAPI_E_NOT_INITIALIZED;
122 /***********************************************************************
123 * MAPILogon
125 * Logs on to a MAPI provider. If available, we pass this through to a
126 * Simple MAPI provider. Otherwise, we maintain basic functionality
127 * ourselves.
129 ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password,
130 FLAGS flags, ULONG reserved, LPLHANDLE session)
132 TRACE("(0x%08Ix %s %p 0x%08x 0x%08x %p)\n", uiparam,
133 debugstr_a(profile), password, flags, reserved, session);
135 if (mapiFunctions.MAPILogon)
136 return mapiFunctions.MAPILogon(uiparam, profile, password, flags, reserved, session);
138 if (session) *session = 1;
139 return SUCCESS_SUCCESS;
142 /***********************************************************************
143 * MAPILogoff
145 * Logs off from a MAPI provider. If available, we pass this through to a
146 * Simple MAPI provider. Otherwise, we maintain basic functionality
147 * ourselves.
149 ULONG WINAPI MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags,
150 ULONG reserved )
152 TRACE("(0x%08Ix 0x%08Ix 0x%08x 0x%08x)\n", session,
153 uiparam, flags, reserved);
155 if (mapiFunctions.MAPILogoff)
156 return mapiFunctions.MAPILogoff(session, uiparam, flags, reserved);
158 return SUCCESS_SUCCESS;
161 /***********************************************************************
162 * MAPILogonEx
164 * Logs on to a MAPI provider. If available, we pass this through to an
165 * Extended MAPI provider. Otherwise, we return an error.
167 HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
168 LPWSTR password, ULONG flags, LPMAPISESSION *session)
170 TRACE("(0x%08Ix %s %p 0x%08x %p)\n", uiparam,
171 debugstr_w(profile), password, flags, session);
173 if (mapiFunctions.MAPILogonEx)
174 return mapiFunctions.MAPILogonEx(uiparam, profile, password, flags, session);
176 return E_FAIL;
179 HRESULT WINAPI MAPIOpenLocalFormContainer(LPVOID *ppfcnt)
181 if (mapiFunctions.MAPIOpenLocalFormContainer)
182 return mapiFunctions.MAPIOpenLocalFormContainer(ppfcnt);
184 FIXME("(%p) Stub\n", ppfcnt);
185 return E_FAIL;
188 /***********************************************************************
189 * MAPIUninitialize
191 * Uninitialises the MAPI library. In our case, we pass through to the
192 * loaded Extended MAPI provider.
195 VOID WINAPI MAPIUninitialize(void)
197 TRACE("()\n");
199 /* Try to uninitialise the Extended MAPI library */
200 if (mapiFunctions.MAPIUninitialize)
201 mapiFunctions.MAPIUninitialize();
204 HRESULT WINAPI MAPIAdminProfiles(ULONG ulFlags, LPPROFADMIN *lppProfAdmin)
206 if (mapiFunctions.MAPIAdminProfiles)
207 return mapiFunctions.MAPIAdminProfiles(ulFlags, lppProfAdmin);
209 FIXME("(%u, %p): stub\n", ulFlags, lppProfAdmin);
210 *lppProfAdmin = NULL;
211 return E_FAIL;
214 ULONG WINAPI MAPIAddress(LHANDLE session, ULONG_PTR uiparam, LPSTR caption,
215 ULONG editfields, LPSTR labels, ULONG nRecips, lpMapiRecipDesc lpRecips,
216 FLAGS flags, ULONG reserved, LPULONG newRecips, lpMapiRecipDesc * lppNewRecips)
218 if (mapiFunctions.MAPIAddress)
219 return mapiFunctions.MAPIAddress(session, uiparam, caption, editfields, labels,
220 nRecips, lpRecips, flags, reserved, newRecips, lppNewRecips);
222 return MAPI_E_NOT_SUPPORTED;
225 ULONG WINAPI MAPIDeleteMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
226 FLAGS flags, ULONG reserved)
228 if (mapiFunctions.MAPIDeleteMail)
229 return mapiFunctions.MAPIDeleteMail(session, uiparam, msg_id, flags, reserved);
231 return MAPI_E_NOT_SUPPORTED;
234 ULONG WINAPI MAPIDetails(LHANDLE session, ULONG_PTR uiparam, lpMapiRecipDesc recip,
235 FLAGS flags, ULONG reserved)
237 if (mapiFunctions.MAPIDetails)
238 return mapiFunctions.MAPIDetails(session, uiparam, recip, flags, reserved);
240 return MAPI_E_NOT_SUPPORTED;
243 ULONG WINAPI MAPIFindNext(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_type,
244 LPSTR seed_msg_id, FLAGS flags, ULONG reserved, LPSTR msg_id)
246 if (mapiFunctions.MAPIFindNext)
247 return mapiFunctions.MAPIFindNext(session, uiparam, msg_type, seed_msg_id, flags, reserved, msg_id);
249 return MAPI_E_NOT_SUPPORTED;
252 ULONG WINAPI MAPIReadMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
253 FLAGS flags, ULONG reserved, lpMapiMessage msg)
255 if (mapiFunctions.MAPIReadMail)
256 return mapiFunctions.MAPIReadMail(session, uiparam, msg_id, flags, reserved, msg);
258 return MAPI_E_NOT_SUPPORTED;
261 ULONG WINAPI MAPIResolveName(LHANDLE session, ULONG_PTR uiparam, LPSTR name,
262 FLAGS flags, ULONG reserved, lpMapiRecipDesc *recip)
264 if (mapiFunctions.MAPIResolveName)
265 return mapiFunctions.MAPIResolveName(session, uiparam, name, flags, reserved, recip);
267 return MAPI_E_NOT_SUPPORTED;
270 ULONG WINAPI MAPISaveMail(LHANDLE session, ULONG_PTR uiparam, lpMapiMessage msg,
271 FLAGS flags, ULONG reserved, LPSTR msg_id)
273 if (mapiFunctions.MAPISaveMail)
274 return mapiFunctions.MAPISaveMail(session, uiparam, msg, flags, reserved, msg_id);
276 return MAPI_E_NOT_SUPPORTED;