Don't use SYNCED_MESSAGE_URI for POP3/Drafts/Outbox/Search

Bug: 6330408
Change-Id: I84114d95fe4cf2a0137e2e9108ba349e58e21788
This commit is contained in:
Marc Blank 2012-04-16 13:44:38 -07:00
parent ba30ce9343
commit 37e2be2556
2 changed files with 16 additions and 3 deletions

View File

@ -518,6 +518,14 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
return false;
}
public boolean uploadsToServer(Context context) {
if (mType == TYPE_DRAFTS || mType == TYPE_OUTBOX || mType == TYPE_SEARCH) {
return false;
}
String protocol = Account.getProtocol(context, mAccountKey);
return (!protocol.equals(HostAuth.SCHEME_POP3));
}
/**
* @return true if messages in a mailbox of a type can be replied/forwarded.
*/

View File

@ -3319,10 +3319,15 @@ outer:
}
private int uiUpdateMessage(Uri uri, ContentValues values) {
Uri ourUri = convertToEmailProviderUri(uri, Message.SYNCED_CONTENT_URI, true);
if (ourUri == null) return 0;
Context context = getContext();
Message msg = getMessageFromLastSegment(uri);
if (msg == null) return 0;
Mailbox mailbox = Mailbox.restoreMailboxWithId(context, msg.mMailboxKey);
if (mailbox == null) return 0;
Uri ourBaseUri =
mailbox.uploadsToServer(context) ? Message.SYNCED_CONTENT_URI : Message.CONTENT_URI;
Uri ourUri = convertToEmailProviderUri(uri, ourBaseUri, true);
if (ourUri == null) return 0;
ContentValues undoValues = new ContentValues();
ContentValues ourValues = convertUiMessageValues(msg, values);
for (String columnName: ourValues.keySet()) {
@ -3339,7 +3344,7 @@ outer:
}
ContentProviderOperation op =
ContentProviderOperation.newUpdate(convertToEmailProviderUri(
uri,Message.SYNCED_CONTENT_URI, false))
uri, ourBaseUri, false))
.withValues(undoValues)
.build();
addToSequence(uri, op);