1f8e2c85aSAndrew Rist /**************************************************************
2*ae77b8caSAriel Constenla-Haile  *
3f8e2c85aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e2c85aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e2c85aSAndrew Rist  * distributed with this work for additional information
6f8e2c85aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e2c85aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e2c85aSAndrew Rist  * "License"); you may not use this file except in compliance
9f8e2c85aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ae77b8caSAriel Constenla-Haile  *
11f8e2c85aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ae77b8caSAriel Constenla-Haile  *
13f8e2c85aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e2c85aSAndrew Rist  * software distributed under the License is distributed on an
15f8e2c85aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e2c85aSAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e2c85aSAndrew Rist  * specific language governing permissions and limitations
18f8e2c85aSAndrew Rist  * under the License.
19*ae77b8caSAriel Constenla-Haile  *
20f8e2c85aSAndrew Rist  *************************************************************/
21f8e2c85aSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_shell.hxx"
24*ae77b8caSAriel Constenla-Haile #include "sysmapi.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <string>
27cdf0e10cSrcweir #include <stdexcept>
28cdf0e10cSrcweir 
29*ae77b8caSAriel Constenla-Haile namespace shell
30*ae77b8caSAriel Constenla-Haile {
31*ae77b8caSAriel Constenla-Haile 
WinSysMapi()32*ae77b8caSAriel Constenla-Haile WinSysMapi::WinSysMapi() :
33cdf0e10cSrcweir     m_lpfnMapiLogon(NULL),
34cdf0e10cSrcweir     m_lpfnMapiLogoff(NULL),
35cdf0e10cSrcweir     m_lpfnMapiSendMail(NULL)
36*ae77b8caSAriel Constenla-Haile {
37cdf0e10cSrcweir     m_hMapiDll = LoadLibrary("mapi32.dll");
38cdf0e10cSrcweir     if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL))
39cdf0e10cSrcweir         throw std::runtime_error("Couldn't load MAPI library");
40*ae77b8caSAriel Constenla-Haile 
41cdf0e10cSrcweir     m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon"));
42cdf0e10cSrcweir     if (!m_lpfnMapiLogon)
43cdf0e10cSrcweir         throw std::runtime_error("Couldn't find method MAPILogon");
44*ae77b8caSAriel Constenla-Haile 
45cdf0e10cSrcweir     m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff"));
46cdf0e10cSrcweir     if (!m_lpfnMapiLogoff)
47cdf0e10cSrcweir         throw std::runtime_error("Couldn't find method MAPILogoff");
48*ae77b8caSAriel Constenla-Haile 
49*ae77b8caSAriel Constenla-Haile     m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail"));
50cdf0e10cSrcweir     if (!m_lpfnMapiSendMail)
51cdf0e10cSrcweir         throw std::runtime_error("Couldn't find method MAPISendMail");
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
~WinSysMapi()54*ae77b8caSAriel Constenla-Haile WinSysMapi::~WinSysMapi()
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     FreeLibrary(m_hMapiDll);
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
MAPILogon(ULONG ulUIParam,LPTSTR lpszProfileName,LPTSTR lpszPassword,FLAGS flFlags,ULONG ulReserved,LPLHANDLE lplhSession)59*ae77b8caSAriel Constenla-Haile ULONG WinSysMapi::MAPILogon(
60*ae77b8caSAriel Constenla-Haile     ULONG ulUIParam,
61*ae77b8caSAriel Constenla-Haile     LPTSTR lpszProfileName,
62*ae77b8caSAriel Constenla-Haile     LPTSTR lpszPassword,
63*ae77b8caSAriel Constenla-Haile     FLAGS flFlags,
64*ae77b8caSAriel Constenla-Haile     ULONG ulReserved,
65cdf0e10cSrcweir     LPLHANDLE lplhSession )
66*ae77b8caSAriel Constenla-Haile {
67*ae77b8caSAriel Constenla-Haile     return m_lpfnMapiLogon(
68*ae77b8caSAriel Constenla-Haile         ulUIParam,
69*ae77b8caSAriel Constenla-Haile         lpszProfileName,
70*ae77b8caSAriel Constenla-Haile         lpszPassword,
71*ae77b8caSAriel Constenla-Haile         flFlags,
72*ae77b8caSAriel Constenla-Haile         ulReserved,
73cdf0e10cSrcweir         lplhSession );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
MAPILogoff(LHANDLE lhSession,ULONG ulUIParam,FLAGS flFlags,ULONG ulReserved)76*ae77b8caSAriel Constenla-Haile ULONG WinSysMapi::MAPILogoff(
77cdf0e10cSrcweir     LHANDLE lhSession,
78cdf0e10cSrcweir     ULONG ulUIParam,
79cdf0e10cSrcweir     FLAGS flFlags,
80cdf0e10cSrcweir     ULONG ulReserved )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
MAPISendMail(LHANDLE lhSession,ULONG ulUIParam,lpMapiMessage lpMessage,FLAGS flFlags,ULONG ulReserved)85*ae77b8caSAriel Constenla-Haile ULONG WinSysMapi::MAPISendMail(
86*ae77b8caSAriel Constenla-Haile     LHANDLE lhSession,
87*ae77b8caSAriel Constenla-Haile     ULONG ulUIParam,
88*ae77b8caSAriel Constenla-Haile     lpMapiMessage lpMessage,
89*ae77b8caSAriel Constenla-Haile     FLAGS flFlags,
90cdf0e10cSrcweir     ULONG ulReserved )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved);
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95*ae77b8caSAriel Constenla-Haile }
96*ae77b8caSAriel Constenla-Haile 
97