1 /* 2 * Copyright (c) 2021-2022 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 CONTACT_NAPI_OBJECT_H 17 #define CONTACT_NAPI_OBJECT_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace ContactsApi { 23 enum class Attribute { 24 /** 25 * Indicates the email address. 26 */ 27 ATTR_EMAIL = 1, 28 29 /** 30 * Indicates the instant messaging (IM) address. 31 */ 32 ATTR_IM, 33 34 /** 35 * Indicates the nickname. 36 */ 37 ATTR_NICKNAME, 38 39 /** 40 * Indicates the organization. 41 */ 42 ATTR_ORGANIZATION, 43 44 /** 45 * Indicates the phone number. 46 */ 47 ATTR_PHONE, 48 49 /** 50 * Indicates the name. 51 */ 52 ATTR_NAME, 53 54 /** 55 * Indicates the postal address. 56 */ 57 ATTR_POSTAL_ADDRESS, 58 59 /** 60 * Indicates the portrait. 61 */ 62 ATTR_PORTRAIT, 63 64 /** 65 * Indicates the contact group. 66 */ 67 ATTR_GROUP_MEMBERSHIP, 68 69 /** 70 * Indicates the note. 71 */ 72 ATTR_NOTE, 73 74 /** 75 * Indicates the contact event. 76 */ 77 ATTR_CONTACT_EVENT, 78 79 /** 80 * Indicates the website. 81 */ 82 ATTR_WEBSITE, 83 84 /** 85 * Indicates the relation. 86 */ 87 ATTR_RELATION, 88 89 /** 90 * Indicates the Session Initiation Protocol (SIP) address. 91 */ 92 ATTR_SIP_ADDRESS = 17 93 }; 94 95 /** 96 * Provides methods for contact attributes information 97 */ 98 class ContactAttributes { 99 public: 100 /** 101 * Indicates the contact attributes. 102 */ 103 std::vector<int> attributes; 104 }; 105 106 /** 107 * Provides methods for email information 108 */ 109 class Email { 110 public: 111 /** 112 * Indicates a custom label. 113 */ 114 static const int CUSTOM_LABEL = 0; 115 116 /** 117 * Indicates a home email. 118 */ 119 static const int EMAIL_HOME = 1; 120 121 /** 122 * Indicates a work email. 123 */ 124 static const int EMAIL_WORK = 2; 125 126 /** 127 * Indicates an email of the OTHER type. 128 */ 129 static const int EMAIL_OTHER = 3; 130 131 /** 132 * Indicates an invalid label ID. 133 */ 134 static const int INVALID_LABEL_ID = -1; 135 136 /** 137 * Indicates the email address. 138 */ 139 std::string email; 140 141 /** 142 * Indicates the label name of an attribute. 143 */ 144 std::string labelName; 145 146 /** 147 * Indicates the displayed email name. 148 */ 149 std::string displayName; 150 151 /** 152 * Indicates the label id. 153 */ 154 int labelId = -1; 155 }; 156 157 /** 158 * Provides methods for event information 159 */ 160 class Event { 161 public: 162 /** 163 * Indicates a custom label. 164 */ 165 static const int CUSTOM_LABEL = 0; 166 167 /** 168 * Indicates an anniversary event. 169 */ 170 static const int EVENT_ANNIVERSARY = 1; 171 172 /** 173 * Indicates an event of the OTHER type. 174 */ 175 static const int EVENT_OTHER = 2; 176 177 /** 178 * Indicates an birthday event. 179 */ 180 static const int EVENT_BIRTHDAY = 3; 181 182 /** 183 * Indicates an invalid label ID. 184 */ 185 static const int INVALID_LABEL_ID = -1; 186 187 /** 188 * Indicates the event date. 189 */ 190 std::string eventDate; 191 192 /** 193 * Indicates the label name of an attribute. 194 */ 195 std::string labelName; 196 197 /** 198 * Indicates the label id. 199 */ 200 int labelId = -1; 201 }; 202 203 /** 204 * Provides methods for group information 205 */ 206 class Group { 207 public: 208 /** 209 * Indicates the contact group ID. 210 */ 211 int groupId = -1; 212 213 /** 214 * Indicates the contact group title. 215 */ 216 std::string title; 217 }; 218 219 /** 220 * Provides methods for holder information 221 */ 222 class Holder { 223 public: 224 /** 225 * Indicates the bundle name of a contact holder. 226 */ 227 std::string bundleName; 228 229 /** 230 * Indicates the displayed name of a contact holder. 231 */ 232 std::string displayName; 233 234 /** 235 * Indicates the holder ID. 236 */ 237 int holderId = -1; 238 }; 239 240 /** 241 * Provides methods for ImAddress information 242 */ 243 class ImAddress { 244 public: 245 /** 246 * Indicates a custom label. 247 */ 248 static const int CUSTOM_LABEL = -1; 249 250 /** 251 * Indicates an AIM instant message. 252 */ 253 static const int IM_AIM = 0; 254 255 /** 256 * Indicates a Windows Live instant message. 257 */ 258 static const int IM_MSN = 1; 259 260 /** 261 * Indicates a Yahoo instant message. 262 */ 263 static const int IM_YAHOO = 2; 264 265 /** 266 * Indicates a Skype instant message. 267 */ 268 static const int IM_SKYPE = 3; 269 270 /** 271 * Indicates a QQ instant message. 272 */ 273 static const int IM_QQ = 4; 274 275 /** 276 * Indicates an ICQ instant message. 277 */ 278 static const int IM_ICQ = 6; 279 280 /** 281 * Indicates a Jabber instant message. 282 */ 283 static const int IM_JABBER = 7; 284 285 /** 286 * Indicates an invalid label ID. 287 */ 288 static const int INVALID_LABEL_ID = -2; 289 290 /** 291 * Indicates the IM address. 292 */ 293 std::string imAddress; 294 295 /** 296 * Indicates the label name of an attribute. 297 */ 298 std::string labelName; 299 300 /** 301 * Indicates the label id. 302 */ 303 int labelId = -1; 304 }; 305 /** 306 * Provides methods for name information 307 */ 308 class Name { 309 public: 310 /** 311 * Indicates the family name of the contact. 312 */ 313 std::string familyName; 314 315 /** 316 * Indicates the phonetic family name of the contact. 317 */ 318 std::string familyNamePhonetic; 319 320 /** 321 * Indicates the full name of the contact. 322 */ 323 std::string fullName; 324 325 /** 326 * Indicates the given name of the contact. 327 */ 328 std::string givenName; 329 330 /** 331 * Indicates the phonetic given name of the contact. 332 */ 333 std::string givenNamePhonetic; 334 335 /** 336 * Indicates the middle name of the contact. 337 */ 338 std::string middleName; 339 340 /** 341 * Indicates the phonetic middle name of the contact. 342 */ 343 std::string middleNamePhonetic; 344 345 /** 346 * Indicates the prefix of the contact name. 347 */ 348 std::string namePrefix; 349 350 /** 351 * Indicates the suffix of this contact name. 352 */ 353 std::string nameSuffix; 354 }; 355 /** 356 * Provides methods for nick name information 357 */ 358 class NickName { 359 public: 360 /** 361 * Indicates the nickname of the contact. 362 */ 363 std::string nickName; 364 }; 365 366 /** 367 * Provides methods for note information 368 */ 369 class Note { 370 public: 371 /** 372 * Indicates the note content. 373 */ 374 std::string noteContent; 375 }; 376 /** 377 * Provides methods for organization information 378 */ 379 class Organization { 380 public: 381 /** 382 * Indicates the name of the organization to which the contact belongs. 383 */ 384 std::string name; 385 386 /** 387 * Indicates the title of the contact. 388 */ 389 std::string title; 390 }; 391 /** 392 * Provides methods for phone number information 393 */ 394 class PhoneNumber { 395 public: 396 /** 397 * Indicates a custom label. 398 */ 399 static const int CUSTOM_LABEL = 0; 400 401 /** 402 * Indicates a home number. 403 */ 404 static const int NUM_HOME = 1; 405 406 /** 407 * Indicates a mobile phone number. 408 */ 409 static const int NUM_MOBILE = 2; 410 411 /** 412 * Indicates a work number. 413 */ 414 static const int NUM_WORK = 3; 415 416 /** 417 * Indicates a work fax number. 418 */ 419 static const int NUM_FAX_WORK = 4; 420 421 /** 422 * Indicates a home fax number. 423 */ 424 static const int NUM_FAX_HOME = 5; 425 426 /** 427 * Indicates a pager number. 428 */ 429 static const int NUM_PAGER = 6; 430 431 /** 432 * Indicates a number of the OTHER type. 433 */ 434 static const int NUM_OTHER = 7; 435 436 /** 437 * Indicates a callback number. 438 */ 439 static const int NUM_CALLBACK = 8; 440 441 /** 442 * Indicates a car number. 443 */ 444 static const int NUM_CAR = 9; 445 446 /** 447 * Indicates a company director number. 448 */ 449 static const int NUM_COMPANY_MAIN = 10; 450 451 /** 452 * Indicates an Integrated Services Digital Network (ISDN) number. 453 */ 454 static const int NUM_ISDN = 11; 455 456 /** 457 * Indicates a main number. 458 */ 459 static const int NUM_MAIN = 12; 460 461 /** 462 * Indicates a number of the OTHER_FAX type. 463 */ 464 static const int NUM_OTHER_FAX = 13; 465 466 /** 467 * Indicates a radio number. 468 */ 469 static const int NUM_RADIO = 14; 470 471 /** 472 * Indicates a telex number. 473 */ 474 static const int NUM_TELEX = 15; 475 476 /** 477 * Indicates a teletypewriter (TTY) or test-driven development (TDD) number. 478 */ 479 static const int NUM_TTY_TDD = 16; 480 481 /** 482 * Indicates a work mobile phone number. 483 */ 484 static const int NUM_WORK_MOBILE = 17; 485 486 /** 487 * Indicates a work pager number. 488 */ 489 static const int NUM_WORK_PAGER = 18; 490 491 /** 492 * Indicates an assistant number. 493 */ 494 static const int NUM_ASSISTANT = 19; 495 496 /** 497 * Indicates an MMS number. 498 */ 499 static const int NUM_MMS = 20; 500 501 /** 502 * Indicates an invalid label ID. 503 */ 504 static const int INVALID_LABEL_ID = -1; 505 506 /** 507 * Indicates the label name of an attribute. 508 */ 509 std::string labelName; 510 511 /** 512 * Indicates the phone number of the contact. 513 */ 514 std::string phoneNumber; 515 516 /** 517 * Indicates the label id. 518 */ 519 int labelId = -1; 520 }; 521 522 /** 523 * Provides methods for portrait information 524 */ 525 class Portrait { 526 public: 527 /** 528 * Indicates the uri of the contact portrait. 529 */ 530 std::string uri; 531 }; 532 /** 533 * Provides methods for postal address information 534 */ 535 class PostalAddress { 536 public: 537 /** 538 * Indicates a custom label. 539 */ 540 static const int CUSTOM_LABEL = 0; 541 542 /** 543 * Indicates a home address. 544 */ 545 static const int ADDR_HOME = 1; 546 547 /** 548 * Indicates a work address. 549 */ 550 static const int ADDR_WORK = 2; 551 552 /** 553 * Indicates an address of the OTHER type. 554 */ 555 static const int ADDR_OTHER = 3; 556 557 /** 558 * Indicates an invalid label ID. 559 */ 560 static const int INVALID_LABEL_ID = -1; 561 562 /** 563 * Indicates the city where this contact is located. 564 */ 565 std::string city; 566 567 /** 568 * Indicates the country/region where this contact is located. 569 */ 570 std::string country; 571 572 /** 573 * Indicates the label name of an attribute. 574 */ 575 std::string labelName; 576 577 /** 578 * Indicates the neighborhood where this contact is located. 579 */ 580 std::string neighborhood; 581 582 /** 583 * Indicates the post box of this contact. 584 */ 585 std::string pobox; 586 587 /** 588 * Indicates the postal address of this contact. 589 */ 590 std::string postalAddress; 591 592 /** 593 * Indicates the postal code of this contact. 594 */ 595 std::string postcode; 596 597 /** 598 * Indicates the area where this contact is located. 599 */ 600 std::string region; 601 602 /** 603 * Indicates the street where this contact is located. 604 */ 605 std::string street; 606 607 /** 608 * Indicates the label id. 609 */ 610 int labelId = -1; 611 }; 612 613 class Relation { 614 public: 615 /** 616 * Indicates a custom label. 617 */ 618 static const int CUSTOM_LABEL = 0; 619 620 /** 621 * Indicates an assistant. 622 */ 623 static const int RELATION_ASSISTANT = 1; 624 625 /** 626 * Indicates a brother. 627 */ 628 static const int RELATION_BROTHER = 2; 629 630 /** 631 * Indicates a child. 632 */ 633 static const int RELATION_CHILD = 3; 634 635 /** 636 * Indicates a domestic partner. 637 */ 638 static const int RELATION_DOMESTIC_PARTNER = 4; 639 640 /** 641 * Indicates a father. 642 */ 643 static const int RELATION_FATHER = 5; 644 645 /** 646 * Indicates a friend. 647 */ 648 static const int RELATION_FRIEND = 6; 649 650 /** 651 * Indicates a manager. 652 */ 653 static const int RELATION_MANAGER = 7; 654 655 /** 656 * Indicates a mother. 657 */ 658 static const int RELATION_MOTHER = 8; 659 660 /** 661 * Indicates a parent. 662 */ 663 static const int RELATION_PARENT = 9; 664 665 /** 666 * Indicates a partner. 667 */ 668 static const int RELATION_PARTNER = 10; 669 670 /** 671 * Indicates a referrer. 672 */ 673 static const int RELATION_REFERRED_BY = 11; 674 675 /** 676 * Indicates a relative. 677 */ 678 static const int RELATION_RELATIVE = 12; 679 680 /** 681 * Indicates a sister. 682 */ 683 static const int RELATION_SISTER = 13; 684 685 /** 686 * Indicates a spouse. 687 */ 688 static const int RELATION_SPOUSE = 14; 689 690 /** 691 * Indicates an invalid label ID. 692 */ 693 static const int INVALID_LABEL_ID = -1; 694 695 /** 696 * Indicates the label name of an attribute. 697 */ 698 std::string labelName; 699 700 /** 701 * Indicates the relation name. 702 */ 703 std::string relationName; 704 705 /** 706 * Indicates the label id. 707 */ 708 int labelId = -1; 709 }; 710 711 class SipAddress { 712 public: 713 /** 714 * Indicates a custom label. 715 */ 716 static const int CUSTOM_LABEL = 0; 717 718 /** 719 * Indicates a home SIP address. 720 */ 721 static const int SIP_HOME = 1; 722 723 /** 724 * Indicates a work SIP address. 725 */ 726 static const int SIP_WORK = 2; 727 728 /** 729 * Indicates an SIP address of the OTHER type. 730 */ 731 static const int SIP_OTHER = 3; 732 733 /** 734 * Indicates an invalid label ID. 735 */ 736 static const int INVALID_LABEL_ID = -1; 737 738 /** 739 * Indicates the label name of an attribute. 740 */ 741 std::string labelName; 742 743 /** 744 * Indicates the SIP address. 745 */ 746 std::string sipAddress; 747 748 /** 749 * Indicates the label id. 750 */ 751 int labelId = -1; 752 }; 753 754 class Website { 755 public: 756 std::string website; 757 }; 758 759 /** 760 * Provides methods for contact information 761 */ 762 class Contacts { 763 public: 764 /** 765 * Indicates the contact ID. 766 */ 767 static const int INVALID_CONTACT_ID = -1; 768 769 /** 770 * Indicates the contact ID. 771 */ 772 int id; 773 774 /** 775 * Indicates the query key that identifies the contact. 776 */ 777 std::string key; 778 779 /** 780 * Indicates the contact attributes. 781 */ 782 ContactAttributes contactAttributes; 783 784 /** 785 * Indicates an email address of the contact. 786 */ 787 std::vector<Email> emails; 788 789 /** 790 * Indicates an event (special date) of the contact. 791 */ 792 std::vector<Event> events; 793 794 /** 795 * Indicates a group of the contact. 796 */ 797 std::vector<Group> groups; 798 799 /** 800 * Indicates an IM address of the contact. 801 */ 802 std::vector<ImAddress> imAddresses; 803 804 /** 805 * Indicates a phone number of the contact. 806 */ 807 std::vector<PhoneNumber> phoneNumbers; 808 809 /** 810 * Indicates the contact portrait. 811 */ 812 Portrait portrait; 813 814 /** 815 * Indicates a postal address of the contact. 816 */ 817 std::vector<PostalAddress> postalAddresses; 818 819 /** 820 * Indicates a relation of the contact. 821 */ 822 std::vector<Relation> relations; 823 824 /** 825 * Indicates a Session Initiation Protocol (SIP) address of the contact. 826 */ 827 std::vector<SipAddress> sipAddresses; 828 829 /** 830 * Indicates a website of the contact. 831 */ 832 std::vector<Website> websites; 833 834 /** 835 * Indicates the contact name. 836 */ 837 Name name; 838 839 /** 840 * Indicates the contact nickname. 841 */ 842 NickName nickName; 843 /** 844 * Indicates the contact note. 845 */ 846 Note note; 847 /** 848 * Indicates organization information about the contact. 849 */ 850 Organization organization; 851 }; 852 } // namespace ContactsApi 853 } // namespace OHOS 854 #endif // CONTACT_NAPI_OBJECT_H 855