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_sender.h"
17 
18 #include "telephony_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace Telephony {
22 std::string SEND_METHOD = "POST";
23 
MmsSender(int32_t slotId)24 MmsSender::MmsSender(int32_t slotId) : DataRequest(slotId)
25 {
26     slotId_ = slotId;
27     CreateRequestId();
28 }
29 
~MmsSender()30 MmsSender::~MmsSender() {}
31 
ExecuteSendMms(const std::string & contentUrl,std::string pduDir,const std::string & ua,const std::string & uaprof)32 int32_t MmsSender::ExecuteSendMms(
33     const std::string &contentUrl, std::string pduDir, const std::string &ua, const std::string &uaprof)
34 {
35     auto mmsNetworkMgr = std::make_shared<MmsNetworkManager>();
36     if (mmsNetworkMgr == nullptr) {
37         TELEPHONY_LOGE("mmsNetworkMgr_ is nullptr");
38         return TELEPHONY_ERR_LOCAL_PTR_NULL;
39     }
40 
41     std::unique_lock<std::mutex> lock(sendMmsMutex_);
42     return ExecuteMms(SEND_METHOD, mmsNetworkMgr, contentUrl, pduDir, ua, uaprof);
43 }
44 } // namespace Telephony
45 } // namespace OHOS