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 FMsgMmsManager.cpp
19 * @brief This is the implementation file for the %MmsManager class.
21 * This file contains the implementation of the %MmsManager class.
25 #include <msg_transport.h>
26 #include <msg_storage.h>
27 #include <dbus/dbus.h>
28 #include <email-api.h>
29 #include <FMsgMmsManager.h>
30 #include <FMsgMmsMessage.h>
31 #include <FBaseSysLog.h>
32 #include <FSec_AccessController.h>
33 #include <FSys_SystemInfoImpl.h>
34 #include "FMsg_Types.h"
35 #include "FMsg_MmsEvent.h"
36 #include "FMsg_MsgUtil.h"
37 #include "FMsg_MmsManagerImpl.h"
38 #include "FMsg_RecipientListImpl.h"
40 using namespace Tizen::Base;
41 using namespace Tizen::Messaging;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Security;
45 namespace Tizen { namespace Messaging
48 MmsManager::MmsManager(void)
53 MmsManager::~MmsManager(void)
63 MmsManager::Construct(IMmsListener& listener)
67 bool isMmsSupported = false;
69 SysAssertf(__pImpl == null, "The MmsManager instance is already constructed.");
71 r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/network.telephony.mms", isMmsSupported);
72 SysTryReturnResult(NID_MSG, (r == E_SUCCESS) && (isMmsSupported == true), E_UNSUPPORTED_OPERATION, " MMS is not supported.");
74 // create an _MmsManagerImpl instance
75 __pImpl = new (std::nothrow) _MmsManagerImpl();
76 SysTryReturn(NID_MSG, __pImpl != null, E_OUT_OF_MEMORY, r = E_OUT_OF_MEMORY, "Failed to allocate memory");
78 r = __pImpl->Construct(listener);
79 SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to construct an instance.", GetErrorMessage(r));
94 MmsManager::Send(const MmsMessage& message, const RecipientList& recipientList, bool saveToSentBox)
99 r = _AccessController::CheckUserPrivilege(_PRV_MESSAGING_MMS, _PRV_MESSAGING_WRITE);
100 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
101 SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "The application is not permitted to call this method.");
103 SysAssertf(__pImpl != null, "The MmsManager instance is not constructed yet.");
104 SysTryReturnResult(NID_MSG,
105 MAX_MMS_RECIPIENT_COUNT >= _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_MAX_EXCEEDED,
106 "The number of recipients exceeds the limit (%d).", MAX_MMS_RECIPIENT_COUNT);
107 SysTryReturnResult(NID_MSG,
108 0 != _RecipientListImpl::GetInstance(recipientList)->GetTotalRecipientCount(), E_INVALID_ARG,
109 "[E_INVALID_ARG] The number of recipients is 0.");
111 ////////////////////////////////////////////////////////////////////////////////
112 // address-check will be done in SHP layer.
113 ////////////////////////////////////////////////////////////////////////////////
115 // mms address validity check
116 r = _MsgUtil::CheckPhoneNumberValidity(_MSG_MMS, recipientList);
120 SysLogException(NID_MSG, r, "[%s] There is an invalid phone number in the recipient list.", GetErrorMessage(r));
124 // not allow the empty message.
125 if (message.GetSubject().IsEmpty() && message.GetText().IsEmpty() && message.GetAttachment(MMS_IMAGE).IsEmpty() &&
126 message.GetAttachment(MMS_AUDIO).IsEmpty() && message.GetAttachment(MMS_VIDEO).IsEmpty())
129 SysLogException(NID_MSG, r, "[E_INVALID_ARG] The message is empty.");
130 return E_INVALID_ARG;
133 // send an MMS message
134 r = __pImpl->Send(message, recipientList, saveToSentBox);
137 SysLogException(NID_MSG, r, "[%s] Failed to send the MMS message.", GetErrorMessage(r));
146 } } // Tizen::Messaging