Skip to content

Commit 7412f82

Browse files
committed
Caldav: merge #480 Teach fixVCalendar to convert TZIDs individually
git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@4096 3d1905a2-6b24-0410-a738-b14d5a86fcbd
1 parent db3a35a commit 7412f82

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

src/java/davmail/exchange/VCalendar.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,12 @@ protected void fixVCalendar(boolean fromServer) {
180180
}
181181

182182
// rename TZID for maximum iCal/iPhone compatibility
183-
String tzid = null;
184183
if (fromServer) {
185184
// get current tzid
186185
VObject vObject = vTimezone;
187186
if (vObject != null) {
188187
String currentTzid = vObject.getPropertyValue("TZID");
189-
// fix TZID with \n (Exchange 2010 bug)
190-
if (currentTzid != null && currentTzid.endsWith("\n")) {
191-
currentTzid = currentTzid.substring(0, currentTzid.length() - 1);
192-
vObject.setPropertyValue("TZID", currentTzid);
193-
}
194-
if (currentTzid != null && currentTzid.indexOf(' ') >= 0) {
195-
try {
196-
tzid = ResourceBundle.getBundle("timezones").getString(currentTzid);
197-
vObject.setPropertyValue("TZID", tzid);
198-
} catch (MissingResourceException e) {
199-
LOGGER.debug("Timezone " + currentTzid + " not found in rename table");
200-
}
201-
}
188+
vObject.setPropertyValue("TZID", fixupTZID(currentTzid));
202189
}
203190
}
204191

@@ -253,24 +240,22 @@ protected void fixVCalendar(boolean fromServer) {
253240
if ("".equals(vObject.getPropertyValue("CLASS"))) {
254241
vObject.removeProperty("CLASS");
255242
}
256-
// rename TZID
257-
if (tzid != null) {
258-
VProperty dtStart = vObject.getProperty("DTSTART");
259-
if (dtStart != null && dtStart.getParam("TZID") != null) {
260-
dtStart.setParam("TZID", tzid);
261-
}
262-
VProperty dtEnd = vObject.getProperty("DTEND");
263-
if (dtEnd != null && dtEnd.getParam("TZID") != null) {
264-
dtEnd.setParam("TZID", tzid);
265-
}
266-
VProperty recurrenceId = vObject.getProperty("RECURRENCE-ID");
267-
if (recurrenceId != null && recurrenceId.getParam("TZID") != null) {
268-
recurrenceId.setParam("TZID", tzid);
269-
}
270-
VProperty exDate = vObject.getProperty("EXDATE");
271-
if (exDate != null && exDate.getParam("TZID") != null) {
272-
exDate.setParam("TZID", tzid);
273-
}
243+
// rename TZIDs
244+
VProperty dtStart = vObject.getProperty("DTSTART");
245+
if (dtStart != null && dtStart.getParam("TZID") != null) {
246+
dtStart.setParam("TZID", fixupTZID(dtStart.getParamValue("TZID")));
247+
}
248+
VProperty dtEnd = vObject.getProperty("DTEND");
249+
if (dtEnd != null && dtEnd.getParam("TZID") != null) {
250+
dtEnd.setParam("TZID", fixupTZID(dtEnd.getParamValue("TZID")));
251+
}
252+
VProperty recurrenceId = vObject.getProperty("RECURRENCE-ID");
253+
if (recurrenceId != null && recurrenceId.getParam("TZID") != null) {
254+
recurrenceId.setParam("TZID", fixupTZID(recurrenceId.getParamValue("TZID")));
255+
}
256+
VProperty exDate = vObject.getProperty("EXDATE");
257+
if (exDate != null && exDate.getParam("TZID") != null) {
258+
exDate.setParam("TZID", fixupTZID(exDate.getParamValue("TZID")));
274259
}
275260
// remove unsupported attachment reference
276261
if (vObject.getProperty("ATTACH") != null) {
@@ -324,6 +309,21 @@ protected void fixVCalendar(boolean fromServer) {
324309

325310
}
326311

312+
private String fixupTZID(String currentTzid) {
313+
// fix TZID with \n (Exchange 2010 bug)
314+
if (currentTzid != null && currentTzid.endsWith("\n")) {
315+
currentTzid = currentTzid.substring(0, currentTzid.length() - 1);
316+
}
317+
if (currentTzid != null && currentTzid.indexOf(' ') >= 0) {
318+
try {
319+
currentTzid = ResourceBundle.getBundle("timezones").getString(currentTzid);
320+
} catch (MissingResourceException e) {
321+
LOGGER.debug("Timezone " + currentTzid + " not found in rename table");
322+
}
323+
}
324+
return currentTzid;
325+
}
326+
327327
private void fixTimezoneToServer() {
328328
if (vTimezone != null && vTimezone.vObjects != null && vTimezone.vObjects.size() > 2) {
329329
VObject standard = null;
@@ -361,7 +361,7 @@ private void fixTimezoneToServer() {
361361
}
362362
}
363363
}
364-
364+
365365
// validate RRULE - COUNT and UNTIL may not occur at once
366366
if (vTimezone != null && vTimezone.vObjects != null) {
367367
for (VObject vObject : vTimezone.vObjects) {
@@ -375,7 +375,7 @@ private void fixTimezoneToServer() {
375375
}
376376
}
377377
// end validate RRULE
378-
378+
379379
// convert TZID to Exchange time zone id
380380
ResourceBundle tzBundle = ResourceBundle.getBundle("exchtimezones");
381381
ResourceBundle tzidsBundle = ResourceBundle.getBundle("stdtimezones");

0 commit comments

Comments
 (0)