1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-05 17:15:05 -05:00

Convert OpenMode from an Enum to static ints for perf improvement.

(Based on profiling of long folder list opens)

This should be backported to 4.4
This commit is contained in:
Jesse Vincent 2013-07-30 16:36:47 -04:00
parent e9a0cbb269
commit bbad298bf6
12 changed files with 116 additions and 114 deletions

View File

@ -69,7 +69,7 @@ public class FolderInfoHolder implements Comparable<FolderInfoHolder> {
public void populate(Context context, Folder folder, Account account, int unreadCount) {
try {
folder.open(Folder.OpenMode.READ_WRITE);
folder.open(Folder.OPEN_MODE_RW);
// unreadCount = folder.getUnreadMessageCount();
} catch (MessagingException me) {
Log.e(K9.LOG_TAG, "Folder.getUnreadMessageCount() failed", me);

View File

@ -465,7 +465,7 @@ public class FolderList extends K9ListActivity {
return;
}
localFolder = account.getLocalStore().getFolder(folderName);
localFolder.open(Folder.OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
localFolder.clearAllMessages();
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Exception while clearing folder", e);

View File

@ -11,8 +11,9 @@ import android.util.Log;
import com.fsck.k9.*;
import com.fsck.k9.activity.FolderInfoHolder;
import com.fsck.k9.activity.K9PreferenceActivity;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Folder.FolderClass;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Store;
import com.fsck.k9.mail.store.LocalStore;
@ -57,7 +58,7 @@ public class FolderSettings extends K9PreferenceActivity {
try {
LocalStore localStore = mAccount.getLocalStore();
mFolder = localStore.getFolder(folderName);
mFolder.open(OpenMode.READ_WRITE);
mFolder.open(Folder.OPEN_MODE_RW);
} catch (MessagingException me) {
Log.e(K9.LOG_TAG, "Unable to edit folder " + folderName + " preferences", me);
return;

View File

@ -65,7 +65,7 @@ import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Folder.FolderType;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.Message.RecipientType;
import com.fsck.k9.mail.CertificateValidationException;
@ -991,7 +991,7 @@ public class MessagingController implements Runnable {
final LocalStore localStore = account.getLocalStore();
tLocalFolder = localStore.getFolder(folder);
final LocalFolder localFolder = tLocalFolder;
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
localFolder.updateLastUid();
Message[] localMessages = localFolder.getMessages(null);
HashMap<String, Message> localUidMap = new HashMap<String, Message>();
@ -1039,7 +1039,7 @@ public class MessagingController implements Runnable {
if (K9.DEBUG)
Log.v(K9.LOG_TAG, "SYNC: About to open remote folder " + folder);
remoteFolder.open(OpenMode.READ_WRITE);
remoteFolder.open(Folder.OPEN_MODE_RW);
if (Account.EXPUNGE_ON_POLL.equals(account.getExpungePolicy())) {
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
@ -2074,8 +2074,8 @@ public class MessagingController implements Runnable {
return;
}
}
remoteFolder.open(OpenMode.READ_WRITE);
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
@ -2307,8 +2307,8 @@ public class MessagingController implements Runnable {
if (!remoteSrcFolder.exists()) {
throw new MessagingException("processingPendingMoveOrCopy: remoteFolder " + srcFolder + " does not exist", true);
}
remoteSrcFolder.open(OpenMode.READ_WRITE);
if (remoteSrcFolder.getMode() != OpenMode.READ_WRITE) {
remoteSrcFolder.open(Folder.OPEN_MODE_RW);
if (remoteSrcFolder.getMode() != Folder.OPEN_MODE_RW) {
throw new MessagingException("processingPendingMoveOrCopy: could not open remoteSrcFolder " + srcFolder + " read/write", true);
}
@ -2415,8 +2415,8 @@ public class MessagingController implements Runnable {
}
try {
remoteFolder.open(OpenMode.READ_WRITE);
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
List<Message> messages = new ArrayList<Message>();
@ -2459,8 +2459,8 @@ public class MessagingController implements Runnable {
if (!remoteFolder.exists()) {
return;
}
remoteFolder.open(OpenMode.READ_WRITE);
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
Message remoteMessage = null;
@ -2506,8 +2506,8 @@ public class MessagingController implements Runnable {
if (!remoteFolder.exists()) {
return;
}
remoteFolder.open(OpenMode.READ_WRITE);
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
remoteFolder.expunge();
@ -2544,8 +2544,8 @@ public class MessagingController implements Runnable {
if (!remoteSrcFolder.exists()) {
throw new MessagingException("processPendingMoveOrCopyOld: remoteFolder " + srcFolder + " does not exist", true);
}
remoteSrcFolder.open(OpenMode.READ_WRITE);
if (remoteSrcFolder.getMode() != OpenMode.READ_WRITE) {
remoteSrcFolder.open(Folder.OPEN_MODE_RW);
if (remoteSrcFolder.getMode() != Folder.OPEN_MODE_RW) {
throw new MessagingException("processPendingMoveOrCopyOld: could not open remoteSrcFolder " + srcFolder + " read/write", true);
}
@ -2570,8 +2570,8 @@ public class MessagingController implements Runnable {
return;
}
remoteDestFolder.open(OpenMode.READ_WRITE);
if (remoteDestFolder.getMode() != OpenMode.READ_WRITE) {
remoteDestFolder.open(Folder.OPEN_MODE_RW);
if (remoteDestFolder.getMode() != Folder.OPEN_MODE_RW) {
throw new MessagingException("processPendingMoveOrCopyOld: could not open remoteDestFolder " + srcFolder + " read/write", true);
}
@ -2591,7 +2591,7 @@ public class MessagingController implements Runnable {
try {
Store localStore = account.getLocalStore();
localFolder = (LocalFolder) localStore.getFolder(folder);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
Message[] messages = localFolder.getMessages(null, false);
for (Message message : messages) {
if (!message.isSet(Flag.SEEN)) {
@ -2617,8 +2617,8 @@ public class MessagingController implements Runnable {
if (!remoteFolder.exists() || !remoteFolder.isFlagSupported(Flag.SEEN)) {
return;
}
remoteFolder.open(OpenMode.READ_WRITE);
if (remoteFolder.getMode() != OpenMode.READ_WRITE) {
remoteFolder.open(Folder.OPEN_MODE_RW);
if (remoteFolder.getMode() != Folder.OPEN_MODE_RW) {
return;
}
@ -2883,7 +2883,7 @@ public class MessagingController implements Runnable {
try {
Store localStore = account.getLocalStore();
localFolder = localStore.getFolder(folderName);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
// Allows for re-allowing sending of messages that could not be sent
if (flag == Flag.FLAGGED && !newState &&
@ -2950,7 +2950,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(folderName);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
Message message = localFolder.getMessage(uid);
if (message != null) {
@ -2993,7 +2993,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(folder);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
Message message = localFolder.getMessage(uid);
@ -3036,7 +3036,7 @@ public class MessagingController implements Runnable {
Store remoteStore = account.getRemoteStore();
remoteFolder = remoteStore.getFolder(folder);
remoteFolder.open(OpenMode.READ_WRITE);
remoteFolder.open(Folder.OPEN_MODE_RW);
// Get the remote message and fully download it
Message remoteMessage = remoteFolder.getMessage(uid);
@ -3098,7 +3098,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolder(folder);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
LocalMessage message = localFolder.getMessage(uid);
if (message == null
@ -3224,7 +3224,7 @@ public class MessagingController implements Runnable {
Store remoteStore = account.getRemoteStore();
localFolder = localStore.getFolder(message.getFolder().getName());
remoteFolder = remoteStore.getFolder(message.getFolder().getName());
remoteFolder.open(OpenMode.READ_WRITE);
remoteFolder.open(Folder.OPEN_MODE_RW);
//FIXME: This is an ugly hack that won't be needed once the Message objects have been united.
Message remoteMessage = remoteFolder.getMessage(message.getUid());
@ -3266,7 +3266,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolder(account.getOutboxFolderName());
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
localFolder.appendMessages(new Message[] { message });
Message localMessage = localFolder.getMessage(message.getUid());
localMessage.setFlag(Flag.X_DOWNLOADED_FULL, true);
@ -3468,7 +3468,7 @@ public class MessagingController implements Runnable {
return false;
}
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
if (localFolder.getMessageCount() > 0) {
return true;
@ -3498,7 +3498,7 @@ public class MessagingController implements Runnable {
for (MessagingListener l : getListeners()) {
l.sendPendingMessagesStarted(account);
}
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
Message[] localMessages = localFolder.getMessages(null);
int progress = 0;
@ -3967,7 +3967,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(account.getDraftsFolderName());
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
String uid = localFolder.getMessageUidById(id);
if (uid != null) {
Message message = localFolder.getMessage(uid);
@ -4155,7 +4155,7 @@ public class MessagingController implements Runnable {
Folder remoteFolder = remoteStore.getFolder(account.getTrashFolderName());
try {
if (remoteFolder.exists()) {
remoteFolder.open(OpenMode.READ_WRITE);
remoteFolder.open(Folder.OPEN_MODE_RW);
remoteFolder.setFlags(new Flag [] { Flag.DELETED }, true);
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
remoteFolder.expunge();
@ -4181,7 +4181,7 @@ public class MessagingController implements Runnable {
try {
Store localStore = account.getLocalStore();
localFolder = (LocalFolder) localStore.getFolder(account.getTrashFolderName());
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
boolean isTrashLocalOnly = isTrashLocalOnly(account);
if (isTrashLocalOnly) {
@ -4399,7 +4399,7 @@ public class MessagingController implements Runnable {
Store localStore = account.getLocalStore();
for (final Folder folder : localStore.getPersonalNamespaces(false)) {
folder.open(Folder.OpenMode.READ_WRITE);
folder.open(Folder.OPEN_MODE_RW);
folder.refresh(prefs);
Folder.FolderClass fDisplayClass = folder.getDisplayClass();
@ -4485,7 +4485,7 @@ public class MessagingController implements Runnable {
// once
final LocalStore localStore = account.getLocalStore();
tLocalFolder = localStore.getFolder(folder.getName());
tLocalFolder.open(Folder.OpenMode.READ_WRITE);
tLocalFolder.open(Folder.OPEN_MODE_RW);
if (!ignoreLastCheckedTime && tLocalFolder.getLastChecked() >
(System.currentTimeMillis() - accountInterval)) {
@ -5091,7 +5091,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolder(account.getDraftsFolderName());
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
if (existingDraftId != INVALID_MESSAGE_ID) {
String uid = localFolder.getMessageUidById(existingDraftId);
@ -5216,7 +5216,7 @@ public class MessagingController implements Runnable {
continue;
}
folder.open(Folder.OpenMode.READ_WRITE);
folder.open(Folder.OPEN_MODE_RW);
folder.refresh(prefs);
Folder.FolderClass fDisplayClass = folder.getDisplayClass();
@ -5320,7 +5320,7 @@ public class MessagingController implements Runnable {
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(remoteFolder.getName());
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
account.setRingNotified(false);
int newCount = downloadMessages(account, remoteFolder, localFolder, messages, flagSyncOnly);

View File

@ -8,7 +8,7 @@ import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.PushReceiver;
import com.fsck.k9.mail.store.LocalStore;
@ -88,7 +88,7 @@ public class MessagingControllerPushReceiver implements PushReceiver {
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(folderName);
localFolder.open(OpenMode.READ_WRITE);
localFolder.open(Folder.OPEN_MODE_RW);
return localFolder.getPushState();
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Unable to get push state from account " + account.getDescription()

View File

@ -85,7 +85,7 @@ import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.store.LocalStore;
@ -1024,7 +1024,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick
try {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolderById(folderId);
localFolder.open(OpenMode.READ_ONLY);
localFolder.open(Folder.OPEN_MODE_RO);
return localFolder;
} catch (Exception e) {
Log.e(K9.LOG_TAG, "getFolderNameById() failed.", e);

View File

@ -17,9 +17,10 @@ public abstract class Folder {
private String status = null;
private long lastChecked = 0;
private long lastPush = 0;
public enum OpenMode {
READ_WRITE, READ_ONLY,
}
public static final int OPEN_MODE_RW=0;
public static final int OPEN_MODE_RO=0;
// NONE is obsolete, it will be translated to NO_CLASS for display and to INHERITED for sync and push
public enum FolderClass {
NONE, NO_CLASS, INHERITED, FIRST_CLASS, SECOND_CLASS
@ -39,7 +40,7 @@ public abstract class Folder {
*
* @param mode READ_ONLY or READ_WRITE
*/
public abstract void open(OpenMode mode) throws MessagingException;
public abstract void open(int mode) throws MessagingException;
/**
* Forces a close of the MailProvider. Any further access will attempt to
@ -58,7 +59,7 @@ public abstract class Folder {
* was requested with.
* @return
*/
public abstract OpenMode getMode();
public abstract int getMode();
public abstract boolean create(FolderType type) throws MessagingException;

View File

@ -814,7 +814,7 @@ public class ImapStore extends Store {
protected volatile int mMessageCount = -1;
protected volatile long uidNext = -1L;
protected volatile ImapConnection mConnection;
private OpenMode mMode;
private int mMode;
private volatile boolean mExists;
private ImapStore store = null;
Map<Long, String> msgSeqUidMap = new ConcurrentHashMap<Long, String>();
@ -863,7 +863,7 @@ public class ImapStore extends Store {
}
@Override
public void open(OpenMode mode) throws MessagingException {
public void open(int mode) throws MessagingException {
internalOpen(mode);
if (mMessageCount == -1) {
@ -872,7 +872,7 @@ public class ImapStore extends Store {
}
}
public List<ImapResponse> internalOpen(OpenMode mode) throws MessagingException {
public List<ImapResponse> internalOpen(int mode) throws MessagingException {
if (isOpen() && mMode == mode) {
// Make sure the connection is valid. If it's not we'll close it down and continue
// on to get a new one.
@ -898,7 +898,7 @@ public class ImapStore extends Store {
// 2 OK [READ-WRITE] Select completed.
try {
msgSeqUidMap.clear();
String command = String.format("%s %s", mode == OpenMode.READ_WRITE ? "SELECT"
String command = String.format("%s %s", mode == OPEN_MODE_RW ? "SELECT"
: "EXAMINE", encodeString(encodeFolderName(getPrefixedName())));
List<ImapResponse> responses = executeSimpleCommand(command);
@ -932,9 +932,9 @@ public class ImapStore extends Store {
if (response.mTag != null) {
if ("READ-ONLY".equalsIgnoreCase(key)) {
mMode = OpenMode.READ_ONLY;
mMode = OPEN_MODE_RO;
} else if ("READ-WRITE".equalsIgnoreCase(key)) {
mMode = OpenMode.READ_WRITE;
mMode = OPEN_MODE_RW;
}
}
}
@ -984,7 +984,7 @@ public class ImapStore extends Store {
}
@Override
public OpenMode getMode() {
public int getMode() {
return mMode;
}
@ -1994,7 +1994,7 @@ public class ImapStore extends Store {
*/
@Override
public Map<String, String> appendMessages(Message[] messages) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
checkOpen();
try {
Map<String, String> uidMap = new HashMap<String, String>();
@ -2107,7 +2107,7 @@ public class ImapStore extends Store {
@Override
public void expunge() throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
checkOpen();
try {
executeSimpleCommand("EXPUNGE");
@ -2140,7 +2140,7 @@ public class ImapStore extends Store {
@Override
public void setFlags(Flag[] flags, boolean value)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
checkOpen();
@ -2175,7 +2175,7 @@ public class ImapStore extends Store {
@Override
public void setFlags(Message[] messages, Flag[] flags, boolean value)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
checkOpen();
String[] uids = new String[messages.length];
for (int i = 0, count = messages.length; i < count; i++) {
@ -2327,7 +2327,7 @@ public class ImapStore extends Store {
// Execute the search
try {
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
checkOpen();
mInSearch = true;
@ -2975,7 +2975,7 @@ public class ImapStore extends Store {
Log.e(K9.LOG_TAG, "Unable to get oldUidNext for " + getLogId(), e);
}
ImapConnection oldConnection = mConnection;
internalOpen(OpenMode.READ_ONLY);
internalOpen(OPEN_MODE_RO);
ImapConnection conn = mConnection;
if (conn == null) {
receiver.pushError("Could not establish connection for IDLE", null);

View File

@ -1362,9 +1362,9 @@ public class LocalStore extends Store implements Serializable {
}
@Override
public void open(final OpenMode mode) throws MessagingException {
public void open(final int mode) throws MessagingException {
if (isOpen() && (getMode() == mode || mode == OpenMode.READ_ONLY)) {
if (isOpen() && (getMode() == mode || mode == OPEN_MODE_RO)) {
return;
} else if (isOpen()) {
//previously opened in READ_ONLY and now requesting READ_WRITE
@ -1436,8 +1436,8 @@ public class LocalStore extends Store implements Serializable {
}
@Override
public OpenMode getMode() {
return OpenMode.READ_WRITE;
public int getMode() {
return OPEN_MODE_RW;
}
@Override
@ -1506,7 +1506,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Integer doDbWork(final SQLiteDatabase db) throws WrappedException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
} catch (MessagingException e) {
throw new WrappedException(e);
}
@ -1531,7 +1531,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public int getUnreadMessageCount() throws MessagingException {
if (mFolderId == -1) {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
}
try {
@ -1562,7 +1562,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public int getFlaggedMessageCount() throws MessagingException {
if (mFolderId == -1) {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
}
try {
@ -1593,7 +1593,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public void setLastChecked(final long lastChecked) throws MessagingException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
LocalFolder.super.setLastChecked(lastChecked);
} catch (MessagingException e) {
throw new WrappedException(e);
@ -1604,7 +1604,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public void setLastPush(final long lastChecked) throws MessagingException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
LocalFolder.super.setLastPush(lastChecked);
} catch (MessagingException e) {
throw new WrappedException(e);
@ -1613,7 +1613,7 @@ public class LocalStore extends Store implements Serializable {
}
public int getVisibleLimit() throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
return mVisibleLimit;
}
@ -1623,7 +1623,7 @@ public class LocalStore extends Store implements Serializable {
if (mVisibleLimit == 0) {
return ;
}
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
Message[] messages = getMessages(null, false);
for (int i = mVisibleLimit; i < messages.length; i++) {
if (listener != null) {
@ -1655,7 +1655,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
} catch (MessagingException e) {
throw new WrappedException(e);
}
@ -1726,7 +1726,7 @@ public class LocalStore extends Store implements Serializable {
}
private String getPrefId() throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
return getPrefId(mName);
}
@ -1826,7 +1826,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
if (fp.contains(FetchProfile.Item.BODY)) {
for (Message message : messages) {
LocalMessage localMessage = (LocalMessage)message;
@ -2013,7 +2013,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Message[] getMessages(int start, int end, Date earliestDate, MessageRetrievalListener listener)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
throw new MessagingException(
"LocalStore.getMessages(int, int, MessageRetrievalListener) not yet implemented");
}
@ -2077,7 +2077,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public String doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
Cursor cursor = null;
try {
@ -2111,7 +2111,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public LocalMessage doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
LocalMessage message = new LocalMessage(uid, LocalFolder.this);
Cursor cursor = null;
@ -2155,7 +2155,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Message[] doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
return LocalStore.this.getMessages(
listener,
LocalFolder.this,
@ -2180,7 +2180,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Message[] getMessages(String[] uids, MessageRetrievalListener listener)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
if (uids == null) {
return getMessages(listener);
}
@ -2217,7 +2217,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
lDestFolder.open(OpenMode.READ_WRITE);
lDestFolder.open(OPEN_MODE_RW);
for (Message message : msgs) {
LocalMessage lMessage = (LocalMessage)message;
@ -2274,7 +2274,7 @@ public class LocalStore extends Store implements Serializable {
*/
// We need to open this folder to get the folder id
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
cv.clear();
cv.put("uid", oldUID);
@ -2435,7 +2435,7 @@ public class LocalStore extends Store implements Serializable {
* @return Map<String, String> uidMap of srcUids -> destUids
*/
private Map<String, String> appendMessages(final Message[] messages, final boolean copy) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
try {
final Map<String, String> uidMap = new HashMap<String, String>();
database.execute(true, new DbCallback<Void>() {
@ -2604,7 +2604,7 @@ public class LocalStore extends Store implements Serializable {
* @throws MessagingException
*/
public void updateMessage(final LocalMessage message) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
try {
database.execute(false, new DbCallback<Void>() {
@Override
@ -2912,7 +2912,7 @@ public class LocalStore extends Store implements Serializable {
* @throws com.fsck.k9.mail.MessagingException
*/
public void changeUid(final LocalMessage message) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
final ContentValues cv = new ContentValues();
cv.put("uid", message.getUid());
database.execute(false, new DbCallback<Void>() {
@ -2931,7 +2931,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public void setFlags(final Message[] messages, final Flag[] flags, final boolean value)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
// Use one transaction to set all flags
try {
@ -2959,7 +2959,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public void setFlags(Flag[] flags, boolean value)
throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
for (Message message : getMessages(null)) {
message.setFlags(flags, value);
}
@ -2971,7 +2971,7 @@ public class LocalStore extends Store implements Serializable {
}
public void clearMessagesOlderThan(long cutoff) throws MessagingException {
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
Message[] messages = LocalStore.this.getMessages(
null,
@ -2995,7 +2995,7 @@ public class LocalStore extends Store implements Serializable {
public void clearAllMessages() throws MessagingException {
final String[] folderIdArg = new String[] { Long.toString(mFolderId) };
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
try {
database.execute(false, new DbCallback<Void>() {
@ -3047,7 +3047,7 @@ public class LocalStore extends Store implements Serializable {
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
// We need to open the folder first to make sure we've got it's id
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
Message[] messages = getMessages(null);
for (Message message : messages) {
deleteAttachments(message.getUid());
@ -3079,7 +3079,7 @@ public class LocalStore extends Store implements Serializable {
}
private void deleteAttachments(final long messageId) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
database.execute(false, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
@ -3122,7 +3122,7 @@ public class LocalStore extends Store implements Serializable {
}
private void deleteAttachments(final String uid) throws MessagingException {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
try {
database.execute(false, new DbCallback<Void>() {
@Override
@ -3186,7 +3186,7 @@ public class LocalStore extends Store implements Serializable {
public Integer doDbWork(final SQLiteDatabase db) {
Cursor cursor = null;
try {
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
cursor = db.rawQuery("SELECT MAX(uid) FROM messages WHERE folder_id=?", new String[] { Long.toString(mFolderId) });
if (cursor.getCount() > 0) {
cursor.moveToFirst();
@ -3211,7 +3211,7 @@ public class LocalStore extends Store implements Serializable {
public Long doDbWork(final SQLiteDatabase db) {
Cursor cursor = null;
try {
open(OpenMode.READ_ONLY);
open(OPEN_MODE_RO);
cursor = db.rawQuery("SELECT MIN(date) FROM messages WHERE folder_id=?", new String[] { Long.toString(mFolderId) });
if (cursor.getCount() > 0) {
cursor.moveToFirst();
@ -3338,7 +3338,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public List<Message> doDbWork(final SQLiteDatabase db) throws WrappedException {
try {
open(OpenMode.READ_WRITE);
open(OPEN_MODE_RW);
} catch (MessagingException e) {
throw new WrappedException(e);
}
@ -3491,7 +3491,7 @@ public class LocalStore extends Store implements Serializable {
if (this.mFolder == null) {
LocalFolder f = new LocalFolder(cursor.getInt(13));
f.open(LocalFolder.OpenMode.READ_WRITE);
f.open(LocalFolder.OPEN_MODE_RW);
this.mFolder = f;
}

View File

@ -8,7 +8,7 @@ import com.fsck.k9.K9;
import com.fsck.k9.controller.MessageRetrievalListener;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.internet.MimeMessage;
import javax.net.ssl.SSLContext;
@ -270,7 +270,7 @@ public class Pop3Store extends Store {
@Override
public void checkSettings() throws MessagingException {
Pop3Folder folder = new Pop3Folder(mAccount.getInboxFolderName());
folder.open(OpenMode.READ_WRITE);
folder.open(Folder.OPEN_MODE_RW);
if (!mCapabilities.uidl) {
/*
* Run an additional test to see if UIDL is supported on the server. If it's not we
@ -312,7 +312,7 @@ public class Pop3Store extends Store {
}
@Override
public synchronized void open(OpenMode mode) throws MessagingException {
public synchronized void open(int mode) throws MessagingException {
if (isOpen()) {
return;
}
@ -417,8 +417,8 @@ public class Pop3Store extends Store {
}
@Override
public OpenMode getMode() {
return OpenMode.READ_WRITE;
public int getMode() {
return Folder.OPEN_MODE_RW;
}
@Override
@ -1020,7 +1020,7 @@ public class Pop3Store extends Store {
private String executeSimpleCommand(String command, boolean sensitive) throws MessagingException {
try {
open(OpenMode.READ_WRITE);
open(Folder.OPEN_MODE_RW);
if (command != null) {
if (K9.DEBUG && K9.DEBUG_PROTOCOL_POP3) {

View File

@ -7,7 +7,7 @@ import com.fsck.k9.K9;
import com.fsck.k9.controller.MessageRetrievalListener;
import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.*;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.transport.TrustedSocketFactory;
@ -1257,7 +1257,7 @@ public class WebDavStore extends Store {
public void sendMessages(Message[] messages) throws MessagingException {
WebDavFolder tmpFolder = (WebDavStore.WebDavFolder) getFolder(mAccount.getDraftsFolderName());
try {
tmpFolder.open(OpenMode.READ_WRITE);
tmpFolder.open(Folder.OPEN_MODE_RW);
Message[] retMessages = tmpFolder.appendWebDavMessages(messages);
tmpFolder.moveMessages(retMessages, getSendSpoolFolder());
@ -1325,7 +1325,7 @@ public class WebDavStore extends Store {
}
@Override
public void open(OpenMode mode) throws MessagingException {
public void open(int mode) throws MessagingException {
getHttpClient();
this.mIsOpen = true;
@ -1406,14 +1406,14 @@ public class WebDavStore extends Store {
@Override
public int getMessageCount() throws MessagingException {
open(OpenMode.READ_WRITE);
open(Folder.OPEN_MODE_RW);
this.mMessageCount = getMessageCount(true);
return this.mMessageCount;
}
@Override
public int getUnreadMessageCount() throws MessagingException {
open(OpenMode.READ_WRITE);
open(Folder.OPEN_MODE_RW);
this.mUnreadMessageCount = getMessageCount(false);
return this.mUnreadMessageCount;
}
@ -1429,8 +1429,8 @@ public class WebDavStore extends Store {
}
@Override
public OpenMode getMode() {
return OpenMode.READ_WRITE;
public int getMode() {
return Folder.OPEN_MODE_RW;
}
@Override
@ -1932,7 +1932,7 @@ public class WebDavStore extends Store {
out = new ByteArrayOutputStream(message.getSize());
open(OpenMode.READ_WRITE);
open(Folder.OPEN_MODE_RW);
EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream(
new BufferedOutputStream(out, 1024));
message.writeTo(msgOut);

View File

@ -4,7 +4,7 @@ import java.util.List;
import com.fsck.k9.Account;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Folder.OpenMode;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.store.LocalStore;
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
import com.fsck.k9.search.SearchSpecification.Attribute;
@ -98,7 +98,7 @@ public class SqlQueryBuilder {
try {
LocalStore localStore = account.getLocalStore();
LocalFolder folder = localStore.getFolder(folderName);
folder.open(OpenMode.READ_ONLY);
folder.open(Folder.OPEN_MODE_RO);
folderId = folder.getId();
} catch (MessagingException e) {
//FIXME