1/*
2 * Copyright (C) 2021-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#ifndef SMS_SEND_INDEXER_H
17#define SMS_SEND_INDEXER_H
18
19#include <vector>
20
21#include "i_sms_service_interface.h"
22#include "gsm_pdu_code_type.h"
23#include "sms_base_message.h"
24#include "sms_common.h"
25
26namespace OHOS {
27namespace Telephony {
28class SmsSendIndexer {
29public:
30    SmsSendIndexer(const std::string &desAddr, const std::string &scAddr, const std::string &text,
31        const sptr<ISendShortMessageCallback> &sendCallback,
32        const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
33    SmsSendIndexer(const std::string &desAddr, const std::string &scAddr, int32_t port, const uint8_t *data,
34        uint32_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
35        const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
36    ~SmsSendIndexer();
37    uint8_t GetPsResendCount() const;
38    void SetPsResendCount(uint8_t resendCount);
39    uint8_t GetCsResendCount() const;
40    void SetCsResendCount(uint8_t resendCount);
41    uint8_t GetMsgRefId() const;
42    void SetMsgRefId(uint8_t msgRefId);
43    int64_t GetMsgRefId64Bit() const;
44    void SetMsgRefId64Bit(int64_t msgRefId64Bit);
45    const std::vector<uint8_t>& GetAckPdu() const;
46    void SetAckPdu(const std::vector<uint8_t> &ackPdu);
47    const std::vector<uint8_t>& GetData() const;
48    void SetData(const std::vector<uint8_t> &data);
49    uint8_t GetErrorCode() const;
50    void SetErrorCode(uint8_t errorCode);
51    bool GetIsText() const;
52    std::string GetSmcaAddr() const;
53    void SetSmcaAddr(const std::string &scAddr);
54    std::string GetDestAddr() const;
55    void SetDestAddr(const std::string &destAddr);
56    int32_t GetDestPort() const;
57    void SetDestPort(int32_t destPort);
58    sptr<ISendShortMessageCallback> GetSendCallback() const;
59    void SetSendCallback(const sptr<ISendShortMessageCallback> &sendCallback);
60    sptr<IDeliveryShortMessageCallback> GetDeliveryCallback() const;
61    void SetDeliveryCallback(const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
62    std::string GetText() const;
63    void SetText(const std::string &text);
64    uint8_t GetUnSentCellCount() const;
65    void SetUnSentCellCount(const uint8_t unSentCellCount);
66    std::shared_ptr<bool> GetHasCellFailed() const;
67    void SetHasCellFailed(const std::shared_ptr<bool> &hasCellFailed);
68    bool GetIsFailure() const;
69    void SetIsFailure(bool isFailure);
70    bool GetHasMore() const;
71    void SetHasMore(bool hasMore);
72    int64_t GetTimeStamp() const;
73    void SetTimeStamp(int64_t timeStamp);
74    void SetNetWorkType(NetWorkType netWorkType);
75    NetWorkType GetNetWorkType() const;
76    void SetEncodeSmca(const std::vector<uint8_t> &smca);
77    const std::vector<uint8_t>& GetEncodeSmca() const;
78    void SetEncodePdu(const std::vector<uint8_t> &pdu);
79    const std::vector<uint8_t>& GetEncodePdu() const;
80    void SetImsSmsForCdma(const bool isImsSms);
81    const bool &IsImsSmsForCdma() const;
82    void UpdatePduForResend();
83    void SetEncodePdu(const std::vector<uint8_t> &&pdu);
84    void SetEncodeSmca(const std::vector<uint8_t> &&smca);
85    void SetAckPdu(const std::vector<uint8_t> &&ackPdu);
86    void SetData(const std::vector<uint8_t> &&data);
87    void SetDcs(enum DataCodingScheme dcs);
88    enum DataCodingScheme GetDcs() const;
89    bool GetIsConcat() const;
90    void SetIsConcat(bool concat);
91    void SetSmsConcat(const SmsConcat &smsConcat);
92    SmsConcat GetSmsConcat() const;
93    uint8_t GetLangId() const;
94    void SetLangId(uint8_t langId);
95    uint16_t GetMsgId() const;
96    void SetMsgId(uint16_t msgId);
97    uint16_t GetDataBaseId() const;
98    void SetDataBaseId(uint16_t msgId);
99    bool GetIsMmsApp() const;
100    void SetIsMmsApp(bool isMmsApp);
101
102private:
103    std::vector<uint8_t> pdu_;
104    std::vector<uint8_t> smca_;
105    std::vector<uint8_t> ackPdu_;
106    std::vector<uint8_t> data_;
107    uint8_t errorCode_ = 0;
108    std::string text_;
109    NetWorkType netWorkType_ = NetWorkType::NET_TYPE_UNKNOWN;
110    std::string scAddr_;
111    std::string destAddr_;
112    int32_t destPort_ = 0;
113    bool isCdmaIms_ = false;
114    bool hasMore_ = false;
115    long timeStamp_ = 0;
116    uint8_t csResendCount_ = 0;
117    uint8_t psResendCount_ = 0;
118    uint8_t msgRefId_ = 0;
119    int64_t msgRefId64Bit_ = 0;
120    uint8_t unSentCellCount_ = 0;
121    std::shared_ptr<bool> hasCellFailed_ = nullptr;
122    sptr<ISendShortMessageCallback> sendCallback_ = nullptr;
123    sptr<IDeliveryShortMessageCallback> deliveryCallback_ = nullptr;
124    bool isFailure_ = false;
125    enum DataCodingScheme dcs_ = DATA_CODING_7BIT;
126    bool isConcat_ = false;
127    SmsConcat smsConcat_ = {0, 0, 0, false};
128    uint8_t langId_ = 0;
129    bool isText_ = false;
130    bool isMmsApp_ = true;
131    uint16_t msgId_ = 0;
132    uint16_t dataBaseId_ = 0;
133};
134} // namespace Telephony
135} // namespace OHOS
136#endif