• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 VCARD_CONSTANT_H
17 #define VCARD_CONSTANT_H
18 #include <cstdint>
19 
20 namespace OHOS {
21 namespace Telephony {
22 const int32_t DB_FAILD = -1;
23 const int32_t ID_NONE = -1;
24 constexpr const int32_t VERSION_21_NUM = 0;
25 constexpr const int32_t VERSION_30_NUM = 1;
26 constexpr const int32_t VERSION_40_NUM = 2;
27 constexpr const char *VERSION_21 = "2.1";
28 constexpr const char *VERSION_30 = "3.0";
29 constexpr const char *VERSION_40 = "4.0";
30 constexpr const char *DEFAULT_INTERMEDIATE_CHARSET = "ISO-8859-1";
31 constexpr const char *DEFAULT_IMPORT_CHARSET = "UTF-8";
32 constexpr const char *DEFAULT_EXPORT_CHARSET = "UTF-8";
33 constexpr const char *DEFAULT_ENCODING = "8BIT";
34 constexpr const char *DEFAULT_CHARSET = "UTF-8";
35 constexpr const char *VCARD_TYPE_VERSION = "VERSION";
36 constexpr const char *VCARD_TYPE_BEGIN = "BEGIN";
37 constexpr const char *VCARD_TYPE_N = "N";
38 constexpr const char *VCARD_TYPE_FN = "FN";
39 constexpr const char *VCARD_TYPE_ADR = "ADR";
40 constexpr const char *VCARD_TYPE_EMAIL = "EMAIL";
41 constexpr const char *VCARD_TYPE_NOTE = "NOTE";
42 constexpr const char *VCARD_TYPE_ORG = "ORG";
43 constexpr const char *VCARD_TYPE_SOUND = "SOUND";
44 constexpr const char *VCARD_TYPE_TEL = "TEL";
45 constexpr const char *VCARD_TYPE_TITLE = "TITLE";
46 constexpr const char *VCARD_TYPE_ROLE = "ROLE";
47 constexpr const char *VCARD_TYPE_PHOTO = "PHOTO";
48 constexpr const char *VCARD_TYPE_LOGO = "LOGO";
49 constexpr const char *VCARD_TYPE_URL = "URL";
50 constexpr const char *VCARD_TYPE_BDAY = "BDAY";
51 constexpr const char *VCARD_TYPE_ANNIVERSARY = "ANNIVERSARY";
52 constexpr const char *VCARD_TYPE_NAME = "NAME";
53 constexpr const char *VCARD_TYPE_NICKNAME = "NICKNAME";
54 constexpr const char *VCARD_TYPE_SORT_STRING = "SORT-STRING";
55 constexpr const char *VCARD_TYPE_IMPP = "IMPP";
56 constexpr const char *VCARD_TYPE_END = "END";
57 constexpr const char *VCARD_TYPE_REV = "REV";
58 constexpr const char *VCARD_TYPE_AGENT = "AGENT";
59 constexpr const char *VCARD_TYPE_GENDER = "GENDER";
60 constexpr const char *VCARD_TYPE_XML = "XML";
61 constexpr const char *VCARD_TYPE_FBURL = "FBURL";
62 constexpr const char *VCARD_TYPE_PRODID = "PRODID";
63 constexpr const char *VCARD_TYPE_RELATED = "RELATED";
64 constexpr const char *VCARD_TYPE_CATEGORIES = "CATEGORIES";
65 constexpr const char *VCARD_TYPE_CLIENTPIDMAP = "CLIENTPIDMAP";
66 constexpr const char *VCARD_TYPE_CALURI = "CALURI";
67 constexpr const char *VCARD_TYPE_X_SIP = "X-SIP";
68 constexpr const char *VCARD_TYPE_X_PHONETIC_FIRST_NAME = "X-PHONETIC-FIRST-NAME";
69 constexpr const char *VCARD_TYPE_X_PHONETIC_MIDDLE_NAME = "X-PHONETIC-MIDDLE-NAME";
70 constexpr const char *VCARD_TYPE_X_PHONETIC_LAST_NAME = "X-PHONETIC-LAST-NAME";
71 constexpr const char *VCARD_TYPE_X_AIM = "X-AIM";
72 constexpr const char *VCARD_TYPE_X_MSN = "X-MSN";
73 constexpr const char *VCARD_TYPE_X_YAHOO = "X-YAHOO";
74 constexpr const char *VCARD_TYPE_X_ICQ = "X-ICQ";
75 constexpr const char *VCARD_TYPE_X_JABBER = "X-JABBER";
76 constexpr const char *VCARD_TYPE_X_SKYPE_USERNAME = "X-SKYPE-USERNAME";
77 constexpr const char *VCARD_TYPE_X_QQ = "X-QQ";
78 constexpr const char *VCARD_TYPE_X_NETMEETING = "X-NETMEETING";
79 constexpr const char *VCARD_TYPE_X_SKYPE_PSTNNUMBER = "X-SKYPE-PSTNNUMBER";
80 
81 constexpr const char *VCARD_TYPE_X_CLASS = "X-CLASS";
82 constexpr const char *VCARD_TYPE_X_REDUCTION = "X-REDUCTION";
83 constexpr const char *VCARD_TYPE_X_NO = "X-NO";
84 constexpr const char *VCARD_TYPE_X_DCM_HMN_MODE = "X-DCM-HMN-MODE";
85 constexpr const char *VCARD_TYPE_X_OHOS_CUSTOM = "X_OHOS_CUSTOM";
86 
87 constexpr const char *VCARD_PARAM_TYPE = "TYPE";
88 constexpr const char *VCARD_PARAM_X_IRMC_N = "X-IRMC-N";
89 
90 constexpr const char *VCARD_PARAM_TYPE_HOME = "HOME";
91 constexpr const char *VCARD_PARAM_TYPE_WORK = "WORK";
92 constexpr const char *VCARD_PARAM_TYPE_FAX = "FAX";
93 constexpr const char *VCARD_PARAM_TYPE_CELL = "CELL";
94 constexpr const char *VCARD_PARAM_TYPE_VOICE = "VOICE";
95 constexpr const char *VCARD_PARAM_TYPE_INTERNET = "INTERNET";
96 
97 constexpr const char *VCARD_PARAM_VALUE = "VALUE";
98 constexpr const char *VCARD_PARAM_CHARSET = "CHARSET";
99 constexpr const char *VCARD_PARAM_ENCODING = "ENCODING";
100 
101 constexpr const char *VCARD_PARAM_TYPE_PREF = "PREF";
102 
103 constexpr const char *VCARD_PARAM_TYPE_CAR = "CAR";
104 constexpr const char *VCARD_PARAM_TYPE_ISDN = "ISDN";
105 constexpr const char *VCARD_PARAM_TYPE_PAGER = "PAGER";
106 constexpr const char *VCARD_PARAM_TYPE_TLX = "TLX";
107 
108 constexpr const char *VCARD_PARAM_TYPE_MODEM = "MODEM";
109 constexpr const char *VCARD_PARAM_TYPE_MSG = "MSG";
110 constexpr const char *VCARD_PARAM_TYPE_BBS = "BBS";
111 constexpr const char *VCARD_PARAM_TYPE_VIDEO = "VIDEO";
112 
113 constexpr const char *VCARD_PARAM_ENCODING_7BIT = "7BIT";
114 constexpr const char *VCARD_PARAM_ENCODING_8BIT = "8BIT";
115 constexpr const char *VCARD_PARAM_ENCODING_QP = "QUOTED-PRINTABLE";
116 constexpr const char *VCARD_PARAM_ENCODING_BASE64 = "BASE64";
117 constexpr const char *VCARD_PARAM_ENCODING_B = "B";
118 
119 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_CALLBACK = "CALLBACK";
120 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_RADIO = "RADIO";
121 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_TTY_TDD = "TTY-TDD";
122 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_ASSISTANT = "ASSISTANT";
123 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_COMPANY_MAIN = "COMPANY-MAIN";
124 constexpr const char *VCARD_PARAM_PHONE_EXTRA_TYPE_OTHER = "OTHER";
125 
126 constexpr const char *VCARD_PARAM_ADR_TYPE_PARCEL = "PARCEL";
127 constexpr const char *VCARD_PARAM_ADR_TYPE_DOM = "DOM";
128 constexpr const char *VCARD_PARAM_ADR_TYPE_INTL = "INTL";
129 constexpr const char *VCARD_PARAM_ADR_EXTRA_TYPE_OTHER = "OTHER";
130 
131 constexpr const char *VCARD_PARAM_LANGUAGE = "LANGUAGE";
132 
133 constexpr const char *VCARD_PARAM_SORT_AS = "SORT-AS";
134 
135 constexpr const char *VCARD_PARAM_EXTRA_TYPE_COMPANY = "COMPANY";
136 constexpr const char *VCARD_EXPORT_FILE_PATH = "/data/storage/el2/base/files/";
137 constexpr const char *VCARD_TIME_FORMAT = "%Y%m%d_%H%M%S";
138 constexpr const char *VCARD_FILE_EXTENSION = ".vcf";
139 
140 constexpr const int32_t VCARD_PHONE_NUM_FORMAT_JAPAN = 2;
141 constexpr const int32_t VCARD_PHONE_NUM_FORMAT_NANP = 1;
142 constexpr const int32_t SIZE_ZERO = 0;
143 constexpr const int32_t SIZE_ONE = 1;
144 constexpr const int32_t SIZE_TWO = 2;
145 constexpr const int32_t SIZE_THREE = 3;
146 constexpr const int32_t SIZE_FOUR = 4;
147 constexpr const int32_t SIZE_FIVE = 5;
148 constexpr const int32_t VALUE_INDEX_ZERO = 0;
149 constexpr const int32_t VALUE_INDEX_ONE = 1;
150 constexpr const int32_t VALUE_INDEX_TWO = 2;
151 constexpr const int32_t VALUE_INDEX_THREE = 3;
152 constexpr const int32_t VALUE_INDEX_FOUR = 4;
153 constexpr const int32_t VALUE_INDEX_FIVE = 5;
154 constexpr const int32_t VALUE_LEN_ZERO = 0;
155 constexpr const int32_t VALUE_LEN_ONE = 1;
156 constexpr const int32_t VALUE_LEN_TWO = 2;
157 constexpr const int32_t VALUE_LEN_THREE = 3;
158 constexpr const int32_t VALUE_LEN_FOUR = 4;
159 constexpr const int32_t VALUE_LEN_FIVE = 5;
160 constexpr const int32_t CONTACTS_NOT_DELETED = 0;
161 constexpr const int32_t ENCODEN_QUOTED_PRIN_MAX_LEN = 67;
162 constexpr const int32_t NUM_MINUS_ONE = -1;
163 constexpr const int32_t DECODE_CHAR_MAX_SIZE = 16;
164 constexpr const int32_t BATCH_INSERT_MAX_SIZE = 300;
165 
166 class TypeId {
167 public:
168     static constexpr int32_t EMAIL = 1;
169     static constexpr int32_t IM = 2;
170     static constexpr int32_t NICKNAME = 3;
171     static constexpr int32_t ORGANIZATION = 4;
172     static constexpr int32_t PHONE = 5;
173     static constexpr int32_t NAME = 6;
174     static constexpr int32_t POSTAL_ADDRESS = 7;
175     static constexpr int32_t PHOTO = 8;
176     static constexpr int32_t NOTE = 10;
177     static constexpr int32_t CONTACT_EVENT = 11;
178     static constexpr int32_t WEBSITE = 12;
179     static constexpr int32_t RELATION = 13;
180     static constexpr int32_t SIP_ADDRESS = 17;
181 };
182 
183 class TypeData {
184 public:
185     static constexpr const char *EMAIL = "email";
186     static constexpr const char *IM = "im";
187     static constexpr const char *NICKNAME = "nickname";
188     static constexpr const char *ORGANIZATION = "organization";
189     static constexpr const char *PHONE = "phone";
190     static constexpr const char *NAME = "name";
191     static constexpr const char *ADDRESS = "postal_address";
192     static constexpr const char *PHOTO = "photo";
193     static constexpr const char *GROUP_MEMBERSHIP = "group_membership";
194     static constexpr const char *NOTE = "note";
195     static constexpr const char *CONTACT_EVENT = "contact_event";
196     static constexpr const char *WEBSITE = "website";
197     static constexpr const char *RELATION = "relation";
198     static constexpr const char *CONTACT_MISC = "contact_misc";
199     static constexpr const char *HICALL_DEVICE = "hicall_device";
200     static constexpr const char *CAMCARD = "camcard";
201     static constexpr const char *SIP_ADDRESS = "sip_address";
202 };
203 
204 // account
205 class Account {
206 public:
207     static constexpr const char *ID = "id";
208     static constexpr const char *ACCOUNT_TYPE = "account_type";
209 };
210 
211 // contact
212 class Contact {
213 public:
214     static constexpr const char *ID = "id";
215 };
216 
217 // raw_contact
218 class RawContact {
219 public:
220     static constexpr const char *ID = "id";
221     static constexpr const char *ACCOUNT_ID = "account_id";
222     static constexpr const char *CONTACT_ID = "contact_id";
223     static constexpr const char *IS_DELETED = "is_deleted";
224 };
225 
226 // contact_data
227 class ContactData {
228 public:
229     static constexpr const char *CONTACT_DATA_ID = "id";
230     static constexpr const char *RAW_CONTACT_ID = "raw_contact_id";
231     static constexpr const char *TYPE_ID = "type_id";
232     static constexpr const char *DETAIL_INFO = "detail_info";
233     static constexpr const char *LABEL_ID = "extend7";
234     static constexpr const char *LABEL_NAME = "custom_data";
235     static constexpr const char *FULL_NAME = "detail_info";
236     static constexpr const char *FAMILY_NAME = "family_name";
237     static constexpr const char *FAMILY_NAME_PHONETIC = "phonetic_name";
238     static constexpr const char *GIVEN_NAME = "given_name";
239     static constexpr const char *GIVEN_NAME_PHONETIC = "given_name_phonetic";
240     static constexpr const char *MIDDLE_NAME_PHONETIC = "middle_name_phonetic";
241     static constexpr const char *MIDDLE_NAME = "other_lan_last_name";
242     static constexpr const char *ALIAS_DETAIL_INFO_KEY = "alias_detail_info";
243     static constexpr const char *NAME_PREFIX = "alpha_name";
244     static constexpr const char *NAME_SUFFIX = "other_lan_first_name";
245     static constexpr const char *POBOX = "pobox";
246     static constexpr const char *POSTCODE = "postcode";
247     static constexpr const char *REGION = "region";
248     static constexpr const char *STREET = "street";
249     static constexpr const char *COUNTRY = "country";
250     static constexpr const char *CITY = "city";
251     static constexpr const char *POSITION = "position";
252     static constexpr const char *PHONETIC_NAME = "phonetic_name";
253 };
254 
255 enum class EmailType {
256     /**
257      * Indicates an invalid label ID.
258      */
259     INVALID_LABEL_ID = -1,
260     /**
261      * Indicates a custom label.
262      */
263     CUSTOM_LABEL = 0,
264 
265     /**
266      * Indicates a home email.
267      */
268     EMAIL_HOME = 1,
269 
270     /**
271      * Indicates a work email.
272      */
273     EMAIL_WORK = 2,
274 
275     /**
276      * Indicates an email of the OTHER type.
277      */
278     EMAIL_OTHER = 3,
279 };
280 
281 enum class EventType {
282     /**
283      * Indicates an invalid label ID.
284      */
285     INVALID_LABEL_ID = -1,
286     /**
287      * Indicates a custom label.
288      */
289     CUSTOM_LABEL = 0,
290 
291     /**
292      * Indicates an anniversary event.
293      */
294     EVENT_ANNIVERSARY = 1,
295 
296     /**
297      * Indicates an event of the OTHER type.
298      */
299     EVENT_OTHER = 2,
300 
301     /**
302      * Indicates an birthday event.
303      */
304     EVENT_BIRTHDAY = 3,
305 };
306 
307 enum class ImType {
308     /**
309      * Indicates an invalid label ID.
310      */
311     INVALID_LABEL_ID = -2,
312 
313     /**
314      * Indicates a custom label.
315      */
316     CUSTOM_LABEL = -1,
317 
318     /**
319      * Indicates an AIM instant message.
320      */
321     IM_AIM = 0,
322 
323     /**
324      * Indicates a Windows Live instant message.
325      */
326     IM_MSN = 1,
327 
328     /**
329      * Indicates a Yahoo instant message.
330      */
331     IM_YAHOO = 2,
332 
333     /**
334      * Indicates a Skype instant message.
335      */
336     IM_SKYPE = 3,
337 
338     /**
339      * Indicates a QQ instant message.
340      */
341     IM_QQ = 4,
342 
343     /**
344      * Indicates an ICQ instant message.
345      */
346     IM_ICQ = 6,
347 
348     /**
349      * Indicates a Jabber instant message.
350      */
351     IM_JABBER = 7,
352 };
353 
354 enum class PhoneVcType {
355     /**
356      * Indicates an invalid label ID.
357      */
358     INVALID_LABEL_ID = -1,
359 
360     /**
361      * Indicates a custom label.
362      */
363     CUSTOM_LABEL = 0,
364 
365     /**
366      * Indicates a home number.
367      */
368     NUM_HOME = 1,
369 
370     /**
371      * Indicates a mobile phone number.
372      */
373     NUM_MOBILE = 2,
374 
375     /**
376      * Indicates a work number.
377      */
378     NUM_WORK = 3,
379 
380     /**
381      * Indicates a work fax number.
382      */
383     NUM_FAX_WORK = 4,
384 
385     /**
386      * Indicates a home fax number.
387      */
388     NUM_FAX_HOME = 5,
389 
390     /**
391      * Indicates a pager number.
392      */
393     NUM_PAGER = 6,
394 
395     /**
396      * Indicates a number of the OTHER type.
397      */
398     NUM_OTHER = 7,
399 
400     /**
401      * Indicates a callback number.
402      */
403     NUM_CALLBACK = 8,
404 
405     /**
406      * Indicates a car number.
407      */
408     NUM_CAR = 9,
409 
410     /**
411      * Indicates a company director number.
412      */
413     NUM_COMPANY_MAIN = 10,
414 
415     /**
416      * Indicates an Integrated Services Digital Network (ISDN) number.
417      */
418     NUM_ISDN = 11,
419 
420     /**
421      * Indicates a main number.
422      */
423     NUM_MAIN = 12,
424 
425     /**
426      * Indicates a number of the OTHER_FAX type.
427      */
428     NUM_OTHER_FAX = 13,
429 
430     /**
431      * Indicates a radio number.
432      */
433     NUM_RADIO = 14,
434 
435     /**
436      * Indicates a telex number.
437      */
438     NUM_TELEX = 15,
439 
440     /**
441      * Indicates a teletypewriter (TTY) or test-driven development (TDD) number.
442      */
443     NUM_TTY_TDD = 16,
444 
445     /**
446      * Indicates a work mobile phone number.
447      */
448     NUM_WORK_MOBILE = 17,
449 
450     /**
451      * Indicates a work pager number.
452      */
453     NUM_WORK_PAGER = 18,
454 
455     /**
456      * Indicates an assistant number.
457      */
458     NUM_ASSISTANT = 19,
459 
460     /**
461      * Indicates an MMS number.
462      */
463     NUM_MMS = 20,
464 };
465 
466 enum class PostalType {
467     /**
468      * Indicates an invalid label ID.
469      */
470     INVALID_LABEL_ID = -1,
471 
472     /**
473      * Indicates a custom label.
474      */
475     CUSTOM_LABEL = 0,
476 
477     /**
478      * Indicates a home address.
479      */
480     ADDR_HOME = 1,
481 
482     /**
483      * Indicates a work address.
484      */
485     ADDR_WORK = 2,
486 
487     /**
488      * Indicates an address of the OTHER type.
489      */
490     ADDR_OTHER = 3,
491 };
492 
493 enum class SipType {
494     /**
495      * Indicates an invalid label ID.
496      */
497     INVALID_LABEL_ID = -1,
498 
499     /**
500      * Indicates a custom label.
501      */
502     CUSTOM_LABEL = 0,
503 
504     /**
505      * Indicates a home SIP address.
506      */
507     SIP_HOME = 1,
508 
509     /**
510      * Indicates a work SIP address.
511      */
512     SIP_WORK = 2,
513 
514     /**
515      * Indicates an SIP address of the OTHER type.
516      */
517     SIP_OTHER = 3,
518 };
519 
520 enum class RelationType {
521     /**
522      * Indicates an invalid label ID.
523      */
524     INVALID_LABEL_ID = -1,
525 
526     /**
527      * Indicates a custom label.
528      */
529     CUSTOM_LABEL = 0,
530 
531     /**
532      * Indicates an assistant.
533      */
534     RELATION_ASSISTANT = 1,
535 
536     /**
537      * Indicates a brother.
538      */
539     RELATION_BROTHER = 2,
540 
541     /**
542      * Indicates a child.
543      */
544     RELATION_CHILD = 3,
545 
546     /**
547      * Indicates a domestic partner.
548      */
549     RELATION_DOMESTIC_PARTNER = 4,
550 
551     /**
552      * Indicates a father.
553      */
554     RELATION_FATHER = 5,
555 
556     /**
557      * Indicates a friend.
558      */
559     RELATION_FRIEND = 6,
560 
561     /**
562      * Indicates a relation manager.
563      */
564     RELATION_MANAGER = 7,
565 
566     /**
567      * Indicates a mother.
568      */
569     RELATION_MOTHER = 8,
570 
571     /**
572      * Indicates a parent.
573      */
574     RELATION_PARENT = 9,
575 
576     /**
577      * Indicates a partner.
578      */
579     RELATION_PARTNER = 10,
580 
581     /**
582      * Indicates a referrer.
583      */
584     RELATION_REFERRED_BY = 11,
585 
586     /**
587      * Indicates a relative.
588      */
589     RELATION_RELATIVE = 12,
590 
591     /**
592      * Indicates a sister.
593      */
594     RELATION_SISTER = 13,
595 
596     /**
597      * Indicates a spouse.
598      */
599     RELATION_SPOUSE = 14,
600 };
601 
602 constexpr const char *DATA_VCARD = "VCARD";
603 constexpr const char *DATA_PUBLIC = "PUBLIC";
604 
605 constexpr const char *PARAM_SEPARATOR = ";";
606 constexpr const char *PARAM_SEPARATOR_V3_V4 = ",";
607 constexpr const char *END_OF_LINE = "\r\n";
608 constexpr const char *DATA_SEPARATOR = ":";
609 constexpr const char *ITEM_SEPARATOR = ";";
610 constexpr const char *WS = " ";
611 constexpr const char *PARAM_EQUAL = "=";
612 
613 constexpr const char *PARAM_ENCODING_QP = "ENCODING=QUOTED-PRINTABLE";
614 constexpr const char *PARAM_ENCODING_BASE64_V21 = "ENCODING=BASE64";
615 constexpr const char *PARAM_ENCODING_BASE64_AS_B = "ENCODING=B";
616 
617 constexpr const char *SHIFT_JIS = "SHIFT_JIS";
618 const int32_t MAX_LINE_NUMS_BASE64_V30 = 75;
619 
620 } // namespace Telephony
621 } // namespace OHOS
622 #endif // VCARD_CONSTANT_H
623