2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
package com.fsck.k9;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2010-07-28 17:28:51 -04:00
|
|
|
import com.fsck.k9.crypto.Apg;
|
2010-08-22 05:51:17 -04:00
|
|
|
import com.fsck.k9.crypto.CryptoProvider;
|
2010-05-19 14:17:06 -04:00
|
|
|
import com.fsck.k9.helper.Utility;
|
2010-05-15 16:35:39 -04:00
|
|
|
import com.fsck.k9.mail.Address;
|
|
|
|
import com.fsck.k9.mail.Folder;
|
|
|
|
import com.fsck.k9.mail.MessagingException;
|
|
|
|
import com.fsck.k9.mail.Store;
|
|
|
|
import com.fsck.k9.mail.store.LocalStore;
|
|
|
|
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
2010-05-30 17:20:47 -04:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
2010-05-15 16:35:39 -04:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Account stores all of the settings for a single account defined by the user. It is able to save
|
|
|
|
* and delete itself given a Preferences to work with. Each account is defined by a UUID.
|
|
|
|
*/
|
|
|
|
public class Account implements BaseAccount
|
|
|
|
{
|
|
|
|
public static final String EXPUNGE_IMMEDIATELY = "EXPUNGE_IMMEDIATELY";
|
|
|
|
public static final String EXPUNGE_MANUALLY = "EXPUNGE_MANUALLY";
|
|
|
|
public static final String EXPUNGE_ON_POLL = "EXPUNGE_ON_POLL";
|
|
|
|
|
|
|
|
public static final int DELETE_POLICY_NEVER = 0;
|
|
|
|
public static final int DELETE_POLICY_7DAYS = 1;
|
|
|
|
public static final int DELETE_POLICY_ON_DELETE = 2;
|
|
|
|
public static final int DELETE_POLICY_MARK_AS_READ = 3;
|
|
|
|
|
|
|
|
public static final String TYPE_WIFI = "WIFI";
|
|
|
|
public static final String TYPE_MOBILE = "MOBILE";
|
|
|
|
public static final String TYPE_OTHER = "OTHER";
|
|
|
|
private static String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER };
|
|
|
|
|
2010-06-20 10:07:03 -04:00
|
|
|
private static final String DEFAULT_QUOTE_PREFIX = ">";
|
2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <pre>
|
|
|
|
* 0 - Never (DELETE_POLICY_NEVER)
|
|
|
|
* 1 - After 7 days (DELETE_POLICY_7DAYS)
|
|
|
|
* 2 - When I delete from inbox (DELETE_POLICY_ON_DELETE)
|
|
|
|
* 3 - Mark as read (DELETE_POLICY_MARK_AS_READ)
|
|
|
|
* </pre>
|
|
|
|
*/
|
|
|
|
private int mDeletePolicy;
|
|
|
|
|
|
|
|
private String mUuid;
|
|
|
|
private String mStoreUri;
|
|
|
|
private String mLocalStoreUri;
|
|
|
|
private String mTransportUri;
|
|
|
|
private String mDescription;
|
|
|
|
private String mAlwaysBcc;
|
|
|
|
private int mAutomaticCheckIntervalMinutes;
|
|
|
|
private int mDisplayCount;
|
|
|
|
private int mChipColor;
|
2010-05-15 16:35:59 -04:00
|
|
|
private int mLedColor;
|
2010-05-15 16:35:39 -04:00
|
|
|
private long mLastAutomaticCheckTime;
|
|
|
|
private boolean mNotifyNewMail;
|
|
|
|
private boolean mNotifySelfNewMail;
|
|
|
|
private String mDraftsFolderName;
|
|
|
|
private String mSentFolderName;
|
|
|
|
private String mTrashFolderName;
|
2010-07-04 09:48:06 -04:00
|
|
|
private String mArchiveFolderName;
|
|
|
|
private String mSpamFolderName;
|
2010-05-15 16:35:39 -04:00
|
|
|
private String mOutboxFolderName;
|
|
|
|
private String mAutoExpandFolderName;
|
|
|
|
private FolderMode mFolderDisplayMode;
|
|
|
|
private FolderMode mFolderSyncMode;
|
|
|
|
private FolderMode mFolderPushMode;
|
|
|
|
private FolderMode mFolderTargetMode;
|
|
|
|
private int mAccountNumber;
|
|
|
|
private boolean mVibrate;
|
2010-07-02 10:47:01 -04:00
|
|
|
private int mVibratePattern;
|
|
|
|
private int mVibrateTimes;
|
2010-05-15 16:35:39 -04:00
|
|
|
private boolean mRing;
|
2010-05-21 11:34:29 -04:00
|
|
|
private boolean mSaveAllHeaders;
|
2010-05-15 16:35:39 -04:00
|
|
|
private boolean mPushPollOnConnect;
|
|
|
|
private String mRingtoneUri;
|
|
|
|
private boolean mNotifySync;
|
|
|
|
private HideButtons mHideMessageViewButtons;
|
2010-07-05 09:41:52 -04:00
|
|
|
private HideButtons mHideMessageViewMoveButtons;
|
2010-08-07 18:38:08 -04:00
|
|
|
private ShowPictures mShowPictures;
|
2010-07-05 09:41:52 -04:00
|
|
|
private boolean mEnableMoveButtons;
|
2010-05-15 16:35:39 -04:00
|
|
|
private boolean mIsSignatureBeforeQuotedText;
|
|
|
|
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
|
|
|
private int mMaxPushFolders;
|
|
|
|
private int mIdleRefreshMinutes;
|
|
|
|
private boolean goToUnreadMessageSearch;
|
|
|
|
private Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
|
|
|
|
private Searchable searchableFolders;
|
2010-05-30 12:56:50 -04:00
|
|
|
private boolean subscribedFoldersOnly;
|
2010-05-30 17:20:47 -04:00
|
|
|
private int maximumPolledMessageAge;
|
2010-07-11 07:59:14 -04:00
|
|
|
private int maximumAutoDownloadMessageSize;
|
2010-05-15 16:35:39 -04:00
|
|
|
// Tracks if we have sent a notification for this account for
|
|
|
|
// current set of fetched messages
|
|
|
|
private boolean mRingNotified;
|
2010-06-20 10:07:03 -04:00
|
|
|
private String mQuotePrefix;
|
2010-07-03 09:10:38 -04:00
|
|
|
private boolean mSyncRemoteDeletions;
|
2010-07-27 08:10:09 -04:00
|
|
|
private String mCryptoApp;
|
|
|
|
private boolean mCryptoAutoSignature;
|
2010-05-15 16:35:39 -04:00
|
|
|
|
2010-08-22 05:51:17 -04:00
|
|
|
private CryptoProvider mCryptoProvider = null;
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
/**
|
|
|
|
* Name of the folder that was last selected for a copy or move operation.
|
|
|
|
*
|
|
|
|
* Note: For now this value isn't persisted. So it will be reset when
|
2010-07-06 06:29:26 -04:00
|
|
|
* K-9 Mail is restarted.
|
2010-07-04 19:29:57 -04:00
|
|
|
*/
|
|
|
|
private String lastSelectedFolderName = null;
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
private List<Identity> identities;
|
|
|
|
|
|
|
|
public enum FolderMode
|
|
|
|
{
|
|
|
|
NONE, ALL, FIRST_CLASS, FIRST_AND_SECOND_CLASS, NOT_SECOND_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum HideButtons
|
|
|
|
{
|
|
|
|
NEVER, ALWAYS, KEYBOARD_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2010-08-07 18:38:08 -04:00
|
|
|
public enum ShowPictures
|
|
|
|
{
|
|
|
|
NEVER, ALWAYS, ONLY_FROM_CONTACTS;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
public enum Searchable
|
|
|
|
{
|
|
|
|
ALL, DISPLAYABLE, NONE
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Account(Context context)
|
|
|
|
{
|
|
|
|
// TODO Change local store path to something readable / recognizable
|
|
|
|
mUuid = UUID.randomUUID().toString();
|
|
|
|
mLocalStoreUri = "local://localhost/" + context.getDatabasePath(mUuid + ".db");
|
|
|
|
mAutomaticCheckIntervalMinutes = -1;
|
|
|
|
mIdleRefreshMinutes = 24;
|
2010-05-21 11:34:29 -04:00
|
|
|
mSaveAllHeaders = false;
|
2010-05-15 16:35:39 -04:00
|
|
|
mPushPollOnConnect = true;
|
2010-06-07 11:55:14 -04:00
|
|
|
mDisplayCount = K9.DEFAULT_VISIBLE_LIMIT;
|
2010-05-15 16:35:39 -04:00
|
|
|
mAccountNumber = -1;
|
|
|
|
mNotifyNewMail = true;
|
|
|
|
mNotifySync = true;
|
|
|
|
mVibrate = false;
|
2010-07-02 10:47:01 -04:00
|
|
|
mVibratePattern = 0;
|
|
|
|
mVibrateTimes = 5;
|
2010-05-15 16:35:39 -04:00
|
|
|
mRing = true;
|
|
|
|
mNotifySelfNewMail = true;
|
|
|
|
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
|
|
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
|
|
|
mFolderPushMode = FolderMode.FIRST_CLASS;
|
|
|
|
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
|
|
|
|
mHideMessageViewButtons = HideButtons.NEVER;
|
2010-07-05 09:41:52 -04:00
|
|
|
mHideMessageViewMoveButtons = HideButtons.NEVER;
|
2010-08-07 18:38:08 -04:00
|
|
|
mShowPictures = ShowPictures.NEVER;
|
2010-07-05 09:41:52 -04:00
|
|
|
mEnableMoveButtons = false;
|
2010-05-15 16:35:39 -04:00
|
|
|
mRingtoneUri = "content://settings/system/notification_sound";
|
|
|
|
mIsSignatureBeforeQuotedText = false;
|
|
|
|
mExpungePolicy = EXPUNGE_IMMEDIATELY;
|
|
|
|
mAutoExpandFolderName = "INBOX";
|
|
|
|
mMaxPushFolders = 10;
|
2010-05-15 16:35:47 -04:00
|
|
|
mChipColor = (new Random()).nextInt(0xffffff) + 0xff000000;
|
2010-05-15 16:35:59 -04:00
|
|
|
mLedColor = mChipColor;
|
2010-05-15 16:35:39 -04:00
|
|
|
goToUnreadMessageSearch = false;
|
2010-05-30 12:56:50 -04:00
|
|
|
subscribedFoldersOnly = false;
|
2010-06-27 22:51:47 -04:00
|
|
|
maximumPolledMessageAge = -1;
|
2010-07-11 07:59:14 -04:00
|
|
|
maximumAutoDownloadMessageSize = 32768;
|
2010-06-20 10:07:03 -04:00
|
|
|
mQuotePrefix = DEFAULT_QUOTE_PREFIX;
|
2010-07-03 09:10:38 -04:00
|
|
|
mSyncRemoteDeletions = true;
|
2010-07-28 17:28:51 -04:00
|
|
|
mCryptoApp = Apg.NAME;
|
2010-07-27 08:10:09 -04:00
|
|
|
mCryptoAutoSignature = false;
|
2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
searchableFolders = Searchable.ALL;
|
|
|
|
|
|
|
|
identities = new ArrayList<Identity>();
|
|
|
|
|
|
|
|
Identity identity = new Identity();
|
|
|
|
identity.setSignatureUse(true);
|
|
|
|
identity.setSignature(context.getString(R.string.default_signature));
|
|
|
|
identity.setDescription(context.getString(R.string.default_identity_description));
|
|
|
|
identities.add(identity);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Account(Preferences preferences, String uuid)
|
|
|
|
{
|
|
|
|
this.mUuid = uuid;
|
|
|
|
loadAccount(preferences);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load stored settings for this account.
|
|
|
|
*/
|
|
|
|
private synchronized void loadAccount(Preferences preferences)
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
|
|
|
|
SharedPreferences prefs = preferences.getPreferences();
|
|
|
|
|
|
|
|
mStoreUri = Utility.base64Decode(prefs.getString(mUuid
|
2010-05-15 16:35:39 -04:00
|
|
|
+ ".storeUri", null));
|
2010-07-18 21:52:43 -04:00
|
|
|
mLocalStoreUri = prefs.getString(mUuid + ".localStoreUri", null);
|
|
|
|
mTransportUri = Utility.base64Decode(prefs.getString(mUuid
|
2010-05-15 16:35:39 -04:00
|
|
|
+ ".transportUri", null));
|
2010-07-18 21:52:43 -04:00
|
|
|
mDescription = prefs.getString(mUuid + ".description", null);
|
|
|
|
mAlwaysBcc = prefs.getString(mUuid + ".alwaysBcc", mAlwaysBcc);
|
|
|
|
mAutomaticCheckIntervalMinutes = prefs.getInt(mUuid
|
2010-05-15 16:35:39 -04:00
|
|
|
+ ".automaticCheckIntervalMinutes", -1);
|
2010-07-18 21:52:43 -04:00
|
|
|
mIdleRefreshMinutes = prefs.getInt(mUuid
|
2010-07-18 21:57:49 -04:00
|
|
|
+ ".idleRefreshMinutes", 24);
|
2010-07-18 21:52:43 -04:00
|
|
|
mSaveAllHeaders = prefs.getBoolean(mUuid
|
2010-07-18 21:57:49 -04:00
|
|
|
+ ".saveAllHeaders", false);
|
2010-07-18 21:52:43 -04:00
|
|
|
mPushPollOnConnect = prefs.getBoolean(mUuid
|
2010-07-18 21:57:49 -04:00
|
|
|
+ ".pushPollOnConnect", true);
|
2010-07-18 21:52:43 -04:00
|
|
|
mDisplayCount = prefs.getInt(mUuid + ".displayCount", K9.DEFAULT_VISIBLE_LIMIT);
|
2010-07-04 09:48:06 -04:00
|
|
|
if (mDisplayCount < 0)
|
|
|
|
{
|
|
|
|
mDisplayCount = K9.DEFAULT_VISIBLE_LIMIT;
|
|
|
|
}
|
2010-07-18 21:52:43 -04:00
|
|
|
mLastAutomaticCheckTime = prefs.getLong(mUuid
|
2010-07-18 21:57:49 -04:00
|
|
|
+ ".lastAutomaticCheckTime", 0);
|
2010-07-18 21:52:43 -04:00
|
|
|
mNotifyNewMail = prefs.getBoolean(mUuid + ".notifyNewMail",
|
2010-07-18 21:57:49 -04:00
|
|
|
false);
|
2010-07-18 21:52:43 -04:00
|
|
|
mNotifySelfNewMail = prefs.getBoolean(mUuid + ".notifySelfNewMail",
|
2010-07-18 21:57:49 -04:00
|
|
|
true);
|
2010-07-18 21:52:43 -04:00
|
|
|
mNotifySync = prefs.getBoolean(mUuid + ".notifyMailCheck",
|
2010-07-18 21:57:49 -04:00
|
|
|
false);
|
2010-07-18 21:52:43 -04:00
|
|
|
mDeletePolicy = prefs.getInt(mUuid + ".deletePolicy", 0);
|
|
|
|
mDraftsFolderName = prefs.getString(mUuid + ".draftsFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Drafts");
|
2010-07-18 21:52:43 -04:00
|
|
|
mSentFolderName = prefs.getString(mUuid + ".sentFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Sent");
|
2010-07-18 21:52:43 -04:00
|
|
|
mTrashFolderName = prefs.getString(mUuid + ".trashFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Trash");
|
2010-07-18 21:52:43 -04:00
|
|
|
mArchiveFolderName = prefs.getString(mUuid + ".archiveFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Archive");
|
2010-07-18 21:52:43 -04:00
|
|
|
mSpamFolderName = prefs.getString(mUuid + ".spamFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Spam");
|
2010-07-18 21:52:43 -04:00
|
|
|
mOutboxFolderName = prefs.getString(mUuid + ".outboxFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"Outbox");
|
2010-07-18 21:52:43 -04:00
|
|
|
mExpungePolicy = prefs.getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY);
|
|
|
|
mSyncRemoteDeletions = prefs.getBoolean(mUuid + ".syncRemoteDeletions", true);
|
2010-07-04 09:48:06 -04:00
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10);
|
|
|
|
goToUnreadMessageSearch = prefs.getBoolean(mUuid + ".goToUnreadMessageSearch",
|
2010-05-30 12:56:50 -04:00
|
|
|
false);
|
2010-07-18 21:52:43 -04:00
|
|
|
subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly",
|
2010-07-06 06:29:26 -04:00
|
|
|
false);
|
2010-07-18 21:52:43 -04:00
|
|
|
maximumPolledMessageAge = prefs.getInt(mUuid
|
2010-07-18 21:57:49 -04:00
|
|
|
+ ".maximumPolledMessageAge", -1);
|
2010-07-18 21:52:43 -04:00
|
|
|
maximumAutoDownloadMessageSize = prefs.getInt(mUuid
|
2010-07-11 11:39:26 -04:00
|
|
|
+ ".maximumAutoDownloadMessageSize", 32768);
|
2010-07-18 21:52:43 -04:00
|
|
|
mQuotePrefix = prefs.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
|
2010-05-15 16:35:39 -04:00
|
|
|
for (String type : networkTypes)
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type,
|
2010-05-15 16:35:39 -04:00
|
|
|
true);
|
|
|
|
compressionMap.put(type, useCompression);
|
|
|
|
}
|
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mAutoExpandFolderName = prefs.getString(mUuid + ".autoExpandFolderName",
|
2010-07-18 21:57:49 -04:00
|
|
|
"INBOX");
|
2010-05-15 16:35:39 -04:00
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mAccountNumber = prefs.getInt(mUuid + ".accountNumber", 0);
|
2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
Random random = new Random((long)mAccountNumber+4);
|
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mChipColor = prefs.getInt(mUuid+".chipColor",
|
2010-07-18 21:57:49 -04:00
|
|
|
(random.nextInt(0x70)) +
|
|
|
|
(random.nextInt(0x70) * 0xff) +
|
|
|
|
(random.nextInt(0x70) * 0xffff) +
|
|
|
|
0xff000000);
|
2010-07-18 21:52:43 -04:00
|
|
|
mLedColor = prefs.getInt(mUuid+".ledColor", mChipColor);
|
2010-05-15 16:35:59 -04:00
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mVibrate = prefs.getBoolean(mUuid + ".vibrate", false);
|
|
|
|
mVibratePattern = prefs.getInt(mUuid + ".vibratePattern", 0);
|
|
|
|
mVibrateTimes = prefs.getInt(mUuid + ".vibrateTimes", 5);
|
2010-07-02 10:47:01 -04:00
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mRing = prefs.getBoolean(mUuid + ".ring", true);
|
2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mHideMessageViewButtons = HideButtons.valueOf(prefs.getString(mUuid + ".hideButtonsEnum",
|
2010-05-15 16:35:39 -04:00
|
|
|
HideButtons.NEVER.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mHideMessageViewButtons = HideButtons.NEVER;
|
|
|
|
}
|
|
|
|
|
2010-07-05 09:41:52 -04:00
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mHideMessageViewMoveButtons = HideButtons.valueOf(prefs.getString(mUuid + ".hideMoveButtonsEnum",
|
2010-07-05 09:41:52 -04:00
|
|
|
HideButtons.NEVER.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mHideMessageViewMoveButtons = HideButtons.NEVER;
|
|
|
|
}
|
|
|
|
|
2010-08-07 18:38:08 -04:00
|
|
|
try
|
|
|
|
{
|
|
|
|
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
|
2010-08-17 22:48:55 -04:00
|
|
|
ShowPictures.NEVER.name()));
|
2010-08-07 18:38:08 -04:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mShowPictures = ShowPictures.NEVER;
|
|
|
|
}
|
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mEnableMoveButtons = prefs.getBoolean(mUuid + ".enableMoveButtons", false);
|
2010-07-05 09:41:52 -04:00
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mRingtoneUri = prefs.getString(mUuid + ".ringtone",
|
2010-07-18 21:57:49 -04:00
|
|
|
"content://settings/system/notification_sound");
|
2010-05-15 16:35:39 -04:00
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mFolderDisplayMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderDisplayMode",
|
2010-05-15 16:35:39 -04:00
|
|
|
FolderMode.NOT_SECOND_CLASS.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mFolderSyncMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderSyncMode",
|
2010-05-15 16:35:39 -04:00
|
|
|
FolderMode.FIRST_CLASS.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mFolderPushMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderPushMode",
|
2010-05-15 16:35:39 -04:00
|
|
|
FolderMode.FIRST_CLASS.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mFolderPushMode = FolderMode.FIRST_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
mFolderTargetMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderTargetMode",
|
2010-05-15 16:35:39 -04:00
|
|
|
FolderMode.NOT_SECOND_CLASS.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2010-07-18 21:52:43 -04:00
|
|
|
searchableFolders = Searchable.valueOf(prefs.getString(mUuid + ".searchableFolders",
|
2010-05-15 16:35:39 -04:00
|
|
|
Searchable.ALL.name()));
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
searchableFolders = Searchable.ALL;
|
|
|
|
}
|
|
|
|
|
2010-07-18 21:52:43 -04:00
|
|
|
mIsSignatureBeforeQuotedText = prefs.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
|
|
|
|
identities = loadIdentities(prefs);
|
2010-07-27 08:10:09 -04:00
|
|
|
|
2010-08-14 15:30:37 -04:00
|
|
|
mCryptoApp = prefs.getString(mUuid + ".cryptoApp", Apg.NAME);
|
2010-07-27 08:10:09 -04:00
|
|
|
mCryptoAutoSignature = prefs.getBoolean(mUuid + ".cryptoAutoSignature", false);
|
2010-05-15 16:35:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected synchronized void delete(Preferences preferences)
|
|
|
|
{
|
|
|
|
String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
for (int i = 0, length = uuids.length; i < length; i++)
|
|
|
|
{
|
|
|
|
if (!uuids[i].equals(mUuid))
|
|
|
|
{
|
|
|
|
if (sb.length() > 0)
|
|
|
|
{
|
|
|
|
sb.append(',');
|
|
|
|
}
|
|
|
|
sb.append(uuids[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String accountUuids = sb.toString();
|
|
|
|
SharedPreferences.Editor editor = preferences.getPreferences().edit();
|
|
|
|
editor.putString("accountUuids", accountUuids);
|
|
|
|
|
|
|
|
editor.remove(mUuid + ".storeUri");
|
|
|
|
editor.remove(mUuid + ".localStoreUri");
|
|
|
|
editor.remove(mUuid + ".transportUri");
|
|
|
|
editor.remove(mUuid + ".description");
|
|
|
|
editor.remove(mUuid + ".name");
|
|
|
|
editor.remove(mUuid + ".email");
|
|
|
|
editor.remove(mUuid + ".alwaysBcc");
|
|
|
|
editor.remove(mUuid + ".automaticCheckIntervalMinutes");
|
|
|
|
editor.remove(mUuid + ".pushPollOnConnect");
|
2010-05-21 11:34:29 -04:00
|
|
|
editor.remove(mUuid + ".saveAllHeaders");
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.remove(mUuid + ".idleRefreshMinutes");
|
|
|
|
editor.remove(mUuid + ".lastAutomaticCheckTime");
|
|
|
|
editor.remove(mUuid + ".notifyNewMail");
|
|
|
|
editor.remove(mUuid + ".notifySelfNewMail");
|
|
|
|
editor.remove(mUuid + ".deletePolicy");
|
|
|
|
editor.remove(mUuid + ".draftsFolderName");
|
|
|
|
editor.remove(mUuid + ".sentFolderName");
|
|
|
|
editor.remove(mUuid + ".trashFolderName");
|
2010-07-04 09:48:06 -04:00
|
|
|
editor.remove(mUuid + ".archiveFolderName");
|
|
|
|
editor.remove(mUuid + ".spamFolderName");
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.remove(mUuid + ".outboxFolderName");
|
|
|
|
editor.remove(mUuid + ".autoExpandFolderName");
|
|
|
|
editor.remove(mUuid + ".accountNumber");
|
|
|
|
editor.remove(mUuid + ".vibrate");
|
2010-07-02 10:47:01 -04:00
|
|
|
editor.remove(mUuid + ".vibratePattern");
|
|
|
|
editor.remove(mUuid + ".vibrateTimes");
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.remove(mUuid + ".ring");
|
|
|
|
editor.remove(mUuid + ".ringtone");
|
|
|
|
editor.remove(mUuid + ".lastFullSync");
|
|
|
|
editor.remove(mUuid + ".folderDisplayMode");
|
|
|
|
editor.remove(mUuid + ".folderSyncMode");
|
|
|
|
editor.remove(mUuid + ".folderPushMode");
|
|
|
|
editor.remove(mUuid + ".folderTargetMode");
|
|
|
|
editor.remove(mUuid + ".hideButtonsEnum");
|
|
|
|
editor.remove(mUuid + ".signatureBeforeQuotedText");
|
|
|
|
editor.remove(mUuid + ".expungePolicy");
|
2010-07-03 09:10:38 -04:00
|
|
|
editor.remove(mUuid + ".syncRemoteDeletions");
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.remove(mUuid + ".maxPushFolders");
|
|
|
|
editor.remove(mUuid + ".searchableFolders");
|
2010-05-22 10:07:02 -04:00
|
|
|
editor.remove(mUuid + ".chipColor");
|
|
|
|
editor.remove(mUuid + ".ledColor");
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.remove(mUuid + ".goToUnreadMessageSearch");
|
2010-05-30 12:56:50 -04:00
|
|
|
editor.remove(mUuid + ".subscribedFoldersOnly");
|
2010-05-30 17:20:47 -04:00
|
|
|
editor.remove(mUuid + ".maximumPolledMessageAge");
|
2010-07-11 07:59:14 -04:00
|
|
|
editor.remove(mUuid + ".maximumAutoDownloadMessageSize");
|
2010-06-20 10:07:03 -04:00
|
|
|
editor.remove(mUuid + ".quotePrefix");
|
2010-05-15 16:35:39 -04:00
|
|
|
for (String type : networkTypes)
|
|
|
|
{
|
|
|
|
editor.remove(mUuid + ".useCompression." + type);
|
|
|
|
}
|
|
|
|
deleteIdentities(preferences.getPreferences(), editor);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void save(Preferences preferences)
|
|
|
|
{
|
|
|
|
SharedPreferences.Editor editor = preferences.getPreferences().edit();
|
|
|
|
|
|
|
|
if (!preferences.getPreferences().getString("accountUuids", "").contains(mUuid))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* When the account is first created we assign it a unique account number. The
|
|
|
|
* account number will be unique to that account for the lifetime of the account.
|
|
|
|
* So, we get all the existing account numbers, sort them ascending, loop through
|
|
|
|
* the list and check if the number is greater than 1 + the previous number. If so
|
|
|
|
* we use the previous number + 1 as the account number. This refills gaps.
|
|
|
|
* mAccountNumber starts as -1 on a newly created account. It must be -1 for this
|
|
|
|
* algorithm to work.
|
|
|
|
*
|
|
|
|
* I bet there is a much smarter way to do this. Anyone like to suggest it?
|
|
|
|
*/
|
|
|
|
Account[] accounts = preferences.getAccounts();
|
|
|
|
int[] accountNumbers = new int[accounts.length];
|
|
|
|
for (int i = 0; i < accounts.length; i++)
|
|
|
|
{
|
|
|
|
accountNumbers[i] = accounts[i].getAccountNumber();
|
|
|
|
}
|
|
|
|
Arrays.sort(accountNumbers);
|
|
|
|
for (int accountNumber : accountNumbers)
|
|
|
|
{
|
|
|
|
if (accountNumber > mAccountNumber + 1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mAccountNumber = accountNumber;
|
|
|
|
}
|
|
|
|
mAccountNumber++;
|
|
|
|
|
|
|
|
String accountUuids = preferences.getPreferences().getString("accountUuids", "");
|
|
|
|
accountUuids += (accountUuids.length() != 0 ? "," : "") + mUuid;
|
|
|
|
editor.putString("accountUuids", accountUuids);
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.putString(mUuid + ".storeUri", Utility.base64Encode(mStoreUri));
|
|
|
|
editor.putString(mUuid + ".localStoreUri", mLocalStoreUri);
|
|
|
|
editor.putString(mUuid + ".transportUri", Utility.base64Encode(mTransportUri));
|
|
|
|
editor.putString(mUuid + ".description", mDescription);
|
|
|
|
editor.putString(mUuid + ".alwaysBcc", mAlwaysBcc);
|
|
|
|
editor.putInt(mUuid + ".automaticCheckIntervalMinutes", mAutomaticCheckIntervalMinutes);
|
|
|
|
editor.putInt(mUuid + ".idleRefreshMinutes", mIdleRefreshMinutes);
|
2010-05-21 11:34:29 -04:00
|
|
|
editor.putBoolean(mUuid + ".saveAllHeaders", mSaveAllHeaders);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putBoolean(mUuid + ".pushPollOnConnect", mPushPollOnConnect);
|
|
|
|
editor.putInt(mUuid + ".displayCount", mDisplayCount);
|
|
|
|
editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
|
|
|
|
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
|
|
|
|
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
|
|
|
|
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
|
|
|
|
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
|
|
|
|
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
|
|
|
|
editor.putString(mUuid + ".sentFolderName", mSentFolderName);
|
|
|
|
editor.putString(mUuid + ".trashFolderName", mTrashFolderName);
|
2010-07-04 09:48:06 -04:00
|
|
|
editor.putString(mUuid + ".archiveFolderName", mArchiveFolderName);
|
|
|
|
editor.putString(mUuid + ".spamFolderName", mSpamFolderName);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putString(mUuid + ".outboxFolderName", mOutboxFolderName);
|
|
|
|
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
|
|
|
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
|
|
|
editor.putBoolean(mUuid + ".vibrate", mVibrate);
|
2010-07-02 10:47:01 -04:00
|
|
|
editor.putInt(mUuid + ".vibratePattern", mVibratePattern);
|
|
|
|
editor.putInt(mUuid + ".vibrateTimes", mVibrateTimes);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putBoolean(mUuid + ".ring", mRing);
|
|
|
|
editor.putString(mUuid + ".hideButtonsEnum", mHideMessageViewButtons.name());
|
2010-07-05 09:41:52 -04:00
|
|
|
editor.putString(mUuid + ".hideMoveButtonsEnum", mHideMessageViewMoveButtons.name());
|
2010-08-07 18:38:08 -04:00
|
|
|
editor.putString(mUuid + ".showPicturesEnum", mShowPictures.name());
|
2010-07-05 09:41:52 -04:00
|
|
|
editor.putBoolean(mUuid + ".enableMoveButtons", mEnableMoveButtons);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putString(mUuid + ".ringtone", mRingtoneUri);
|
|
|
|
editor.putString(mUuid + ".folderDisplayMode", mFolderDisplayMode.name());
|
|
|
|
editor.putString(mUuid + ".folderSyncMode", mFolderSyncMode.name());
|
|
|
|
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
|
|
|
|
editor.putString(mUuid + ".folderTargetMode", mFolderTargetMode.name());
|
|
|
|
editor.putBoolean(mUuid + ".signatureBeforeQuotedText", this.mIsSignatureBeforeQuotedText);
|
|
|
|
editor.putString(mUuid + ".expungePolicy", mExpungePolicy);
|
2010-07-03 09:10:38 -04:00
|
|
|
editor.putBoolean(mUuid + ".syncRemoteDeletions", mSyncRemoteDeletions);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
|
|
|
|
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
|
|
|
|
editor.putInt(mUuid + ".chipColor", mChipColor);
|
2010-05-15 16:35:59 -04:00
|
|
|
editor.putInt(mUuid + ".ledColor", mLedColor);
|
2010-05-15 16:35:39 -04:00
|
|
|
editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
|
2010-05-30 12:56:50 -04:00
|
|
|
editor.putBoolean(mUuid + ".subscribedFoldersOnly", subscribedFoldersOnly);
|
2010-05-30 17:20:47 -04:00
|
|
|
editor.putInt(mUuid + ".maximumPolledMessageAge", maximumPolledMessageAge);
|
2010-07-11 07:59:14 -04:00
|
|
|
editor.putInt(mUuid + ".maximumAutoDownloadMessageSize", maximumAutoDownloadMessageSize);
|
2010-06-20 10:07:03 -04:00
|
|
|
editor.putString(mUuid + ".quotePrefix", mQuotePrefix);
|
2010-07-27 08:10:09 -04:00
|
|
|
editor.putString(mUuid + ".cryptoApp", mCryptoApp);
|
|
|
|
editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature);
|
2010-07-04 09:48:06 -04:00
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
for (String type : networkTypes)
|
|
|
|
{
|
|
|
|
Boolean useCompression = compressionMap.get(type);
|
|
|
|
if (useCompression != null)
|
|
|
|
{
|
|
|
|
editor.putBoolean(mUuid + ".useCompression." + type, useCompression);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveIdentities(preferences.getPreferences(), editor);
|
|
|
|
|
|
|
|
editor.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public AccountStats getStats(Context context) throws MessagingException
|
|
|
|
{
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
AccountStats stats = new AccountStats();
|
|
|
|
int unreadMessageCount = 0;
|
|
|
|
int flaggedMessageCount = 0;
|
|
|
|
LocalStore localStore = getLocalStore();
|
|
|
|
if (K9.measureAccounts())
|
|
|
|
{
|
|
|
|
stats.size = localStore.getSize();
|
|
|
|
}
|
|
|
|
Account.FolderMode aMode = getFolderDisplayMode();
|
|
|
|
Preferences prefs = Preferences.getPreferences(context);
|
|
|
|
long folderLoadStart = System.currentTimeMillis();
|
2010-05-30 12:56:50 -04:00
|
|
|
List<? extends Folder> folders = localStore.getPersonalNamespaces(false);
|
2010-05-15 16:35:39 -04:00
|
|
|
long folderLoadEnd = System.currentTimeMillis();
|
|
|
|
long folderEvalStart = folderLoadEnd;
|
|
|
|
for (Folder folder : folders)
|
|
|
|
{
|
|
|
|
LocalFolder localFolder = (LocalFolder)folder;
|
|
|
|
//folder.refresh(prefs);
|
|
|
|
Folder.FolderClass fMode = localFolder.getDisplayClass(prefs);
|
|
|
|
|
2010-07-04 09:48:06 -04:00
|
|
|
// Always get stats about the INBOX (see issue 1817)
|
2010-06-17 08:42:22 -04:00
|
|
|
if (folder.getName().equals(K9.INBOX) || (
|
2010-08-01 21:27:40 -04:00
|
|
|
!folder.getName().equals(getTrashFolderName()) &&
|
|
|
|
!folder.getName().equals(getDraftsFolderName()) &&
|
|
|
|
!folder.getName().equals(getArchiveFolderName()) &&
|
|
|
|
!folder.getName().equals(getSpamFolderName()) &&
|
|
|
|
!folder.getName().equals(getOutboxFolderName()) &&
|
|
|
|
!folder.getName().equals(getSentFolderName()) &&
|
|
|
|
!folder.getName().equals(getErrorFolderName())))
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
if (aMode == Account.FolderMode.NONE)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (aMode == Account.FolderMode.FIRST_CLASS &&
|
|
|
|
fMode != Folder.FolderClass.FIRST_CLASS)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS &&
|
|
|
|
fMode != Folder.FolderClass.FIRST_CLASS &&
|
|
|
|
fMode != Folder.FolderClass.SECOND_CLASS)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (aMode == Account.FolderMode.NOT_SECOND_CLASS &&
|
|
|
|
fMode == Folder.FolderClass.SECOND_CLASS)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
unreadMessageCount += folder.getUnreadMessageCount();
|
|
|
|
flaggedMessageCount += folder.getFlaggedMessageCount();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
long folderEvalEnd = System.currentTimeMillis();
|
|
|
|
stats.unreadMessageCount = unreadMessageCount;
|
|
|
|
stats.flaggedMessageCount = flaggedMessageCount;
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
if (K9.DEBUG)
|
|
|
|
Log.d(K9.LOG_TAG, "Account.getStats() on " + getDescription() + " took " + (endTime - startTime) + " ms;"
|
|
|
|
+ " loading " + folders.size() + " took " + (folderLoadEnd - folderLoadStart) + " ms;"
|
|
|
|
+ " evaluating took " + (folderEvalEnd - folderEvalStart) + " ms");
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setChipColor(int color)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
mChipColor = color;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized int getChipColor()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return mChipColor;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:59 -04:00
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setLedColor(int color)
|
2010-05-15 16:35:59 -04:00
|
|
|
{
|
|
|
|
mLedColor = color;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized int getLedColor()
|
2010-05-15 16:35:59 -04:00
|
|
|
{
|
|
|
|
return mLedColor;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
public String getUuid()
|
|
|
|
{
|
|
|
|
return mUuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Uri getContentUri()
|
|
|
|
{
|
|
|
|
return Uri.parse("content://accounts/" + getUuid());
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getStoreUri()
|
|
|
|
{
|
|
|
|
return mStoreUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setStoreUri(String storeUri)
|
|
|
|
{
|
|
|
|
this.mStoreUri = storeUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getTransportUri()
|
|
|
|
{
|
|
|
|
return mTransportUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setTransportUri(String transportUri)
|
|
|
|
{
|
|
|
|
this.mTransportUri = transportUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getDescription()
|
|
|
|
{
|
|
|
|
return mDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDescription(String description)
|
|
|
|
{
|
|
|
|
this.mDescription = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getName()
|
|
|
|
{
|
|
|
|
return identities.get(0).getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setName(String name)
|
|
|
|
{
|
|
|
|
identities.get(0).setName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean getSignatureUse()
|
|
|
|
{
|
|
|
|
return identities.get(0).getSignatureUse();
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setSignatureUse(boolean signatureUse)
|
|
|
|
{
|
|
|
|
identities.get(0).setSignatureUse(signatureUse);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getSignature()
|
|
|
|
{
|
|
|
|
return identities.get(0).getSignature();
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setSignature(String signature)
|
|
|
|
{
|
|
|
|
identities.get(0).setSignature(signature);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getEmail()
|
|
|
|
{
|
|
|
|
return identities.get(0).getEmail();
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setEmail(String email)
|
|
|
|
{
|
|
|
|
identities.get(0).setEmail(email);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getAlwaysBcc()
|
|
|
|
{
|
|
|
|
return mAlwaysBcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setAlwaysBcc(String alwaysBcc)
|
|
|
|
{
|
|
|
|
this.mAlwaysBcc = alwaysBcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean isVibrate()
|
|
|
|
{
|
|
|
|
return mVibrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setVibrate(boolean vibrate)
|
|
|
|
{
|
|
|
|
mVibrate = vibrate;
|
|
|
|
}
|
|
|
|
|
2010-07-02 10:47:01 -04:00
|
|
|
public synchronized int getVibratePattern()
|
|
|
|
{
|
|
|
|
return mVibratePattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setVibratePattern(int pattern)
|
|
|
|
{
|
|
|
|
mVibratePattern = pattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int getVibrateTimes()
|
|
|
|
{
|
|
|
|
return mVibrateTimes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setVibrateTimes(int times)
|
|
|
|
{
|
|
|
|
mVibrateTimes = times;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Have we sent a new mail notification on this account */
|
|
|
|
public boolean isRingNotified()
|
|
|
|
{
|
|
|
|
return mRingNotified;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRingNotified(boolean ringNotified)
|
|
|
|
{
|
|
|
|
mRingNotified = ringNotified;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getRingtone()
|
|
|
|
{
|
|
|
|
return mRingtoneUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setRingtone(String ringtoneUri)
|
|
|
|
{
|
|
|
|
mRingtoneUri = ringtoneUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getLocalStoreUri()
|
|
|
|
{
|
|
|
|
return mLocalStoreUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setLocalStoreUri(String localStoreUri)
|
|
|
|
{
|
|
|
|
this.mLocalStoreUri = localStoreUri;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns -1 for never.
|
|
|
|
*/
|
|
|
|
public synchronized int getAutomaticCheckIntervalMinutes()
|
|
|
|
{
|
|
|
|
return mAutomaticCheckIntervalMinutes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param automaticCheckIntervalMinutes or -1 for never.
|
|
|
|
*/
|
|
|
|
public synchronized boolean setAutomaticCheckIntervalMinutes(int automaticCheckIntervalMinutes)
|
|
|
|
{
|
|
|
|
int oldInterval = this.mAutomaticCheckIntervalMinutes;
|
|
|
|
int newInterval = automaticCheckIntervalMinutes;
|
|
|
|
this.mAutomaticCheckIntervalMinutes = automaticCheckIntervalMinutes;
|
|
|
|
|
|
|
|
return (oldInterval != newInterval);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int getDisplayCount()
|
|
|
|
{
|
|
|
|
return mDisplayCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDisplayCount(int displayCount)
|
|
|
|
{
|
|
|
|
if (displayCount != -1)
|
|
|
|
{
|
|
|
|
this.mDisplayCount = displayCount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.mDisplayCount = K9.DEFAULT_VISIBLE_LIMIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized long getLastAutomaticCheckTime()
|
|
|
|
{
|
|
|
|
return mLastAutomaticCheckTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setLastAutomaticCheckTime(long lastAutomaticCheckTime)
|
|
|
|
{
|
|
|
|
this.mLastAutomaticCheckTime = lastAutomaticCheckTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean isNotifyNewMail()
|
|
|
|
{
|
|
|
|
return mNotifyNewMail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setNotifyNewMail(boolean notifyNewMail)
|
|
|
|
{
|
|
|
|
this.mNotifyNewMail = notifyNewMail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int getDeletePolicy()
|
|
|
|
{
|
|
|
|
return mDeletePolicy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDeletePolicy(int deletePolicy)
|
|
|
|
{
|
|
|
|
this.mDeletePolicy = deletePolicy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getDraftsFolderName()
|
|
|
|
{
|
|
|
|
return mDraftsFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setDraftsFolderName(String draftsFolderName)
|
|
|
|
{
|
|
|
|
mDraftsFolderName = draftsFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getSentFolderName()
|
|
|
|
{
|
|
|
|
return mSentFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getErrorFolderName()
|
|
|
|
{
|
|
|
|
return K9.ERROR_FOLDER_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setSentFolderName(String sentFolderName)
|
|
|
|
{
|
|
|
|
mSentFolderName = sentFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getTrashFolderName()
|
|
|
|
{
|
|
|
|
return mTrashFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setTrashFolderName(String trashFolderName)
|
|
|
|
{
|
|
|
|
mTrashFolderName = trashFolderName;
|
|
|
|
}
|
|
|
|
|
2010-07-04 09:48:06 -04:00
|
|
|
public synchronized String getArchiveFolderName()
|
|
|
|
{
|
|
|
|
return mArchiveFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setArchiveFolderName(String archiveFolderName)
|
|
|
|
{
|
|
|
|
mArchiveFolderName = archiveFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getSpamFolderName()
|
|
|
|
{
|
|
|
|
return mSpamFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setSpamFolderName(String spamFolderName)
|
|
|
|
{
|
|
|
|
mSpamFolderName = spamFolderName;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
public synchronized String getOutboxFolderName()
|
|
|
|
{
|
|
|
|
return mOutboxFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setOutboxFolderName(String outboxFolderName)
|
|
|
|
{
|
|
|
|
mOutboxFolderName = outboxFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getAutoExpandFolderName()
|
|
|
|
{
|
|
|
|
return mAutoExpandFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setAutoExpandFolderName(String autoExpandFolderName)
|
|
|
|
{
|
|
|
|
mAutoExpandFolderName = autoExpandFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int getAccountNumber()
|
|
|
|
{
|
|
|
|
return mAccountNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized FolderMode getFolderDisplayMode()
|
|
|
|
{
|
|
|
|
return mFolderDisplayMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean setFolderDisplayMode(FolderMode displayMode)
|
|
|
|
{
|
|
|
|
FolderMode oldDisplayMode = mFolderDisplayMode;
|
|
|
|
mFolderDisplayMode = displayMode;
|
|
|
|
return oldDisplayMode != displayMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized FolderMode getFolderSyncMode()
|
|
|
|
{
|
|
|
|
return mFolderSyncMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean setFolderSyncMode(FolderMode syncMode)
|
|
|
|
{
|
|
|
|
FolderMode oldSyncMode = mFolderSyncMode;
|
|
|
|
mFolderSyncMode = syncMode;
|
|
|
|
|
|
|
|
if (syncMode == FolderMode.NONE && oldSyncMode != FolderMode.NONE)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (syncMode != FolderMode.NONE && oldSyncMode == FolderMode.NONE)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized FolderMode getFolderPushMode()
|
|
|
|
{
|
|
|
|
return mFolderPushMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean setFolderPushMode(FolderMode pushMode)
|
|
|
|
{
|
|
|
|
FolderMode oldPushMode = mFolderPushMode;
|
|
|
|
|
|
|
|
mFolderPushMode = pushMode;
|
|
|
|
return pushMode != oldPushMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean isShowOngoing()
|
|
|
|
{
|
|
|
|
return mNotifySync;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setShowOngoing(boolean showOngoing)
|
|
|
|
{
|
|
|
|
this.mNotifySync = showOngoing;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized HideButtons getHideMessageViewButtons()
|
|
|
|
{
|
|
|
|
return mHideMessageViewButtons;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setHideMessageViewButtons(HideButtons hideMessageViewButtons)
|
|
|
|
{
|
|
|
|
mHideMessageViewButtons = hideMessageViewButtons;
|
|
|
|
}
|
|
|
|
|
2010-07-05 09:41:52 -04:00
|
|
|
public synchronized HideButtons getHideMessageViewMoveButtons()
|
|
|
|
{
|
|
|
|
return mHideMessageViewMoveButtons;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setHideMessageViewMoveButtons(HideButtons hideMessageViewButtons)
|
|
|
|
{
|
|
|
|
mHideMessageViewMoveButtons = hideMessageViewButtons;
|
|
|
|
}
|
|
|
|
|
2010-08-07 18:38:08 -04:00
|
|
|
public synchronized ShowPictures getShowPictures()
|
|
|
|
{
|
|
|
|
return mShowPictures;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setShowPictures(ShowPictures showPictures)
|
|
|
|
{
|
|
|
|
mShowPictures = showPictures;
|
|
|
|
}
|
|
|
|
|
2010-05-15 16:35:39 -04:00
|
|
|
public synchronized FolderMode getFolderTargetMode()
|
|
|
|
{
|
|
|
|
return mFolderTargetMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setFolderTargetMode(FolderMode folderTargetMode)
|
|
|
|
{
|
|
|
|
mFolderTargetMode = folderTargetMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean isSignatureBeforeQuotedText()
|
|
|
|
{
|
|
|
|
return mIsSignatureBeforeQuotedText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setSignatureBeforeQuotedText(boolean mIsSignatureBeforeQuotedText)
|
|
|
|
{
|
|
|
|
this.mIsSignatureBeforeQuotedText = mIsSignatureBeforeQuotedText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean isNotifySelfNewMail()
|
|
|
|
{
|
|
|
|
return mNotifySelfNewMail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setNotifySelfNewMail(boolean notifySelfNewMail)
|
|
|
|
{
|
|
|
|
mNotifySelfNewMail = notifySelfNewMail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized String getExpungePolicy()
|
|
|
|
{
|
|
|
|
return mExpungePolicy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setExpungePolicy(String expungePolicy)
|
|
|
|
{
|
|
|
|
mExpungePolicy = expungePolicy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int getMaxPushFolders()
|
|
|
|
{
|
|
|
|
return mMaxPushFolders;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized boolean setMaxPushFolders(int maxPushFolders)
|
|
|
|
{
|
|
|
|
int oldMaxPushFolders = mMaxPushFolders;
|
|
|
|
mMaxPushFolders = maxPushFolders;
|
|
|
|
return oldMaxPushFolders != maxPushFolders;
|
|
|
|
}
|
|
|
|
|
2010-07-14 23:42:01 -04:00
|
|
|
public synchronized boolean shouldRing()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return mRing;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setRing(boolean ring)
|
|
|
|
{
|
|
|
|
mRing = ring;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LocalStore getLocalStore() throws MessagingException
|
|
|
|
{
|
|
|
|
return Store.getLocalInstance(this, K9.app);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Store getRemoteStore() throws MessagingException
|
|
|
|
{
|
|
|
|
return Store.getRemoteInstance(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized String toString()
|
|
|
|
{
|
|
|
|
return mDescription;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setCompression(String networkType, boolean useCompression)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
compressionMap.put(networkType, useCompression);
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean useCompression(String networkType)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
Boolean useCompression = compressionMap.get(networkType);
|
|
|
|
if (useCompression == null)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return useCompression;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean useCompression(int type)
|
|
|
|
{
|
|
|
|
String networkType = TYPE_OTHER;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case ConnectivityManager.TYPE_MOBILE:
|
|
|
|
networkType = TYPE_MOBILE;
|
|
|
|
break;
|
|
|
|
case ConnectivityManager.TYPE_WIFI:
|
|
|
|
networkType = TYPE_WIFI;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return useCompression(networkType);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o)
|
|
|
|
{
|
|
|
|
if (o instanceof Account)
|
|
|
|
{
|
|
|
|
return ((Account)o).mUuid.equals(mUuid);
|
|
|
|
}
|
|
|
|
return super.equals(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
|
|
|
return mUuid.hashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private synchronized List<Identity> loadIdentities(SharedPreferences prefs)
|
|
|
|
{
|
|
|
|
List<Identity> newIdentities = new ArrayList<Identity>();
|
|
|
|
int ident = 0;
|
|
|
|
boolean gotOne = false;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
gotOne = false;
|
|
|
|
String name = prefs.getString(mUuid + ".name." + ident, null);
|
|
|
|
String email = prefs.getString(mUuid + ".email." + ident, null);
|
|
|
|
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse." + ident, true);
|
|
|
|
String signature = prefs.getString(mUuid + ".signature." + ident, null);
|
|
|
|
String description = prefs.getString(mUuid + ".description." + ident, null);
|
2010-06-20 08:48:22 -04:00
|
|
|
final String replyTo = prefs.getString(mUuid + ".replyTo." + ident, null);
|
2010-05-15 16:35:39 -04:00
|
|
|
if (email != null)
|
|
|
|
{
|
|
|
|
Identity identity = new Identity();
|
|
|
|
identity.setName(name);
|
|
|
|
identity.setEmail(email);
|
|
|
|
identity.setSignatureUse(signatureUse);
|
|
|
|
identity.setSignature(signature);
|
|
|
|
identity.setDescription(description);
|
2010-06-20 08:48:22 -04:00
|
|
|
identity.setReplyTo(replyTo);
|
2010-05-15 16:35:39 -04:00
|
|
|
newIdentities.add(identity);
|
|
|
|
gotOne = true;
|
|
|
|
}
|
|
|
|
ident++;
|
|
|
|
}
|
|
|
|
while (gotOne);
|
|
|
|
|
|
|
|
if (newIdentities.size() == 0)
|
|
|
|
{
|
|
|
|
String name = prefs.getString(mUuid + ".name", null);
|
|
|
|
String email = prefs.getString(mUuid + ".email", null);
|
|
|
|
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse", true);
|
|
|
|
String signature = prefs.getString(mUuid + ".signature", null);
|
|
|
|
Identity identity = new Identity();
|
|
|
|
identity.setName(name);
|
|
|
|
identity.setEmail(email);
|
|
|
|
identity.setSignatureUse(signatureUse);
|
|
|
|
identity.setSignature(signature);
|
|
|
|
identity.setDescription(email);
|
|
|
|
newIdentities.add(identity);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newIdentities;
|
|
|
|
}
|
|
|
|
|
|
|
|
private synchronized void deleteIdentities(SharedPreferences prefs, SharedPreferences.Editor editor)
|
|
|
|
{
|
|
|
|
int ident = 0;
|
|
|
|
boolean gotOne = false;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
gotOne = false;
|
|
|
|
String email = prefs.getString(mUuid + ".email." + ident, null);
|
|
|
|
if (email != null)
|
|
|
|
{
|
|
|
|
editor.remove(mUuid + ".name." + ident);
|
|
|
|
editor.remove(mUuid + ".email." + ident);
|
|
|
|
editor.remove(mUuid + ".signatureUse." + ident);
|
|
|
|
editor.remove(mUuid + ".signature." + ident);
|
|
|
|
editor.remove(mUuid + ".description." + ident);
|
2010-06-20 08:48:22 -04:00
|
|
|
editor.remove(mUuid + ".replyTo." + ident);
|
2010-05-15 16:35:39 -04:00
|
|
|
gotOne = true;
|
|
|
|
}
|
|
|
|
ident++;
|
|
|
|
}
|
|
|
|
while (gotOne);
|
|
|
|
}
|
|
|
|
|
|
|
|
private synchronized void saveIdentities(SharedPreferences prefs, SharedPreferences.Editor editor)
|
|
|
|
{
|
|
|
|
deleteIdentities(prefs, editor);
|
|
|
|
int ident = 0;
|
|
|
|
|
|
|
|
for (Identity identity : identities)
|
|
|
|
{
|
|
|
|
editor.putString(mUuid + ".name." + ident, identity.getName());
|
|
|
|
editor.putString(mUuid + ".email." + ident, identity.getEmail());
|
|
|
|
editor.putBoolean(mUuid + ".signatureUse." + ident, identity.getSignatureUse());
|
|
|
|
editor.putString(mUuid + ".signature." + ident, identity.getSignature());
|
|
|
|
editor.putString(mUuid + ".description." + ident, identity.getDescription());
|
2010-06-20 08:48:22 -04:00
|
|
|
editor.putString(mUuid + ".replyTo." + ident, identity.getReplyTo());
|
2010-05-15 16:35:39 -04:00
|
|
|
ident++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized List<Identity> getIdentities()
|
|
|
|
{
|
|
|
|
return identities;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setIdentities(List<Identity> newIdentities)
|
|
|
|
{
|
|
|
|
identities = new ArrayList<Identity>(newIdentities);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized Identity getIdentity(int i)
|
|
|
|
{
|
|
|
|
if (i < identities.size())
|
|
|
|
{
|
|
|
|
return identities.get(i);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAnIdentity(Address[] addrs)
|
|
|
|
{
|
|
|
|
if (addrs == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (Address addr : addrs)
|
|
|
|
{
|
|
|
|
if (findIdentity(addr) != null)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAnIdentity(Address addr)
|
|
|
|
{
|
|
|
|
return findIdentity(addr) != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized Identity findIdentity(Address addr)
|
|
|
|
{
|
|
|
|
for (Identity identity : identities)
|
|
|
|
{
|
|
|
|
String email = identity.getEmail();
|
|
|
|
if (email != null && email.equalsIgnoreCase(addr.getAddress()))
|
|
|
|
{
|
|
|
|
return identity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized Searchable getSearchableFolders()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return searchableFolders;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setSearchableFolders(Searchable searchableFolders)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
this.searchableFolders = searchableFolders;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized int getIdleRefreshMinutes()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return mIdleRefreshMinutes;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setIdleRefreshMinutes(int idleRefreshMinutes)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
mIdleRefreshMinutes = idleRefreshMinutes;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean isPushPollOnConnect()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return mPushPollOnConnect;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setPushPollOnConnect(boolean pushPollOnConnect)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
mPushPollOnConnect = pushPollOnConnect;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean isSaveAllHeaders()
|
2010-05-21 11:34:29 -04:00
|
|
|
{
|
|
|
|
return mSaveAllHeaders;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setSaveAllHeaders(boolean saveAllHeaders)
|
2010-05-21 11:34:29 -04:00
|
|
|
{
|
|
|
|
mSaveAllHeaders = saveAllHeaders;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean goToUnreadMessageSearch()
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
return goToUnreadMessageSearch;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setGoToUnreadMessageSearch(boolean goToUnreadMessageSearch)
|
2010-05-15 16:35:39 -04:00
|
|
|
{
|
|
|
|
this.goToUnreadMessageSearch = goToUnreadMessageSearch;
|
|
|
|
}
|
2010-05-30 12:56:50 -04:00
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean subscribedFoldersOnly()
|
2010-05-30 12:56:50 -04:00
|
|
|
{
|
|
|
|
return subscribedFoldersOnly;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setSubscribedFoldersOnly(boolean subscribedFoldersOnly)
|
2010-05-30 12:56:50 -04:00
|
|
|
{
|
|
|
|
this.subscribedFoldersOnly = subscribedFoldersOnly;
|
|
|
|
}
|
2010-05-30 17:20:47 -04:00
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized int getMaximumPolledMessageAge()
|
2010-05-30 17:20:47 -04:00
|
|
|
{
|
|
|
|
return maximumPolledMessageAge;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setMaximumPolledMessageAge(int maximumPolledMessageAge)
|
2010-05-30 17:20:47 -04:00
|
|
|
{
|
|
|
|
this.maximumPolledMessageAge = maximumPolledMessageAge;
|
|
|
|
}
|
2010-06-20 10:07:03 -04:00
|
|
|
|
2010-07-11 07:59:14 -04:00
|
|
|
public synchronized int getMaximumAutoDownloadMessageSize()
|
|
|
|
{
|
|
|
|
return maximumAutoDownloadMessageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setMaximumAutoDownloadMessageSize(int maximumAutoDownloadMessageSize)
|
|
|
|
{
|
|
|
|
this.maximumAutoDownloadMessageSize = maximumAutoDownloadMessageSize;
|
|
|
|
}
|
|
|
|
|
2010-05-30 17:20:47 -04:00
|
|
|
public Date getEarliestPollDate()
|
|
|
|
{
|
|
|
|
int age = getMaximumPolledMessageAge();
|
2010-07-26 21:27:54 -04:00
|
|
|
if (age >= 0)
|
2010-05-30 17:20:47 -04:00
|
|
|
{
|
|
|
|
Calendar now = Calendar.getInstance();
|
|
|
|
now.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
|
now.set(Calendar.MINUTE, 0);
|
|
|
|
now.set(Calendar.SECOND, 0);
|
|
|
|
now.set(Calendar.MILLISECOND, 0);
|
|
|
|
if (age < 28)
|
|
|
|
{
|
|
|
|
now.add(Calendar.DATE, age * -1);
|
|
|
|
}
|
|
|
|
else switch (age)
|
2010-07-06 06:29:26 -04:00
|
|
|
{
|
|
|
|
case 28:
|
|
|
|
now.add(Calendar.MONTH, -1);
|
|
|
|
break;
|
|
|
|
case 56:
|
|
|
|
now.add(Calendar.MONTH, -2);
|
|
|
|
break;
|
|
|
|
case 84:
|
|
|
|
now.add(Calendar.MONTH, -3);
|
|
|
|
break;
|
|
|
|
case 168:
|
|
|
|
now.add(Calendar.MONTH, -6);
|
|
|
|
break;
|
|
|
|
case 365:
|
|
|
|
now.add(Calendar.YEAR, -1);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-04 09:48:06 -04:00
|
|
|
|
2010-05-30 17:20:47 -04:00
|
|
|
return now.getTime();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2010-06-20 10:07:03 -04:00
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized String getQuotePrefix()
|
2010-06-20 10:07:03 -04:00
|
|
|
{
|
|
|
|
return mQuotePrefix;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setQuotePrefix(String quotePrefix)
|
2010-06-20 10:07:03 -04:00
|
|
|
{
|
|
|
|
mQuotePrefix = quotePrefix;
|
|
|
|
}
|
2010-07-03 09:10:38 -04:00
|
|
|
|
2010-07-05 09:41:52 -04:00
|
|
|
public boolean getEnableMoveButtons()
|
|
|
|
{
|
|
|
|
return mEnableMoveButtons;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnableMoveButtons(boolean enableMoveButtons)
|
|
|
|
{
|
|
|
|
mEnableMoveButtons = enableMoveButtons;
|
|
|
|
}
|
|
|
|
|
2010-07-27 08:10:09 -04:00
|
|
|
public String getCryptoApp()
|
|
|
|
{
|
|
|
|
return mCryptoApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCryptoApp(String cryptoApp)
|
|
|
|
{
|
|
|
|
mCryptoApp = cryptoApp;
|
2010-08-22 05:51:17 -04:00
|
|
|
// invalidate the provider
|
|
|
|
mCryptoProvider = null;
|
2010-07-27 08:10:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getCryptoAutoSignature()
|
|
|
|
{
|
|
|
|
return mCryptoAutoSignature;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCryptoAutoSignature(boolean cryptoAutoSignature)
|
|
|
|
{
|
|
|
|
mCryptoAutoSignature = cryptoAutoSignature;
|
|
|
|
}
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized boolean syncRemoteDeletions()
|
2010-07-03 09:10:38 -04:00
|
|
|
{
|
|
|
|
return mSyncRemoteDeletions;
|
|
|
|
}
|
|
|
|
|
2010-07-04 19:29:57 -04:00
|
|
|
public synchronized void setSyncRemoteDeletions(boolean syncRemoteDeletions)
|
2010-07-03 09:10:38 -04:00
|
|
|
{
|
|
|
|
mSyncRemoteDeletions = syncRemoteDeletions;
|
|
|
|
}
|
2010-07-04 19:29:57 -04:00
|
|
|
|
|
|
|
public synchronized String getLastSelectedFolderName()
|
|
|
|
{
|
|
|
|
return lastSelectedFolderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void setLastSelectedFolderName(String folderName)
|
|
|
|
{
|
|
|
|
lastSelectedFolderName = folderName;
|
|
|
|
}
|
2010-08-22 05:51:17 -04:00
|
|
|
|
|
|
|
public synchronized CryptoProvider getCryptoProvider() {
|
|
|
|
if (mCryptoProvider == null) {
|
|
|
|
mCryptoProvider = CryptoProvider.createInstance(getCryptoApp());
|
|
|
|
}
|
|
|
|
return mCryptoProvider;
|
|
|
|
}
|
2010-05-15 16:35:39 -04:00
|
|
|
}
|