Caldav: rebuild meeting attendees only for Exchange 2007, Exchange 2010 ics parser is correct

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1930 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-03-20 23:08:42 +00:00
parent f1c53cfc5e
commit 321c1b0454
4 changed files with 46 additions and 11 deletions

View File

@ -130,7 +130,7 @@ public class VCalendar extends VObject {
return firstVevent != null && isCdoAllDay(firstVevent);
}
protected String getEmailValue(VProperty property) {
public String getEmailValue(VProperty property) {
if (property == null) {
return null;
}
@ -498,7 +498,7 @@ public class VCalendar extends VObject {
}
protected List<VProperty> getFirstVeventProperties(String name) {
public List<VProperty> getFirstVeventProperties(String name) {
if (firstVevent == null) {
return null;
} else {

View File

@ -291,6 +291,15 @@ public class VProperty {
return null;
}
public String getParamValue(String paramName) {
Param param = getParam(paramName);
if (param != null) {
return param.getValue();
} else {
return null;
}
}
protected List<Param> getParams() {
return params;
}

View File

@ -1399,16 +1399,41 @@ public class EwsExchangeSession extends ExchangeSession {
updates.add(Field.createFieldUpdate("xmozsnoozetime", xMozSnoozeTime));
}
if (vCalendar.isMeeting()) {
VCalendar.Recipients recipients = vCalendar.getRecipients(false);
if (recipients.attendees != null) {
updates.add(Field.createFieldUpdate("to", recipients.attendees));
if (vCalendar.isMeeting() && "Exchange2007_SP1".equals(serverVersion)) {
Set<String> requiredAttendees = new HashSet<String>();
Set<String> optionalAttendees = new HashSet<String>();
List<VProperty> attendeeProperties = vCalendar.getFirstVeventProperties("ATTENDEE");
if (attendeeProperties != null) {
for (VProperty property : attendeeProperties) {
String attendeeEmail = vCalendar.getEmailValue(property);
if (attendeeEmail != null && attendeeEmail.indexOf('@') >= 0) {
EWSMethod.Attendee attendee = new EWSMethod.Attendee();
attendee.email = attendeeEmail;
attendee.name = property.getParamValue("CN");
String attendeeRole = property.getParamValue("ROLE");
if ("REQ-PARTICIPANT".equals(attendeeRole)) {
requiredAttendees.add(attendeeEmail);
} else {
optionalAttendees.add(attendeeEmail);
}
newItem.addAttendee(attendee);
}
}
}
if (recipients.optionalAttendees != null) {
updates.add(Field.createFieldUpdate("cc", recipients.optionalAttendees));
List<VProperty> organizerProperties = vCalendar.getFirstVeventProperties("ORGANIZER");
if (organizerProperties != null) {
VProperty property = organizerProperties.get(0);
String organizerEmail = vCalendar.getEmailValue(property);
if (organizerEmail != null && organizerEmail.indexOf('@') >= 0) {
updates.add(Field.createFieldUpdate("from", organizerEmail));
}
}
if (recipients.organizer != null && !vCalendar.isMeetingOrganizer()) {
updates.add(Field.createFieldUpdate("from", recipients.optionalAttendees));
if (requiredAttendees.size() > 0) {
updates.add(Field.createFieldUpdate("to", StringUtil.join(requiredAttendees, ", ")));
}
if (optionalAttendees.size() > 0) {
updates.add(Field.createFieldUpdate("cc", StringUtil.join(optionalAttendees, ", ")));
}
}
@ -1936,7 +1961,7 @@ public class EwsExchangeSession extends ExchangeSession {
}
private FolderId getFolderId(String folderPath) throws IOException {
public FolderId getFolderId(String folderPath) throws IOException {
FolderId folderId = getFolderIdIfExists(folderPath);
if (folderId == null) {
throw new HttpNotFoundException("Folder '" + folderPath + "' not found");

View File

@ -195,6 +195,7 @@ public final class Field {
FIELD_MAP.put("reminderset", new UnindexedFieldURI("item:ReminderIsSet"));
FIELD_MAP.put("ismeeting", new UnindexedFieldURI("item:IsMeeting"));
FIELD_MAP.put("apptstateflags", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.Appointment, 0x8217, ExtendedFieldURI.PropertyType.Integer)); // PidLidAppointmentStateFlags 1: Meeting, 2: Received, 4: Cancelled
FIELD_MAP.put("appointmentstate", new UnindexedFieldURI("calendar:AppointmentState"));
FIELD_MAP.put("calendaruid", new ExtendedFieldURI(ExtendedFieldURI.DistinguishedPropertySetType.PublicStrings, "urn:schemas:calendar:uid", ExtendedFieldURI.PropertyType.String));
FIELD_MAP.put("meetingtimezone", new UnindexedFieldURI("calendar:MeetingTimeZone"));