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
31 #include "wine/debug.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
);
47 case DLL_PROCESS_ATTACH
:
48 DisableThreadLibraryCalls(hinstDLL
);
49 load_mapi_providers();
51 case DLL_PROCESS_DETACH
:
52 TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount
);
53 unload_mapi_providers();
59 /***********************************************************************
60 * DllGetClassObject (MAPI32.27)
62 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
64 if (mapiFunctions
.DllGetClassObject
)
66 HRESULT ret
= mapiFunctions
.DllGetClassObject(rclsid
, iid
, ppv
);
68 TRACE("ret: %x\n", ret
);
72 FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid
), debugstr_guid(iid
));
75 return CLASS_E_CLASSNOTAVAILABLE
;
78 /***********************************************************************
79 * DllCanUnloadNow (MAPI32.28)
81 * Determine if this dll can be unloaded from the callers address space.
87 * S_OK, if the dll can be unloaded,
90 HRESULT WINAPI
DllCanUnloadNow(void)
94 if (mapiFunctions
.DllCanUnloadNow
)
96 ret
= mapiFunctions
.DllCanUnloadNow();
97 TRACE("(): provider returns %d\n", ret
);
100 return MAPI_ObjectCount
== 0 ? ret
: S_FALSE
;
103 /***********************************************************************
106 * Initialises the MAPI library. In our case, we pass through to the
107 * loaded Extended MAPI provider.
109 HRESULT WINAPI
MAPIInitialize(LPVOID init
)
111 TRACE("(%p)\n", init
);
113 if (mapiFunctions
.MAPIInitialize
)
114 return mapiFunctions
.MAPIInitialize(init
);
116 return MAPI_E_NOT_INITIALIZED
;
119 /***********************************************************************
122 * Logs on to a MAPI provider. If available, we pass this through to a
123 * Simple MAPI provider. Otherwise, we maintain basic functionality
126 ULONG WINAPI
MAPILogon(ULONG_PTR uiparam
, LPSTR profile
, LPSTR password
,
127 FLAGS flags
, ULONG reserved
, LPLHANDLE session
)
129 TRACE("(0x%08lx %s %p 0x%08x 0x%08x %p)\n", uiparam
,
130 debugstr_a(profile
), password
, flags
, reserved
, session
);
132 if (mapiFunctions
.MAPILogon
)
133 return mapiFunctions
.MAPILogon(uiparam
, profile
, password
, flags
, reserved
, session
);
135 if (session
) *session
= 1;
136 return SUCCESS_SUCCESS
;
139 /***********************************************************************
142 * Logs off from a MAPI provider. If available, we pass this through to a
143 * Simple MAPI provider. Otherwise, we maintain basic functionality
146 ULONG WINAPI
MAPILogoff(LHANDLE session
, ULONG_PTR uiparam
, FLAGS flags
,
149 TRACE("(0x%08lx 0x%08lx 0x%08x 0x%08x)\n", session
,
150 uiparam
, flags
, reserved
);
152 if (mapiFunctions
.MAPILogoff
)
153 return mapiFunctions
.MAPILogoff(session
, uiparam
, flags
, reserved
);
155 return SUCCESS_SUCCESS
;
158 /***********************************************************************
161 * Logs on to a MAPI provider. If available, we pass this through to an
162 * Extended MAPI provider. Otherwise, we return an error.
164 HRESULT WINAPI
MAPILogonEx(ULONG_PTR uiparam
, LPWSTR profile
,
165 LPWSTR password
, ULONG flags
, LPMAPISESSION
*session
)
167 TRACE("(0x%08lx %s %p 0x%08x %p)\n", uiparam
,
168 debugstr_w(profile
), password
, flags
, session
);
170 if (mapiFunctions
.MAPILogonEx
)
171 return mapiFunctions
.MAPILogonEx(uiparam
, profile
, password
, flags
, session
);
176 HRESULT WINAPI
MAPIOpenLocalFormContainer(LPVOID
*ppfcnt
)
178 if (mapiFunctions
.MAPIOpenLocalFormContainer
)
179 return mapiFunctions
.MAPIOpenLocalFormContainer(ppfcnt
);
181 FIXME("(%p) Stub\n", ppfcnt
);
185 /***********************************************************************
188 * Uninitialises the MAPI library. In our case, we pass through to the
189 * loaded Extended MAPI provider.
192 VOID WINAPI
MAPIUninitialize(void)
196 /* Try to uninitialise the Extended MAPI library */
197 if (mapiFunctions
.MAPIUninitialize
)
198 mapiFunctions
.MAPIUninitialize();
201 HRESULT WINAPI
MAPIAdminProfiles(ULONG ulFlags
, LPPROFADMIN
*lppProfAdmin
)
203 if (mapiFunctions
.MAPIAdminProfiles
)
204 return mapiFunctions
.MAPIAdminProfiles(ulFlags
, lppProfAdmin
);
206 FIXME("(%u, %p): stub\n", ulFlags
, lppProfAdmin
);
207 *lppProfAdmin
= NULL
;
211 ULONG WINAPI
MAPIAddress(LHANDLE session
, ULONG_PTR uiparam
, LPSTR caption
,
212 ULONG editfields
, LPSTR labels
, ULONG nRecips
, lpMapiRecipDesc lpRecips
,
213 FLAGS flags
, ULONG reserved
, LPULONG newRecips
, lpMapiRecipDesc
* lppNewRecips
)
215 if (mapiFunctions
.MAPIAddress
)
216 return mapiFunctions
.MAPIAddress(session
, uiparam
, caption
, editfields
, labels
,
217 nRecips
, lpRecips
, flags
, reserved
, newRecips
, lppNewRecips
);
219 return MAPI_E_NOT_SUPPORTED
;
222 ULONG WINAPI
MAPIDeleteMail(LHANDLE session
, ULONG_PTR uiparam
, LPSTR msg_id
,
223 FLAGS flags
, ULONG reserved
)
225 if (mapiFunctions
.MAPIDeleteMail
)
226 return mapiFunctions
.MAPIDeleteMail(session
, uiparam
, msg_id
, flags
, reserved
);
228 return MAPI_E_NOT_SUPPORTED
;
231 ULONG WINAPI
MAPIDetails(LHANDLE session
, ULONG_PTR uiparam
, lpMapiRecipDesc recip
,
232 FLAGS flags
, ULONG reserved
)
234 if (mapiFunctions
.MAPIDetails
)
235 return mapiFunctions
.MAPIDetails(session
, uiparam
, recip
, flags
, reserved
);
237 return MAPI_E_NOT_SUPPORTED
;
240 ULONG WINAPI
MAPIFindNext(LHANDLE session
, ULONG_PTR uiparam
, LPSTR msg_type
,
241 LPSTR seed_msg_id
, FLAGS flags
, ULONG reserved
, LPSTR msg_id
)
243 if (mapiFunctions
.MAPIFindNext
)
244 return mapiFunctions
.MAPIFindNext(session
, uiparam
, msg_type
, seed_msg_id
, flags
, reserved
, msg_id
);
246 return MAPI_E_NOT_SUPPORTED
;
249 ULONG WINAPI
MAPIReadMail(LHANDLE session
, ULONG_PTR uiparam
, LPSTR msg_id
,
250 FLAGS flags
, ULONG reserved
, lpMapiMessage msg
)
252 if (mapiFunctions
.MAPIReadMail
)
253 return mapiFunctions
.MAPIReadMail(session
, uiparam
, msg_id
, flags
, reserved
, msg
);
255 return MAPI_E_NOT_SUPPORTED
;
258 ULONG WINAPI
MAPIResolveName(LHANDLE session
, ULONG_PTR uiparam
, LPSTR name
,
259 FLAGS flags
, ULONG reserved
, lpMapiRecipDesc
*recip
)
261 if (mapiFunctions
.MAPIResolveName
)
262 return mapiFunctions
.MAPIResolveName(session
, uiparam
, name
, flags
, reserved
, recip
);
264 return MAPI_E_NOT_SUPPORTED
;
267 ULONG WINAPI
MAPISaveMail(LHANDLE session
, ULONG_PTR uiparam
, lpMapiMessage msg
,
268 FLAGS flags
, ULONG reserved
, LPSTR msg_id
)
270 if (mapiFunctions
.MAPISaveMail
)
271 return mapiFunctions
.MAPISaveMail(session
, uiparam
, msg
, flags
, reserved
, msg_id
);
273 return MAPI_E_NOT_SUPPORTED
;