From 820714fb17e78997e5bbd84fad2f7dc235c4b422 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 12 Apr 2011 14:12:22 +0000 Subject: [PATCH] See ChangeLog. Monotone-Parent: 9ad26f9553c4800488d1baf29bf4bb97c6827456 Monotone-Revision: b0de250ad5fa2e4afb2daba52426ee8123e26ef1 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-04-12T14:12:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++ .../Appointments/SOGoAppointmentFolder.m | 43 ++++++++++++++----- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a75da81d2..61d987866 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-12 Francis Lachapelle + + * SoObjects/Appointments/SOGoAppointmentFolder.m + (-importCalendar:): we now associate the proper vtimezone to each + event found in the calendar. + 2011-04-11 Francis Lachapelle * UI/WebServerResources/UIxMailToSelection.js diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 78435eadb..0498d1bcf 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -2609,8 +2609,13 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir - (int) importCalendar: (iCalCalendar *) calendar { + NSArray *vtimezones; NSMutableArray *components; + NSMutableDictionary *timezones; NSString *tz; + iCalEntityObject *element; + iCalDateTime *startDate; + iCalTimeZone *timezone; int imported, count, i; @@ -2618,25 +2623,41 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir if (calendar) { + // Build a hash with the timezones includes in the calendar + vtimezones = [calendar timezones]; + count = [vtimezones count]; + timezones = [NSMutableDictionary dictionaryWithCapacity: count]; + for (i = 0; i < count; i++) + { + timezone = (iCalTimeZone *)[vtimezones objectAtIndex: i]; + [timezones setValue: [NSString stringWithFormat: @"%@\n", [timezone versitString]] + forKey: [timezone tzId]]; + } + + // Parse events/todos/journals and import them components = [[calendar events] mutableCopy]; [components autorelease]; [components addObjectsFromArray: [calendar todos]]; [components addObjectsFromArray: [calendar journals]]; [components addObjectsFromArray: [calendar freeBusys]]; - -#warning FIXME we might want to eventually support multiple timezone definitions and match the one used by the event - if ([[calendar timezones] count]) - tz = [NSString stringWithFormat: @"%@\n", - [[[calendar timezones] lastObject] versitString]]; - else - tz = @""; - count = [components count]; for (i = 0; i < count; i++) - if ([self importComponent: [components objectAtIndex: i] timezone: tz]) - imported++; + { + tz = nil; + element = [components objectAtIndex: i]; + // Use the timezone of the start date. + startDate = (iCalDateTime *)[element uniqueChildWithTag: @"dtstart"]; + if (startDate) + { + timezone = [startDate timeZone]; + tz = [timezones valueForKey: [timezone tzId]]; + } + if ([self importComponent: element + timezone: (tz == nil? @"" : tz)]) + imported++; + } } - + return imported; }