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