1e5d0e473Sopenharmony_ci/*
2e5d0e473Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3e5d0e473Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e5d0e473Sopenharmony_ci * you may not use this file except in compliance with the License.
5e5d0e473Sopenharmony_ci * You may obtain a copy of the License at
6e5d0e473Sopenharmony_ci *
7e5d0e473Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e5d0e473Sopenharmony_ci *
9e5d0e473Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e5d0e473Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e5d0e473Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e5d0e473Sopenharmony_ci * See the License for the specific language governing permissions and
13e5d0e473Sopenharmony_ci * limitations under the License.
14e5d0e473Sopenharmony_ci */
15e5d0e473Sopenharmony_ci
16e5d0e473Sopenharmony_ci#include "mms_receive.h"
17e5d0e473Sopenharmony_ci
18e5d0e473Sopenharmony_ci#include "data_request.h"
19e5d0e473Sopenharmony_ci#include "telephony_log_wrapper.h"
20e5d0e473Sopenharmony_ci
21e5d0e473Sopenharmony_cinamespace OHOS {
22e5d0e473Sopenharmony_cinamespace Telephony {
23e5d0e473Sopenharmony_cistd::string DOWNLOAD_METHOD = "GET";
24e5d0e473Sopenharmony_ci
25e5d0e473Sopenharmony_ciMmsReceive::MmsReceive(int32_t slotId) : DataRequest(slotId)
26e5d0e473Sopenharmony_ci{
27e5d0e473Sopenharmony_ci    slotId_ = slotId;
28e5d0e473Sopenharmony_ci    CreateRequestId();
29e5d0e473Sopenharmony_ci}
30e5d0e473Sopenharmony_ci
31e5d0e473Sopenharmony_ciMmsReceive::~MmsReceive() {}
32e5d0e473Sopenharmony_ci
33e5d0e473Sopenharmony_ciint32_t MmsReceive::ExecuteDownloadMms(
34e5d0e473Sopenharmony_ci    const std::string &contentUrl, std::string &pduDir, const std::string &ua, const std::string &uaprof)
35e5d0e473Sopenharmony_ci{
36e5d0e473Sopenharmony_ci    auto mmsNetworkMgr = std::make_shared<MmsNetworkManager>();
37e5d0e473Sopenharmony_ci    if (mmsNetworkMgr == nullptr) {
38e5d0e473Sopenharmony_ci        TELEPHONY_LOGE("mmsNetworkMgr_ is nullptr");
39e5d0e473Sopenharmony_ci        return TELEPHONY_ERR_LOCAL_PTR_NULL;
40e5d0e473Sopenharmony_ci    }
41e5d0e473Sopenharmony_ci
42e5d0e473Sopenharmony_ci    std::unique_lock<std::mutex> lock(downloadMmsMutex_);
43e5d0e473Sopenharmony_ci    return ExecuteMms(DOWNLOAD_METHOD, mmsNetworkMgr, contentUrl, pduDir, ua, uaprof);
44e5d0e473Sopenharmony_ci}
45e5d0e473Sopenharmony_ci} // namespace Telephony
46e5d0e473Sopenharmony_ci} // namespace OHOS