• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CDMA_SMS_MESSAGE_H
17 #define CDMA_SMS_MESSAGE_H
18 #include <memory>
19 #include <stdint.h>
20 #include <string>
21 #include <vector>
22 
23 #include "sms_base_message.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class CdmaSmsMessage : public SmsBaseMessage {
28 public:
29     CdmaSmsMessage() = default;
30     virtual ~CdmaSmsMessage() = default;
31     virtual int GetProtocolId() const;
32     virtual bool IsReplaceMessage();
33     virtual bool IsCphsMwi() const;
34     virtual bool IsWapPushMsg();
35     virtual int GetTransMsgType() const;
36     virtual int GetTransTeleService() const;
37     virtual bool IsStatusReport() const;
38     virtual int16_t GetDestPort() const;
39     virtual bool IsBroadcastMsg() const;
40     virtual bool AddUserDataHeader(const struct SmsUDH &header);
41     virtual int8_t GetCMASCategory() const;
42     virtual int8_t GetCMASResponseType() const;
43     virtual int8_t GetCMASSeverity() const;
44     virtual int8_t GetCMASUrgency() const;
45     virtual int8_t GetCMASCertainty() const;
46     virtual int8_t GetCMASMessageClass() const;
47     virtual bool IsCMAS() const;
48     virtual uint16_t GetMessageId() const;
49     virtual int8_t GetFormat() const;
50     virtual int8_t GetLanguage() const;
51     virtual std::string GetCbInfo() const;
52     virtual int8_t GetPriority() const;
53     virtual bool IsEmergencyMsg() const;
54     virtual uint16_t GetServiceCategoty() const;
55     virtual uint8_t GetGeoScope() const;
56     long GetReceTime() const;
57 
58     virtual std::shared_ptr<SpecialSmsIndication> GetSpecialSmsInd();
59     static std::shared_ptr<CdmaSmsMessage> CreateMessage(const std::string &pdu);
60 
61     std::unique_ptr<SmsTransMsg> CreateSubmitTransMsg(const std::string &dest, const std::string &sc,
62         const std::string &text, bool bStatusReport, const SmsCodingScheme codingScheme);
63     std::unique_ptr<SmsTransMsg> CreateSubmitTransMsg(const std::string &dest, const std::string &sc, int32_t port,
64         const uint8_t *data, uint32_t dataLen, bool bStatusReport);
65 
66 private:
67     SmsEncodingType CovertEncodingType(const SmsCodingScheme &codingScheme);
68     bool PduAnalysis(const std::string &pduHex);
69     void AnalysisP2pMsg(const SmsTransP2PMsg &p2pMsg);
70     void AnalysisCbMsg(const SmsTransBroadCastMsg &cbMsg);
71     void AnalsisAckMsg(const SmsTransAckMsg &ackMsg);
72     void AnalsisDeliverMwi(const SmsTransP2PMsg &p2pMsg);
73     void AnalsisDeliverMsg(const SmsTeleSvcDeliver &deliver);
74     void AnalsisDeliverAck(const SmsTeleSvcDeliverAck &deliverAck);
75     void AnalsisSubmitReport(const SmsTeleSvcDeliverReport &report);
76     void AnalsisSubmitMsg(const SmsTeleSvcSubmit &submit);
77     void AnalsisUserData(const SmsTeleSvcUserData &userData);
78     void AnalsisCMASMsg(const SmsTeleSvcDeliver &deliver);
79     void AnalsisHeader(const SmsTeleSvcUserData &userData);
80     virtual int DecodeMessage(unsigned char *decodeData, unsigned int length, SmsCodingScheme &codingType,
81         const std::string &msgText, bool &bAbnormal, MSG_LANGUAGE_ID_T &langId);
82 
83 private:
84     uint16_t destPort_ = -1;
85     std::unique_ptr<SmsTransAddr> address_;
86     std::unique_ptr<SmsTeleSvcAddr> callbackNumber_;
87     std::vector<struct SmsUDH> userHeaders_;
88     int8_t category_ = SMS_CMAE_CTG_RESERVED;
89     int8_t responseType_ = SMS_CMAE_RESP_TYPE_RESERVED;
90     int8_t severity_ = SMS_CMAE_SEVERITY_RESERVED;
91     int8_t urgency_ = SMS_CMAE_URGENCY_RESERVED;
92     int8_t certainty_ = SMS_CMAE_CERTAINTY_RESERVED;
93     int8_t messageClass_ = SMS_CMAE_ALERT_RESERVED;
94     int8_t priority_ = SMS_PRIORITY_NORMAL;
95     bool isCmas_ = false;
96     uint16_t messageId_;
97     int8_t language_;
98     uint16_t serviceCategory_;
99 
100     std::unique_ptr<struct SmsTransMsg> transMsg_;
101     std::unique_ptr<struct SmsTransMsg> GreateTransMsg();
102 };
103 } // namespace Telephony
104 } // namespace OHOS
105 #endif
106