push 6c2bed22d4a356b01aae243fbf554b5dba1af534
[wine/hacks.git] / dlls / mapi32 / mapi32_main.c
blob5039c2927070be5cf42cc044ec8a36837863f5ee
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 LONG MAPI_ObjectCount = 0;
38 /***********************************************************************
39 * DllMain (MAPI32.init)
41 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
43 TRACE("(%p,%d,%p)\n", hinstDLL, fdwReason, fImpLoad);
45 switch (fdwReason)
47 case DLL_PROCESS_ATTACH:
48 DisableThreadLibraryCalls(hinstDLL);
49 load_mapi_providers();
50 break;
51 case DLL_PROCESS_DETACH:
52 TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount);
53 unload_mapi_providers();
54 break;
56 return TRUE;
59 /***********************************************************************
60 * DllGetClassObject (MAPI32.27)
62 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
64 *ppv = NULL;
65 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
66 return CLASS_E_CLASSNOTAVAILABLE;
69 /***********************************************************************
70 * DllCanUnloadNow (MAPI32.28)
72 * Determine if this dll can be unloaded from the callers address space.
74 * PARAMS
75 * None.
77 * RETURNS
78 * S_OK, if the dll can be unloaded,
79 * S_FALSE, otherwise.
81 HRESULT WINAPI DllCanUnloadNow(void)
83 return MAPI_ObjectCount == 0 ? S_OK : S_FALSE;
86 /***********************************************************************
87 * MAPIInitialize
89 * Initialises the MAPI library. In our case, we pass through to the
90 * loaded Extended MAPI provider.
92 HRESULT WINAPI MAPIInitialize(LPVOID init)
94 TRACE("(%p)\n", init);
96 if (mapiFunctions.MAPIInitialize)
97 return mapiFunctions.MAPIInitialize(init);
99 return MAPI_E_NOT_INITIALIZED;
102 /***********************************************************************
103 * MAPILogon
105 * Logs on to a MAPI provider. If available, we pass this through to a
106 * Simple MAPI provider. Otherwise, we maintain basic functionality
107 * ourselves.
109 ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password,
110 FLAGS flags, ULONG reserved, LPLHANDLE session)
112 TRACE("(0x%08lx %s %p 0x%08x 0x%08x %p)\n", uiparam,
113 debugstr_a(profile), password, flags, reserved, session);
115 if (mapiFunctions.MAPILogon)
116 return mapiFunctions.MAPILogon(uiparam, profile, password, flags, reserved, session);
118 if (session) *session = 1;
119 return SUCCESS_SUCCESS;
122 /***********************************************************************
123 * MAPILogoff
125 * Logs off from 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 MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags,
130 ULONG reserved )
132 TRACE("(0x%08lx 0x%08lx 0x%08x 0x%08x)\n", session,
133 uiparam, flags, reserved);
135 if (mapiFunctions.MAPILogoff)
136 return mapiFunctions.MAPILogoff(session, uiparam, flags, reserved);
138 return SUCCESS_SUCCESS;
141 /***********************************************************************
142 * MAPILogonEx
144 * Logs on to a MAPI provider. If available, we pass this through to an
145 * Extended MAPI provider. Otherwise, we return an error.
147 HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
148 LPWSTR password, ULONG flags, LPMAPISESSION *session)
150 TRACE("(0x%08lx %s %p 0x%08x %p)\n", uiparam,
151 debugstr_w(profile), password, flags, session);
153 if (mapiFunctions.MAPILogonEx)
154 return mapiFunctions.MAPILogonEx(uiparam, profile, password, flags, session);
156 return E_FAIL;
159 HRESULT WINAPI MAPIOpenLocalFormContainer(LPVOID *ppfcnt)
161 FIXME("(%p) Stub\n", ppfcnt);
162 return E_FAIL;
165 /***********************************************************************
166 * MAPIUninitialize
168 * Uninitialises the MAPI library. In our case, we pass through to the
169 * loaded Extended MAPI provider.
172 VOID WINAPI MAPIUninitialize(void)
174 TRACE("()\n");
176 /* Try to uninitialise the Extended MAPI library */
177 if (mapiFunctions.MAPIUninitialize)
178 mapiFunctions.MAPIUninitialize();
181 HRESULT WINAPI MAPIAdminProfiles(ULONG ulFlags, LPPROFADMIN *lppProfAdmin)
183 FIXME("(%u, %p): stub\n", ulFlags, lppProfAdmin);
184 *lppProfAdmin = NULL;
185 return E_FAIL;
188 ULONG WINAPI MAPIAddress(LHANDLE session, ULONG_PTR uiparam, LPSTR caption,
189 ULONG editfields, LPSTR labels, ULONG nRecips, lpMapiRecipDesc lpRecips,
190 FLAGS flags, ULONG reserved, LPULONG newRecips, lpMapiRecipDesc * lppNewRecips)
192 if (mapiFunctions.MAPIAddress)
193 return mapiFunctions.MAPIAddress(session, uiparam, caption, editfields, labels,
194 nRecips, lpRecips, flags, reserved, newRecips, lppNewRecips);
196 return MAPI_E_NOT_SUPPORTED;
199 ULONG WINAPI MAPIDeleteMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
200 FLAGS flags, ULONG reserved)
202 if (mapiFunctions.MAPIDeleteMail)
203 return mapiFunctions.MAPIDeleteMail(session, uiparam, msg_id, flags, reserved);
205 return MAPI_E_NOT_SUPPORTED;
208 ULONG WINAPI MAPIDetails(LHANDLE session, ULONG_PTR uiparam, lpMapiRecipDesc recip,
209 FLAGS flags, ULONG reserved)
211 if (mapiFunctions.MAPIDetails)
212 return mapiFunctions.MAPIDetails(session, uiparam, recip, flags, reserved);
214 return MAPI_E_NOT_SUPPORTED;
217 ULONG WINAPI MAPIFindNext(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_type,
218 LPSTR seed_msg_id, FLAGS flags, ULONG reserved, LPSTR msg_id)
220 if (mapiFunctions.MAPIFindNext)
221 return mapiFunctions.MAPIFindNext(session, uiparam, msg_type, seed_msg_id, flags, reserved, msg_id);
223 return MAPI_E_NOT_SUPPORTED;
226 ULONG WINAPI MAPIReadMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
227 FLAGS flags, ULONG reserved, lpMapiMessage msg)
229 if (mapiFunctions.MAPIReadMail)
230 return mapiFunctions.MAPIReadMail(session, uiparam, msg_id, flags, reserved, msg);
232 return MAPI_E_NOT_SUPPORTED;
235 ULONG WINAPI MAPIResolveName(LHANDLE session, ULONG_PTR uiparam, LPSTR name,
236 FLAGS flags, ULONG reserved, lpMapiRecipDesc *recip)
238 if (mapiFunctions.MAPIResolveName)
239 return mapiFunctions.MAPIResolveName(session, uiparam, name, flags, reserved, recip);
241 return MAPI_E_NOT_SUPPORTED;
244 ULONG WINAPI MAPISaveMail(LHANDLE session, ULONG_PTR uiparam, lpMapiMessage msg,
245 FLAGS flags, ULONG reserved, LPSTR msg_id)
247 if (mapiFunctions.MAPISaveMail)
248 return mapiFunctions.MAPISaveMail(session, uiparam, msg, flags, reserved, msg_id);
250 return MAPI_E_NOT_SUPPORTED;