Issue 234

Fix POP3 deletes.  Verizon uses - in their POP3 UIDs, and K9 was
assuming that only Local UIDs have -.  Removed that assumption.  Also,
after issuing DELE on POP3 connection, need to also issue a QUIT.  The
delete code in MessagingController now closes the folder after
deleting a message, which will slow down IMAP deletes, but also
conserve connections, so is probably a net benefit.
This commit is contained in:
Daniel Applebaum 2009-05-09 15:22:36 +00:00
parent 718e27dab9
commit 97a4f97b64
3 changed files with 20 additions and 14 deletions

View File

@ -99,6 +99,14 @@ public class Email extends Application {
*/ */
public static final String FOLDER_NONE = "-NONE-"; 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 * 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 * on each new folder and can be incremented with "Load more messages..." by the

View File

@ -1323,8 +1323,7 @@ s * critical data as fast as possible, and then we'll fill in the de
} }
Message remoteMessage = null; Message remoteMessage = null;
if (!localMessage.getUid().startsWith("Local") if (!localMessage.getUid().startsWith(Email.LOCAL_UID_PREFIX)) {
&& !localMessage.getUid().contains("-")) {
remoteMessage = remoteFolder.getMessage(localMessage.getUid()); 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; Message remoteMessage = null;
if (!uid.startsWith("Local") if (!uid.startsWith(Email.LOCAL_UID_PREFIX)) {
&& !uid.contains("-")) {
// Why bother with this, perhaps just pass the UID to the store to save a roundtrip? And check for error returns, of course // 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 // Same applies for deletion
remoteMessage = remoteSrcFolder.getMessage(uid); 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"); Log.d(Email.LOG_TAG, "processingPendingMoveOrCopy doing special case for deleting message");
remoteMessage.delete(account.getTrashFolderName()); remoteMessage.delete(account.getTrashFolderName());
remoteSrcFolder.close(true);
return; return;
} }
@ -1524,8 +1523,7 @@ s * critical data as fast as possible, and then we'll fill in the de
return; return;
} }
Message remoteMessage = null; Message remoteMessage = null;
if (!uid.startsWith("Local") if (!uid.startsWith(Email.LOCAL_UID_PREFIX)) {
&& !uid.contains("-")) {
remoteMessage = remoteFolder.getMessage(uid); remoteMessage = remoteFolder.getMessage(uid);
} }
if (remoteMessage == null) { 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, public boolean moveMessage(final Account account, final String srcFolder, final Message message, final String destFolder,
final MessagingListener listener) final MessagingListener listener)
{ {
if (!message.getUid().startsWith("Local") if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) {
&& !message.getUid().contains("-")) {
put("moveMessage", null, new Runnable() { put("moveMessage", null, new Runnable() {
public void run() { public void run() {
moveOrCopyMessageSynchronous(account, srcFolder, message, destFolder, false, listener); 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) { public boolean isMoveCapable(Message message) {
if (!message.getUid().startsWith("Local") if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) {
&& !message.getUid().contains("-")) {
return true; return true;
} }
else { 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, public boolean copyMessage(final Account account, final String srcFolder, final Message message, final String destFolder,
final MessagingListener listener) final MessagingListener listener)
{ {
if (!message.getUid().startsWith("Local") if (!message.getUid().startsWith(Email.LOCAL_UID_PREFIX)) {
&& !message.getUid().contains("-")) {
put("copyMessage", null, new Runnable() { put("copyMessage", null, new Runnable() {
public void run() { public void run() {
moveOrCopyMessageSynchronous(account, srcFolder, message, destFolder, true, listener); moveOrCopyMessageSynchronous(account, srcFolder, message, destFolder, true, listener);

View File

@ -63,6 +63,9 @@ import com.android.email.provider.AttachmentProvider;
* </pre> * </pre>
*/ */
public class LocalStore extends Store implements Serializable { 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 int DB_VERSION = 24;
private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN }; 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 " 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.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[] { mDb.execSQL("UPDATE messages " + "SET folder_id = ?, uid = ? " + "WHERE id = ?", new Object[] {
lDestFolder.getId(), lDestFolder.getId(),
@ -1051,7 +1054,7 @@ public class LocalStore extends Store implements Serializable {
String uid = message.getUid(); String uid = message.getUid();
if (uid == null) { if (uid == null) {
message.setUid("Local" + UUID.randomUUID().toString()); message.setUid(Email.LOCAL_UID_PREFIX + UUID.randomUUID().toString());
} }
else { else {
/* /*