From 46c0b8d68ea87c8ca971913cd488b58bd7b8d081 Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 22 Feb 2005 15:33:04 +0000 Subject: [PATCH] minor code cleanups git-svn-id: http://svn.opengroupware.org/SOGo/trunk@600 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Appointments/ChangeLog | 4 + .../Appointments/SOGoAppointmentFolder.m | 108 ++++++++++-------- .../Appointments/SOGoAppointmentObject.m | 3 +- SOGo/SoObjects/Appointments/Version | 2 +- 4 files changed, 66 insertions(+), 51 deletions(-) diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index 07d3f48d..16cf5827 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,3 +1,7 @@ +2005-02-22 Helge Hess + + * SOGoAppointmentFolder.m: minor code cleanups (v0.9.27) + 2005-02-17 Helge Hess * fixed for removal of SOGoLogic (v0.9.26) diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index 6a20cf0c..92c93901 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -174,9 +174,40 @@ static NSTimeZone *MET = nil; return md; } +- (void)_flattenCycleRecord:(NSDictionary *)row + forRange:(NGCalendarDateRange *)_r + intoArray:(NSMutableArray *)ma +{ + NSString *uid; + id aptObject; + iCalEvent *apt; + NSArray *ranges; + unsigned k, rCount; + + uid = [row valueForKey:@"uid"]; + +#warning FIXME: lookup done by name, not by UID + // TODO: this is wrong, we need to lookup the appointment by UID, not name + aptObject = [self appointmentWithName:uid inContext:nil]; + + apt = [aptObject event]; + ranges = [apt recurrenceRangesWithinCalendarDateRange:_r]; + rCount = [ranges count]; + for (k = 0; k < rCount; k++) { + NGCalendarDateRange *rRange; + id fixedRow; + + rRange = [ranges objectAtIndex:k]; + fixedRow = [self fixupRecord:row fetchRange:rRange]; + if (fixedRow != nil) [ma addObject:fixedRow]; + } +} + - (NSArray *)fixupRecords:(NSArray *)_records fetchRange:(NGCalendarDateRange *)_r { + // TODO: is the result supposed to be sorted by date? + // TODO: move cycle handling out of fixup NSMutableArray *ma; unsigned i, count; @@ -184,35 +215,19 @@ static NSTimeZone *MET = nil; if ((count = [_records count]) == 0) return _records; + // TODO: inefficient, does a lot of fetches for cycles, separate cycle + // handling from fixup! ma = [NSMutableArray arrayWithCapacity:count]; for (i = 0; i < count; i++) { - id row; - + id row; // TODO: what is the type of the record? + row = [_records objectAtIndex:i]; if ([[row valueForKey:@"iscycle"] intValue] != 0) { - NSString *uid; - id aptObject; - iCalEvent *apt; - NSArray *ranges; - unsigned k, rCount; - - uid = [row valueForKey:@"uid"]; - aptObject = [self appointmentWithName:uid inContext:nil]; - apt = [aptObject event]; - ranges = [apt recurrenceRangesWithinCalendarDateRange:_r]; - rCount = [ranges count]; - for (k = 0; k < rCount; k++) { - NGCalendarDateRange *rRange; - id fixedRow; - - rRange = [ranges objectAtIndex:k]; - fixedRow = [self fixupRecord:row fetchRange:rRange]; - if (fixedRow) [ma addObject:fixedRow]; - } + [self _flattenCycleRecord:row forRange:_r intoArray:ma]; } else { row = [self fixupRecord:row fetchRange:_r]; - if (row) [ma addObject:row]; + if (row != nil) [ma addObject:row]; } } return ma; @@ -270,37 +285,32 @@ static NSTimeZone *MET = nil; __PRETTY_FUNCTION__]; return nil; } - return [self fetchFields:_fields - fromFolder:folder - from:_startDate - to:_endDate]; + return [self fetchFields:_fields fromFolder:folder + from:_startDate to:_endDate]; } - (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate to:(NSCalendarDate *)_endDate { - static NSArray *infos = nil; - if(!infos) { - infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate", - nil] retain]; + static NSArray *infos = nil; // TODO: move to a plist file + if (infos == nil) { + infos = [[NSArray alloc] initWithObjects:@"uid", @"startdate", @"enddate", + nil]; } - return [self fetchFields:infos - from:_startDate - to:_endDate]; + return [self fetchFields:infos from:_startDate to:_endDate]; } - (NSArray *)fetchOverviewInfosFrom:(NSCalendarDate *)_startDate to:(NSCalendarDate *)_endDate { - static NSArray *infos = nil; - if(!infos) { - infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate", - @"title", @"location", @"orgmail", - @"status", @"ispublic", @"iscycle", - @"isallday", - nil] retain]; + static NSArray *infos = nil; // TODO: move to a plist file + if (infos == nil) { + infos = [[NSArray alloc] initWithObjects: + @"uid", @"startdate", @"enddate", @"title", + @"location", @"orgmail", @"status", @"ispublic", + @"iscycle", @"isallday", nil]; } return [self fetchFields:infos from:_startDate @@ -310,15 +320,15 @@ static NSTimeZone *MET = nil; - (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate to:(NSCalendarDate *)_endDate { - static NSArray *infos = nil; - if(!infos) { - infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate", - @"title", @"location", @"orgmail", - @"status", @"ispublic", @"iscycle", - @"isallday", @"isopaque", - @"participants", @"partmails", - @"partstates", @"sequence", - nil] retain]; + static NSArray *infos = nil; // TODO: move to a plist file + if (infos == nil) { + infos = [[NSArray alloc] initWithObjects:@"uid", @"startdate", @"enddate", + @"title", @"location", @"orgmail", + @"status", @"ispublic", @"iscycle", + @"isallday", @"isopaque", + @"participants", @"partmails", + @"partstates", @"sequence", + nil]; } return [self fetchFields:infos from:_startDate diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentObject.m b/SOGo/SoObjects/Appointments/SOGoAppointmentObject.m index 90492304..66f149b8 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentObject.m @@ -148,6 +148,7 @@ static NGLogger *logger = nil; /* folder management */ - (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx { + // TODO: what does this do? lookup the home of the organizer? return [[self container] lookupHomeFolderForUID:_uid inContext:_ctx]; } - (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx { @@ -166,7 +167,7 @@ static NGLogger *logger = nil; e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx] objectEnumerator]; - while ((folder = [e nextObject])) { + while ((folder = [e nextObject]) != nil) { NSException *error; SOGoAppointmentObject *apt; diff --git a/SOGo/SoObjects/Appointments/Version b/SOGo/SoObjects/Appointments/Version index 00badea1..00d21930 100644 --- a/SOGo/SoObjects/Appointments/Version +++ b/SOGo/SoObjects/Appointments/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=26 +SUBMINOR_VERSION:=27 # v0.9.26 requires libSOGo v0.9.30 # v0.9.19 requires NGiCal v4.5.36 -- 2.39.5