From 34f2e5dfa50f40ff8bd827d943b5391e1b78e0d9 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 13 Jul 2005 10:36:09 +0000 Subject: [PATCH] added class versions to some files added uid=>resourcename mapping git-svn-id: http://svn.opengroupware.org/SOGo/trunk@733 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Appointments/ChangeLog | 5 ++ .../Appointments/SOGoAppointmentFolder.h | 15 +++- .../Appointments/SOGoAppointmentFolder.m | 74 ++++++++++++++++++- .../Appointments/SOGoGroupAppointmentFolder.m | 12 ++- SOGo/SoObjects/SOGo/ChangeLog | 3 + SOGo/SoObjects/SOGo/SOGoFolder.m | 9 +++ SOGo/SoObjects/SOGo/SOGoObject.m | 4 + SOGo/SoObjects/SOGo/SOGoUserFolder.m | 7 +- SOGo/SoObjects/SOGo/Version | 2 +- 9 files changed, 116 insertions(+), 15 deletions(-) diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index a3a68373..0020203e 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,3 +1,8 @@ +2005-07-13 Helge Hess + + * SOGoAppointmentFolder.m: added a method to determine the resource + name from a vevent UID (v0.9.41) + 2005-07-12 Marcus Mueller * SOGoAppointmentObject.m: tries ambitiously to detect the baseURL in diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h index 9214e38a..27782d98 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Appointments_SOGoAppointmentFolder_H__ #define __Appointments_SOGoAppointmentFolder_H__ @@ -32,13 +31,19 @@ The SOGoAppointmentFolder maps to an GCS folder of type 'appointment', that is, a content folder containing iCalendar files (and a proper quicktable). + + Important: + The folder assumes a 1:1 mapping between the vevent UID field and the + resource name in the content store. In other words, you are not allowed to + create two different vevent-files with the same uid in the store. */ -@class NSString, NSArray, NSCalendarDate, NSException; +@class NSString, NSArray, NSCalendarDate, NSException, NSMutableDictionary; @class GCSFolder; @interface SOGoAppointmentFolder : SOGoFolder { + NSMutableDictionary *uidToFilename; } + (NSString *)globallyUniqueObjectId; @@ -47,6 +52,10 @@ - (NSArray *)calendarUIDs; +/* vevent UID handling */ + +- (NSString *)resourceNameForEventUID:(NSString *)_uid; + /* fetching */ - (NSArray *)fetchFields:(NSArray *)_fields diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index e85d762a..b01b4a3f 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -42,12 +42,19 @@ static NGLogger *logger = nil; static NSTimeZone *MET = nil; ++ (int)version { + return [super version] + 1 /* v1 */; +} + (void)initialize { NGLoggerManager *lm; static BOOL didInit = NO; if (didInit) return; didInit = YES; + + NSAssert2([super version] == 0, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); lm = [NGLoggerManager defaultLoggerManager]; logger = [lm loggerForDefaultKey:@"SOGoAppointmentFolderDebugEnabled"]; @@ -77,6 +84,7 @@ static NSTimeZone *MET = nil; } - (void)dealloc { + [self->uidToFilename release]; [super dealloc]; } @@ -142,6 +150,63 @@ static NSTimeZone *MET = nil; return MET; } +/* vevent UID handling */ + +- (NSString *)resourceNameForEventUID:(NSString *)_u inFolder:(GCSFolder *)_f { + static NSArray *nameFields = nil; + EOQualifier *qualifier; + NSArray *records; + + if (![_u isNotNull]) return nil; + if (_f == nil) { + [self errorWithFormat:@"(%s): missing folder for fetch!", + __PRETTY_FUNCTION__]; + return nil; + } + + if (nameFields == nil) + nameFields = [[NSArray alloc] initWithObjects:@"c_name", nil]; + + qualifier = [EOQualifier qualifierWithQualifierFormat:@"uid = %@", _u]; + records = [_f fetchFields:nameFields matchingQualifier:qualifier]; + + if ([records count] == 1) + return [[records objectAtIndex:0] valueForKey:@"c_name"]; + if ([records count] == 0) + return nil; + + [self errorWithFormat: + @"The storage contains more than file with the same UID!"]; + return [[records objectAtIndex:0] valueForKey:@"c_name"]; +} + +- (NSString *)resourceNameForEventUID:(NSString *)_uid { + /* caches UIDs */ + GCSFolder *folder; + NSString *rname; + + if (![_uid isNotNull]) + return nil; + if ((rname = [self->uidToFilename objectForKey:_uid]) != nil) + return [rname isNotNull] ? rname : nil; + + if ((folder = [self ocsFolder]) == nil) { + [self errorWithFormat:@"(%s): missing folder for fetch!", + __PRETTY_FUNCTION__]; + return nil; + } + + if (self->uidToFilename == nil) + self->uidToFilename = [[NSMutableDictionary alloc] initWithCapacity:16]; + + if ((rname = [self resourceNameForEventUID:_uid inFolder:folder]) == nil) + [self->uidToFilename setObject:[NSNull null] forKey:_uid]; + else + [self->uidToFilename setObject:rname forKey:_uid]; + + return rname; +} + /* fetching */ - (NSMutableDictionary *)fixupRecord:(NSDictionary *)_record @@ -323,10 +388,10 @@ static NSTimeZone *MET = nil; if (records != nil) { records = [self fixupRecords:records fetchRange:r]; if (logger) - [self debugWithFormat:@"fetched %i records: %@", [records count], records]; + [self debugWithFormat:@"fetched %i records: %@",[records count],records]; ma = [NSMutableArray arrayWithArray:records]; } - + /* fetch recurrent apts now */ sql = [NSString stringWithFormat:@"(startdate < %d) AND (cycleenddate > %d)" @" AND (iscycle = 1)", @@ -395,7 +460,7 @@ static NSTimeZone *MET = nil; if (infos == nil) { infos = [[NSArray alloc] initWithObjects: @"title", - @"location", @"orgmail", @"status", @"ispublic", + @"location", @"orgmail", @"status", @"ispublic", @"isallday", @"priority", @"partmails", @"partstates", nil]; @@ -425,6 +490,7 @@ static NSTimeZone *MET = nil; /* URL generation */ - (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx { + // TODO: who calls this? NSString *url; if ([_uid length] == 0) @@ -433,6 +499,8 @@ static NSTimeZone *MET = nil; url = [self baseURLInContext:_ctx]; if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; + + // TODO: this should run a query to determine the uid! return [url stringByAppendingString:_uid]; } diff --git a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m index 324fa443..4c513553 100644 --- a/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoGroupAppointmentFolder.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,13 +18,21 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: SOGoAppointmentFolder.m 137 2004-07-02 17:42:14Z helge $ #include "SOGoGroupAppointmentFolder.h" #include "common.h" @implementation SOGoGroupAppointmentFolder ++ (int)version { + return [super version] + 0 /* v1 */; +} ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + - (void)dealloc { [self->uidToFolder release]; [super dealloc]; diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index f51ea626..4635c188 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,5 +1,8 @@ 2005-07-13 Helge Hess + * SOGoObject.m, SOGoFolder.m: added +version methods to detect fragile + base class issues (v0.9.51) + * SOGoFolder.m: changed to use plain column names (v0.9.50) 2005-07-12 Marcus Mueller diff --git a/SOGo/SoObjects/SOGo/SOGoFolder.m b/SOGo/SoObjects/SOGo/SOGoFolder.m index d8e10aee..c4a11c08 100644 --- a/SOGo/SoObjects/SOGo/SOGoFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoFolder.m @@ -26,6 +26,15 @@ @implementation SOGoFolder ++ (int)version { + return [super version] + 0 /* v0 */; +} ++ (void)initialize { + NSAssert2([super version] == 0, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + - (void)dealloc { [self->ocsFolder release]; [self->ocsPath release]; diff --git a/SOGo/SoObjects/SOGo/SOGoObject.m b/SOGo/SoObjects/SOGo/SOGoObject.m index f29e295b..c597beb2 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.m +++ b/SOGo/SoObjects/SOGo/SOGoObject.m @@ -29,6 +29,10 @@ @implementation SOGoObject ++ (int)version { + return 0; +} + - (BOOL)doesRetainContainer { return YES; } diff --git a/SOGo/SoObjects/SOGo/SOGoUserFolder.m b/SOGo/SoObjects/SOGo/SOGoUserFolder.m index 66057cc4..469c862c 100644 --- a/SOGo/SoObjects/SOGo/SOGoUserFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoUserFolder.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "SOGoUserFolder.h" #include "WOContext+Agenor.h" @@ -26,10 +25,6 @@ @implementation SOGoUserFolder -- (void)dealloc { - [super dealloc]; -} - /* accessors */ - (NSString *)login { diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index 5ccb7b3c..fae7b092 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=50 +SUBMINOR_VERSION:=51 # v0.9.50 requires libGDLContentStore v4.5.30 # v0.9.34 requires libGDLContentStore v4.5.26 -- 2.39.5