2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FMsgEmailManager.cpp
19 * @brief This is the implementation file for the %EmailManager class.
21 * This file contains the implementation of the %EmailManager class.
25 #include <msg_transport.h>
26 #include <msg_storage.h>
27 #include <dbus/dbus.h>
28 #include <email-api.h>
29 #include <FMsgEmailManager.h>
30 #include <FBaseSysLog.h>
31 #include <FSec_AccessController.h>
32 #include "FMsg_EmailManagerImpl.h"
33 #include "FMsg_MsgUtil.h"
34 #include "FMsg_RecipientListImpl.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Messaging;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Security;
41 namespace Tizen { namespace Messaging
44 EmailManager::EmailManager(void)
49 EmailManager::~EmailManager(void)
59 EmailManager::Construct(IEmailListener& listener)
64 SysAssertf(__pImpl == null, "The EmailManager instance is already constructed.");
66 // create an _EmailManagerImpl instance
67 __pImpl = new (std::nothrow) _EmailManagerImpl();
68 SysTryReturnResult(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, "memory allocation failed.");
70 r = __pImpl->Construct(listener);
73 SysLogException(NID_MSG, r, "[%s] Failed to Construct an instance.", GetErrorMessage(r));
84 EmailManager::Send(const EmailMessage& message, const RecipientList& recipientList, bool saveToSentBox)
89 r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_EMAIL);
90 SysTryReturn(NID_MSG, r == E_SUCCESS, E_PRIVILEGE_DENIED, r = E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] Propagating.");
92 SysAssertf(__pImpl != null, "The EmailManager instance is not constructed yet.");
93 SysTryReturnResult(NID_MSG,
94 MAX_EMAIL_RECIPIENT_COUNT >= _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_MAX_EXCEEDED,
95 "[E_MAX_EXCEEDED] The number of recipients (%d) exceeds the limit (%d).",
96 _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), MAX_EMAIL_RECIPIENT_COUNT);
97 SysTryReturnResult(NID_MSG,
98 0 != _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_INVALID_ARG,
99 "[E_INVALID_ARG] The number of recipients is 0.");
101 // email address validity check
102 r = _MsgUtil::CheckEmailAddressValidity(recipientList);
105 SysLogException(NID_MSG, r, "[%s] There is an invalid email address in the recipient list.", GetErrorMessage(r));
109 // send an email message
110 r = __pImpl->Send(message, recipientList, saveToSentBox);
113 SysLogException(NID_MSG, r, "[%s] Failed to send the email message.", GetErrorMessage(r));
123 } } // Tizen::Messaging