1 /* 2 * Copyright (C) 2008-2009 Marc Blank 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.exchange; 19 20 import com.android.emailcommon.provider.Mailbox; 21 import com.android.emailcommon.service.EmailServiceProxy; 22 import com.android.mail.utils.LogUtils; 23 24 /** 25 * Constants used throughout the EAS implementation are stored here. 26 * 27 */ 28 public class Eas { 29 30 // For logging. 31 public static final String LOG_TAG = "Exchange"; 32 33 // For debugging 34 public static boolean WAIT_DEBUG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 35 public static boolean DEBUG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 36 37 // The following two are for user logging (the second providing more detail) 38 public static boolean USER_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 39 public static boolean PARSER_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 40 public static boolean FILE_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 41 42 public static final String CLIENT_VERSION = "EAS-1.3"; 43 public static final String ACCOUNT_MAILBOX_PREFIX = "__eas"; 44 45 // Define our default protocol version as 2.5 (Exchange 2003) 46 public static final String SUPPORTED_PROTOCOL_EX2003 = "2.5"; 47 public static final double SUPPORTED_PROTOCOL_EX2003_DOUBLE = 2.5; 48 public static final String SUPPORTED_PROTOCOL_EX2007 = "12.0"; 49 public static final double SUPPORTED_PROTOCOL_EX2007_DOUBLE = 12.0; 50 public static final String SUPPORTED_PROTOCOL_EX2007_SP1 = "12.1"; 51 public static final double SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE = 12.1; 52 public static final String SUPPORTED_PROTOCOL_EX2010 = "14.0"; 53 public static final double SUPPORTED_PROTOCOL_EX2010_DOUBLE = 14.0; 54 public static final String SUPPORTED_PROTOCOL_EX2010_SP1 = "14.1"; 55 public static final double SUPPORTED_PROTOCOL_EX2010_SP1_DOUBLE = 14.1; 56 public static final String DEFAULT_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_EX2003; 57 58 public static final String EXCHANGE_ACCOUNT_MANAGER_TYPE = 59 com.android.exchange.Configuration.EXCHANGE_ACCOUNT_MANAGER_TYPE; 60 public static final String PROTOCOL = com.android.exchange.Configuration.EXCHANGE_PROTOCOL; 61 public static final String EXCHANGE_SERVICE_INTENT_ACTION = 62 com.android.exchange.Configuration.EXCHANGE_SERVICE_INTENT_ACTION; 63 64 // From EAS spec 65 // Mail Cal 66 // 0 No filter Yes Yes 67 // 1 1 day ago Yes No 68 // 2 3 days ago Yes No 69 // 3 1 week ago Yes No 70 // 4 2 weeks ago Yes Yes 71 // 5 1 month ago Yes Yes 72 // 6 3 months ago No Yes 73 // 7 6 months ago No Yes 74 75 // TODO Rationalize this with SYNC_WINDOW_ALL 76 public static final String FILTER_ALL = "0"; 77 public static final String FILTER_1_DAY = "1"; 78 public static final String FILTER_3_DAYS = "2"; 79 public static final String FILTER_1_WEEK = "3"; 80 public static final String FILTER_2_WEEKS = "4"; 81 public static final String FILTER_1_MONTH = "5"; 82 public static final String FILTER_3_MONTHS = "6"; 83 public static final String FILTER_6_MONTHS = "7"; 84 85 public static final String BODY_PREFERENCE_TEXT = "1"; 86 public static final String BODY_PREFERENCE_HTML = "2"; 87 88 public static final String MIME_BODY_PREFERENCE_TEXT = "0"; 89 public static final String MIME_BODY_PREFERENCE_MIME = "2"; 90 91 // Mailbox Types 92 // Section 2.2.3.170.3 Type (FolderSync) 93 // http://msdn.microsoft.com/en-us/library/gg650877(v=exchg.80).aspx 94 public static final int MAILBOX_TYPE_USER_GENERIC = 1; 95 public static final int MAILBOX_TYPE_INBOX = 2; 96 public static final int MAILBOX_TYPE_DRAFTS = 3; 97 public static final int MAILBOX_TYPE_DELETED = 4; 98 public static final int MAILBOX_TYPE_SENT = 5; 99 public static final int MAILBOX_TYPE_OUTBOX = 6; 100 // public static final int MAILBOX_TYPE_TASKS = 7; 101 public static final int MAILBOX_TYPE_CALENDAR = 8; 102 public static final int MAILBOX_TYPE_CONTACTS = 9; 103 // public static final int MAILBOX_TYPE_NOTES = 10; 104 // public static final int MAILBOX_TYPE_JOURNAL = 11; 105 public static final int MAILBOX_TYPE_USER_MAIL = 12; 106 public static final int MAILBOX_TYPE_USER_CALENDAR = 13; 107 public static final int MAILBOX_TYPE_USER_CONTACTS = 14; 108 // public static final int MAILBOX_TYPE_USER_TASKS = 15; 109 // public static final int MAILBOX_TYPE_USER_JOURNAL = 16; 110 // public static final int MAILBOX_TYPE_USER_NOTES = 17; 111 // public static final int MAILBOX_TYPE_UNKNOWN = 18; 112 // public static final int MAILBOX_TYPE_RECIPIENT_INFORMATION_CACHE = 19; 113 114 115 // These limits must never exceed about 500k which is half the max size of a Binder IPC buffer. 116 117 // For EAS 12, we use HTML, so we want a larger size than in EAS 2.5 118 public static final String EAS12_TRUNCATION_SIZE = "200000"; 119 // For EAS 2.5, truncation is a code; the largest is "7", which is 100k 120 public static final String EAS2_5_TRUNCATION_SIZE = "7"; 121 122 public static final int FOLDER_STATUS_OK = 1; 123 public static final int FOLDER_STATUS_INVALID_KEY = 9; 124 125 public static final int EXCHANGE_ERROR_NOTIFICATION = 0x10; 126 127 public static void setUserDebug(int state) { 128 // DEBUG takes precedence and is never true in a user build 129 if (!DEBUG) { 130 USER_LOG = (state & EmailServiceProxy.DEBUG_BIT) != 0; 131 PARSER_LOG = (state & EmailServiceProxy.DEBUG_VERBOSE_BIT) != 0; 132 FILE_LOG = (state & EmailServiceProxy.DEBUG_FILE_BIT) != 0; 133 if (FILE_LOG || PARSER_LOG) { 134 USER_LOG = true; 135 } 136 LogUtils.d("Eas Debug", "Logging: " + (USER_LOG ? "User " : "") + 137 (PARSER_LOG ? "Parser " : "") + (FILE_LOG ? "File" : "")); 138 } 139 } 140 141 static public Double getProtocolVersionDouble(String version) { 142 if (SUPPORTED_PROTOCOL_EX2003.equals(version)) { 143 return SUPPORTED_PROTOCOL_EX2003_DOUBLE; 144 } else if (SUPPORTED_PROTOCOL_EX2007.equals(version)) { 145 return SUPPORTED_PROTOCOL_EX2007_DOUBLE; 146 } if (SUPPORTED_PROTOCOL_EX2007_SP1.equals(version)) { 147 return SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE; 148 } if (SUPPORTED_PROTOCOL_EX2010.equals(version)) { 149 return SUPPORTED_PROTOCOL_EX2010_DOUBLE; 150 } if (SUPPORTED_PROTOCOL_EX2010_SP1.equals(version)) { 151 return SUPPORTED_PROTOCOL_EX2010_SP1_DOUBLE; 152 } 153 throw new IllegalArgumentException("illegal protocol version"); 154 } 155 156 /** 157 * Gets the Exchange folder class for a mailbox type (PIM collections have different values 158 * from email), needed when forming the request. 159 * @param mailboxType The type of the mailbox we're interested in, from {@link Mailbox}. 160 * @return The folder class for the mailbox we're interested in. 161 */ 162 public static String getFolderClass(final int mailboxType) { 163 switch (mailboxType) { 164 case Mailbox.TYPE_CALENDAR: 165 return "Calendar"; 166 case Mailbox.TYPE_CONTACTS: 167 return "Contacts"; 168 default: 169 return "Email"; 170 } 171 } 172 } 173