rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright Statement: |
| 2 | * |
| 3 | * This software/firmware and related documentation ("MediaTek Software") are |
| 4 | * protected under relevant copyright laws. The information contained herein |
| 5 | * is confidential and proprietary to MediaTek Inc. and/or its licensors. |
| 6 | * Without the prior written permission of MediaTek inc. and/or its licensors, |
| 7 | * any reproduction, modification, use or disclosure of MediaTek Software, |
| 8 | * and information contained herein, in whole or in part, shall be strictly prohibited. |
| 9 | */ |
| 10 | /* MediaTek Inc. (C) 2010. All rights reserved. |
| 11 | * |
| 12 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 13 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 14 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON |
| 15 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 18 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 19 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 20 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH |
| 21 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES |
| 22 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES |
| 23 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK |
| 24 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 25 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND |
| 26 | * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 27 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 28 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO |
| 29 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 30 | * |
| 31 | * The following software/firmware and/or related documentation ("MediaTek Software") |
| 32 | * have been modified by MediaTek Inc. All revisions are subject to any receiver's |
| 33 | * applicable license agreements with MediaTek Inc. |
| 34 | */ |
| 35 | |
| 36 | #ifndef SMSMESSAGE_H_ |
| 37 | #define SMSMESSAGE_H_ |
| 38 | #include <cstdint> |
| 39 | #include <memory> |
| 40 | #include <string> |
| 41 | #include <vector> |
| 42 | |
| 43 | #include "SmsMessageBase.h" |
| 44 | #include "SmsEnvelope.h" |
| 45 | #include "BearerData.h" |
| 46 | |
| 47 | class SmsMessage: public SmsMessageBase { |
| 48 | public: |
| 49 | SmsMessage(); |
| 50 | SmsMessage(std::shared_ptr<SmsAddress> addr, |
| 51 | std::shared_ptr<SmsEnvelope> env); |
| 52 | virtual ~SmsMessage(); |
| 53 | class SubmitPdu: SubmitPduBase { |
| 54 | }; |
| 55 | static std::shared_ptr<SmsMessage> createFromPdu(std::vector<uint8_t> pdu); |
| 56 | virtual SmsConstants::MessageClass getMessageClass() override; |
| 57 | virtual int getProtocolIdentifier() override; |
| 58 | virtual bool isReplace() override; |
| 59 | virtual bool isCphsMwiMessage() override; |
| 60 | virtual bool isMWIClearMessage() override; |
| 61 | virtual bool isMWISetMessage() override; |
| 62 | virtual bool isMwiDontStore() override; |
| 63 | virtual int getStatus() override; |
| 64 | virtual bool isStatusReportMessage() override; |
| 65 | virtual bool isReplyPathPresent() override; |
| 66 | //static std::shared_ptr<SmsMessage> createFromEfRecord(int index, uint8_t* data, int length); |
| 67 | int getTeleService() { |
| 68 | return mEnvelope->teleService; |
| 69 | } |
| 70 | int getMessageType(); |
| 71 | void parseSms(); |
| 72 | void createPdu(); |
| 73 | std::vector<std::uint8_t> getIncomingSmsFingerprint(); |
| 74 | static uint8_t convertDtmfToAscii(uint8_t dtmfDigit); |
| 75 | private: |
| 76 | |
| 77 | //void parsePduFromEfRecord(uint8_t* pdu, int length); |
| 78 | constexpr static uint8_t TELESERVICE_IDENTIFIER = 0x00; |
| 79 | constexpr static uint8_t SERVICE_CATEGORY = 0x01; |
| 80 | constexpr static uint8_t ORIGINATING_ADDRESS = 0x02; |
| 81 | constexpr static uint8_t ORIGINATING_SUB_ADDRESS = 0x03; |
| 82 | constexpr static uint8_t DESTINATION_ADDRESS = 0x04; |
| 83 | constexpr static uint8_t DESTINATION_SUB_ADDRESS = 0x05; |
| 84 | constexpr static uint8_t BEARER_REPLY_OPTION = 0x06; |
| 85 | constexpr static uint8_t CAUSE_CODES = 0x07; |
| 86 | constexpr static uint8_t BEARER_DATA = 0x08; |
| 87 | |
| 88 | /** |
| 89 | * Status of a previously submitted SMS. |
| 90 | * This field applies to SMS Delivery Acknowledge messages. 0 indicates success; |
| 91 | * Here, the error class is defined by the bits from 9-8, the status code by the bits from 7-0. |
| 92 | * See C.S0015-B, v2.0, 4.5.21 for a detailed description of possible values. |
| 93 | */ |
| 94 | int status = 0; |
| 95 | |
| 96 | /** Specifies if a return of an acknowledgment is requested for send SMS */ |
| 97 | static constexpr int RETURN_NO_ACK = 0; |
| 98 | static constexpr int RETURN_ACK = 1; |
| 99 | |
| 100 | /** |
| 101 | * Supported priority modes for CDMA SMS messages |
| 102 | * (See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1) |
| 103 | */ |
| 104 | static constexpr int PRIORITY_NORMAL = 0x0; |
| 105 | static constexpr int PRIORITY_INTERACTIVE = 0x1; |
| 106 | static constexpr int PRIORITY_URGENT = 0x2; |
| 107 | static constexpr int PRIORITY_EMERGENCY = 0x3; |
| 108 | |
| 109 | std::shared_ptr<SmsEnvelope> mEnvelope = nullptr; |
| 110 | std::shared_ptr<BearerData> mBearerData = nullptr; |
| 111 | static uint32_t mPos; |
| 112 | void writeInt(uint32_t data); |
| 113 | uint32_t readInt(std::vector<uint8_t> pdu); |
| 114 | void writeVector(std::vector<uint8_t> v); |
| 115 | std::vector<uint8_t> readVector(std::vector<uint8_t> v, int length); |
| 116 | void writeByte(uint8_t data); |
| 117 | uint8_t readByte(std::vector<uint8_t> pdu); |
| 118 | void parsePdu(std::vector<uint8_t> pdu); |
| 119 | }; |
| 120 | |
| 121 | #endif /* SMSMESSAGE_H_ */ |