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 <stdint.h> 19 #include <memory> 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 static constexpr uint16_t DEFAULT_PORT = -1; 68 static constexpr uint16_t CDMA_MAX_UD_HEADER_NUM = 7; 69 static constexpr uint16_t TAPI_NETTEXT_SMDATA_SIZE_MAX = 255; 70 static constexpr uint8_t MAX_GSM_7BIT_DATA_LEN = 160; 71 72 uint16_t destPort_ = -1; 73 std::unique_ptr<SmsTransAddr> address_; 74 std::unique_ptr<SmsTeleSvcAddr> callbackNumber_; 75 std::vector<struct SmsUDH> userHeaders_; 76 int8_t category_ = SMS_CMAE_CTG_RESERVED; 77 int8_t responseType_ = SMS_CMAE_RESP_TYPE_RESERVED; 78 int8_t severity_ = SMS_CMAE_SEVERITY_RESERVED; 79 int8_t urgency_ = SMS_CMAE_URGENCY_RESERVED; 80 int8_t certainty_ = SMS_CMAE_CERTAINTY_RESERVED; 81 int8_t messageClass_ = SMS_CMAE_ALERT_RESERVED; 82 int8_t priority_ = SMS_PRIORITY_NORMAL; 83 bool isCmas_ = false; 84 uint16_t messageId_; 85 int8_t language_; 86 uint16_t serviceCategory_; 87 88 std::unique_ptr<struct SmsTransMsg> transMsg_; 89 std::unique_ptr<struct SmsTransMsg> GreateTransMsg(); 90 SmsEncodingType CovertEncodingType(const SmsCodingScheme &codingScheme); 91 bool PduAnalysis(const std::string &pduHex); 92 void AnalysisP2pMsg(const SmsTransP2PMsg &p2pMsg); 93 void AnalysisCbMsg(const SmsTransBroadCastMsg &cbMsg); 94 void AnalsisAckMsg(const SmsTransAckMsg &ackMsg); 95 void AnalsisDeliverMwi(const SmsTransP2PMsg &p2pMsg); 96 void AnalsisDeliverMsg(const SmsTeleSvcDeliver &deliver); 97 void AnalsisDeliverAck(const SmsTeleSvcDeliverAck &deliverAck); 98 void AnalsisSubmitReport(const SmsTeleSvcDeliverReport &report); 99 void AnalsisSubmitMsg(const SmsTeleSvcSubmit &submit); 100 void AnalsisUserData(const SmsTeleSvcUserData &userData); 101 void AnalsisCMASMsg(const SmsTeleSvcDeliver &deliver); 102 void AnalsisHeader(const SmsTeleSvcUserData &userData); 103 virtual int DecodeMessage(unsigned char *decodeData, SmsCodingScheme &codingType, const std::string &msgText, 104 bool &bAbnormal, MSG_LANGUAGE_ID_T &langId); 105 }; 106 } // namespace Telephony 107 } // namespace OHOS 108 #endif