rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef CDMASMSADDRESS_H_ |
| 18 | #define CDMASMSADDRESS_H_ |
| 19 | #include <map> |
| 20 | #include <string> |
| 21 | #include <memory> |
| 22 | #include "SmsAddress.h" |
| 23 | |
| 24 | class CdmaSmsAddress: public SmsAddress { |
| 25 | public: |
| 26 | CdmaSmsAddress(); |
| 27 | virtual ~CdmaSmsAddress(); |
| 28 | |
| 29 | /** |
| 30 | * Digit Mode Indicator is a 1-bit value that indicates whether |
| 31 | * the address digits are 4-bit DTMF codes or 8-bit codes. (See |
| 32 | * 3GPP2 C.S0015-B, v2, 3.4.3.3) |
| 33 | */ |
| 34 | static constexpr int DIGIT_MODE_4BIT_DTMF = 0x00; |
| 35 | static constexpr int DIGIT_MODE_8BIT_CHAR = 0x01; |
| 36 | |
| 37 | int digitMode = -1; |
| 38 | |
| 39 | /** |
| 40 | * Number Mode Indicator is 1-bit value that indicates whether the |
| 41 | * address type is a data network address or not. (See 3GPP2 |
| 42 | * C.S0015-B, v2, 3.4.3.3) |
| 43 | */ |
| 44 | static constexpr int NUMBER_MODE_NOT_DATA_NETWORK = 0x00; |
| 45 | static constexpr int NUMBER_MODE_DATA_NETWORK = 0x01; |
| 46 | |
| 47 | int numberMode = -1; |
| 48 | |
| 49 | /** |
| 50 | * Number Types for data networks. |
| 51 | * (See 3GPP2 C.S005-D, table2.7.1.3.2.4-2 for complete table) |
| 52 | * (See 3GPP2 C.S0015-B, v2, 3.4.3.3 for data network subset) |
| 53 | * NOTE: value is stored in the parent class ton field. |
| 54 | */ |
| 55 | static constexpr int TON_UNKNOWN = 0x00; |
| 56 | static constexpr int TON_INTERNATIONAL_OR_IP = 0x01; |
| 57 | static constexpr int TON_NATIONAL_OR_EMAIL = 0x02; |
| 58 | static constexpr int TON_NETWORK = 0x03; |
| 59 | static constexpr int TON_SUBSCRIBER = 0x04; |
| 60 | static constexpr int TON_ALPHANUMERIC = 0x05; |
| 61 | static constexpr int TON_ABBREVIATED = 0x06; |
| 62 | static constexpr int TON_RESERVED = 0x07; |
| 63 | |
| 64 | /** |
| 65 | * Maximum lengths for fields as defined in ril_cdma_sms.h. |
| 66 | */ |
| 67 | static constexpr int SMS_ADDRESS_MAX = 36; |
| 68 | static constexpr int SMS_SUBADDRESS_MAX = 36; |
| 69 | |
| 70 | /** |
| 71 | * This field shall be set to the number of address digits |
| 72 | * (See 3GPP2 C.S0015-B, v2, 3.4.3.3) |
| 73 | */ |
| 74 | int numberOfDigits = -1; |
| 75 | |
| 76 | /** |
| 77 | * Numbering Plan identification is a 0 or 4-bit value that |
| 78 | * indicates which numbering plan identification is set. (See |
| 79 | * 3GPP2, C.S0015-B, v2, 3.4.3.3 and C.S005-D, table2.7.1.3.2.4-3) |
| 80 | */ |
| 81 | static constexpr int NUMBERING_PLAN_UNKNOWN = 0x0; |
| 82 | static constexpr int NUMBERING_PLAN_ISDN_TELEPHONY = 0x1; |
| 83 | //static protected final int NUMBERING_PLAN_DATA = 0x3; |
| 84 | //static protected final int NUMBERING_PLAN_TELEX = 0x4; |
| 85 | //static protected final int NUMBERING_PLAN_PRIVATE = 0x9; |
| 86 | |
| 87 | int numberPlan = -1; |
| 88 | static std::vector<uint8_t> parseToDtmf(std::string address); |
| 89 | static std::shared_ptr<CdmaSmsAddress> parse(char* adr); |
| 90 | std::string toString(); |
| 91 | private: |
| 92 | static const char numericCharsDialable[]; |
| 93 | |
| 94 | static const char numericCharsSugar[]; |
| 95 | |
| 96 | static std::map<char, bool> numericCharDialableMap; |
| 97 | static std::map<char, bool> init(); |
| 98 | static std::string filterNumericSugar(std::string address); |
| 99 | static std::string filterWhitespace(std::string address); |
| 100 | |
| 101 | }; |
| 102 | #endif /* CDMASMSADDRESS_H_ */ |