From 1855d58c384be0f35856158e79d029a4e6bbc61d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 11 Jun 2007 21:28:28 +0000 Subject: [PATCH] Monotone-Parent: 499f99a4ec1e217106656209b339db3a1b287d74 Monotone-Revision: d2e4731dde2d6d07f3c17c2438ce006ce1a226c6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-11T21:28:28 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++ UI/Scheduler/UIxCalListingActions.h | 3 ++ UI/Scheduler/UIxCalListingActions.m | 50 +++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f9ce4f9f..9288125f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-06-11 Wolfgang Sourdeau + * UI/Scheduler/UIxCalListingActions.m ([UIxCalListingActions + -init]): initialize an instance of SOGoDateFormatter. + ([UIxCalListingActions -eventsListAction]): the display start and + end dates are added to the listing for each event. + * UI/Scheduler/UIxCalDayTable.m: no longer retrieve appointments. * UI/Scheduler/UIxAppointmentEditor.m ([UIxAppointmentEditor diff --git a/UI/Scheduler/UIxCalListingActions.h b/UI/Scheduler/UIxCalListingActions.h index c222ec0c1..ed455673f 100644 --- a/UI/Scheduler/UIxCalListingActions.h +++ b/UI/Scheduler/UIxCalListingActions.h @@ -31,6 +31,8 @@ @class NSString; @class NSTimeZone; +@class SOGoDateFormatter; + @class WOResponse; @class WORequest; @@ -41,6 +43,7 @@ NSCalendarDate *endDate; NSString *userLogin; WORequest *request; + SOGoDateFormatter *dateFormatter; } - (WOResponse *) eventsListAction; diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index 246462dc4..02987da45 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -38,27 +38,33 @@ #import #import +#import "../SOGoUI/SOGoDateFormatter.h" + #import "UIxCalListingActions.h" @implementation UIxCalListingActions - (id) init { + NSDictionary *locale; + if ((self = [super init])) { componentsData = [NSMutableDictionary new]; startDate = nil; endDate = nil; request = nil; -// knowsToShow = NO; -// showCompleted = NO; - } + locale = [[self context] valueForKey: @"locale"]; + dateFormatter = [[SOGoDateFormatter alloc] initWithLocale: locale]; + [dateFormatter setFullWeekdayNameAndDetails]; + } return self; } - (void) dealloc { + [dateFormatter release]; [componentsData release]; [startDate release]; [endDate release]; @@ -159,7 +165,7 @@ else startDate = nil; - param = [request formValueForKey: @"sd"]; + param = [request formValueForKey: @"ed"]; if ([param length] > 0) endDate = [[NSCalendarDate dateFromShortDateString: param andShortTimeString: nil @@ -292,16 +298,42 @@ - (WOResponse *) eventsListAction { - NSArray *fields; - NSArray *events; + NSArray *fields, *oldEvent; + NSEnumerator *events; + NSString *date; + NSMutableArray *newEvents, *newEvent; + unsigned int interval; [self _setupContext]; + newEvents = [NSMutableArray array]; fields = [NSArray arrayWithObjects: @"c_name", @"owner", @"status", - @"title", @"startdate", @"enddate", @"location", nil]; - events = [self _fetchFields: fields forComponentOfType: @"vevent"]; + @"title", @"startdate", @"enddate", @"location", + @"isallday", nil]; + events = [[self _fetchFields: fields + forComponentOfType: @"vevent"] objectEnumerator]; + oldEvent = [events nextObject]; + while (oldEvent) + { + newEvent = [NSMutableArray arrayWithArray: oldEvent]; + interval = [[oldEvent objectAtIndex: 4] intValue]; + date + = [dateFormatter stringForObjectValue: + [NSCalendarDate dateWithTimeIntervalSince1970: interval]]; + [newEvent addObject: date]; + interval = [[oldEvent objectAtIndex: 5] intValue]; + if ([[oldEvent objectAtIndex: 7] boolValue]) + interval -= 86400; + date + = [dateFormatter stringForObjectValue: + [NSCalendarDate dateWithTimeIntervalSince1970: interval]]; + [newEvent addObject: date]; + [newEvents addObject: newEvent]; - return [self _responseWithData: events]; + oldEvent = [events nextObject]; + } + + return [self _responseWithData: newEvents]; } - (NSString *) _getStatusClassForStatusCode: (int) statusCode