VCardConstants.java revision 88d0f1ef715f2e1209eba5d175b1b71c556fa8b0
1/*
2 * Copyright (C) 2009 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 */
16package com.android.vcard;
17
18/**
19 * Constants used in both exporter and importer code.
20 */
21public class VCardConstants {
22    public static final String VERSION_V21 = "2.1";
23    public static final String VERSION_V30 = "3.0";
24    public static final String VERSION_V40 = "4.0";
25
26    // The property names valid both in vCard 2.1 and 3.0.
27    public static final String PROPERTY_BEGIN = "BEGIN";
28    public static final String PROPERTY_VERSION = "VERSION";
29    public static final String PROPERTY_N = "N";
30    public static final String PROPERTY_FN = "FN";
31    public static final String PROPERTY_ADR = "ADR";
32    public static final String PROPERTY_EMAIL = "EMAIL";
33    public static final String PROPERTY_NOTE = "NOTE";
34    public static final String PROPERTY_ORG = "ORG";
35    public static final String PROPERTY_SOUND = "SOUND";  // Not fully supported.
36    public static final String PROPERTY_TEL = "TEL";
37    public static final String PROPERTY_TITLE = "TITLE";
38    public static final String PROPERTY_ROLE = "ROLE";
39    public static final String PROPERTY_PHOTO = "PHOTO";
40    public static final String PROPERTY_LOGO = "LOGO";
41    public static final String PROPERTY_URL = "URL";
42    public static final String PROPERTY_BDAY = "BDAY";  // Birthday (3.0, 4.0)
43    public static final String PROPERTY_BIRTH = "BIRTH";  // Place of birth (4.0)
44    public static final String PROPERTY_ANNIVERSARY = "ANNIVERSARY";  // Date of marriage (4.0)
45    public static final String PROPERTY_NAME = "NAME";  // (3.0, 4,0)
46    public static final String PROPERTY_NICKNAME = "NICKNAME";  // (3.0, 4.0)
47    public static final String PROPERTY_SORT_STRING = "SORT-STRING";  // (3.0, 4.0)
48    public static final String PROPERTY_IMPP = "IMPP";  // RFC 4770 (for 3.0 only)
49    public static final String PROPERTY_END = "END";
50
51    // Valid property names not supported (not appropriately handled) by our importer.
52    // TODO: Should be removed from the view of memory efficiency?
53    public static final String PROPERTY_REV = "REV";
54    public static final String PROPERTY_AGENT = "AGENT";  // (3.0)
55    public static final String PROPERTY_DDAY = "DDAY";  // Date of death (4.0)
56    public static final String PROPERTY_DEATH = "DEATH";  // Place of death (4.0)
57
58    // Available in vCard 3.0. Shoud not use when composing vCard 2.1 file.
59
60    // De-fact property values expressing phonetic names.
61    public static final String PROPERTY_X_PHONETIC_FIRST_NAME = "X-PHONETIC-FIRST-NAME";
62    public static final String PROPERTY_X_PHONETIC_MIDDLE_NAME = "X-PHONETIC-MIDDLE-NAME";
63    public static final String PROPERTY_X_PHONETIC_LAST_NAME = "X-PHONETIC-LAST-NAME";
64
65    // Properties both ContactsStruct and de-fact vCard extensions
66    // Shown in http://en.wikipedia.org/wiki/VCard support are defined here.
67    public static final String PROPERTY_X_AIM = "X-AIM";
68    public static final String PROPERTY_X_MSN = "X-MSN";
69    public static final String PROPERTY_X_YAHOO = "X-YAHOO";
70    public static final String PROPERTY_X_ICQ = "X-ICQ";
71    public static final String PROPERTY_X_JABBER = "X-JABBER";
72    public static final String PROPERTY_X_GOOGLE_TALK = "X-GOOGLE-TALK";
73    public static final String PROPERTY_X_SKYPE_USERNAME = "X-SKYPE-USERNAME";
74    // Properties only ContactsStruct has. We alse use this.
75    public static final String PROPERTY_X_QQ = "X-QQ";
76    public static final String PROPERTY_X_NETMEETING = "X-NETMEETING";
77
78    // Phone number for Skype, available as usual phone.
79    public static final String PROPERTY_X_SKYPE_PSTNNUMBER = "X-SKYPE-PSTNNUMBER";
80
81    // Property for Android-specific fields.
82    public static final String PROPERTY_X_ANDROID_CUSTOM = "X-ANDROID-CUSTOM";
83
84    // Properties for DoCoMo vCard.
85    public static final String PROPERTY_X_CLASS = "X-CLASS";
86    public static final String PROPERTY_X_REDUCTION = "X-REDUCTION";
87    public static final String PROPERTY_X_NO = "X-NO";
88    public static final String PROPERTY_X_DCM_HMN_MODE = "X-DCM-HMN-MODE";
89
90    public static final String PARAM_TYPE = "TYPE";
91
92    public static final String PARAM_TYPE_HOME = "HOME";
93    public static final String PARAM_TYPE_WORK = "WORK";
94    public static final String PARAM_TYPE_FAX = "FAX";
95    public static final String PARAM_TYPE_CELL = "CELL";
96    public static final String PARAM_TYPE_VOICE = "VOICE";
97    public static final String PARAM_TYPE_INTERNET = "INTERNET";
98
99    public static final String PARAM_CHARSET = "CHARSET";
100    public static final String PARAM_ENCODING = "ENCODING";
101
102    // Abbreviation of "prefered" according to vCard 2.1 specification.
103    // We interpret this value as "primary" property during import/export.
104    //
105    // Note: Both vCard specs does not mention anything about the requirement for this parameter,
106    //       but there may be some vCard importer which will get confused with more than
107    //       one "PREF"s in one property name, while Android accepts them.
108    public static final String PARAM_TYPE_PREF = "PREF";
109
110    // Phone type parameters valid in vCard and known to ContactsContract, but not so common.
111    public static final String PARAM_TYPE_CAR = "CAR";
112    public static final String PARAM_TYPE_ISDN = "ISDN";
113    public static final String PARAM_TYPE_PAGER = "PAGER";
114    public static final String PARAM_TYPE_TLX = "TLX";  // Telex
115
116    // Phone types existing in vCard 2.1 but not known to ContactsContract.
117    public static final String PARAM_TYPE_MODEM = "MODEM";
118    public static final String PARAM_TYPE_MSG = "MSG";
119    public static final String PARAM_TYPE_BBS = "BBS";
120    public static final String PARAM_TYPE_VIDEO = "VIDEO";
121
122    public static final String PARAM_ENCODING_7BIT = "7BIT";
123    public static final String PARAM_ENCODING_8BIT = "8BIT";
124    public static final String PARAM_ENCODING_QP = "QUOTED-PRINTABLE";
125    public static final String PARAM_ENCODING_BASE64 = "BASE64";  // Available in vCard 2.1
126    public static final String PARAM_ENCODING_B = "B";  // Available in vCard 3.0
127
128    // TYPE parameters for Phones, which are not formally valid in vCard (at least 2.1).
129    // These types are basically encoded to "X-" parameters when composing vCard.
130    // Parser passes these when "X-" is added to the parameter or not.
131    public static final String PARAM_PHONE_EXTRA_TYPE_CALLBACK = "CALLBACK";
132    public static final String PARAM_PHONE_EXTRA_TYPE_RADIO = "RADIO";
133    public static final String PARAM_PHONE_EXTRA_TYPE_TTY_TDD = "TTY-TDD";
134    public static final String PARAM_PHONE_EXTRA_TYPE_ASSISTANT = "ASSISTANT";
135    // vCard composer translates this type to "WORK" + "PREF". Just for parsing.
136    public static final String PARAM_PHONE_EXTRA_TYPE_COMPANY_MAIN = "COMPANY-MAIN";
137    // vCard composer translates this type to "VOICE" Just for parsing.
138    public static final String PARAM_PHONE_EXTRA_TYPE_OTHER = "OTHER";
139
140    // TYPE parameters for postal addresses.
141    public static final String PARAM_ADR_TYPE_PARCEL = "PARCEL";
142    public static final String PARAM_ADR_TYPE_DOM = "DOM";
143    public static final String PARAM_ADR_TYPE_INTL = "INTL";
144
145    public static final String PARAM_LANGUAGE = "LANGUAGE";
146
147    // SORT-AS parameter introduced in vCard 4.0 (as of rev.13)
148    public static final String PARAM_SORT_AS = "SORT-AS";
149
150    // TYPE parameters not officially valid but used in some vCard exporter.
151    // Do not use in composer side.
152    public static final String PARAM_EXTRA_TYPE_COMPANY = "COMPANY";
153
154    public interface ImportOnly {
155        public static final String PROPERTY_X_NICKNAME = "X-NICKNAME";
156        // Some device emits this "X-" parameter for expressing Google Talk,
157        // which is specifically invalid but should be always properly accepted, and emitted
158        // in some special case (for that device/application).
159        public static final String PROPERTY_X_GOOGLE_TALK_WITH_SPACE = "X-GOOGLE TALK";
160    }
161
162    //// Mainly for package constants.
163
164    // DoCoMo specific type parameter. Used with "SOUND" property, which is alternate of
165    // SORT-STRING invCard 3.0.
166    /* package */ static final String PARAM_TYPE_X_IRMC_N = "X-IRMC-N";
167
168    // Used in unit test.
169    public static final int MAX_DATA_COLUMN = 15;
170
171    /* package */ static final int MAX_CHARACTER_NUMS_QP = 76;
172    static final int MAX_CHARACTER_NUMS_BASE64_V30 = 75;
173
174    private VCardConstants() {
175    }
176}