diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java index 330b13f65..ee2f0a095 100644 --- a/src/com/android/email/Email.java +++ b/src/com/android/email/Email.java @@ -99,6 +99,14 @@ public class Email extends Application { */ public static final String FOLDER_NONE = "-NONE-"; + + // The next time the LocalStore.java DB_VERSION is incremented, please delete the current + // LOCAL_UID_PREFIX and this comment, and uncomment the K9LOCAL: version of this static string + public static final String LOCAL_UID_PREFIX = "Local"; + //public static final String LOCAL_UID_PREFIX = "K9LOCAL:"; + + public static final String REMOTE_UID_PREFIX = "K9REMOTE:"; + /** * Specifies how many messages will be shown in a folder by default. This number is set * on each new folder and can be incremented with "Load more messages..." by the diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index 6fe4b0291..7696d324a 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -1323,8 +1323,7 @@ s * critical data as fast as possible, and then we'll fill in the de } Message remoteMessage = null; - if (!localMessage.getUid().startsWith("Local") - && !localMessage.getUid().contains("-")) { + if (!localMessage.getUid().startsWith(Email.LOCAL_UID_PREFIX)) { remoteMessage = remoteFolder.getMessage(localMessage.getUid()); } @@ -1453,8 +1452,7 @@ s * critical data as fast as possible, and then we'll fill in the de } Message remoteMessage = null; - if (!uid.startsWith("Local") - && !uid.contains("-")) { + if (!uid.startsWith(Email.LOCAL_UID_PREFIX)) { // Why bother with this, perhaps just pass the UID to the store to save a roundtrip? And check for error returns, of course // Same applies for deletion remoteMessage = remoteSrcFolder.getMessage(uid); @@ -1473,6 +1471,7 @@ s * critical data as fast as possible, and then we'll fill in the de { Log.d(Email.LOG_TAG, "processingPendingMoveOrCopy doing special case for deleting message"); remoteMessage.delete(account.getTrashFolderName()); + remoteSrcFolder.close(true); return; } @@ -1524,8 +1523,7 @@ s * critical data as fast as possible, and then we'll fill in the de return; } Message remoteMessage = null; - if (!uid.startsWith("Local") - && !uid.contains("-")) { + if (!uid.startsWith(Email.LOCAL_UID_PREFIX)) { remoteMessage = remoteFolder.getMessage(uid); } if (remoteMessage == null) { @@ -2245,8 +2243,7 @@ s * critical data as fast as possible, and then we'll fill in the de public boolean moveMessage(final Account account, final String srcFolder, final Message message, final String destFolder, final MessagingListener listener) { - if (!message.getUid().startsWith("Local") - && !message.getUid().contains("-")) { + if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) { put("moveMessage", null, new Runnable() { public void run() { moveOrCopyMessageSynchronous(account, srcFolder, message, destFolder, false, listener); @@ -2261,8 +2258,7 @@ s * critical data as fast as possible, and then we'll fill in the de } public boolean isMoveCapable(Message message) { - if (!message.getUid().startsWith("Local") - && !message.getUid().contains("-")) { + if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) { return true; } else { @@ -2304,8 +2300,7 @@ s * critical data as fast as possible, and then we'll fill in the de public boolean copyMessage(final Account account, final String srcFolder, final Message message, final String destFolder, final MessagingListener listener) { - if (!message.getUid().startsWith("Local") - && !message.getUid().contains("-")) { + if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) { put("copyMessage", null, new Runnable() { public void run() { moveOrCopyMessageSynchronous(account, srcFolder, message, destFolder, true, listener); diff --git a/src/com/android/email/mail/store/LocalStore.java b/src/com/android/email/mail/store/LocalStore.java index 698e78f9b..f648213ce 100644 --- a/src/com/android/email/mail/store/LocalStore.java +++ b/src/com/android/email/mail/store/LocalStore.java @@ -63,6 +63,9 @@ import com.android.email.provider.AttachmentProvider; * */ public class LocalStore extends Store implements Serializable { + // If you are going to change the DB_VERSION, please also go into Email.java and local for the comment + // on LOCAL_UID_PREFIX and follow the instructions there. If you follow the instructions there, + // please delete this comment. private static final int DB_VERSION = 24; private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN }; @@ -1011,7 +1014,7 @@ public class LocalStore extends Store implements Serializable { Log.d(Email.LOG_TAG, "Updating folder_id to " + lDestFolder.getId() + " for message with UID " + message.getUid() + ", id " + lMessage.getId() + " currently in folder " + getName()); - message.setUid("Local" + UUID.randomUUID().toString()); + message.setUid(Email.LOCAL_UID_PREFIX + UUID.randomUUID().toString()); mDb.execSQL("UPDATE messages " + "SET folder_id = ?, uid = ? " + "WHERE id = ?", new Object[] { lDestFolder.getId(), @@ -1051,7 +1054,7 @@ public class LocalStore extends Store implements Serializable { String uid = message.getUid(); if (uid == null) { - message.setUid("Local" + UUID.randomUUID().toString()); + message.setUid(Email.LOCAL_UID_PREFIX + UUID.randomUUID().toString()); } else { /*