1 /*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "mms_send_manager.h"
17
18 #include "string_utils.h"
19 #include "telephony_log_wrapper.h"
20
21 namespace OHOS {
22 namespace Telephony {
23 using namespace std;
MmsSendManager(int32_t slotId)24 MmsSendManager::MmsSendManager(int32_t slotId) : TelEventHandler("MmsSendManager"), slotId_(slotId) {}
25
~MmsSendManager()26 MmsSendManager::~MmsSendManager() {}
27
Init()28 void MmsSendManager::Init()
29 {
30 mmsSender_ = std::make_shared<MmsSender>(slotId_);
31 if (mmsSender_ == nullptr) {
32 TELEPHONY_LOGE("failed to create MmsSender");
33 return;
34 }
35 }
36
SendMms(const std::u16string & mmsc,const std::u16string & data,const std::u16string & ua,const std::u16string & uaprof)37 int32_t MmsSendManager::SendMms(
38 const std::u16string &mmsc, const std::u16string &data, const std::u16string &ua, const std::u16string &uaprof)
39 {
40 if (mmsSender_ == nullptr) {
41 TELEPHONY_LOGE("mmsSender_ is nullptr");
42 return TELEPHONY_ERR_LOCAL_PTR_NULL;
43 }
44
45 int32_t sendResult = mmsSender_->ExecuteSendMms(
46 StringUtils::ToUtf8(mmsc), StringUtils::ToUtf8(data), StringUtils::ToUtf8(ua), StringUtils::ToUtf8(uaprof));
47 if (sendResult == TELEPHONY_ERR_SUCCESS) {
48 TELEPHONY_LOGI("send mms successed");
49 return TELEPHONY_ERR_SUCCESS;
50 } else {
51 TELEPHONY_LOGI("send mms failed");
52 return sendResult;
53 }
54 }
55 } // namespace Telephony
56 } // namespace OHOS