From e959645070c9bfa5b5169e0b9e8472606d2246a9 Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Fri, 25 Sep 2009 10:13:12 -0700 Subject: [PATCH] Don't drop local mailboxes if we created them. Reimplement a dropped snippet from the original MessagingController that preserved locally-created special mailboxes (drafts, sent, etc.) instead of dropping them when they were not found on the server. Bug # 2078209 --- .../android/email/MessagingController.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index e14681f6a..74d82f95c 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -227,20 +227,23 @@ public class MessagingController implements Runnable { private static final int COLUMN_ID = 0; private static final int COLUMN_DISPLAY_NAME = 1; private static final int COLUMN_ACCOUNT_KEY = 2; + private static final int COLUMN_TYPE = 3; private static final String[] PROJECTION = new String[] { EmailContent.RECORD_ID, - MailboxColumns.DISPLAY_NAME, MailboxColumns.ACCOUNT_KEY, + MailboxColumns.DISPLAY_NAME, MailboxColumns.ACCOUNT_KEY, MailboxColumns.TYPE, }; long mId; String mDisplayName; long mAccountKey; + int mType; public LocalMailboxInfo(Cursor c) { mId = c.getLong(COLUMN_ID); mDisplayName = c.getString(COLUMN_DISPLAY_NAME); mAccountKey = c.getLong(COLUMN_ACCOUNT_KEY); + mType = c.getInt(COLUMN_TYPE); } } @@ -304,12 +307,24 @@ public class MessagingController implements Runnable { // Drops first, to make things smaller rather than larger HashSet localsToDrop = new HashSet(localFolderNames); localsToDrop.removeAll(remoteFolderNames); - // TODO drop all attachment files too for (String localNameToDrop : localsToDrop) { LocalMailboxInfo localInfo = localFolders.get(localNameToDrop); - Uri uri = ContentUris.withAppendedId( - EmailContent.Mailbox.CONTENT_URI, localInfo.mId); - mContext.getContentResolver().delete(uri, null, null); + // Exclusion list - never delete local special folders, irrespective + // of server-side existence. + switch (localInfo.mType) { + case Mailbox.TYPE_INBOX: + case Mailbox.TYPE_DRAFTS: + case Mailbox.TYPE_OUTBOX: + case Mailbox.TYPE_SENT: + case Mailbox.TYPE_TRASH: + break; + default: + // TODO drop all attachment files too + Uri uri = ContentUris.withAppendedId( + EmailContent.Mailbox.CONTENT_URI, localInfo.mId); + mContext.getContentResolver().delete(uri, null, null); + break; + } } // Now do the adds