blob: cd1369c4a3e5ac3a91b7b54352af401147ae77a1 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* 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 SMSHEADER_H_
37#define SMSHEADER_H_
38#include <cstdint>
39#include <list>
40#include <memory>
41#include <vector>
42#include <string>
43class SmsHeader {
44public:
45 SmsHeader();
46 virtual ~SmsHeader();
47
48 // TODO(cleanup): this data structure is generally referred to as
49 // the 'user data header' or UDH, and so the class name should
50 // change to reflect this...
51
52 /** SMS user data header information element identifiers.
53 * (see TS 23.040 9.2.3.24)
54 */
55 static constexpr int ELT_ID_CONCATENATED_8_BIT_REFERENCE = 0x00;
56 static constexpr int ELT_ID_SPECIAL_SMS_MESSAGE_INDICATION = 0x01;
57 static constexpr int ELT_ID_APPLICATION_PORT_ADDRESSING_8_BIT = 0x04;
58 static constexpr int ELT_ID_APPLICATION_PORT_ADDRESSING_16_BIT = 0x05;
59 static constexpr int ELT_ID_SMSC_CONTROL_PARAMS = 0x06;
60 static constexpr int ELT_ID_UDH_SOURCE_INDICATION = 0x07;
61 static constexpr int ELT_ID_CONCATENATED_16_BIT_REFERENCE = 0x08;
62 static constexpr int ELT_ID_WIRELESS_CTRL_MSG_PROTOCOL = 0x09;
63 static constexpr int ELT_ID_TEXT_FORMATTING = 0x0A;
64 static constexpr int ELT_ID_PREDEFINED_SOUND = 0x0B;
65 static constexpr int ELT_ID_USER_DEFINED_SOUND = 0x0C;
66 static constexpr int ELT_ID_PREDEFINED_ANIMATION = 0x0D;
67 static constexpr int ELT_ID_LARGE_ANIMATION = 0x0E;
68 static constexpr int ELT_ID_SMALL_ANIMATION = 0x0F;
69 static constexpr int ELT_ID_LARGE_PICTURE = 0x10;
70 static constexpr int ELT_ID_SMALL_PICTURE = 0x11;
71 static constexpr int ELT_ID_VARIABLE_PICTURE = 0x12;
72 static constexpr int ELT_ID_USER_PROMPT_INDICATOR = 0x13;
73 static constexpr int ELT_ID_EXTENDED_OBJECT = 0x14;
74 static constexpr int ELT_ID_REUSED_EXTENDED_OBJECT = 0x15;
75 static constexpr int ELT_ID_COMPRESSION_CONTROL = 0x16;
76 static constexpr int ELT_ID_OBJECT_DISTR_INDICATOR = 0x17;
77 static constexpr int ELT_ID_STANDARD_WVG_OBJECT = 0x18;
78 static constexpr int ELT_ID_CHARACTER_SIZE_WVG_OBJECT = 0x19;
79 static constexpr int ELT_ID_EXTENDED_OBJECT_DATA_REQUEST_CMD = 0x1A;
80 static constexpr int ELT_ID_RFC_822_EMAIL_HEADER = 0x20;
81 static constexpr int ELT_ID_HYPERLINK_FORMAT_ELEMENT = 0x21;
82 static constexpr int ELT_ID_REPLY_ADDRESS_ELEMENT = 0x22;
83 static constexpr int ELT_ID_ENHANCED_VOICE_MAIL_INFORMATION = 0x23;
84 static constexpr int ELT_ID_NATIONAL_LANGUAGE_SINGLE_SHIFT = 0x24;
85 static constexpr int ELT_ID_NATIONAL_LANGUAGE_LOCKING_SHIFT = 0x25;
86
87 static constexpr int PORT_WAP_PUSH = 2948;
88 static constexpr int PORT_WAP_WSP = 9200;
89
90 class PortAddrs {
91 public:
92 int destPort;
93 int origPort;
94 bool areEightBits;
95 };
96
97 class ConcatRef {
98 public:
99 int refNumber;
100 int seqNumber;
101 int msgCount;
102 bool isEightBits;
103 };
104
105 class SpecialSmsMsg {
106 public:
107 int msgIndType;
108 int msgCount;
109 };
110
111 /**
112 * A header element that is not explicitly parsed, meaning not
113 * PortAddrs or ConcatRef or SpecialSmsMsg.
114 */
115 class MiscElt {
116 public:
117 int id;
118 std::vector<uint8_t> data;
119 //uint8_t* data; //Remember to free
120 //uint32_t data_length;
121 };
122
123 std::shared_ptr<PortAddrs> portAddrs = nullptr;
124 std::shared_ptr<ConcatRef> concatRef;
125 std::list<std::shared_ptr<SpecialSmsMsg>> specialSmsMsgList;
126 std::list<std::shared_ptr<MiscElt>> miscEltList;
127 //list<SpecialSmsMsg> specialSmsMsgList = new ArrayList<SpecialSmsMsg>();
128 //ArrayList<MiscElt> miscEltList = new ArrayList<MiscElt>();
129
130 /** 7 bit national language locking shift table, or 0 for GSM default 7 bit alphabet. */
131 int languageTable;
132
133 /** 7 bit national language single shift table, or 0 for GSM default 7 bit extension table. */
134 int languageShiftTable;
135 static std::shared_ptr<SmsHeader> fromByteArray(std::vector<uint8_t> v);
136 static std::vector<uint8_t> toByteArray(std::shared_ptr<SmsHeader> smsHeader);
137 std::string toString();
138};
139
140#endif /* SMSHEADER_H_ */