Caldav: fix floating timezone in iCal: rename TZID for maximum iCal/iPhone compatibility
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1578 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
80712f6063
commit
2f47f173d0
|
@ -25,10 +25,7 @@ import org.apache.log4j.Logger;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VCalendar object.
|
* VCalendar object.
|
||||||
|
@ -146,6 +143,20 @@ public class VCalendar extends VObject {
|
||||||
setPropertyValue("METHOD", "PUBLISH");
|
setPropertyValue("METHOD", "PUBLISH");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rename TZID for maximum iCal/iPhone compatibility
|
||||||
|
String tzid = null;
|
||||||
|
if (fromServer) {
|
||||||
|
// get current tzid
|
||||||
|
VObject vObject = getVTimezone();
|
||||||
|
if (vObject != null) {
|
||||||
|
try {
|
||||||
|
tzid = ResourceBundle.getBundle("timezones").getString(vObject.getPropertyValue("TZID"));
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
LOGGER.debug("Timezone rename failed, timezone "+vObject.getPropertyValue("TZID")+" not found in table");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// iterate over vObjects
|
// iterate over vObjects
|
||||||
for (VObject vObject : vObjects) {
|
for (VObject vObject : vObjects) {
|
||||||
if ("VEVENT".equals(vObject.type)) {
|
if ("VEVENT".equals(vObject.type)) {
|
||||||
|
@ -187,6 +198,17 @@ public class VCalendar extends VObject {
|
||||||
if ("".equals(vObject.getPropertyValue("CLASS"))) {
|
if ("".equals(vObject.getPropertyValue("CLASS"))) {
|
||||||
vObject.removeProperty("CLASS");
|
vObject.removeProperty("CLASS");
|
||||||
}
|
}
|
||||||
|
// rename TZID
|
||||||
|
if (tzid != null) {
|
||||||
|
VProperty dtStart = vObject.getProperty("DTSTART");
|
||||||
|
if (dtStart != null && dtStart.getParam("TZID") != null) {
|
||||||
|
dtStart.setParam("TZID", tzid);
|
||||||
|
}
|
||||||
|
VProperty dtEnd = vObject.getProperty("DTEND");
|
||||||
|
if (dtEnd != null && dtStart.getParam("TZID") != null) {
|
||||||
|
dtEnd.setParam("TZID", tzid);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// add organizer line to all events created in Exchange for active sync
|
// add organizer line to all events created in Exchange for active sync
|
||||||
String organizer = getEmailValue(vObject.getProperty("ORGANIZER"));
|
String organizer = getEmailValue(vObject.getProperty("ORGANIZER"));
|
||||||
|
|
|
@ -230,6 +230,14 @@ public class VProperty {
|
||||||
addParam(paramName, (String) null);
|
addParam(paramName, (String) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParam(String paramName, String paramValue) {
|
||||||
|
Param currentParam = getParam(paramName);
|
||||||
|
if (currentParam != null) {
|
||||||
|
getParams().remove(currentParam);
|
||||||
|
}
|
||||||
|
addParam(paramName, paramValue);
|
||||||
|
}
|
||||||
|
|
||||||
public void addParam(String paramName, String paramValue) {
|
public void addParam(String paramName, String paramValue) {
|
||||||
List<String> paramValues = new ArrayList<String>();
|
List<String> paramValues = new ArrayList<String>();
|
||||||
paramValues.add(paramValue);
|
paramValues.add(paramValue);
|
||||||
|
|
Loading…
Reference in New Issue