1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

Caldav: additional VCalendar properties for rebuilt item: RRULE, EXDATE, CLASS

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1440 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-13 19:27:16 +00:00
parent cb2b6baac3
commit 7619bb715d
4 changed files with 55 additions and 5 deletions

View File

@ -205,6 +205,13 @@ public class VObject {
}
}
public void addPropertyValue(String name, String value) {
if (value != null) {
VProperty property = new VProperty(name, value);
addProperty(property);
}
}
public void removeProperty(String name) {
if (properties != null) {
VProperty property = getProperty(name);

View File

@ -1307,9 +1307,10 @@ public class DavExchangeSession extends ExchangeSession {
result = getICSFromItemProperties();
}
// debug code
//if (new String(result).indexOf("VTODO") < 0) {
// LOGGER.debug("Rebuilt body: " + new String(getICSFromItemProperties()));
//}
if (new String(result).indexOf("VTODO") < 0) {
result = getICSFromItemProperties();
LOGGER.debug("Rebuilt body: " + new String(result));
}
return result;
}
@ -1332,6 +1333,9 @@ public class DavExchangeSession extends ExchangeSession {
davPropertyNameSet.add(Field.getPropertyName("organizer"));
davPropertyNameSet.add(Field.getPropertyName("to"));
davPropertyNameSet.add(Field.getPropertyName("description"));
davPropertyNameSet.add(Field.getPropertyName("rrule"));
davPropertyNameSet.add(Field.getPropertyName("exdate"));
davPropertyNameSet.add(Field.getPropertyName("sensitivity"));
davPropertyNameSet.add(Field.getPropertyName("alldayevent"));
davPropertyNameSet.add(Field.getPropertyName("busystatus"));
@ -1356,6 +1360,23 @@ public class DavExchangeSession extends ExchangeSession {
vEvent.setPropertyValue("DTSTART", convertDateFromExchange(getPropertyIfExists(davPropertySet, "dtstart")));
vEvent.setPropertyValue("DTEND", convertDateFromExchange(getPropertyIfExists(davPropertySet, "dtend")));
vEvent.setPropertyValue("TRANSP", getPropertyIfExists(davPropertySet, "transparent"));
vEvent.setPropertyValue("RRULE", getPropertyIfExists(davPropertySet, "rrule"));
String exdates = getPropertyIfExists(davPropertySet, "exdate");
if (exdates != null) {
String[] exdatearray = exdates.split(",");
for (String exdate:exdatearray) {
vEvent.addPropertyValue("EXDATE",
StringUtil.convertZuluDateTimeToAllDay(convertDateFromExchange(exdate)));
}
}
String sensitivity = getPropertyIfExists(davPropertySet, "sensitivity");
if ("2".equals(sensitivity)) {
vEvent.setPropertyValue("CLASS", "PRIVATE");
} else if ("3".equals(sensitivity)) {
vEvent.setPropertyValue("CLASS", "CONFIDENTIAL");
} else if ("0".equals(sensitivity)) {
vEvent.setPropertyValue("CLASS", "PUBLIC");
}
String organizer = getPropertyIfExists(davPropertySet, "organizer");
String organizerEmail = null;
if (organizer != null) {

View File

@ -174,6 +174,9 @@ public class Field {
createField(URN_SCHEMAS_CALENDAR, "created"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:created/SystemTime
createField(URN_SCHEMAS_CALENDAR, "alldayevent"); // DistinguishedPropertySetType.Appointment/0x8215 Boolean
createField(URN_SCHEMAS_CALENDAR, "rrule"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:rrule/PtypMultipleString
createField(URN_SCHEMAS_CALENDAR, "exdate"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:exdate/PtypMultipleTime
// TODO
createField(SCHEMAS_MAPI, "allattendeesstring"); // PidLidAllAttendeesString
createField(SCHEMAS_MAPI, "required_attendees"); // PidLidRequiredAttendees
@ -184,11 +187,9 @@ public class Field {
createField(URN_SCHEMAS_CALENDAR, "location"); // DistinguishedPropertySetType.Appointment/0x8208 String
createField(URN_SCHEMAS_CALENDAR, "attendeerole"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:attendeerole/Integer
createField(URN_SCHEMAS_CALENDAR, "busystatus"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:busystatus/String
createField(URN_SCHEMAS_CALENDAR, "exdate"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:exdate/PtypMultipleTime
createField(URN_SCHEMAS_CALENDAR, "exrule"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:exrule/PtypMultipleString
createField(URN_SCHEMAS_CALENDAR, "recurrenceidrange"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:recurrenceidrange/String
createField(URN_SCHEMAS_CALENDAR, "rdate"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:rdate/PtypMultipleTime
createField(URN_SCHEMAS_CALENDAR, "rrule"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:rrule/PtypMultipleString
createField(URN_SCHEMAS_CALENDAR, "reminderoffset"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:reminderoffset/Integer
createField(URN_SCHEMAS_CALENDAR, "timezone"); // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezone/String

View File

@ -22,6 +22,9 @@ import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Set;
import java.util.regex.Pattern;
@ -313,4 +316,22 @@ public final class StringUtil {
}
return result;
}
public static String convertZuluDateTimeToAllDay(String value) {
String result = value;
if (value != null && value.length() != 8) {
// try to convert datetime value to date value
try {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateParser = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
calendar.setTime(dateParser.parse(value));
calendar.add(Calendar.HOUR_OF_DAY, 12);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd");
result = dateFormatter.format(calendar.getTime());
} catch (ParseException e) {
// ignore
}
}
return result;
}
}