Merge "Change IEmailService.sync to have two different forms" into ub-mail-master
diff --git a/src/com/android/exchange/adapter/CalendarSyncParser.java b/src/com/android/exchange/adapter/CalendarSyncParser.java
index 5fb9383..1216e51 100644
--- a/src/com/android/exchange/adapter/CalendarSyncParser.java
+++ b/src/com/android/exchange/adapter/CalendarSyncParser.java
@@ -790,7 +790,7 @@
cv.put(Events.ORIGINAL_SYNC_ID, parentCv.getAsString(Events._SYNC_ID));
String exceptionStartTime = "_noStartTime";
- while (nextTag(Tags.SYNC_APPLICATION_DATA) != END) {
+ while (nextTag(Tags.CALENDAR_EXCEPTION) != END) {
switch (tag) {
case Tags.CALENDAR_ATTACHMENTS:
attachmentsParser();
diff --git a/src/com/android/exchange/adapter/EmailSyncAdapter.java b/src/com/android/exchange/adapter/EmailSyncAdapter.java
index 6a9680f..7ca2575 100644
--- a/src/com/android/exchange/adapter/EmailSyncAdapter.java
+++ b/src/com/android/exchange/adapter/EmailSyncAdapter.java
@@ -355,7 +355,7 @@
return true;
}
- public void parseGetItemEstimate() throws IOException {
+ private void parseGetItemEstimate() throws IOException {
while (nextTag(Tags.GIE_GET_ITEM_ESTIMATE) != END) {
if (tag == Tags.GIE_RESPONSE) {
parseResponse();
@@ -365,7 +365,7 @@
}
}
- public void parseResponse() throws IOException {
+ private void parseResponse() throws IOException {
while (nextTag(Tags.GIE_RESPONSE) != END) {
if (tag == Tags.GIE_STATUS) {
LogUtils.d(TAG, "GIE status: " + getValue());
@@ -377,7 +377,7 @@
}
}
- public void parseCollection() throws IOException {
+ private void parseCollection() throws IOException {
while (nextTag(Tags.GIE_COLLECTION) != END) {
if (tag == Tags.GIE_CLASS) {
LogUtils.d(TAG, "GIE class: " + getValue());
@@ -523,7 +523,7 @@
switch (tag) {
case Tags.EMAIL_ATTACHMENTS:
case Tags.BASE_ATTACHMENTS: // BASE_ATTACHMENTS is used in EAS 12.0 and up
- attachmentsParser(atts, msg);
+ attachmentsParser(atts, msg, tag);
break;
case Tags.EMAIL_TO:
msg.mTo = Address.toString(Address.parse(getValue()));
@@ -737,7 +737,7 @@
* @return the parsed Message
* @throws IOException
*/
- private Message addParser() throws IOException, CommandStatusException {
+ private Message addParser(final int endingTag) throws IOException, CommandStatusException {
Message msg = new Message();
msg.mAccountKey = mAccount.mId;
msg.mMailboxKey = mMailbox.mId;
@@ -745,7 +745,7 @@
// Default to 1 (success) in case we don't get this tag
int status = 1;
- while (nextTag(Tags.SYNC_ADD) != END) {
+ while (nextTag(endingTag) != END) {
switch (tag) {
case Tags.SYNC_SERVER_ID:
msg.mServerId = getValue();
@@ -785,7 +785,7 @@
private void bodyParser(Message msg) throws IOException {
String bodyType = Eas.BODY_PREFERENCE_TEXT;
String body = "";
- while (nextTag(Tags.EMAIL_BODY) != END) {
+ while (nextTag(Tags.BASE_BODY) != END) {
switch (tag) {
case Tags.BASE_TYPE:
bodyType = getValue();
@@ -835,12 +835,13 @@
}
}
- private void attachmentsParser(ArrayList<Attachment> atts, Message msg) throws IOException {
- while (nextTag(Tags.EMAIL_ATTACHMENTS) != END) {
+ private void attachmentsParser(final ArrayList<Attachment> atts, final Message msg,
+ final int endingTag) throws IOException {
+ while (nextTag(endingTag) != END) {
switch (tag) {
case Tags.EMAIL_ATTACHMENT:
case Tags.BASE_ATTACHMENT: // BASE_ATTACHMENT is used in EAS 12.0 and up
- attachmentParser(atts, msg);
+ attachmentParser(atts, msg, tag);
break;
default:
skipTag();
@@ -848,14 +849,15 @@
}
}
- private void attachmentParser(ArrayList<Attachment> atts, Message msg) throws IOException {
+ private void attachmentParser(final ArrayList<Attachment> atts, final Message msg,
+ final int endingTag) throws IOException {
String fileName = null;
String length = null;
String location = null;
boolean isInline = false;
String contentId = null;
- while (nextTag(Tags.EMAIL_ATTACHMENT) != END) {
+ while (nextTag(endingTag) != END) {
switch (tag) {
// We handle both EAS 2.5 and 12.0+ attachments here
case Tags.EMAIL_DISPLAY_NAME:
@@ -1063,7 +1065,7 @@
public void commandsParser() throws IOException, CommandStatusException {
while (nextTag(Tags.SYNC_COMMANDS) != END) {
if (tag == Tags.SYNC_ADD) {
- newEmails.add(addParser());
+ newEmails.add(addParser(tag));
} else if (tag == Tags.SYNC_DELETE || tag == Tags.SYNC_SOFT_DELETE) {
deleteParser(deletedEmails, tag);
} else if (tag == Tags.SYNC_CHANGE) {
@@ -1113,7 +1115,7 @@
failedUpdateParser(tag);
} else if (tag == Tags.SYNC_FETCH) {
try {
- fetchedEmails.add(addParser());
+ fetchedEmails.add(addParser(tag));
} catch (CommandStatusException sse) {
if (sse.mStatus == 8) {
// 8 = object not found; delete the message from EmailProvider
diff --git a/src/com/android/exchange/adapter/EmailSyncParser.java b/src/com/android/exchange/adapter/EmailSyncParser.java
index 951977f..f7d674c 100644
--- a/src/com/android/exchange/adapter/EmailSyncParser.java
+++ b/src/com/android/exchange/adapter/EmailSyncParser.java
@@ -138,7 +138,7 @@
switch (tag) {
case Tags.EMAIL_ATTACHMENTS:
case Tags.BASE_ATTACHMENTS: // BASE_ATTACHMENTS is used in EAS 12.0 and up
- attachmentsParser(atts, msg);
+ attachmentsParser(atts, msg, tag);
break;
case Tags.EMAIL_TO:
msg.mTo = Address.toString(Address.parse(getValue()));
@@ -352,7 +352,7 @@
* @return the parsed Message
* @throws IOException
*/
- private EmailContent.Message addParser() throws IOException, CommandStatusException {
+ private EmailContent.Message addParser(final int endingTag) throws IOException, CommandStatusException {
EmailContent.Message msg = new EmailContent.Message();
msg.mAccountKey = mAccount.mId;
msg.mMailboxKey = mMailbox.mId;
@@ -360,7 +360,7 @@
// Default to 1 (success) in case we don't get this tag
int status = 1;
- while (nextTag(Tags.SYNC_ADD) != END) {
+ while (nextTag(endingTag) != END) {
switch (tag) {
case Tags.SYNC_SERVER_ID:
msg.mServerId = getValue();
@@ -400,7 +400,7 @@
private void bodyParser(EmailContent.Message msg) throws IOException {
String bodyType = Eas.BODY_PREFERENCE_TEXT;
String body = "";
- while (nextTag(Tags.EMAIL_BODY) != END) {
+ while (nextTag(Tags.BASE_BODY) != END) {
switch (tag) {
case Tags.BASE_TYPE:
bodyType = getValue();
@@ -451,13 +451,13 @@
}
}
- private void attachmentsParser(ArrayList<EmailContent.Attachment> atts,
- EmailContent.Message msg) throws IOException {
- while (nextTag(Tags.EMAIL_ATTACHMENTS) != END) {
+ private void attachmentsParser(final ArrayList<EmailContent.Attachment> atts,
+ final EmailContent.Message msg, final int endingTag) throws IOException {
+ while (nextTag(endingTag) != END) {
switch (tag) {
case Tags.EMAIL_ATTACHMENT:
case Tags.BASE_ATTACHMENT: // BASE_ATTACHMENT is used in EAS 12.0 and up
- attachmentParser(atts, msg);
+ attachmentParser(atts, msg, tag);
break;
default:
skipTag();
@@ -465,15 +465,15 @@
}
}
- private void attachmentParser(ArrayList<EmailContent.Attachment> atts,
- EmailContent.Message msg) throws IOException {
+ private void attachmentParser(final ArrayList<EmailContent.Attachment> atts,
+ final EmailContent.Message msg, final int endingTag) throws IOException {
String fileName = null;
String length = null;
String location = null;
boolean isInline = false;
String contentId = null;
- while (nextTag(Tags.EMAIL_ATTACHMENT) != END) {
+ while (nextTag(endingTag) != END) {
switch (tag) {
// We handle both EAS 2.5 and 12.0+ attachments here
case Tags.EMAIL_DISPLAY_NAME:
@@ -683,7 +683,7 @@
public void commandsParser() throws IOException, CommandStatusException {
while (nextTag(Tags.SYNC_COMMANDS) != END) {
if (tag == Tags.SYNC_ADD) {
- newEmails.add(addParser());
+ newEmails.add(addParser(tag));
} else if (tag == Tags.SYNC_DELETE || tag == Tags.SYNC_SOFT_DELETE) {
deleteParser(deletedEmails, tag);
} else if (tag == Tags.SYNC_CHANGE) {
@@ -743,7 +743,7 @@
messageUpdateParser(tag);
} else if (tag == Tags.SYNC_FETCH) {
try {
- fetchedEmails.add(addParser());
+ fetchedEmails.add(addParser(tag));
} catch (CommandStatusException sse) {
if (sse.mStatus == 8) {
// 8 = object not found; delete the message from EmailProvider
diff --git a/src/com/android/exchange/adapter/GalParser.java b/src/com/android/exchange/adapter/GalParser.java
index 94c8cdf..a67eef0 100644
--- a/src/com/android/exchange/adapter/GalParser.java
+++ b/src/com/android/exchange/adapter/GalParser.java
@@ -53,12 +53,12 @@
return mGalResult.total > 0;
}
- public void parseProperties(GalResult galResult) throws IOException {
- GalData galData = new GalData();
- while (nextTag(Tags.SEARCH_STORE) != END) {
+ private void parseProperties(final GalResult galResult) throws IOException {
+ final GalData galData = new GalData();
+ while (nextTag(Tags.SEARCH_PROPERTIES) != END) {
switch(tag) {
// Display name and email address use both legacy and new code for galData
- case Tags.GAL_DISPLAY_NAME:
+ case Tags.GAL_DISPLAY_NAME:
String displayName = getValue();
galData.put(GalData.DISPLAY_NAME, displayName);
galData.displayName = displayName;
@@ -102,8 +102,8 @@
galResult.addGalData(galData);
}
- public void parseResult(GalResult galResult) throws IOException {
- while (nextTag(Tags.SEARCH_STORE) != END) {
+ private void parseResult(final GalResult galResult) throws IOException {
+ while (nextTag(Tags.SEARCH_RESULT) != END) {
if (tag == Tags.SEARCH_PROPERTIES) {
parseProperties(galResult);
} else {
@@ -112,7 +112,7 @@
}
}
- public void parseResponse(GalResult galResult) throws IOException {
+ private void parseResponse(final GalResult galResult) throws IOException {
while (nextTag(Tags.SEARCH_RESPONSE) != END) {
if (tag == Tags.SEARCH_STORE) {
parseStore(galResult);
@@ -122,7 +122,7 @@
}
}
- public void parseStore(GalResult galResult) throws IOException {
+ private void parseStore(final GalResult galResult) throws IOException {
while (nextTag(Tags.SEARCH_STORE) != END) {
if (tag == Tags.SEARCH_RESULT) {
parseResult(galResult);
diff --git a/src/com/android/exchange/adapter/MoveItemsParser.java b/src/com/android/exchange/adapter/MoveItemsParser.java
index cf478d9..6d1710e 100644
--- a/src/com/android/exchange/adapter/MoveItemsParser.java
+++ b/src/com/android/exchange/adapter/MoveItemsParser.java
@@ -66,7 +66,7 @@
return mSourceServerId;
}
- public void parseResponse() throws IOException {
+ private void parseResponse() throws IOException {
while (nextTag(Tags.MOVE_RESPONSE) != END) {
if (tag == Tags.MOVE_STATUS) {
int status = getValueInt();
diff --git a/src/com/android/exchange/adapter/Parser.java b/src/com/android/exchange/adapter/Parser.java
index cc8f747..8fb356e 100644
--- a/src/com/android/exchange/adapter/Parser.java
+++ b/src/com/android/exchange/adapter/Parser.java
@@ -105,6 +105,9 @@
}
public int getTagNum() {
+ if (Tags.isGlobalTag(mIndex)) {
+ return mIndex;
+ }
return (mPage << Tags.PAGE_SHIFT) | mIndex;
}
diff --git a/src/com/android/exchange/adapter/SettingsParser.java b/src/com/android/exchange/adapter/SettingsParser.java
index 5551db6..54c24f9 100644
--- a/src/com/android/exchange/adapter/SettingsParser.java
+++ b/src/com/android/exchange/adapter/SettingsParser.java
@@ -61,7 +61,7 @@
return res;
}
- public void parseDeviceInformation() throws IOException {
+ private void parseDeviceInformation() throws IOException {
while (nextTag(Tags.SETTINGS_DEVICE_INFORMATION) != END) {
if (tag == Tags.SETTINGS_SET) {
parseSet();
@@ -71,7 +71,7 @@
}
}
- public void parseSet() throws IOException {
+ private void parseSet() throws IOException {
while (nextTag(Tags.SETTINGS_SET) != END) {
if (tag == Tags.SETTINGS_STATUS) {
LogUtils.d(TAG, "Set status = %d", getValueInt());
diff --git a/src/com/android/exchange/adapter/Tags.java b/src/com/android/exchange/adapter/Tags.java
index f93f78f..08ea184 100644
--- a/src/com/android/exchange/adapter/Tags.java
+++ b/src/com/android/exchange/adapter/Tags.java
@@ -794,7 +794,7 @@
// 0x04 Calendar
"CalTimeZone", "CalAllDayEvent", "CalAttendees", "CalAttendee", "CalAttendee_Email",
"CalAttendee_Name", "CalBody", "CalBodyTruncated", "CalBusyStatus", "CalCategories",
- "CalCategory", "CalCompressed_RTF", "CalDTStamp", "CalEndTime", "CalExeption",
+ "CalCategory", "CalCompressed_RTF", "CalDTStamp", "CalEndTime", "CalException",
"CalExceptions", "CalException_IsDeleted", "CalException_StartTime", "CalLocation",
"CalMeetingStatus", "CalOrganizer_Email", "CalOrganizer_Name", "CalRecurrence",
"CalRecurrence_Type", "CalRecurrence_Until", "CalRecurrence_Occurrences",