From 518fc490b29b58153dacfe89e481af20e6be8a06 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 17 May 2011 10:43:46 -0700 Subject: [PATCH] Fix bug where we fail to acknowledge an APPEND After appending a message to a mailbox (i.e. like appending to the 'sent' mailbox after composing a new message), we would try to determine if the append was successful by searching for the message. Most servers return an APPENDUID response with the message's new UID. However, on those that don't support APPENDUID, we need to perform a SEARCH for the message id. On one set of these servers, the search would fail if the query string was surrounded by parenthesis. However, another set of servers will fail if the query string is not surroudned by parenthesis. So, we now try both ways. Change-Id: I5a82ad241fb927e28aa5d05376568d5eac266a95 --- src/com/android/email/mail/store/ImapFolder.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/mail/store/ImapFolder.java b/src/com/android/email/mail/store/ImapFolder.java index 26ea62256..d2f85d9e2 100644 --- a/src/com/android/email/mail/store/ImapFolder.java +++ b/src/com/android/email/mail/store/ImapFolder.java @@ -918,8 +918,15 @@ class ImapFolder extends Folder { if (messageId == null || messageId.length() == 0) { continue; } - String[] uids = searchForUids( - String.format("(HEADER MESSAGE-ID %s)", messageId)); + // Most servers don't care about parenthesis in the search query [and, some + // fail to work if they are used] + String[] uids = searchForUids(String.format("HEADER MESSAGE-ID %s", messageId)); + if (uids.length > 0) { + message.setUid(uids[0]); + } + // However, there's at least one server [AOL] that fails to work unless there + // are parenthesis, so, try this as a last resort + uids = searchForUids(String.format("(HEADER MESSAGE-ID %s)", messageId)); if (uids.length > 0) { message.setUid(uids[0]); }