Eas.java revision 9383babdbd7c0049a0eb238819a5d9737232e8ec
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 18package com.android.exchange; 19 20import com.android.emailcommon.service.EmailServiceProxy; 21import com.android.mail.utils.LogUtils; 22 23/** 24 * Constants used throughout the EAS implementation are stored here. 25 * 26 */ 27public class Eas { 28 29 // For logging. 30 public static final String LOG_TAG = "EAS"; 31 32 // For debugging 33 public static boolean WAIT_DEBUG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 34 public static boolean DEBUG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 35 36 // The following two are for user logging (the second providing more detail) 37 public static boolean USER_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 38 public static boolean PARSER_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 39 public static boolean FILE_LOG = false; // DO NOT CHECK IN WITH THIS SET TO TRUE 40 41 public static final String CLIENT_VERSION = "EAS-1.3"; 42 public static final String ACCOUNT_MAILBOX_PREFIX = "__eas"; 43 44 // Define our default protocol version as 2.5 (Exchange 2003) 45 public static final String SUPPORTED_PROTOCOL_EX2003 = "2.5"; 46 public static final double SUPPORTED_PROTOCOL_EX2003_DOUBLE = 2.5; 47 public static final String SUPPORTED_PROTOCOL_EX2007 = "12.0"; 48 public static final double SUPPORTED_PROTOCOL_EX2007_DOUBLE = 12.0; 49 public static final String SUPPORTED_PROTOCOL_EX2007_SP1 = "12.1"; 50 public static final double SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE = 12.1; 51 public static final String SUPPORTED_PROTOCOL_EX2010 = "14.0"; 52 public static final double SUPPORTED_PROTOCOL_EX2010_DOUBLE = 14.0; 53 public static final String SUPPORTED_PROTOCOL_EX2010_SP1 = "14.1"; 54 public static final double SUPPORTED_PROTOCOL_EX2010_SP1_DOUBLE = 14.1; 55 public static final String DEFAULT_PROTOCOL_VERSION = SUPPORTED_PROTOCOL_EX2003; 56 57 public static final String EXCHANGE_ACCOUNT_MANAGER_TYPE = 58 com.android.exchange.Configuration.EXCHANGE_ACCOUNT_MANAGER_TYPE; 59 public static final String PROTOCOL = com.android.exchange.Configuration.EXCHANGE_PROTOCOL; 60 public static final String EXCHANGE_SERVICE_INTENT_ACTION = 61 com.android.exchange.Configuration.EXCHANGE_SERVICE_INTENT_ACTION; 62 63 // From EAS spec 64 // Mail Cal 65 // 0 No filter Yes Yes 66 // 1 1 day ago Yes No 67 // 2 3 days ago Yes No 68 // 3 1 week ago Yes No 69 // 4 2 weeks ago Yes Yes 70 // 5 1 month ago Yes Yes 71 // 6 3 months ago No Yes 72 // 7 6 months ago No Yes 73 74 // TODO Rationalize this with SYNC_WINDOW_ALL 75 public static final String FILTER_ALL = "0"; 76 public static final String FILTER_1_DAY = "1"; 77 public static final String FILTER_3_DAYS = "2"; 78 public static final String FILTER_1_WEEK = "3"; 79 public static final String FILTER_2_WEEKS = "4"; 80 public static final String FILTER_1_MONTH = "5"; 81 public static final String FILTER_3_MONTHS = "6"; 82 public static final String FILTER_6_MONTHS = "7"; 83 84 public static final String BODY_PREFERENCE_TEXT = "1"; 85 public static final String BODY_PREFERENCE_HTML = "2"; 86 87 public static final String MIME_BODY_PREFERENCE_TEXT = "0"; 88 public static final String MIME_BODY_PREFERENCE_MIME = "2"; 89 90 // For EAS 12, we use HTML, so we want a larger size than in EAS 2.5 91 public static final String EAS12_TRUNCATION_SIZE = "200000"; 92 // For EAS 2.5, truncation is a code; the largest is "7", which is 100k 93 public static final String EAS2_5_TRUNCATION_SIZE = "7"; 94 95 public static final int FOLDER_STATUS_OK = 1; 96 public static final int FOLDER_STATUS_INVALID_KEY = 9; 97 98 public static final int EXCHANGE_ERROR_NOTIFICATION = 0x10; 99 100 public static void setUserDebug(int state) { 101 // DEBUG takes precedence and is never true in a user build 102 if (!DEBUG) { 103 USER_LOG = (state & EmailServiceProxy.DEBUG_BIT) != 0; 104 PARSER_LOG = (state & EmailServiceProxy.DEBUG_VERBOSE_BIT) != 0; 105 FILE_LOG = (state & EmailServiceProxy.DEBUG_FILE_BIT) != 0; 106 if (FILE_LOG || PARSER_LOG) { 107 USER_LOG = true; 108 } 109 LogUtils.d("Eas Debug", "Logging: " + (USER_LOG ? "User " : "") + 110 (PARSER_LOG ? "Parser " : "") + (FILE_LOG ? "File" : "")); 111 } 112 } 113 114 static public Double getProtocolVersionDouble(String version) { 115 if (SUPPORTED_PROTOCOL_EX2003.equals(version)) { 116 return SUPPORTED_PROTOCOL_EX2003_DOUBLE; 117 } else if (SUPPORTED_PROTOCOL_EX2007.equals(version)) { 118 return SUPPORTED_PROTOCOL_EX2007_DOUBLE; 119 } if (SUPPORTED_PROTOCOL_EX2007_SP1.equals(version)) { 120 return SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE; 121 } if (SUPPORTED_PROTOCOL_EX2010.equals(version)) { 122 return SUPPORTED_PROTOCOL_EX2010_DOUBLE; 123 } if (SUPPORTED_PROTOCOL_EX2010_SP1.equals(version)) { 124 return SUPPORTED_PROTOCOL_EX2010_SP1_DOUBLE; 125 } 126 throw new IllegalArgumentException("illegal protocol version"); 127 } 128} 129