1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-12 05:58:48 -05:00

Caldav: Fix complex timezones sent by clients, leave only latest STANDARD and DAYLIGHT definition

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1825 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-10-24 22:24:38 +00:00
parent 7640fcd8ec
commit 396f6790c1

View File

@ -184,6 +184,10 @@ public class VCalendar extends VObject {
}
}
if (!fromServer) {
fixTimezone();
}
// iterate over vObjects
for (VObject vObject : vObjects) {
if ("VEVENT".equals(vObject.type)) {
@ -267,6 +271,30 @@ public class VCalendar extends VObject {
}
private void fixTimezone() {
if (vTimezone != null && vTimezone.vObjects != null && vTimezone.vObjects.size() > 2) {
VObject standard = null;
VObject daylight = null;
for (VObject vObject:vTimezone.vObjects) {
if ("STANDARD".equals(vObject.type)) {
if (standard == null ||
(vObject.getPropertyValue("DTSTART").compareTo(standard.getPropertyValue("DTSTART")) > 0)) {
standard = vObject;
}
}
if ("DAYLIGHT".equals(vObject.type)) {
if (daylight == null ||
(vObject.getPropertyValue("DTSTART").compareTo(daylight.getPropertyValue("DTSTART")) > 0)) {
daylight = vObject;
}
}
}
vTimezone.vObjects.clear();
vTimezone.vObjects.add(standard);
vTimezone.vObjects.add(daylight);
}
}
private void fixTzid(VProperty property) {
if (property != null && !property.hasParam("TZID")) {
property.addParam("TZID", vTimezone.getPropertyValue("TZID"));
@ -549,6 +577,10 @@ public class VCalendar extends VObject {
firstVevent.addProperty(vProperty);
}
/**
* Check if this item is a VTODO item
* @return true with VTODO items
*/
public boolean isTodo() {
return "VTODO".equals(firstVevent.type);
}