summaryrefslogtreecommitdiff
path: root/shell/source/win32/simplemail/simplemapi.cxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2004-06-17 14:43:29 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2004-06-17 14:43:29 +0000
commit719eb2e292f515592c78bdac74f83f0ae4e16a70 (patch)
treeb84d44ff223fae03258d73361a3b5f33b08a8146 /shell/source/win32/simplemail/simplemapi.cxx
parentdfa911221ae48506c0259bf64c8e818cb9ae757c (diff)
INTEGRATION: CWS defaultmailer (1.1.174); FILE MERGED
2004/06/04 15:09:40 tra 1.1.174.1: #i29558#refactoring of simple mail service, MAPI stuff now called in an own executable
Diffstat (limited to 'shell/source/win32/simplemail/simplemapi.cxx')
-rw-r--r--shell/source/win32/simplemail/simplemapi.cxx127
1 files changed, 32 insertions, 95 deletions
diff --git a/shell/source/win32/simplemail/simplemapi.cxx b/shell/source/win32/simplemail/simplemapi.cxx
index 3c5ddec39cb0..20259a9a8c9b 100644
--- a/shell/source/win32/simplemail/simplemapi.cxx
+++ b/shell/source/win32/simplemail/simplemapi.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: simplemapi.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: tra $ $Date: 2001-05-14 08:09:15 $
+ * last change: $Author: rt $ $Date: 2004-06-17 15:43:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,78 +59,40 @@
*
************************************************************************/
-#ifndef _SIMPLEMAPI_HXX_
+#ifndef INCLUDED_SIMPLEMAPI_HXX
#include "simplemapi.hxx"
#endif
-//----------------------------------------------------------
-// static variables
-//----------------------------------------------------------
+#include <string>
+#include <stdexcept>
-CSimpleMapi* CSimpleMapi::s_Instance = NULL;
-osl::Mutex CSimpleMapi::s_aMutex;
-CSimpleMapi::SIMPLEMAPI_SINGLETON_DESTROYER_T CSimpleMapi::s_SingletonDestroyer;
-
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
-CSimpleMapi* CSimpleMapi::create( )
+CSimpleMapi::CSimpleMapi() :
+ m_lpfnMapiLogon(NULL),
+ m_lpfnMapiLogoff(NULL),
+ m_lpfnMapiSendMail(NULL)
{
- if ( !s_Instance )
- {
- osl::MutexGuard aGuard( s_aMutex );
+ m_hMapiDll = LoadLibrary("mapi32.dll");
+ if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL))
+ throw std::runtime_error("Couldn't load MAPI library");
- if ( !s_Instance )
- {
- s_Instance = new CSimpleMapi( );
- s_SingletonDestroyer.reset( s_Instance );
- }
- }
+ m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon"));
+ if (!m_lpfnMapiLogon)
+ throw std::runtime_error("Couldn't find method MAPILogon");
- return s_Instance;
-}
+ m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff"));
+ if (!m_lpfnMapiLogoff)
+ throw std::runtime_error("Couldn't find method MAPILogoff");
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
-CSimpleMapi::CSimpleMapi( ) :
- m_lpfnMapiLogon( NULL ),
- m_lpfnMapiLogoff( NULL ),
- m_lpfnMapiSendMail( NULL )
-{
- // load the library
- m_hMapiDll = LoadLibrary( "mapi32.dll" );
-
- if ( m_hMapiDll )
- {
- // initialize the function pointer
- m_lpfnMapiLogon = reinterpret_cast< LPMAPILOGON >(
- GetProcAddress( m_hMapiDll, "MAPILogon" ) );
-
- m_lpfnMapiLogoff = reinterpret_cast< LPMAPILOGOFF >(
- GetProcAddress( m_hMapiDll, "MAPILogoff" ) );
-
- m_lpfnMapiSendMail = reinterpret_cast< LPMAPISENDMAIL >(
- GetProcAddress( m_hMapiDll, "MAPISendMail" ) );
- }
+ m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail"));
+ if (!m_lpfnMapiSendMail)
+ throw std::runtime_error("Couldn't find method MAPISendMail");
}
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
-CSimpleMapi::~CSimpleMapi( )
+CSimpleMapi::~CSimpleMapi()
{
- if ( m_hMapiDll )
- FreeLibrary( m_hMapiDll );
+ FreeLibrary(m_hMapiDll);
}
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
ULONG CSimpleMapi::MAPILogon(
ULONG ulUIParam,
LPTSTR lpszProfileName,
@@ -139,43 +101,24 @@ ULONG CSimpleMapi::MAPILogon(
ULONG ulReserved,
LPLHANDLE lplhSession )
{
- ULONG ulRet = MAPI_E_FAILURE;
-
- if ( m_lpfnMapiLogon )
- ulRet = m_lpfnMapiLogon(
- ulUIParam,
- lpszProfileName,
- lpszPassword,
- flFlags,
- ulReserved,
- lplhSession );
-
- return ulRet;
+ return m_lpfnMapiLogon(
+ ulUIParam,
+ lpszProfileName,
+ lpszPassword,
+ flFlags,
+ ulReserved,
+ lplhSession );
}
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
ULONG CSimpleMapi::MAPILogoff(
LHANDLE lhSession,
ULONG ulUIParam,
FLAGS flFlags,
ULONG ulReserved )
{
- ULONG ulRet = MAPI_E_FAILURE;
-
- if ( m_lpfnMapiLogoff )
- ulRet = m_lpfnMapiLogoff(
- lhSession, ulUIParam, flFlags, ulReserved );
-
- return ulRet;
+ return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved);
}
-//----------------------------------------------------------
-//
-//----------------------------------------------------------
-
ULONG CSimpleMapi::MAPISendMail(
LHANDLE lhSession,
ULONG ulUIParam,
@@ -183,12 +126,6 @@ ULONG CSimpleMapi::MAPISendMail(
FLAGS flFlags,
ULONG ulReserved )
{
- ULONG ulRet = MAPI_E_FAILURE;
-
- if ( m_lpfnMapiSendMail )
- ulRet = m_lpfnMapiSendMail(
- lhSession, ulUIParam, lpMessage, flFlags, ulReserved );
-
- return ulRet;
+ return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved);
}