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 /** 17 * @addtogroup Bluetooth 18 * @{ 19 * 20 * @brief Defines map client framework interface, including observer and api functions. 21 * 22 * @since 6 23 */ 24 25 /** 26 * @file bluetooth_map_mce.h 27 * 28 * @brief map client interface. 29 * 30 * @since 6 31 */ 32 33 #ifndef BLUETOOTH_MAP_MCE_H 34 #define BLUETOOTH_MAP_MCE_H 35 36 #include "bluetooth_def.h" 37 #include "bluetooth_types.h" 38 #include "bluetooth_remote_device.h" 39 40 namespace OHOS { 41 namespace Bluetooth { 42 /** 43 * @brief Map Event Report 44 * 45 * @since 6 46 */ 47 struct MapEventReport { 48 std::string type = ""; // NewMessage, DeliverySuccess, SendingSuccess, DeliveryFailure ,SendingFailure , 49 // MemoryFull, MemoryAvailable, MessageDeleted, MessageShift, ReadStatusChanged, 50 // MessageRemoved, MessageExtendedData-Changed, ParticipantPresence-Changed, 51 // ParticipantChatState-Changed, ConversationChanged 52 std::string handle = ""; 53 std::u16string folder = u""; 54 std::u16string old_folder = u""; 55 MapMessageType msg_type = MapMessageType::INVALID; 56 std::string datetime = ""; 57 std::string subject = ""; 58 std::string sender_name = ""; 59 MapBoolType priority = MapBoolType::INVALID; // Value "yes" is high priority; "no" is not of high priority. 60 std::string conversation_name = ""; 61 std::string conversation_id = ""; 62 std::string presence_availability = ""; 63 std::string presence_text = ""; 64 std::string last_activity = ""; 65 std::string chat_state = ""; 66 MapMessageStatus read_status = 67 MapMessageStatus::INVALID; // Shall be used only if the event “type” is “NewMessage” or “ReadStatusChanged”. 68 std::string extended_data = ""; // be used only if the event “type” is “MessageExtendedDataChanged”. 69 std::string participant_uci = ""; 70 std::string contact_uid = ""; 71 std::string version = ""; 72 uint8_t masInstanceId_ = 0; 73 std::string eventReportStringObject_ = ""; // all string of the event report object 74 }; 75 76 /** 77 * @brief MessagesOutline in messageslisting 78 * 79 * @since 6 80 */ 81 struct MessageOutline { 82 std::string handle = ""; // is the message handle in hexadecimal representation with up to 16 digits 83 std::string subject = ""; // is the summary of the message 84 std::string datetime = ""; // is the timestamp of the message in format "YYYYMMDDTHHMMSS" or “YYYYMMDDTHHMMSS±HHMM” 85 std::string sender_name = ""; // is the name of the sender of the message when it is known by the MSE device. 86 std::string sender_addressing = ""; // is the addressing information of the sender 87 std::string replyto_addressing = ""; // is the address information for replies to the sender 88 std::string recipient_name = ""; // is the name of the recipient of the message when it is known by the MSE device. 89 std::string recipient_addressing = ""; // is the addressing information of the recipient. 90 MapMessageType type = MapMessageType::INVALID; // gives the type of the message. use the type: MapMessageType. 91 MapMsgReceptionStatus receptionStatus = 92 MapMsgReceptionStatus::INVALID; // Gives the status of reception of the message. use the 93 // type:MapMsgReceptionStatus 94 int size = 0; // The overall size in bytes of the original message as received from the network. 95 int attachment_size = 0; // The overall size of the attachments in bytes. 96 MapBoolType text = 97 MapBoolType::INVALID; // Value "yes" indicates the original message or (in case of multipart-messages) that a 98 // part of the message includes textual content; "no" indicates that the message has no 99 // textual content, only binary. 100 MapMessageStatus read = 101 MapMessageStatus::INVALID; // Value "yes" indicates that the message has already been read on the MSE; "no" 102 // indicates that the message has not yet been read 103 MapBoolType sent = MapBoolType::INVALID; // Value "yes" indicates that the message has already been sent to the 104 // recipient; "no" indicates that the message has not yet been sent. 105 MapBoolType protected_ = 106 MapBoolType::INVALID; // Value "yes" indicates that the message or a part of the message (e.g., attachment) is 107 // protected by a DRM scheme; "no" indicates that the message is not protected by DRM. 108 MapBoolType priority = MapBoolType::INVALID; // Value "yes" indicates that the message is of high priority; "no" 109 // indicates that the message is not of high priority. 110 MapMsgDeliveryStatus delivery_status = 111 MapMsgDeliveryStatus::INVALID; // V1.1 support , Provides the status of delivery of the message. 112 std::string conversation_id = ""; // V1.1 support , The identification of the conversation. 113 std::string conversation_name = ""; // V1.1 support , The human readable name of the conversation. 114 MapMsgDirection direction = 115 MapMsgDirection::INVALID; // V1.1 support , This attribute shall indicate the direction of the message. 116 std::string attachment_mime_types = ""; // V1.1 support , The MIME type of the attachment(s). 117 }; 118 /** 119 * @brief MessagesListing Param Struct 120 * 121 * @since 6 122 */ 123 struct MessagesListingParamStruct { 124 MapOnOffType NewMessage = MapOnOffType::INVALID; // on off 125 std::string MseTime = ""; // String with current time basis and UTC-offset of the MSE. 126 uint16_t ListingSize = 0; 127 std::string DatabaseIdentifier = ""; // 128-bit value in hex string format,max 32 bytes 128 std::string FolderVersionCounter = ""; // 128-bit value in hex string format,max 32 bytes 129 std::string Version = ""; // "1.1" or "1.0" 130 }; 131 132 /** 133 * @brief MessagesListing class 134 */ 135 struct MessagesListing { 136 std::vector<MessageOutline> messageOutlineList_ {}; 137 MessagesListingParamStruct messagesListingParam_ {}; 138 std::string messagesListingStringObject_ = ""; // all string of the messagelist object 139 }; 140 141 /** 142 * @brief Vcard 3_0 143 * 144 * @since 6 145 */ 146 struct MapVcard { 147 std::string VERSION = ""; // shall be included 148 std::string N = ""; // shall be included 149 std::vector<std::string> TEL {}; // may be used 150 std::vector<std::string> EMAIL {}; // may be used 151 std::vector<std::string> X_BT_UID {}; // bmsg V1.1 152 std::vector<std::string> X_BT_UCI {}; // bmsg V1.1 153 std::string FN = ""; // vcard 3.0 , shall be included 154 }; 155 /** 156 * @brief <bmessage-content> 157 * 158 * @since 6 159 */ 160 struct BMessageContent { 161 // <bmessage-body-part-ID> 162 std::string bodyPartID = ""; // This property shall be used if and only if the content of the related message 163 // cannot be delivered completely within one <bmessage-content> object 164 // <bmessage-body-property> 165 std::string body_encoding = ""; // Email/MMS [6], [9]: "8BIT" (for 8-Bit Clean encoding). 166 // GSM-SMS [14]: "G-7BIT" (GSM 7 bit Default Alphabet), "G-7BITEXT" (GSM 7 bit 167 // Alphabet with national language extension), "G-UCS2", and "G-8BIT". CDMA-SMS 168 // [13]: "C-8BIT" (Octet, unspecified), "C-EPM" (Extended Protocol Message), 169 // "C-7ASCII (7-bit ASCII), "C-IA5" (IA5), "C-UNICODE" (UNICODE), "C-SJIS" 170 // (Shift-JIS), "C-KOREAN" (Korean),"C-LATINHEB” (Latin/Hebrew), and “C-LATIN” 171 // (Latin). For IM: [6] "8BIT" (for 8-Bit Clean encoding). Ver1.1 172 std::string body_charset = ""; // UTF-8 or SMS PDU 173 std::string body_language = ""; // GSM-SMS [14]: " TURKISH", " SPANISH", "PORTUGUESE", "UNKNOWN" 174 // CDMA-SMS [13]: "ENGLISH", "FRENCH", "SPANISH", "JAPANESE", "KOREAN", "CHINESE", 175 // "HEBREW", "UNKNOWN" 176 int body_content_length = 0; 177 178 // <bmessage-body-content> 179 std::string body_content = ""; // body-content support V1.1 IM 180 }; 181 /** 182 * @brief <bmessage-envelope> 183 * 184 * @since 6 185 */ 186 struct BMessageEnvelope { 187 // <initial-envelope> [<initial-recipient>]* 188 std::vector<MapVcard> recipientLevel1_ {}; // valid only in level 2/3 189 // <middle-envelope> [<middle-recipient>]* 190 std::vector<MapVcard> recipientLevel2_ {}; // valid only in level 3 191 // <final-envelope> [<final-recipient>]* 192 std::vector<MapVcard> recipientLevel3_ {}; // Final Recipient , always valid 193 // The maximum level of <bmessage-envelope> 194 int maxLevelOfEnvelope_ = 0; 195 // <bmessage-content> 196 BMessageContent msgBody_ {}; 197 }; 198 199 /** 200 * @brief receive msg, support both 1.0 and 1.1 201 * 202 * @since 6 203 */ 204 struct BMessageStruct { 205 // <bmessage-property> 206 std::string version_property = ""; 207 MapMessageStatus readstatus_property = MapMessageStatus::INVALID; // "READ" or "UNREAD" 208 MapMessageType type_property = 209 MapMessageType::INVALID; // V1.0 include "EMAIL","SMS_GSM","SMS_CDMA","MMS", V1.1 add a "IM" 210 std::u16string folder_property = 211 u""; // This is the folder name including the path where the bMessage is located in. 212 std::string extendeddata_property = ""; // extended data only V1.1 213 // [<bmessage-originator>]? 214 std::vector<MapVcard> originator_ {}; // This property includes a vCard identifying the originator 215 // <bmessage-envelope> 216 BMessageEnvelope envelope_ {}; // The maximum level of <bmessage-envelope> encapsulation shall be three. 217 }; 218 /** 219 * @brief BMessage 220 * 221 * @since 6 222 */ 223 struct MapBMessage { 224 MapFractionDeliverType FractionDeliver = 225 MapFractionDeliverType::INVALID; // MapFractionDeliverType type, 0 = "more",1 = "last" 226 BMessageStruct bMessageParam_ {}; 227 std::string bMessageStringObject_ = ""; // all string of the bmessage object 228 }; 229 230 /** 231 * @brief Conversation Participant 232 */ 233 struct Participant { 234 std::string uci = ""; 235 std::string display_name = ""; 236 std::string chat_state = ""; 237 std::string last_activity = ""; 238 std::string x_bt_uid = ""; 239 std::string name = ""; 240 std::string presence_availability = ""; 241 std::string presence_text = ""; 242 std::string priority = ""; 243 }; 244 245 /** 246 * @brief Conversation 247 */ 248 struct Conversation { 249 std::string id = ""; 250 std::string name = ""; 251 std::string last_activity = ""; 252 std::string read_status = ""; 253 std::string version_counter = ""; 254 std::string summary = ""; 255 std::vector<Participant> participantList_ {}; 256 }; 257 258 /** 259 * @brief ConversationListing ParamStuct 260 */ 261 struct ConversationListingParamStuct { 262 std::string ConversationListingVersionCounter = ""; // 128-bit value in hex string format(max 32 bytes) 263 uint16_t ListingSize = 0; 264 std::string DatabaseIdentifier = ""; // 128-bit value in hex string format(max 32 bytes) 265 std::string MseTime = ""; // String with current time basis and UTC-offset of the MSE. 266 std::string Version = ""; 267 }; 268 269 /** 270 * @brief IProfile ConversationListing Object 271 */ 272 struct ConversationListing { 273 std::vector<Conversation> conversationOutlineList_ {}; 274 ConversationListingParamStuct conversationListingParam_ {}; 275 std::string conversationListingStringObject_ = ""; 276 }; 277 278 /** 279 * @brief Get Messages Listing Parameters 280 * 281 * @since 6 282 */ 283 struct GetMessagesListingParameters { 284 std::u16string folder = u""; // such as: inbox , outbox 285 uint16_t MaxListCount = 0; // maximum number of the listing 286 uint16_t ListStartOffset = 0; // the offset of the first entry of the returned listing object 287 uint8_t SubjectLength = 0; 288 uint32_t ParameterMask = 0; // Bit mask: Bit i=1 indicates that the parameter related to Bit i 289 // shall be present in the requested Messages-Listing. 290 // If this value is 0, the MSE shall return all parameters of the Messages- 291 // Listing object DTD labeled as "REQUIRED" and may return all other attributes 292 // The message handle shall always be present. 293 // MAP_GETMESSAGELIST_PARAMETER_MASK_PRESENT_ALL 0b000111111111111111111111 294 // MAP_GETMESSAGELIST_PARAMETER_MASK_SUBJECT 0b000000000000000000000001 295 // MAP_GETMESSAGELIST_PARAMETER_MASK_DATETIME 0b000000000000000000000010 296 // MAP_GETMESSAGELIST_PARAMETER_MASK_SENDER_NAME 0b000000000000000000000100 297 // MAP_GETMESSAGELIST_PARAMETER_MASK_SENDER_ADDRESSING 0b000000000000000000001000 298 // MAP_GETMESSAGELIST_PARAMETER_MASK_RECIPIENT_NAME 0b000000000000000000010000 299 // MAP_GETMESSAGELIST_PARAMETER_MASK_RECIPIENT_ADDRESSING 0b000000000000000000100000 300 // MAP_GETMESSAGELIST_PARAMETER_MASK_TYPE 0b000000000000000001000000 301 // MAP_GETMESSAGELIST_PARAMETER_MASK_SIZE 0b000000000000000010000000 302 // MAP_GETMESSAGELIST_PARAMETER_MASK_RECEPTION_STATUS 0b000000000000000100000000 303 // MAP_GETMESSAGELIST_PARAMETER_MASK_TEXT 0b000000000000001000000000 304 // MAP_GETMESSAGELIST_PARAMETER_MASK_ATTACHMENT_SIZE 0b000000000000010000000000 305 // MAP_GETMESSAGELIST_PARAMETER_MASK_PRIORITY 0b000000000000100000000000 306 // MAP_GETMESSAGELIST_PARAMETER_MASK_READ 0b000000000001000000000000 307 // MAP_GETMESSAGELIST_PARAMETER_MASK_SENT 0b000000000010000000000000 308 // MAP_GETMESSAGELIST_PARAMETER_MASK_PROTECTED 0b000000000100000000000000 309 // MAP_GETMESSAGELIST_PARAMETER_MASK_REPLYTO_ADDRESSING 0b000000001000000000000000 310 // MAP_GETMESSAGELIST_PARAMETER_MASK_DELIVERY_STATUS 0b000000010000000000000000 311 // MAP_GETMESSAGELIST_PARAMETER_MASK_CONVERSATION_ID 0b000000100000000000000000 312 // MAP_GETMESSAGELIST_PARAMETER_MASK_CONVERSATION_NAME 0b000001000000000000000000 313 // MAP_GETMESSAGELIST_PARAMETER_MASK_DIRECTION 0b000010000000000000000000 314 // MAP_GETMESSAGELIST_PARAMETER_MASK_ATTACHMENT_MIME 0b000100000000000000000000 315 uint8_t FilterMessageType = 0; // Bit mask: 0 = no filtering, get this type, 1 = filter out this type 316 // MAP_FILTER_MESSAGE_MASK_SMS_GSM 0b00000001 317 // MAP_FILTER_MESSAGE_MASK_SMS_CDMA 0b00000010 318 // MAP_FILTER_MESSAGE_MASK_EMAIL 0b00000100 319 // MAP_FILTER_MESSAGE_MASK_MMS 0b00001000 320 // MAP_FILTER_MESSAGE_MASK_IM 0b00010000 321 // MAP_FILTER_MESSAGE_MASK_NO_FILTERING 0b00000000 322 std::string FilterPeriodBegin = ""; // String with Begin of filter period. 323 std::string FilterPeriodEnd = ""; // String with End of filter period. 324 uint8_t FilterReadStatus = 0; // Bit mask: 0b01 = get unread only, 0b10 = get read only 325 // MAP_FILTER_READ_STATUS_MASK_UNREAD 0b00000001 326 // MAP_FILTER_READ_STATUS_MASK_READ 0b00000010 327 // MAP_FILTER_READ_STATUS_MASK_NO_FILTERING 0b00000000 328 329 std::string FilterRecipient = ""; // Text (UTF-8), wildcards "*" may be used if required 330 std::string FilterOriginator = ""; // Text (UTF-8), wildcards "*" may be used if required 331 uint8_t FilterPriority = 0; // Bit mask: 0b01 = get high , 0b10 = get no high 332 // MAP_FILTER_PRIORITY_MASK_HIGH 0b00000001 333 // MAP_FILTER_PRIORITY_MASK_NO_HIGH 0b00000010 334 // MAP_FILTER_PRIORITY_MASK_NO_FILTERING 0b00000000 335 std::string ConversationID = ""; 336 std::string FilterMessageHandle = ""; 337 }; 338 /** 339 * @brief Get Message Parameters 340 * 341 * @since 6 342 */ 343 struct GetMessageParameters { 344 MapAttachmentType Attachment = MapAttachmentType::INVALID; 345 MapCharsetType Charset = MapCharsetType::INVALID; 346 MapFractionRequestType FractionRequest = MapFractionRequestType::INVALID; 347 }; 348 /** 349 * @brief Get Conversation Listing Parameters 350 * 351 * @since 6 352 */ 353 struct GetConversationListingParameters { 354 uint16_t MaxListCount = 0; 355 uint16_t ListStartOffset = 0; 356 uint8_t FilterReadStatus = 0; // mask type is: 357 // MAP_FILTER_READ_STATUS_MASK_UNREAD 0b00000001 358 // MAP_FILTER_READ_STATUS_MASK_READ 0b00000010 359 // MAP_FILTER_READ_STATUS_MASK_NO_FILTERING 0b00000000 360 std::string FilterRecipient = ""; // Text (UTF-8), wildcards "*" may be used if required 361 std::string ConversationID = ""; 362 std::string FilterLastActivityBegin = ""; 363 std::string FilterLastActivityEnd = ""; 364 uint32_t ConvParameterMask = 365 0; // ConvParameterMask 0-14 is defined, 15–31 Reserved for Future Use 366 // MAP_GETCONV_PARAMETER_MASK_CONVERSATION_NAME 0b000000000000000000000001 367 // MAP_GETCONV_PARAMETER_MASK_CONVERSATION_LAST_ACTIVITY 0b000000000000000000000010 368 // MAP_GETCONV_PARAMETER_MASK_CONVERSATION_READ_STATUS 0b000000000000000000000100 369 // MAP_GETCONV_PARAMETER_MASK_CONVERSATION_VERSION_COUNTER 0b000000000000000000001000 370 // MAP_GETCONV_PARAMETER_MASK_CONVERSATION_SUMMARY 0b000000000000000000010000 371 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANTS 0b000000000000000000100000 372 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_UCI 0b000000000000000001000000 373 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_DISPLAY_NAME 0b000000000000000010000000 374 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_CHAT_STATE 0b000000000000000100000000 375 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_LAST_ACTIVITY 0b000000000000001000000000 376 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_X_BT_UID 0b000000000000010000000000 377 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_NAME 0b000000000000100000000000 378 // MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_PRESENCE_AVAILABILITY 379 // 0b000000000001000000000000 MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_PRESENCE_TEXT 380 // 0b000000000010000000000000 MAP_GETCONV_PARAMETER_MASK_PARTICIPANT_PRIORITY 381 // 0b000000000100000000000000 382 }; 383 /** 384 * @brief Owner Status Parameters 385 * 386 * @since 6 387 */ 388 struct OwnerStatus { 389 uint8_t PresenceAvailability = 0; 390 std::string PresenceText = ""; 391 std::string LastActivity = ""; 392 uint8_t ChatState = 0; 393 }; 394 /** 395 * @brief Owner Status Parameters 396 * 397 * @since 6 398 */ 399 struct SetOwnerStatusParameters { 400 std::string conversationId_ = ""; 401 OwnerStatus ownerStatus_ {}; 402 }; 403 404 /** 405 * @brief SendMessage Parameters 406 * 407 * @since 6 408 */ 409 struct MapSendMessageParameters { 410 std::string ConversationID = ""; 411 MapAttachmentType Attachment = MapAttachmentType::INVALID; 412 MapCharsetType Charset = MapCharsetType::INVALID; 413 MapOnOffType Transparent = MapOnOffType::INVALID; 414 MapOnOffType Retry = MapOnOffType::INVALID; // 1 is "ON", 0 is "OFF" 415 std::string MessageHandle = ""; // if ModifyText is “PREPEND” 416 MapModifyTextType ModifyText = MapModifyTextType::INVALID; // 0 is “REPLACE” , 1 is “PREPEND” 417 BMessageStruct message {}; 418 }; 419 420 /** 421 * @brief Map MasInstanceInfo Parameters 422 * 423 * @since 6 424 */ 425 struct MapMasInstanceInfo { 426 std::string OwnerUCI = ""; 427 std::string MASInstanceInformation = ""; 428 int supportedMsgTypes_ = 0; // Supported Message Types mask by one instance client 429 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_EMAIL 0x01 430 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_SMS_GSM 0x02 431 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_SMS_CDMA 0x04 432 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_MMS 0x08 433 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_IM 0x10 434 // MAP_MCE_SUPPORTED_MESSAGE_TYPE_ALL 0x01F 435 int instanceId = 0; 436 }; 437 438 /** 439 * @brief Map MasInstanceInfo List Parameters 440 * 441 * @since 6 442 */ 443 struct MapMasInstanceInfoList { 444 bool isValid = false; // data ready 445 std::vector<MapMasInstanceInfo> masInfoList {}; 446 }; 447 /** 448 * @brief set message status 449 * 450 * @since 6 451 */ 452 struct MapSetMessageStatus { 453 std::u16string msgHandle {}; 454 MapStatusIndicatorType statusIndicator = MapStatusIndicatorType::INVALID; 455 MapStatusValueType statusValue = MapStatusValueType::NO; 456 std::string extendedData {}; 457 }; 458 /** 459 * @brief action complete struct 460 * 461 * @since 6 462 */ 463 struct MapAction { 464 MapActionType action_ = MapActionType::UPDATE_INBOX; 465 int supportedFeatures_ = 0; // Map Supported features mask 466 // MAP_SUPPORTED_FEATURES_NOTIFICATION_REGISTRATION 0x00000001 467 // MAP_SUPPORTED_FEATURES_NOTIFICATION_FEATURE 0x00000002 468 // MAP_SUPPORTED_FEATURES_BROWSING 0x00000004 469 // MAP_SUPPORTED_FEATURES_UPLOADING 0x00000008 470 // MAP_SUPPORTED_FEATURES_DELETE_FEATURE 0x00000010 471 // MAP_SUPPORTED_FEATURES_INSTANCE_INFO_FEATURE 0x00000020 472 // MAP_SUPPORTED_FEATURES_EVENT_REPORT_1_1 0x00000040 473 // MAP_SUPPORTED_FEATURES_EVENT_REPORT_1_2 0x00000080 474 // MAP_SUPPORTED_FEATURES_MESSAGE_FORMAT_1_1 0x00000100 475 // MAP_SUPPORTED_FEATURES_MESSAGELIST_FORMAT_1_1 0x00000200 476 // MAP_SUPPORTED_FEATURES_PERSISTENT_MESSAGE_HANDLE 0x00000400 477 // MAP_SUPPORTED_FEATURES_DATABASE_IDENTIFIER 0x00000800 478 // MAP_SUPPORTED_FEATURES_FOLDOR_VERSION_COUNTER 0x00001000 479 // MAP_SUPPORTED_FEATURES_CONVERSATION_VERSION_COUNTER 0x00002000 480 // MAP_SUPPORTED_FEATURES_PARTICIPANT_PRESENCE_CHANGE_NOTIFICATION 0x00004000 481 // MAP_SUPPORTED_FEATURES_PARTICIPANT_CHAT_STATE_CHANGE_NOTIFICATION 0x00008000 482 // MAP_SUPPORTED_FEATURES_PBAP_CONTACT_CROSS_REFERENCE 0x00010000 483 // MAP_SUPPORTED_FEATURES_NOTIFICATION_FILTER 0x00020000 484 // MAP_SUPPORTED_FEATURES_UTC_OFFSET_TIMESTAMP_FORMAT 0x00040000 485 // MAP_SUPPORTED_FEATURES_MAPSUPPORTED_FEATURES 0x00080000 486 // MAP_SUPPORTED_FEATURES_CONVERSATION_LISTING 0x00100000 487 // MAP_SUPPORTED_FEATURES_OWNER_STATUS 0x00200000 488 // MAP_SUPPORTED_FEATURES_MESSAGE_FORWARDING 0x00400000 489 OwnerStatus ownerStatus_ {}; 490 }; 491 492 /** 493 * @brief MapClient Observer 494 * 495 * @since 6 496 */ 497 class MapClientObserver { 498 public: 499 /** 500 * @brief Destroy the Map Client Observer object 501 * 502 * @since 6 503 */ 504 virtual ~MapClientObserver() = default; 505 /** 506 * @brief Map ActionCompleted observer 507 * 508 * @param device bluetooth device address 509 * @param action excute action type and Parameters 510 * @param status excute status 511 * @since 6 512 */ OnMapActionCompleted(const BluetoothRemoteDevice & device,const MapAction & action,MapExecuteStatus status)513 virtual void OnMapActionCompleted( 514 const BluetoothRemoteDevice &device, const MapAction &action, MapExecuteStatus status) {}; 515 /** 516 * @brief Map EventReported observer 517 * 518 * @param device bluetooth device address 519 * @param report EventReported string 520 * @since 6 521 */ OnMapEventReported(const BluetoothRemoteDevice & device,const MapEventReport & report)522 virtual void OnMapEventReported(const BluetoothRemoteDevice &device, const MapEventReport &report) {}; 523 /** 524 * @brief ConnectionState Changed observer 525 * @param device bluetooth device address 526 * @param state EventReported string 527 */ OnConnectionStateChanged(const BluetoothRemoteDevice & device,int state)528 virtual void OnConnectionStateChanged(const BluetoothRemoteDevice &device, int state) {}; 529 /** 530 * @brief Bmessage completed observer 531 * 532 * @param deviceAddress bluetooth address 533 * @param bmsg 534 * @param status 535 * @since 6 536 */ OnBmessageCompleted(const BluetoothRemoteDevice & deviceAddress,const MapBMessage & bmsg,MapExecuteStatus status)537 virtual void OnBmessageCompleted( 538 const BluetoothRemoteDevice &deviceAddress, const MapBMessage &bmsg, MapExecuteStatus status) {}; 539 /** 540 * @brief MessagesListing completed observer 541 * 542 * @param deviceAddress bluetooth address 543 * @param bmsg 544 * @param status 545 * @since 6 546 */ OnMessagesListingCompleted(const BluetoothRemoteDevice & deviceAddress,const MessagesListing & listing,MapExecuteStatus status)547 virtual void OnMessagesListingCompleted( 548 const BluetoothRemoteDevice &deviceAddress, const MessagesListing &listing, MapExecuteStatus status) {}; 549 /** 550 * @brief ConversationListing completed observer 551 * 552 * @param deviceAddress bluetooth address 553 * @param listing 554 * @param status 555 * @since 6 556 */ OnConversationListingCompleted(const BluetoothRemoteDevice & deviceAddress,const ConversationListing & listing,MapExecuteStatus status)557 virtual void OnConversationListingCompleted( 558 const BluetoothRemoteDevice &deviceAddress, const ConversationListing &listing, MapExecuteStatus status) {}; 559 }; 560 /** 561 * @brief MapClient class 562 * 563 * @since 6 564 */ 565 class BLUETOOTH_API MapClient { 566 public: 567 /** 568 * @brief Get the Profile object 569 * 570 * @return MapClient* pointer 571 * @since 6 572 */ 573 static MapClient *GetProfile(); 574 /** 575 * @brief Register Observer 576 * 577 * @param observer observer pointer 578 * @since 6 579 */ 580 void RegisterObserver(MapClientObserver &observer); 581 /** 582 * @brief Deregister Observer 583 * 584 * @param observer observer pointer 585 * @since 6 586 */ 587 void DeregisterObserver(MapClientObserver &observer); 588 /** 589 * @brief Connect to map server 590 * 591 * @param device bluetooth device address 592 * @return bool api accept status, return true if accept ok 593 * @since 6 594 */ 595 bool Connect(const BluetoothRemoteDevice &device); 596 /** 597 * @brief disconnect from map server 598 * 599 * @param device bluetooth device address 600 * @return bool api accept status, return true if accept ok 601 * @since 6 602 */ 603 bool Disconnect(const BluetoothRemoteDevice &device); 604 /** 605 * @brief display connect status 606 * 607 * @param device bluetooth device address 608 * @return bool Returns true if the device status is connected, otherwise return false. 609 * @since 6 610 */ 611 bool IsConnected(const BluetoothRemoteDevice &device); 612 /** 613 * @brief Get the Connected Devices object 614 * 615 * @return Returns the bluetooth device address 616 * @since 6 617 */ 618 std::vector<BluetoothRemoteDevice> GetConnectedDevices() const; 619 /** 620 * @brief Get the device list through the connection status. 621 * 622 * @param statusList Reference to the connection status. 623 * @c BTConnectState::CONNECTING : the state is connecting. 624 * @c BTConnectState::CONNECTED : the state is connected. 625 * @c BTConnectState::DISCONNECTING : the state is disconnecting. 626 * @c BTConnectState::DISCONNECTED : the state is disconnected. 627 * @return Returns the bluetooth device address in the specified status. 628 * @since 6 629 */ 630 std::vector<BluetoothRemoteDevice> GetDevicesByStates(const std::vector<int> &statusList) const; 631 /** 632 * @brief Get the Connection State object 633 * 634 * @param device bluetooth device address 635 * @return int return connection status 636 * @c BTConnectState::CONNECTING : the state is connecting. 637 * @c BTConnectState::CONNECTED : the state is connected. 638 * @c BTConnectState::DISCONNECTING : the state is disconnecting. 639 * @c BTConnectState::DISCONNECTED : the state is disconnected. 640 * @since 6 641 */ 642 int GetConnectionState(const BluetoothRemoteDevice &device) const; 643 /** 644 * @brief Set the connection policy of the specified device. 645 * 646 * @param device Reference to the remote bluetooth device. 647 * @param strategy Reference to the connection policy, 648 * @c BTStrategyType::CONNECTION_UNKNOWN : the connection policy for unknown state. 649 * @c BTStrategyType::CONNECTION_ALLOWED : the connection policy for allowed state. 650 * @c BTStrategyType::CONNECTION_FORBIDDEN : the connection policy for forbidden state. 651 * @return Returns true if the operation is success;returns false if the operation failed. 652 * @since 6 653 */ 654 bool SetConnectionStrategy(const BluetoothRemoteDevice &device, const int strategy); 655 /** 656 * @brief Get the Connection Strategy object 657 * 658 * @param device bluetooth device address 659 * @return int Reference to the connection policy, 660 * @c BTStrategyType::CONNECTION_UNKNOWN : the connection policy for unknown state. 661 * @c BTStrategyType::CONNECTION_ALLOWED : the connection policy for allowed state. 662 * @c BTStrategyType::CONNECTION_FORBIDDEN : the connection policy for forbidden state. 663 * @since 6 664 */ 665 int GetConnectionStrategy(const BluetoothRemoteDevice &device) const; 666 /** 667 * @brief Get the Unread Messages object 668 * 669 * @param device bluetooth device address 670 * @param list uread message list param 671 * @return int api accept status, return RET_NO_ERROR if accept ok, 672 * the excute result will return by observer 673 * @since 6 674 */ 675 int GetUnreadMessages(const BluetoothRemoteDevice &device, MapMessageType type, uint8_t max); 676 /** 677 * @brief Get the Supported Features object 678 * 679 * @param device bluetooth device address 680 * @return int api accept status, return RET_NO_ERROR if accept ok, 681 * the excute result will return by action complete observer 682 * @since 6 683 */ 684 int GetSupportedFeatures(const BluetoothRemoteDevice &device) const; 685 /** 686 * @brief Send Message 687 * 688 * @param device bluetooth device address 689 * @param msg message 690 * @return int api accept status, return RET_NO_ERROR if accept ok, 691 * the excute result will return by observer 692 * @since 6 693 */ 694 int SendMessage(const BluetoothRemoteDevice &device, const MapSendMessageParameters &msg); 695 /** 696 * @brief Set the Notification Filter object 697 * 698 * @param device bluetooth device address 699 * @param mask maskvalue of Notification Filter 700 * MAP_NOTIFICATION_FILTER_MASK_NEW_MESSAGE 0b000000000000000000000001 701 * MAP_NOTIFICATION_FILTER_MASK_MESSAGE_DELETED 0b000000000000000000000010 702 * MAP_NOTIFICATION_FILTER_MASK_MESSAGE_SHIFT 0b000000000000000000000100 703 * MAP_NOTIFICATION_FILTER_MASK_SENDING_SUCCESS 0b000000000000000000001000 704 * MAP_NOTIFICATION_FILTER_MASK_SENDING_FAILURE 0b000000000000000000010000 705 * MAP_NOTIFICATION_FILTER_MASK_DELIVERY_SUCCESS 0b000000000000000000100000 706 * MAP_NOTIFICATION_FILTER_MASK_DELIVERY_FAILURE 0b000000000000000001000000 707 * MAP_NOTIFICATION_FILTER_MASK_MEMORY_FULL 0b000000000000000010000000 708 * MAP_NOTIFICATION_FILTER_MASK_MEMORY_AVAILABLE 0b000000000000000100000000 709 * MAP_NOTIFICATION_FILTER_MASK_READ_STATUS_CHANGED 0b000000000000001000000000 710 * MAP_NOTIFICATION_FILTER_MASK_CONVERSATION_CHANGED 0b000000000000010000000000 711 * MAP_NOTIFICATION_FILTER_MASK_PARTICIPANT_PRESENCE_CHANGED 0b000000000000100000000000 712 * MAP_NOTIFICATION_FILTER_MASK_PARTICIPANT_CHAT_STATE_CHANGED 0b000000000001000000000000 713 * @return int api accept status, return RET_NO_ERROR if accept ok, 714 * the excute result will return by observer 715 * @since 6 716 */ 717 int SetNotificationFilter(const BluetoothRemoteDevice &device, const int mask); 718 /** 719 * @brief Get the Messages Listing object 720 * 721 * @param device bluetooth device address 722 * @param para GetMessagesListing Parameters 723 * @return int api accept status, return RET_NO_ERROR if accept ok, 724 * the excute result will return by observer 725 * @since 6 726 */ 727 int GetMessagesListing(const BluetoothRemoteDevice &device, const GetMessagesListingParameters ¶) const; 728 /** 729 * @brief Get the Message object 730 * 731 * @param device bluetooth device address 732 * @param msgHandle msgHandle of message 733 * @param para GetMessage Parameters 734 * @return int api accept status, return RET_NO_ERROR if accept ok, 735 * the excute result will return by observer 736 * @since 6 737 */ 738 int GetMessage(const BluetoothRemoteDevice &device, MapMessageType type, const std::u16string &msgHandle, 739 const GetMessageParameters ¶) const; 740 /** 741 * @brief Update Inbox 742 * 743 * @param device bluetooth device address 744 * @return int api accept status, return RET_NO_ERROR if accept ok, 745 * the excute result will return by observer 746 * @since 6 747 */ 748 int UpdateInbox(const BluetoothRemoteDevice &device, MapMessageType type); 749 /** 750 * @brief Get the Conversation Listing object 751 * 752 * @param device bluetooth device address 753 * @param para GetConversationListing Parameters 754 * @return int api accept status, return RET_NO_ERROR if accept ok, 755 * the excute result will return by observer 756 * @since 6 757 */ 758 int GetConversationListing 759 (const BluetoothRemoteDevice &device, const GetConversationListingParameters ¶) const; 760 /** 761 * @brief Set the Message Status object 762 * @param device 763 * @param type 764 * @param msgStatus 765 * @return int 766 */ 767 int SetMessageStatus( 768 const BluetoothRemoteDevice &device, MapMessageType type, const MapSetMessageStatus &msgStatus); 769 /** 770 * @brief Set the Owner Status object 771 * 772 * @param device bluetooth device address 773 * @param para OwnerStatus Parameters 774 * @return int api accept status, return RET_NO_ERROR if accept ok, 775 * the excute result will return by observer 776 * @since 6 777 */ 778 int SetOwnerStatus(const BluetoothRemoteDevice &device, const SetOwnerStatusParameters ¶); 779 /** 780 * @brief Get the Owner Status object 781 * 782 * @param device bluetooth device address 783 * @param conversationId conversationId Param 784 * @return int api accept status, return RET_NO_ERROR if accept ok, 785 * the excute result will return by observer 786 * @since 6 787 */ 788 int GetOwnerStatus(const BluetoothRemoteDevice &device, const std::string &conversationId) const; 789 /** 790 * @brief Get the Mas Instance Info object 791 * 792 * @param device bluetooth device address 793 * @return std::vector<MapMasInstanceInfo> instanceinfo list 794 * @since 6 795 */ 796 MapMasInstanceInfoList GetMasInstanceInfo(const BluetoothRemoteDevice &device) const; 797 798 private: 799 /** 800 * @brief Construct a new Map Client object 801 * 802 * @since 6 803 */ 804 MapClient(); 805 /** 806 * @brief Destroy the Map Client object 807 * 808 * @since 6 809 */ 810 ~MapClient(); 811 BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(MapClient); 812 BLUETOOTH_DECLARE_IMPL(); 813 }; 814 } // namespace Bluetooth 815 } // namespace OHOS 816 817 #endif // BLUETOOTH_MAP_MCE_H 818