From 758391571ebcca0bedaab6686a8a06a94be9f578 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 23 Feb 2009 13:11:58 +0000 Subject: [PATCH] Caldav: From dfoody: Split EXDATE exceptions into multiples lines to work with iCal. Ignore X-ENTOURAGE_UUID to avoid problems with iCal. git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@389 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ExchangeSession.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index fec780a1..5e565793 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -1347,6 +1347,16 @@ public class ExchangeSession { result.writeLine("CLASS:" + eventClass); } } + } else if (line.startsWith("EXDATE;TZID=") || line.startsWith("EXDATE:")) { + // Apple iCal doesn't support EXDATE with multiple exceptions + // on one line. Split into multiple EXDATE entries (which is + // also legal according to the caldav standard). + splitExDate(result, line); + continue; + } else if (line.startsWith("X-ENTOURAGE_UUID:")) { + // Apple iCal doesn't understand this key, and it's entourage + // specific (i.e. not needed by any caldav client): strip it out + continue; } else if (line.startsWith("CLASS:")) { if (isAppleiCal) { continue; @@ -1369,6 +1379,20 @@ public class ExchangeSession { return result.toString(); } + protected void splitExDate(ICSBufferedWriter result, String line) throws IOException { + int cur = line.lastIndexOf(':') + 1; + String start = line.substring(0, cur); + + for (int next = line.indexOf(',', cur); next != -1; next = line.indexOf(',', cur)) { + String val = line.substring(cur, next); + result.writeLine(start + val); + + cur = next + 1; + } + + result.writeLine(start + line.substring(cur)); + } + protected String getAllDayLine(String line) throws IOException { int keyIndex = line.indexOf(';'); int valueIndex = line.lastIndexOf(':');