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 MAP_MSE_TYPES_H 17 #define MAP_MSE_TYPES_H 18 19 #include <cstdint> 20 #include <string> 21 #include "bt_def.h" 22 #include "log.h" 23 24 namespace OHOS { 25 namespace bluetooth { 26 #define MAP_MSE_L2CAP_ENABLE 27 #define MSE_LOG_DEBUG(fmt, ...) LOG_DEBUG("[MAP MSE]:" fmt, ##__VA_ARGS__) 28 #define MSE_LOG_INFO(fmt, ...) LOG_INFO("[MAP MSE]:" fmt, ##__VA_ARGS__) 29 #define MSE_LOG_ERROR(fmt, ...) LOG_ERROR("[MAP MSE]:" fmt, ##__VA_ARGS__) 30 enum Result { FAIL = 0, SUCCEED = 1 }; 31 enum TagId {}; 32 enum ObexCallBack { 33 ON_CONNECTED, 34 ON_DISCONNECTED, 35 ON_GET, 36 ON_PUT, 37 ON_ABORT, 38 ON_SET_PATH, 39 ON_TRANSPORT_DISCONNECTED, 40 ON_TRANSPORT_ERROR 41 }; 42 enum class MessageType { NONE, EMAIL, SMS_GSM, SMS_CDMA, MMS, IM }; 43 enum class Attachment : uint8_t { OFF = 0x00, ON = 0x01 }; 44 enum class Transparent : uint8_t { OFF = 0x00, ON = 0x01 }; 45 enum class Retry : uint8_t { OFF = 0x00, ON = 0x01 }; 46 enum class NewMessage : uint8_t { OFF = 0x00, ON = 0x01 }; 47 enum class NotificationStatus : uint8_t { OFF = 0x00, ON = 0x01 }; 48 enum class Charset : uint8_t { NATIVE = 0x00, UTF_8 = 0x01 }; 49 enum class FractionRequest : uint8_t { FIRST = 0x00, NEXT = 0x01 }; 50 enum class FractionDeliver : uint8_t { MORE = 0x00, LAST = 0x01 }; 51 enum class StatusIndicator : uint8_t { READ_STATUS = 0x00, DELETED_STATUS = 0x01, SET_EXTENDED_DATA = 0x02 }; 52 enum class StatusValue : uint8_t { NO = 0x00, YES = 0x01 }; 53 enum class ModifyText : uint8_t { REPLACE = 0x00, PREPEND = 0x01 }; 54 static const std::string MAP_MSE_TYPE_EMAIL = "EMAIL"; 55 static const std::string MAP_MSE_TYPE_SMS_GSM = "SMS_GSM"; 56 static const std::string MAP_MSE_TYPE_SMS_CDMA = "SMS_CDMA"; 57 static const std::string MAP_MSE_TYPE_MMS = "MMS"; 58 static const std::string MAP_MSE_TYPE_IM = "IM"; 59 /// map contract 60 static const std::string MAP_MSE_FOLDER_NAME_INBOX = "inbox"; 61 static const std::string MAP_MSE_FOLDER_NAME_SENT = "sent"; 62 static const std::string MAP_MSE_FOLDER_NAME_OUTBOX = "outbox"; 63 static const std::string MAP_MSE_FOLDER_NAME_DRAFT = "draft"; 64 static const std::string MAP_MSE_FOLDER_NAME_DELETED = "deleted"; 65 static const std::string MAP_MSE_FOLDER_NAME_OTHER = "other"; 66 enum ImFolderId { 67 MAP_MSE_FOLDER_ID_OTHER = 0, 68 MAP_MSE_FOLDER_ID_INBOX = 1, 69 MAP_MSE_FOLDER_ID_SENT = 2, 70 MAP_MSE_FOLDER_ID_DRAFT = 3, 71 MAP_MSE_FOLDER_ID_OUTBOX = 4, 72 MAP_MSE_FOLDER_ID_DELETED = 5 73 }; 74 // SDP Record for the Message Access Service on the MSE Device 75 static const uint16_t MAS_SERVICE_CLASS_ID_NUMBER = 0x0001; 76 static const uint16_t MAS_SERVICE_CLASS_UUID = 0x1132; 77 static const uint16_t MAP_PROFILE_VERSION12 = 0x0102; 78 static const uint16_t MAP_PROFILE_VERSION13 = 0x0103; 79 static const uint16_t MAP_PROFILE_VERSION14 = 0x0104; 80 static const uint16_t MAP_PROFILE_DESCRIPTOR_UUID = 0x1134; 81 static const uint16_t MAP_PROFILE_DESCRIPTOR_NUMBER = 0x0001; 82 static const uint16_t PROTOCOL_DESCRIPTOR_NUMBER = 0x0003; 83 static const uint16_t PROTOCOL_DESCRIPTOR_PARAMETER_NUMBER = 0x01; 84 static const uint16_t MAS_BROWSE_GROUP_UUID_NUMBER = 0x0001; 85 86 // Supported Message Types 87 static const uint8_t MAP_SUPPORTED_MESSAGE_TYPE_EMAIL = 0x01; 88 static const uint8_t MAP_SUPPORTED_MESSAGE_TYPE_SMS_GSM = 0x02; 89 static const uint8_t MAP_SUPPORTED_MESSAGE_TYPE_SMS_CDMA = 0x04; 90 static const uint8_t MAP_SUPPORTED_MESSAGE_TYPE_MMS = 0x08; 91 static const uint8_t MAP_SUPPORTED_MESSAGE_TYPE_IM = 0x10; 92 static const uint16_t MAP_SUPPORTED_MESSAGE_TYPE_ATTRIBUTE_ID = 0x0316; 93 94 // GoepL2capPsm (MAP v1.2 and later) 95 static const uint16_t GOEP_L2CAP_PSM_ATTRIBUTE_ID = 0x0200; 96 97 // MASInstanceID 98 static const uint16_t MAS_INSTANCE_ATTRIBUTE_ID = 0x0315; 99 100 // incoming connect time out 25 sec 101 static const uint16_t MAP_MSE_INCOMING_TIME_OUT = 25000; 102 static const uint16_t MAP_MSE_DELAY_GRANT_TIME = 300; 103 104 // Map service name and type 105 static const std::string SMS_MMS_NAME = "SMS_MMS"; 106 static const std::string EMAIL_NAME = "EMAIL"; 107 static const std::string IM_NAME = "IM"; 108 109 // Map Supported Features 110 static const uint16_t MAP_SUPPORTED_FEATURES_ATTRIBUTE_ID = 0x0317; 111 static const uint32_t MAP_SUPPORTED_FEATURES_V12 = 0x0000007F; 112 static const uint32_t MAP_SUPPORTED_FEATURES_V13 = 0x000603FF; 113 static const uint32_t MAP_SUPPORTED_FEATURES_V14 = 0x007EFFFF; 114 static const uint32_t MAP_SUPPORTED_FEATURES_DEFAULT = 0x0000001F; 115 116 static const uint32_t MAP_FEATURE_NOTIFICATION_REGISTRATION_BIT = uint32_t(1) << 0; 117 static const uint32_t MAP_FEATURE_NOTIFICATION_BIT = uint32_t(1) << 1; 118 static const uint32_t MAP_FEATURE_BROWSING_BIT = uint32_t(1) << 2; 119 static const uint32_t MAP_FEATURE_UPLOADING_BIT = uint32_t(1) << 3; 120 static const uint32_t MAP_FEATURE_DELETE_BIT = uint32_t(1) << 4; 121 static const uint32_t MAP_FEATURE_INSTANCE_INFORMATION_BIT = uint32_t(1) << 5; 122 static const uint32_t MAP_FEATURE_EXTENDED_EVENT_REPORT_11_BIT = uint32_t(1) << 6; 123 static const uint32_t MAP_FEATURE_EVENT_REPORT_V12_BIT = uint32_t(1) << 7; 124 static const uint32_t MAP_FEATURE_MESSAGE_FORMAT_V11_BIT = uint32_t(1) << 8; 125 static const uint32_t MAP_FEATURE_MESSAGE_LISTING_FORMAT_V11_BIT = uint32_t(1) << 9; 126 static const uint32_t MAP_FEATURE_PERSISTENT_MESSAGE_HANDLE_BIT = uint32_t(1) << 10; 127 static const uint32_t MAP_FEATURE_DATABASE_INDENTIFIER_BIT = uint32_t(1) << 11; 128 static const uint32_t MAP_FEATURE_FOLDER_VERSION_COUNTER_BIT = uint32_t(1) << 12; 129 static const uint32_t MAP_FEATURE_CONVERSATION_VERSION_COUNTER_BIT = uint32_t(1) << 13; 130 static const uint32_t MAP_FEATURE_PARTICIPANT_PRESENCE_CHANGE_BIT = uint32_t(1) << 14; 131 static const uint32_t MAP_FEATURE_PARTICIPANT_CHAT_STATE_CHANGE_BIT = uint32_t(1) << 15; 132 133 static const uint32_t MAP_FEATURE_PBAP_CONTACT_CROSS_REFERENCE_BIT = uint32_t(1) << 16; 134 static const uint32_t MAP_FEATURE_NOTIFICATION_FILTERING_BIT = uint32_t(1) << 17; 135 static const uint32_t MAP_FEATURE_DEFINED_TIMESTAMP_FORMAT_BIT = uint32_t(1) << 18; 136 static const uint32_t MAP_FEATURE_CONNECT_REQUEST_BIT = uint32_t(1) << 19; 137 static const uint32_t MAP_FEATURE_CONVERSATIONLISTING_BIT = uint32_t(1) << 20; 138 static const uint32_t MAP_FEATURE_OWNER_STATUS_BIT = uint32_t(1) << 21; 139 static const uint32_t MAP_FEATURE_MESSAGE_FORWARDING_BIT = uint32_t(1) << 22; 140 141 static const std::string MAP_V10 = "1.0"; 142 static const std::string MAP_V11 = "1.1"; 143 static const std::string MAP_V12 = "1.2"; 144 145 // Event Report versions 146 static const uint8_t MAP_EVENT_REPORT_V10 = 0x10; // MAP spec 1.1 147 static const uint8_t MAP_EVENT_REPORT_V11 = 0x11; // MAP spec 1.2 148 static const uint8_t MAP_EVENT_REPORT_V12 = 0x12; // MAP spec 1.3 'to be' incl. IM 149 150 // Message Format versions 151 static const uint8_t MAP_MESSAGE_FORMAT_V10 = 0x10; // MAP spec below 1.3 152 static const uint8_t MAP_MESSAGE_FORMAT_V11 = 0x11; // MAP spec 1.3 153 154 // Message Listing Format versions 155 static const uint8_t MAP_MESSAGE_LISTING_FORMAT_V10 = 0x10; // MAP spec below 1.3 156 static const uint8_t MAP_MESSAGE_LISTING_FORMAT_V11 = 0x11; // MAP spec 1.3 157 158 // Message handle mask 159 static const uint64_t MESSAGE_HANDLE_MASK = 0xff00000000000000; 160 static const uint64_t MESSAGE_HANDLE_MMS_MASK = 0x0100000000000000; 161 static const uint64_t MESSAGE_HANDLE_EMAIL_MASK = 0x0200000000000000; 162 static const uint64_t MESSAGE_HANDLE_SMS_GSM_MASK = 0x0400000000000000; 163 static const uint64_t MESSAGE_HANDLE_SMS_CDMA_MASK = 0x0800000000000000; 164 static const uint64_t MESSAGE_HANDLE_IM_MASK = 0x1000000000000000; 165 166 // Database name 167 static const std::string DEFAULT_MAP_MSE_DB_FILE = "map_mse.s3db"; 168 169 // Table name 170 static const std::string MAP_MSE_TABLE_ACCOUNT = "account"; 171 static const std::string MAP_MSE_TABLE_MESSAGE = "message"; 172 static const std::string MAP_MSE_TABLE_FOLDER = "folder"; 173 static const std::string MAP_MSE_TABLE_CONVERSATION = "conversation"; 174 static const std::string MAP_MSE_TABLE_PARTICIPANT = "participant"; 175 } // namespace bluetooth 176 } // namespace OHOS 177 178 #endif // MAP_MSE_TYPES_H