diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index b09f143b..ff2707e0 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -91,6 +91,23 @@ public class EwsExchangeSession extends ExchangeSession { //AcceptSharingInvitation } + static final Map vTodoToTaskStatusMap = new HashMap(); + static final Map taskTovTodoStatusMap = new HashMap(); + + static { + //taskTovTodoStatusMap.put("NotStarted", null); + taskTovTodoStatusMap.put("InProgress", "IN-PROCESS"); + taskTovTodoStatusMap.put("Completed", "COMPLETED"); + taskTovTodoStatusMap.put("WaitingOnOthers", "NEEDS-ACTION"); + taskTovTodoStatusMap.put("Deferred", "CANCELLED"); + + //vTodoToTaskStatusMap.put(null, "NotStarted"); + vTodoToTaskStatusMap.put("IN-PROCESS", "InProgress"); + vTodoToTaskStatusMap.put("COMPLETED", "Completed"); + vTodoToTaskStatusMap.put("NEEDS-ACTION", "WaitingOnOthers"); + vTodoToTaskStatusMap.put("CANCELLED", "Deferred"); + } + protected Map folderIdMap; protected class Folder extends ExchangeSession.Folder { @@ -1220,6 +1237,17 @@ public class EwsExchangeSession extends ExchangeSession { updates.add(Field.createFieldUpdate("urlcompname", convertItemNameToEML(itemName))); updates.add(Field.createFieldUpdate("subject", vCalendar.getFirstVeventPropertyValue("SUMMARY"))); updates.add(Field.createFieldUpdate("description", vCalendar.getFirstVeventPropertyValue("DESCRIPTION"))); + String percentComplete = vCalendar.getFirstVeventPropertyValue("PERCENT-COMPLETE"); + if (percentComplete == null) { + percentComplete = "0"; + } + updates.add(Field.createFieldUpdate("percentcomplete", percentComplete)); + String vTodoStatus = vCalendar.getFirstVeventPropertyValue("STATUS"); + if (vTodoStatus == null) { + updates.add(Field.createFieldUpdate("status", "NotStarted")); + } else { + updates.add(Field.createFieldUpdate("status", vTodoToTaskStatusMap.get(vTodoStatus))); + } if (currentItemId != null) { // update createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, @@ -1347,6 +1375,8 @@ public class EwsExchangeSession extends ExchangeSession { getItemMethod.addAdditionalProperty(Field.get("lastmodified")); getItemMethod.addAdditionalProperty(Field.get("calendaruid")); getItemMethod.addAdditionalProperty(Field.get("description")); + getItemMethod.addAdditionalProperty(Field.get("percentcomplete")); + getItemMethod.addAdditionalProperty(Field.get("status")); } else if (!"Message".equals(type)) { getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, itemId, true); getItemMethod.addAdditionalProperty(Field.get("reminderset")); @@ -1376,6 +1406,8 @@ public class EwsExchangeSession extends ExchangeSession { vTodo.setPropertyValue("UID", calendarUid); vTodo.setPropertyValue("SUMMARY", getItemMethod.getResponseItem().get(Field.get("subject").getResponseName())); vTodo.setPropertyValue("DESCRIPTION", getItemMethod.getResponseItem().get(Field.get("description").getResponseName())); + vTodo.setPropertyValue("PERCENT-COMPLETE", getItemMethod.getResponseItem().get(Field.get("percentcomplete").getResponseName())); + vTodo.setPropertyValue("STATUS", taskTovTodoStatusMap.get(getItemMethod.getResponseItem().get(Field.get("status").getResponseName()))); localVCalendar.addVObject(vTodo); content = localVCalendar.toString().getBytes("UTF-8"); } else { diff --git a/src/java/davmail/exchange/ews/Field.java b/src/java/davmail/exchange/ews/Field.java index 67469d87..66c4c736 100644 --- a/src/java/davmail/exchange/ews/Field.java +++ b/src/java/davmail/exchange/ews/Field.java @@ -207,6 +207,10 @@ public final class Field { FIELD_MAP.put("xmozsnoozetime", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsnoozetime")); FIELD_MAP.put("xmozsendinvitations", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsendinvitations")); + // task + FIELD_MAP.put("percentcomplete", new UnindexedFieldURI("task:PercentComplete")); + FIELD_MAP.put("status", new UnindexedFieldURI("task:Status")); + // attachments FIELD_MAP.put("attachments", new UnindexedFieldURI("item:Attachments")); } diff --git a/src/java/davmail/exchange/ews/UnindexedFieldURI.java b/src/java/davmail/exchange/ews/UnindexedFieldURI.java index 5ebb05da..94aeec88 100644 --- a/src/java/davmail/exchange/ews/UnindexedFieldURI.java +++ b/src/java/davmail/exchange/ews/UnindexedFieldURI.java @@ -51,6 +51,8 @@ public class UnindexedFieldURI implements FieldURI { itemType = "Message"; } else if (fieldURI.startsWith("calendar") && itemType != null) { itemType = "CalendarItem"; + } else if (fieldURI.startsWith("task") && itemType != null) { + itemType = "Task"; } if (itemType != null) { appendTo(buffer);