From 28fc7799cee83a1de5b7257e4d89c28e8fce89bc Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 20 Jul 2009 17:15:45 -0700 Subject: [PATCH] Add support for the flag (favorite) property in EAS 12; cleanup * Support flag property in Exchange 2007 (EAS 12) * Support startSync/stopSync/reloadFolderList in EAS service * Cleanup files a little bit --- AndroidManifest.xml | 2 + .../email/service/EmailServiceProxy.java | 77 +++++++++++-------- src/com/android/exchange/SyncManager.java | 69 ++++++++++------- .../exchange/adapter/EasEmailSyncAdapter.java | 50 +++++++++--- 4 files changed, 133 insertions(+), 65 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a49bfbac8..48224b242 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -173,6 +173,8 @@ android:enabled="false" > + + changes) throws IOException { String serverId = null; - boolean oldRead = false; - boolean read = true; + Boolean oldRead = false; + Boolean read = null; + Boolean oldFlag = false; + Boolean flag = null; long id = 0; while (nextTag(EasTags.SYNC_CHANGE) != END) { switch (tag) { @@ -349,6 +371,7 @@ public class EasEmailSyncAdapter extends EasSyncAdapter { if (c.moveToFirst()) { mService.userLog("Changing " + serverId); oldRead = c.getInt(Message.LIST_READ_COLUMN) == Message.READ; + oldFlag = c.getInt(Message.LIST_FAVORITE_COLUMN) == 1; id = c.getLong(Message.LIST_ID_COLUMN); } } finally { @@ -358,14 +381,18 @@ public class EasEmailSyncAdapter extends EasSyncAdapter { case EasTags.EMAIL_READ: read = getValueInt() == 1; break; + case EasTags.EMAIL_FLAG: + flag = flagParser(); + break; case EasTags.SYNC_APPLICATION_DATA: break; default: skipTag(); } } - if (oldRead != read) { - changes.add(new ServerChange(id, read)); + if ((read != null && !oldRead.equals(read)) || + (flag != null && !oldFlag.equals(flag))) { + changes.add(new ServerChange(id, read, flag)); } } @@ -401,9 +428,13 @@ public class EasEmailSyncAdapter extends EasSyncAdapter { if (!changedEmails.isEmpty()) { // Server wins in a conflict... for (ServerChange change : changedEmails) { - // For now, don't handle read->unread - ContentValues cv = new ContentValues(); - cv.put(MessageColumns.FLAG_READ, change.read); + ContentValues cv = new ContentValues(); + if (change.read != null) { + cv.put(MessageColumns.FLAG_READ, change.read); + } + if (change.flag != null) { + cv.put(MessageColumns.FLAG_FAVORITE, change.flag); + } ops.add(ContentProviderOperation.newUpdate( ContentUris.withAppendedId(Message.CONTENT_URI, change.id)) .withValues(cv) @@ -541,6 +572,7 @@ public class EasEmailSyncAdapter extends EasSyncAdapter { } // Send the change to "read". We'll do "flagged" here eventually as well // TODO Add support for flags here (EAS 12.0 and above) + // Or is this not safe?? s.start("Change") .data("ServerId", c.getString(Message.LIST_SERVER_ID_COLUMN)) .start("ApplicationData")