1/*
2 * Copyright (C) 2021 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#ifndef SMS_INTERFACE_MANAGER_H
17#define SMS_INTERFACE_MANAGER_H
18
19#include <list>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "i_sms_service_interface.h"
25#include "mms_receive_manager.h"
26#include "mms_send_manager.h"
27#include "sms_misc_manager.h"
28#include "sms_persist_helper.h"
29#include "sms_receive_manager.h"
30#include "sms_send_manager.h"
31
32namespace OHOS {
33namespace Telephony {
34class SmsInterfaceManager {
35public:
36    explicit SmsInterfaceManager(int32_t slotId);
37    virtual ~SmsInterfaceManager();
38    void InitInterfaceManager();
39    int32_t TextBasedSmsDelivery(const std::string &desAddr, const std::string &scAddr, const std::string &text,
40        const sptr<ISendShortMessageCallback> &sendCallback,
41        const sptr<IDeliveryShortMessageCallback> &deliveryCallback, uint16_t id, bool isMmsApp = true);
42    int32_t DataBasedSmsDelivery(const std::string &desAddr, const std::string &scAddr, const uint16_t port,
43        const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
44        const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
45    int32_t AddSimMessage(
46        const std::string &smsc, const std::string &pdu, ISmsServiceInterface::SimMessageStatus status);
47    int32_t DelSimMessage(uint32_t msgIndex);
48    int32_t UpdateSimMessage(uint32_t msgIndex, ISmsServiceInterface::SimMessageStatus newStatus,
49        const std::string &pdu, const std::string &smsc);
50    int32_t GetAllSimMessages(std::vector<ShortMessage> &message);
51    int32_t SetSmscAddr(const std::string &scAddr);
52    int32_t GetSmscAddr(std::u16string &smscAddress);
53    int32_t SetCBConfig(bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType);
54    bool SetImsSmsConfig(int32_t slotId, int32_t enable);
55    int32_t SetDefaultSmsSlotId(int32_t slotId);
56    int32_t GetDefaultSmsSlotId();
57    int32_t GetDefaultSmsSimId(int32_t &simId);
58    int32_t SplitMessage(const std::string &message, std::vector<std::u16string> &splitMessage);
59    int32_t GetSmsSegmentsInfo(const std::string &message, bool force7BitCode, LengthInfo &outInfo);
60    int32_t IsImsSmsSupported(int32_t slotId, bool &isSupported);
61    int32_t GetImsShortMessageFormat(std::u16string &format);
62    bool HasSmsCapability();
63    int32_t SendMms(
64        const std::u16string &mmsc, const std::u16string &data, const std::u16string &ua, const std::u16string &uaprof);
65    int32_t DownloadMms(
66        const std::u16string &mmsc, std::u16string &data, const std::u16string &ua, const std::u16string &uaprof);
67    int32_t OnRilAdapterHostDied();
68
69private:
70    int32_t slotId_;
71    std::unique_ptr<SmsSendManager> smsSendManager_;
72    std::unique_ptr<SmsReceiveManager> smsReceiveManager_;
73    std::shared_ptr<SmsMiscManager> smsMiscManager_;
74    std::unique_ptr<MmsSendManager> mmsSendManager_;
75    std::unique_ptr<MmsReceiveManager> mmsReceiverManager_;
76};
77} // namespace Telephony
78} // namespace OHOS
79#endif