Commit 24190251 authored by Mickaël Guessant's avatar Mickaël Guessant

Caldav: prepare calendar refactoring, do not delete/add received meeting...

Caldav: prepare calendar refactoring, do not delete/add received meeting items, just send an Accept/Decline message

git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@2502 3d1905a2-6b24-0410-a738-b14d5a86fcbd
parent 1f04a6ee
...@@ -733,7 +733,7 @@ public class VCalendar extends VObject { ...@@ -733,7 +733,7 @@ public class VCalendar extends VObject {
return recipients; return recipients;
} }
protected String getAttendeeStatus() { public String getAttendeeStatus() {
String status = null; String status = null;
List<VProperty> attendeeProperties = getFirstVeventProperties("ATTENDEE"); List<VProperty> attendeeProperties = getFirstVeventProperties("ATTENDEE");
if (attendeeProperties != null) { if (attendeeProperties != null) {
......
...@@ -93,6 +93,7 @@ public class EwsExchangeSession extends ExchangeSession { ...@@ -93,6 +93,7 @@ public class EwsExchangeSession extends ExchangeSession {
static final Map<String, String> vTodoToTaskStatusMap = new HashMap<String, String>(); static final Map<String, String> vTodoToTaskStatusMap = new HashMap<String, String>();
static final Map<String, String> taskTovTodoStatusMap = new HashMap<String, String>(); static final Map<String, String> taskTovTodoStatusMap = new HashMap<String, String>();
static final Map<String, String> partstatToResponseMap = new HashMap<String, String>();
static { static {
//taskTovTodoStatusMap.put("NotStarted", null); //taskTovTodoStatusMap.put("NotStarted", null);
...@@ -106,6 +107,10 @@ public class EwsExchangeSession extends ExchangeSession { ...@@ -106,6 +107,10 @@ public class EwsExchangeSession extends ExchangeSession {
vTodoToTaskStatusMap.put("COMPLETED", "Completed"); vTodoToTaskStatusMap.put("COMPLETED", "Completed");
vTodoToTaskStatusMap.put("NEEDS-ACTION", "WaitingOnOthers"); vTodoToTaskStatusMap.put("NEEDS-ACTION", "WaitingOnOthers");
vTodoToTaskStatusMap.put("CANCELLED", "Deferred"); vTodoToTaskStatusMap.put("CANCELLED", "Deferred");
partstatToResponseMap.put("ACCEPTED", "AcceptItem");
partstatToResponseMap.put("TENTATIVE", "TentativelyAcceptItem");
partstatToResponseMap.put("DECLINED", "DeclineItem");
} }
protected Map<String, String> folderIdMap; protected Map<String, String> folderIdMap;
...@@ -1629,18 +1634,31 @@ public class EwsExchangeSession extends ExchangeSession { ...@@ -1629,18 +1634,31 @@ public class EwsExchangeSession extends ExchangeSession {
} else { } else {
if (currentItemId != null) { if (currentItemId != null) {
/*Set<FieldUpdate> updates = new HashSet<FieldUpdate>(); if (vCalendar.isMeeting() && !vCalendar.isMeetingOrganizer()) {
// TODO: update properties instead of brute force delete/add // This is a meeting response
updates.add(new FieldUpdate(Field.get("mimeContent"), new String(Base64.encodeBase64AsString(itemContent)))); EWSMethod.Item item = new EWSMethod.Item();
// update
item.type = partstatToResponseMap.get(vCalendar.getAttendeeStatus());
item.referenceItemId = new ItemId("ReferenceItemId", currentItemId.id, currentItemId.changeKey);
createOrUpdateItemMethod = new CreateItemMethod(MessageDisposition.SendOnly,
SendMeetingInvitations.SendToAllAndSaveCopy,
getFolderId(SENT),
item
);
} else {
List<FieldUpdate> updates = new ArrayList<FieldUpdate>();
// TODO: update all event fields and handle other occurrences
updates.add(Field.createFieldUpdate("dtstart", convertCalendarDateToExchange(vCalendar.getFirstVeventPropertyValue("DTSTART"))));
updates.add(Field.createFieldUpdate("dtend", convertCalendarDateToExchange(vCalendar.getFirstVeventPropertyValue("DTEND"))));
updates.add(Field.createFieldUpdate("description", vCalendar.getFirstVeventPropertyValue("DESCRIPTION")));
updates.add(Field.createFieldUpdate("location", vCalendar.getFirstVeventPropertyValue("LOCATION")));
createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly, createOrUpdateItemMethod = new UpdateItemMethod(MessageDisposition.SaveOnly,
ConflictResolution.AutoResolve, ConflictResolution.AutoResolve,
SendMeetingInvitationsOrCancellations.SendToNone, SendMeetingInvitationsOrCancellations.SendToAllAndSaveCopy,
currentItemId, updates);*/ currentItemId, updates);
// hard method: delete/create on update }
DeleteItemMethod deleteItemMethod = new DeleteItemMethod(currentItemId, DeleteType.HardDelete, SendMeetingCancellations.SendToNone); } else {
executeMethod(deleteItemMethod);
} //else {
// create // create
EWSMethod.Item newItem = new EWSMethod.Item(); EWSMethod.Item newItem = new EWSMethod.Item();
newItem.type = "CalendarItem"; newItem.type = "CalendarItem";
...@@ -1747,8 +1765,8 @@ public class EwsExchangeSession extends ExchangeSession { ...@@ -1747,8 +1765,8 @@ public class EwsExchangeSession extends ExchangeSession {
if (serverVersion != null && serverVersion.startsWith("Exchange201")) { if (serverVersion != null && serverVersion.startsWith("Exchange201")) {
createOrUpdateItemMethod.setTimezoneContext(EwsExchangeSession.this.getVTimezone().getPropertyValue("TZID")); createOrUpdateItemMethod.setTimezoneContext(EwsExchangeSession.this.getVTimezone().getPropertyValue("TZID"));
} }
//}
} }
executeMethod(createOrUpdateItemMethod); executeMethod(createOrUpdateItemMethod);
itemResult.status = createOrUpdateItemMethod.getStatusCode(); itemResult.status = createOrUpdateItemMethod.getStatusCode();
...@@ -1780,6 +1798,7 @@ public class EwsExchangeSession extends ExchangeSession { ...@@ -1780,6 +1798,7 @@ public class EwsExchangeSession extends ExchangeSession {
updates); updates);
executeMethod(createOrUpdateItemMethod); executeMethod(createOrUpdateItemMethod);
} }
}
ItemId newItemId = new ItemId(createOrUpdateItemMethod.getResponseItem()); ItemId newItemId = new ItemId(createOrUpdateItemMethod.getResponseItem());
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, newItemId, false); GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, newItemId, false);
......
...@@ -232,6 +232,8 @@ public final class Field { ...@@ -232,6 +232,8 @@ public final class Field {
FIELD_MAP.put("recurrencestart", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Appointment, 0x8235, ExtendedFieldURI.PropertyType.SystemTime)); FIELD_MAP.put("recurrencestart", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Appointment, 0x8235, ExtendedFieldURI.PropertyType.SystemTime));
FIELD_MAP.put("recurrencetype", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Appointment, 0x8231, ExtendedFieldURI.PropertyType.Integer)); FIELD_MAP.put("recurrencetype", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Appointment, 0x8231, ExtendedFieldURI.PropertyType.Integer));
FIELD_MAP.put("location", new UnindexedFieldURI("calendar:Location"));
FIELD_MAP.put("xmozlastack", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozlastack")); FIELD_MAP.put("xmozlastack", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozlastack"));
FIELD_MAP.put("xmozsnoozetime", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsnoozetime")); FIELD_MAP.put("xmozsnoozetime", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsnoozetime"));
FIELD_MAP.put("xmozsendinvitations", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsendinvitations")); FIELD_MAP.put("xmozsendinvitations", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "xmozsendinvitations"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment