From a4cd44348585121b931b38a31b02f03fea4dfcdb Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 17 Aug 2010 15:19:09 +0000 Subject: [PATCH] Caldav: Fix missing TZID in DTSTART from iPhone git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1356 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/VCalendar.java | 9 +++++++++ src/test/davmail/caldav/TestCaldav.java | 2 -- .../davmail/exchange/TestExchangeSessionEvent.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/java/davmail/exchange/VCalendar.java b/src/java/davmail/exchange/VCalendar.java index f030b7d1..2ad28570 100644 --- a/src/java/davmail/exchange/VCalendar.java +++ b/src/java/davmail/exchange/VCalendar.java @@ -179,6 +179,9 @@ public class VCalendar extends VObject { // convert date values to outlook compatible values setServerAllday(vObject.getProperty("DTSTART")); setServerAllday(vObject.getProperty("DTEND")); + } else { + fixTzid(vObject.getProperty("DTSTART")); + fixTzid(vObject.getProperty("DTEND")); } } @@ -190,6 +193,12 @@ public class VCalendar extends VObject { } + private void fixTzid(VProperty property) { + if (property != null && !property.hasParam("TZID")) { + property.addParam("TZID", vTimezone.getPropertyValue("TZID")); + } + } + protected void splitExDate(VObject vObject) { List exDateProperties = vObject.getProperties("EXDATE"); if (exDateProperties != null) { diff --git a/src/test/davmail/caldav/TestCaldav.java b/src/test/davmail/caldav/TestCaldav.java index 7d95ff9c..3297db83 100644 --- a/src/test/davmail/caldav/TestCaldav.java +++ b/src/test/davmail/caldav/TestCaldav.java @@ -149,8 +149,6 @@ public class TestCaldav extends AbstractDavMailTestCase { MultiStatus multiStatus = method.getResponseBodyAsMultiStatus(); MultiStatusResponse[] responses = multiStatus.getResponses(); - Set ITEM_PROPERTIES = new HashSet(); - ITEM_PROPERTIES.add("instancetype"); List events = session.searchEvents("/users/" + session.getEmail() + "/calendar/", session.and( session.gt("dtstart", session.formatSearchDate(start)), diff --git a/src/test/davmail/exchange/TestExchangeSessionEvent.java b/src/test/davmail/exchange/TestExchangeSessionEvent.java index e862300b..dfafbf74 100644 --- a/src/test/davmail/exchange/TestExchangeSessionEvent.java +++ b/src/test/davmail/exchange/TestExchangeSessionEvent.java @@ -276,4 +276,16 @@ public class TestExchangeSessionEvent extends TestCase { System.out.println("'"+BundleMessage.format(status)+"'"); } + public void testMissingTzid() throws IOException { + String itemBody = "BEGIN:VCALENDAR\n" + + "BEGIN:VEVENT\n" + + "DTSTART:20100101T000000\n" + + "DTEND:20100102T000000\n" + + "END:VEVENT\n" + + "END:VCALENDAR"; + String toServer = fixICS(itemBody, false); + System.out.println(toServer); + assertTrue(toServer.contains("DTSTART;TZID=")); + assertTrue(toServer.contains("DTEND;TZID=")); + } }