[evolution-activesync] calendar: fix VEVENT->EAS conversion of multi-day events



commit a25c42e94b6afd84a1c3b3653ec883b5b2fdfbf9
Author: Patrick Ohly <patrick ohly intel com>
Date:   Thu May 23 00:30:42 2013 -0700

    calendar: fix VEVENT->EAS conversion of multi-day events
    
    All-day events stretching over multiple days were not marked as AllDayEvent
    when sending via ActiveSync. This did not matter with Exchange 2010, which
    automagically set the flag for us and thus let the tests in SyncEvolution
    pass.
    
    Exchange 2010 SP2 no longer does that, IMHO correctly, thus the tests started
    to fail after switching to a test account on Exchange 2010 SP2.
    
    The reason for the missing AllDayEvent flag was an explicit test that start
    and end time are SECONDS_PER_DAY apart. That was probably done to comply with
    the "end of next day" part of the AllDayEvent spec, but is not needed
    in practice and also wrong (because not all days have the same number
    of seconds - think daylight saving time changes). Removing the check fixes
    the problem (only tested with Exchange 2010 SP2, though).

 eas-daemon/libeas/eas-cal-info-translator.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/eas-daemon/libeas/eas-cal-info-translator.c b/eas-daemon/libeas/eas-cal-info-translator.c
index 40a3a95..0a8a745 100644
--- a/eas-daemon/libeas/eas-cal-info-translator.c
+++ b/eas-daemon/libeas/eas-cal-info-translator.c
@@ -59,7 +59,10 @@
 
 #include <wbxml/wbxml.h>
 
-// Values for converting icaldurationtype into a number of minutes
+// Values for converting icaldurationtype into a number of minutes.
+// Note that code using these values is almost certainly wrong.
+// Days involving daylight saving time changes will have 23 or 25
+// hours, etc.
 const gint SECONDS_PER_MINUTE          = 60;
 const gint MINUTES_PER_HOUR            = 60;
 const gint MINUTES_PER_DAY             = 60 * 24;
@@ -2527,8 +2530,10 @@ static void _ical2eas_process_vevent (icalcomponent* vevent, xmlNodePtr appData,
                // (ie. just dates, with time set to midnight) and are 1 day apart
                // (from [MS-ASCAL]: "An item marked as an all day event is understood to begin
                // on midnight of the current day and to end on midnight of the next day.")
-               if (startTime.hour == 0 && startTime.minute == 0 && startTime.second == 0 && endTime.hour == 
0 && endTime.minute == 0 && endTime.second == 0 &&
-                   (icaltime_as_timet (endTime) - icaltime_as_timet (startTime)) == (time_t) 
SECONDS_PER_DAY) {
+               // This description seems to limit AllDayEvent to events covering only one
+               // day. In practice, the end time may also be at midnight of any of the following
+               // days, to allow for multi-day all-day events.
+               if (startTime.hour == 0 && startTime.minute == 0 && startTime.second == 0 && endTime.hour == 
0 && endTime.minute == 0 && endTime.second == 0) {
                        xmlNewTextChild (appData, NULL, (const xmlChar*) EAS_NAMESPACE_CALENDAR 
EAS_ELEMENT_ALLDAYEVENT, (const xmlChar*) EAS_BOOLEAN_TRUE);
                } else {
                        xmlNewTextChild (appData, NULL, (const xmlChar*) EAS_NAMESPACE_CALENDAR 
EAS_ELEMENT_ALLDAYEVENT, (const xmlChar*) EAS_BOOLEAN_FALSE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]