From 4e2b98c36eab93bd2500a578d6761f1780313fb6 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 11 Sep 2007 20:25:57 +0000 Subject: [PATCH] Monotone-Parent: 2092d2f6cbf44065b7b2270044f0ccf6fecd8870 Monotone-Revision: e18a1dc8a0b33293a44781d7fe494c55e2992f5f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-09-11T20:25:57 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 ++++++ SoObjects/SOGo/SOGoFolder.h | 12 +++++++++- SoObjects/SOGo/SOGoFolder.m | 46 +++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f94397b2..53a2270d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-09-11 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder + +folderWithName:aNameandDisplayName:aDisplayNameinContainer:aContainer]): + new method. + ([SOGoFolder -displayName]): new method. + ([SOGoFolder -delete]): accept to proceed only if nameInContainer + != "personal". + * SoObjects/Contacts/SOGoContactLDAPFolder.m ([SOGoContactLDAPFolder +folderWithName:aNameandDisplayName:aDisplayNameinContainer:aContainer]): diff --git a/SoObjects/SOGo/SOGoFolder.h b/SoObjects/SOGo/SOGoFolder.h index 5358299d3..dad4629ad 100644 --- a/SoObjects/SOGo/SOGoFolder.h +++ b/SoObjects/SOGo/SOGoFolder.h @@ -43,7 +43,8 @@ @interface SOGoFolder : SOGoObject { - NSString *ocsPath; + NSString *displayName; + NSString *ocsPath; GCSFolder *ocsFolder; NSMutableDictionary *aclCache; } @@ -52,6 +53,15 @@ /* accessors */ ++ (id) folderWithName: (NSString *) aName + andDisplayName: (NSString *) aDisplayName + inContainer: (id) aContainer; +- (id) initWithName: (NSString *) aName + andDisplayName: (NSString *) aDisplayName + inContainer: (id) aContainer; + +- (NSString *) displayName; + - (void) setOCSPath: (NSString *)_Path; - (NSString *) ocsPath; diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 20a3b8944..18d2d4856 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -29,6 +29,7 @@ #import #import +#import #import #import #import @@ -85,14 +86,30 @@ static NSString *defaultUserID = @""; } sequence++; f = [[NSDate date] timeIntervalSince1970]; + return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X", - pid, *(int *)&f, sequence++, random]; + pid, (int) f, sequence++, random]; +} + ++ (id) folderWithName: (NSString *) aName + andDisplayName: (NSString *) aDisplayName + inContainer: (id) aContainer +{ + id newFolder; + + newFolder = [[self alloc] initWithName: aName + andDisplayName: aDisplayName + inContainer: aContainer]; + [newFolder autorelease]; + + return newFolder; } - (id) init { if ((self = [super init])) { + displayName = nil; ocsPath = nil; ocsFolder = nil; aclCache = [NSMutableDictionary new]; @@ -101,11 +118,23 @@ static NSString *defaultUserID = @""; return self; } +- (id) initWithName: (NSString *) aName + andDisplayName: (NSString *) aDisplayName + inContainer: (id) aContainer +{ + if ((self = [self initWithName: aName + inContainer: aContainer])) + ASSIGN (displayName, aDisplayName); + + return self; +} + - (void) dealloc { [ocsFolder release]; [ocsPath release]; [aclCache release]; + [displayName release]; [super dealloc]; } @@ -154,6 +183,11 @@ static NSString *defaultUserID = @""; return NO; } +- (NSString *) displayName +{ + return displayName; +} + - (GCSFolder *) ocsFolder { GCSFolder *folder; @@ -196,7 +230,15 @@ static NSString *defaultUserID = @""; - (NSException *) delete { - return [[self folderManager] deleteFolderAtPath: ocsPath]; + NSException *error; + + if ([nameInContainer isEqualToString: @"personal"]) + error = [NSException exceptionWithHTTPStatus: 403 + reason: @"the 'personal' folder cannot be deleted"]; + else + error = [[self folderManager] deleteFolderAtPath: ocsPath]; + + return error; } - (NSArray *) fetchContentObjectNames