From: helge Date: Sat, 14 Aug 2004 16:50:06 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/trunk@212 d1b88da0-ebda-0310-925b-ed51d... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bcdb985ca025450d8dccac872a36cde58154c7b;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/trunk@212 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index eacac779..6fc2d052 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,5 +1,9 @@ 2004-08-14 Helge Hess + * SOGoGroupAppointmentFolder.m: implemented proper URL generation for + group calendars (will lookup the appointment in the proper "exact" + folder (v0.9.6) + * SOGoAppointmentFolder.m: fetch location, isallday, iscycle and partmails fields in -fetchCoreInfo (v0.9.5) @@ -35,4 +39,3 @@ * redirect to weekoverview if GET is run on the folder itself * created ChangeLog - diff --git a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.h b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.h index 4dfb99ee..b2f0e050 100644 --- a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.h +++ b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.h @@ -35,10 +35,16 @@ rather looks up the "child" folders for aggregation using regular SOPE techniques. => hm, do we need "aspects" in SOPE? ;-) + + Note: this class retains appointment folders looked up, so watch out for + reference cycles! */ +@class NSMutableDictionary; + @interface SOGoGroupAppointmentFolder : SOGoAppointmentFolder { + NSMutableDictionary *uidToFolder; } @end diff --git a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m index 3089b558..c19463f4 100644 --- a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m @@ -25,6 +25,11 @@ @implementation SOGoGroupAppointmentFolder +- (void)dealloc { + [self->uidToFolder release]; + [super dealloc]; +} + /* looking up shared objects */ - (SOGoGroupsFolder *)lookupGroupsFolder { @@ -37,6 +42,19 @@ return [[self container] valueForKey:@"uids"]; } +/* folders */ + +- (SOGoAppointmentFolder *)folderForUID:(NSString *)_uid { + if (self->uidToFolder == nil) { + // TODO: can we trigger a fetch? + [self logWithFormat: + @"ERROR: called -folderForUID method before fetchCoreInfos .."]; + return nil; + } + + return [self->uidToFolder objectForKey:_uid]; +} + /* merging */ - (BOOL)doesRecord:(NSDictionary *)_rec conflictWith:(NSDictionary *)_other { @@ -70,28 +88,31 @@ /* functionality */ -- (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate - to:(NSCalendarDate *)_endDate - memberFolder:(id)_folder -{ +- (SOGoAppointmentFolder *)calendarFolderForMemberFolder:(id)_folder { SOGoAppointmentFolder *aptFolder; if (![_folder isNotNull]) return nil; aptFolder = [_folder lookupName:@"Calendar" inContext:nil acquire:NO]; - if (![aptFolder isNotNull]) { - [self logWithFormat:@"ERROR: member folder no 'Calendar': %@", _folder]; + if (![aptFolder isNotNull]) return nil; - } if (![aptFolder respondsToSelector:@selector(fetchCoreInfosFrom:to:)]) { [self logWithFormat:@"ERROR: folder does not implemented required API: %@", _folder]; return nil; } - - return [aptFolder fetchCoreInfosFrom:_startDate to:_endDate]; + return aptFolder; +} + +- (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate + to:(NSCalendarDate *)_endDate + folder:(SOGoAppointmentFolder *)_folder +{ + if (![_folder isNotNull]) + return nil; + return [_folder fetchCoreInfosFrom:_startDate to:_endDate]; } - (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate @@ -102,23 +123,35 @@ NSMutableDictionary *uidToRecord; unsigned i, count; + [self sleep]; + if ((count = [_folders count]) == 0) return [NSArray array]; - if (count == 1) { - return [self fetchCoreInfosFrom:_startDate to:_endDate - memberFolder:[_folders objectAtIndex:0]]; - } + + if (self->uidToFolder == nil) + self->uidToFolder = [[NSMutableDictionary alloc] initWithCapacity:7*count]; + else + [self->uidToFolder removeAllObjects]; uidToRecord = [NSMutableDictionary dictionaryWithCapacity:(7 * count)]; result = [NSMutableArray arrayWithCapacity:(7 * count)]; for (i = 0; i < count; i++) { + SOGoAppointmentFolder *aptFolder; id results; NSDictionary *record; + aptFolder = [self calendarFolderForMemberFolder: + [_folders objectAtIndex:i]]; + if (![aptFolder isNotNull]) { + [self debugWithFormat:@"did not find a Calendar folder in folder: %@", + [_folders objectAtIndex:i]]; + continue; + } + results = [self fetchCoreInfosFrom:_startDate to:_endDate - memberFolder:[_folders objectAtIndex:i]]; + folder:aptFolder]; if (![results isNotNull]) continue; - + results = [results objectEnumerator]; while ((record = [results nextObject])) { NSString *uid; @@ -135,6 +168,8 @@ /* record not yet in result set */ [uidToRecord setObject:record forKey:uid]; [result addObject:record]; + + [self->uidToFolder setObject:aptFolder forKey:uid]; } else if ([self doesRecord:existingRecord conflictWith:record]) { /* record already registered and it conflicts (diff values) */ @@ -174,16 +209,28 @@ /* URL generation */ - (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx { - //NSString *url; + /* Note: fetchCore must have been called before this works */ + SOGoAppointmentFolder *folder; + + if ([_uid length] == 0) { + [self logWithFormat:@"ERROR: got invalid UID."]; + return nil; + } - if ([_uid length] == 0) + if ((folder = [self folderForUID:_uid]) == nil) { + [self logWithFormat:@"ERROR: did not find a folder containing UID: '%@'", + _uid]; + return nil; + } + if (![folder respondsToSelector:_cmd]) { + [self logWithFormat:@"ERROR: found folder cannot construct UID URLs: %@", + folder]; return nil; + } -#warning TODO: fix URL generation for aggregate - [self logWithFormat:@"FIXME: URL generation for viewer"]; + [self debugWithFormat:@"found ID %@ in folder: %@", _uid, folder]; - // need to locate the folder containing the apt, then call it - return [super baseURLForAptWithUID:_uid inContext:_ctx]; + return [folder baseURLForAptWithUID:_uid inContext:_ctx]; } @end /* SOGoGroupAppointmentFolder */ diff --git a/SOGo/SoObjects/Appointments/Version b/SOGo/SoObjects/Appointments/Version index 3a46c165..c49415d6 100644 --- a/SOGo/SoObjects/Appointments/Version +++ b/SOGo/SoObjects/Appointments/Version @@ -1,3 +1,3 @@ # $Id: Version,v 1.9 2004/05/19 14:30:45 helge Exp $ -SUBMINOR_VERSION:=5 +SUBMINOR_VERSION:=6 diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index 11e4c4f4..09965357 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,4 +1,15 @@ -2004-08-11 +2004-08-14 Helge Hess + + * v0.9.7 + + * SOGoGroupFolder.m: renamed -reset method to -sleep (called by SOPE) + + * SOGoObject.m: added SOPE -sleep method (resets container and can be + called by subclasses) + + * SOGoGroupFolder.m: made the folder found note log a debug log + +2004-08-11 Helge Hess * v0.9.6 diff --git a/SOGo/SoObjects/SOGo/SOGoGroupFolder.h b/SOGo/SoObjects/SOGo/SOGoGroupFolder.h index ce8e5756..3dd94823 100644 --- a/SOGo/SoObjects/SOGo/SOGoGroupFolder.h +++ b/SOGo/SoObjects/SOGo/SOGoGroupFolder.h @@ -48,7 +48,7 @@ - (NSArray *)memberFolders; - (id)folderForUID:(NSString *)_uid; -- (void)reset; +- (void)sleep; /* pathes */ diff --git a/SOGo/SoObjects/SOGo/SOGoGroupFolder.m b/SOGo/SoObjects/SOGo/SOGoGroupFolder.m index c0d66829..196d8f93 100644 --- a/SOGo/SoObjects/SOGo/SOGoGroupFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoGroupFolder.m @@ -27,6 +27,7 @@ - (void)dealloc { [self->uidToFolder release]; + [self->folders release]; [super dealloc]; } @@ -53,7 +54,7 @@ /* build path */ - path = [NSArray arrayWithObjects:&_uid count:1]; + path = _uid != nil ? [NSArray arrayWithObjects:&_uid count:1] : nil; /* traverse path */ @@ -65,7 +66,7 @@ return nil; } - [self logWithFormat:@"Note: got folder for uid %@ path %@: %@", + [self debugWithFormat:@"Note: got folder for uid %@ path %@: %@", _uid, [path componentsJoinedByString:@"=>"], result]; return result; } @@ -122,9 +123,10 @@ return [self->uidToFolder objectForKey:_uid]; } -- (void)reset { +- (void)sleep { [self->uidToFolder release]; self->uidToFolder = nil; [self->folders release]; self->folders = nil; + [super sleep]; } /* SOPE */ diff --git a/SOGo/SoObjects/SOGo/SOGoObject.h b/SOGo/SoObjects/SOGo/SOGoObject.h index 92095cce..cd3171b7 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.h +++ b/SOGo/SoObjects/SOGo/SOGoObject.h @@ -47,6 +47,8 @@ - (SOGoUserFolder *)lookupUserFolder; - (SOGoGroupsFolder *)lookupGroupsFolder; +- (void)sleep; + /* operations */ - (NSException *)delete; diff --git a/SOGo/SoObjects/SOGo/SOGoObject.m b/SOGo/SoObjects/SOGo/SOGoObject.m index b18e7a46..3d70a8e6 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.m +++ b/SOGo/SoObjects/SOGo/SOGoObject.m @@ -70,6 +70,12 @@ return [[self lookupUserFolder] lookupGroupsFolder]; } +- (void)sleep { + if ([self doesRetainContainer]) + [self->container release]; + self->container = nil; +} + /* operations */ - (NSException *)delete { diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index d0850942..070d8811 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,3 +1,3 @@ # $Id: Version 170 2004-08-11 10:45:40Z helge $ -SUBMINOR_VERSION:=6 +SUBMINOR_VERSION:=7