2006-02-17 00:04:10 +00:00
|
|
|
/*
|
|
|
|
* MAPI basics
|
|
|
|
*
|
2009-10-20 21:40:47 +00:00
|
|
|
* Copyright 2001, 2009 CodeWeavers Inc.
|
2006-02-17 00:04:10 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-07-04 12:05:13 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-17 00:04:10 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-17 12:16:08 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "mapix.h"
|
|
|
|
#include "mapiform.h"
|
|
|
|
#include "mapi.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mapi);
|
2013-01-24 23:00:42 +00:00
|
|
|
|
2013-09-21 12:53:07 +00:00
|
|
|
DECLSPEC_HIDDEN LONG MAPI_ObjectCount = 0;
|
|
|
|
DECLSPEC_HIDDEN HINSTANCE hInstMAPI32;
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllMain (MAPI32.init)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
|
|
|
{
|
2006-11-26 21:19:02 +00:00
|
|
|
TRACE("(%p,%d,%p)\n", hinstDLL, fdwReason, fImpLoad);
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2010-03-05 18:40:20 +00:00
|
|
|
hInstMAPI32 = hinstDLL;
|
2006-02-17 00:04:10 +00:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
2009-10-20 21:40:47 +00:00
|
|
|
load_mapi_providers();
|
2006-02-17 00:04:10 +00:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2013-09-21 12:53:07 +00:00
|
|
|
if (fImpLoad) break;
|
2006-11-26 21:19:02 +00:00
|
|
|
TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount);
|
2009-10-20 21:40:47 +00:00
|
|
|
unload_mapi_providers();
|
2006-02-17 00:04:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-29 10:48:07 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (MAPI32.27)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
|
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
if (mapiFunctions.DllGetClassObject)
|
|
|
|
{
|
|
|
|
HRESULT ret = mapiFunctions.DllGetClassObject(rclsid, iid, ppv);
|
|
|
|
|
|
|
|
TRACE("ret: %x\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-29 10:48:07 +00:00
|
|
|
FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
|
2009-10-20 21:40:47 +00:00
|
|
|
|
|
|
|
*ppv = NULL;
|
2007-11-29 10:48:07 +00:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2006-02-17 00:04:10 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (MAPI32.28)
|
|
|
|
*
|
|
|
|
* Determine if this dll can be unloaded from the callers address space.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK, if the dll can be unloaded,
|
|
|
|
* S_FALSE, otherwise.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
2009-12-05 19:47:30 +00:00
|
|
|
HRESULT ret = S_OK;
|
|
|
|
|
|
|
|
if (mapiFunctions.DllCanUnloadNow)
|
|
|
|
{
|
|
|
|
ret = mapiFunctions.DllCanUnloadNow();
|
|
|
|
TRACE("(): provider returns %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MAPI_ObjectCount == 0 ? ret : S_FALSE;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MAPIInitialize
|
|
|
|
*
|
|
|
|
* Initialises the MAPI library. In our case, we pass through to the
|
|
|
|
* loaded Extended MAPI provider.
|
|
|
|
*/
|
2006-04-17 07:45:48 +00:00
|
|
|
HRESULT WINAPI MAPIInitialize(LPVOID init)
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
TRACE("(%p)\n", init);
|
|
|
|
|
|
|
|
if (mapiFunctions.MAPIInitialize)
|
|
|
|
return mapiFunctions.MAPIInitialize(init);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_INITIALIZED;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MAPILogon
|
|
|
|
*
|
|
|
|
* Logs on to a MAPI provider. If available, we pass this through to a
|
|
|
|
* Simple MAPI provider. Otherwise, we maintain basic functionality
|
|
|
|
* ourselves.
|
|
|
|
*/
|
2006-07-04 12:05:13 +00:00
|
|
|
ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password,
|
2006-04-17 07:45:48 +00:00
|
|
|
FLAGS flags, ULONG reserved, LPLHANDLE session)
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
TRACE("(0x%08lx %s %p 0x%08x 0x%08x %p)\n", uiparam,
|
2006-04-17 07:45:48 +00:00
|
|
|
debugstr_a(profile), password, flags, reserved, session);
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
if (mapiFunctions.MAPILogon)
|
|
|
|
return mapiFunctions.MAPILogon(uiparam, profile, password, flags, reserved, session);
|
|
|
|
|
2006-04-17 07:45:48 +00:00
|
|
|
if (session) *session = 1;
|
|
|
|
return SUCCESS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MAPILogoff
|
|
|
|
*
|
|
|
|
* Logs off from a MAPI provider. If available, we pass this through to a
|
|
|
|
* Simple MAPI provider. Otherwise, we maintain basic functionality
|
|
|
|
* ourselves.
|
|
|
|
*/
|
2006-07-04 12:05:13 +00:00
|
|
|
ULONG WINAPI MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags,
|
2006-04-17 07:45:48 +00:00
|
|
|
ULONG reserved )
|
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
TRACE("(0x%08lx 0x%08lx 0x%08x 0x%08x)\n", session,
|
2006-04-17 07:45:48 +00:00
|
|
|
uiparam, flags, reserved);
|
2009-10-20 21:40:47 +00:00
|
|
|
|
|
|
|
if (mapiFunctions.MAPILogoff)
|
|
|
|
return mapiFunctions.MAPILogoff(session, uiparam, flags, reserved);
|
|
|
|
|
2006-04-17 07:45:48 +00:00
|
|
|
return SUCCESS_SUCCESS;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MAPILogonEx
|
|
|
|
*
|
|
|
|
* Logs on to a MAPI provider. If available, we pass this through to an
|
|
|
|
* Extended MAPI provider. Otherwise, we return an error.
|
|
|
|
*/
|
2006-04-17 07:45:48 +00:00
|
|
|
HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
|
|
|
|
LPWSTR password, ULONG flags, LPMAPISESSION *session)
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
TRACE("(0x%08lx %s %p 0x%08x %p)\n", uiparam,
|
2006-04-17 07:45:48 +00:00
|
|
|
debugstr_w(profile), password, flags, session);
|
2009-10-20 21:40:47 +00:00
|
|
|
|
|
|
|
if (mapiFunctions.MAPILogonEx)
|
|
|
|
return mapiFunctions.MAPILogonEx(uiparam, profile, password, flags, session);
|
|
|
|
|
|
|
|
return E_FAIL;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
2006-07-04 12:05:13 +00:00
|
|
|
HRESULT WINAPI MAPIOpenLocalFormContainer(LPVOID *ppfcnt)
|
|
|
|
{
|
2009-12-05 19:47:30 +00:00
|
|
|
if (mapiFunctions.MAPIOpenLocalFormContainer)
|
|
|
|
return mapiFunctions.MAPIOpenLocalFormContainer(ppfcnt);
|
|
|
|
|
2006-07-04 12:05:13 +00:00
|
|
|
FIXME("(%p) Stub\n", ppfcnt);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2009-10-20 21:40:47 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* MAPIUninitialize
|
|
|
|
*
|
|
|
|
* Uninitialises the MAPI library. In our case, we pass through to the
|
|
|
|
* loaded Extended MAPI provider.
|
|
|
|
*
|
|
|
|
*/
|
2006-02-17 00:04:10 +00:00
|
|
|
VOID WINAPI MAPIUninitialize(void)
|
|
|
|
{
|
2009-10-20 21:40:47 +00:00
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
/* Try to uninitialise the Extended MAPI library */
|
|
|
|
if (mapiFunctions.MAPIUninitialize)
|
|
|
|
mapiFunctions.MAPIUninitialize();
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
2007-04-25 08:21:30 +00:00
|
|
|
|
|
|
|
HRESULT WINAPI MAPIAdminProfiles(ULONG ulFlags, LPPROFADMIN *lppProfAdmin)
|
|
|
|
{
|
2009-12-05 19:47:30 +00:00
|
|
|
if (mapiFunctions.MAPIAdminProfiles)
|
|
|
|
return mapiFunctions.MAPIAdminProfiles(ulFlags, lppProfAdmin);
|
|
|
|
|
2007-04-25 08:21:30 +00:00
|
|
|
FIXME("(%u, %p): stub\n", ulFlags, lppProfAdmin);
|
|
|
|
*lppProfAdmin = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2009-10-20 21:40:47 +00:00
|
|
|
|
|
|
|
ULONG WINAPI MAPIAddress(LHANDLE session, ULONG_PTR uiparam, LPSTR caption,
|
|
|
|
ULONG editfields, LPSTR labels, ULONG nRecips, lpMapiRecipDesc lpRecips,
|
|
|
|
FLAGS flags, ULONG reserved, LPULONG newRecips, lpMapiRecipDesc * lppNewRecips)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIAddress)
|
|
|
|
return mapiFunctions.MAPIAddress(session, uiparam, caption, editfields, labels,
|
|
|
|
nRecips, lpRecips, flags, reserved, newRecips, lppNewRecips);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPIDeleteMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
|
|
|
|
FLAGS flags, ULONG reserved)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIDeleteMail)
|
|
|
|
return mapiFunctions.MAPIDeleteMail(session, uiparam, msg_id, flags, reserved);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPIDetails(LHANDLE session, ULONG_PTR uiparam, lpMapiRecipDesc recip,
|
|
|
|
FLAGS flags, ULONG reserved)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIDetails)
|
|
|
|
return mapiFunctions.MAPIDetails(session, uiparam, recip, flags, reserved);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPIFindNext(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_type,
|
|
|
|
LPSTR seed_msg_id, FLAGS flags, ULONG reserved, LPSTR msg_id)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIFindNext)
|
|
|
|
return mapiFunctions.MAPIFindNext(session, uiparam, msg_type, seed_msg_id, flags, reserved, msg_id);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPIReadMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
|
|
|
|
FLAGS flags, ULONG reserved, lpMapiMessage msg)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIReadMail)
|
|
|
|
return mapiFunctions.MAPIReadMail(session, uiparam, msg_id, flags, reserved, msg);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPIResolveName(LHANDLE session, ULONG_PTR uiparam, LPSTR name,
|
|
|
|
FLAGS flags, ULONG reserved, lpMapiRecipDesc *recip)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPIResolveName)
|
|
|
|
return mapiFunctions.MAPIResolveName(session, uiparam, name, flags, reserved, recip);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI MAPISaveMail(LHANDLE session, ULONG_PTR uiparam, lpMapiMessage msg,
|
|
|
|
FLAGS flags, ULONG reserved, LPSTR msg_id)
|
|
|
|
{
|
|
|
|
if (mapiFunctions.MAPISaveMail)
|
|
|
|
return mapiFunctions.MAPISaveMail(session, uiparam, msg, flags, reserved, msg_id);
|
|
|
|
|
|
|
|
return MAPI_E_NOT_SUPPORTED;
|
|
|
|
}
|