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