From 772b31b27766139c829ae844fcecdfdab9ae3973 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 11 Apr 2007 19:03:42 +0000 Subject: [PATCH] Monotone-Parent: 98814195ee0653059251e5fef63d4cfbcda8d5f1 Monotone-Revision: 1b89ce2fe004930400d04b4bed9edb04d4d4fa82 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-04-11T19:03:42 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++ SoObjects/SOGo/SOGoObject.h | 6 +-- SoObjects/SOGo/SOGoObject.m | 96 ++++++++----------------------------- 3 files changed, 24 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index ddca7c8d9..b25a4d9e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-04-11 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoObject.m: new ivar "context" that permits + every subclass to access [WOApplication context] without having to + invoke it more than once. + * SoObjects/Appointments/SOGoCalendarComponent.m ([SOGoCalendarComponent -changeParticipationStatus:_status]): moved method from SOGoTaskObject and SOGoAppointmentObject up to diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index e06864b24..b09b636cc 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -44,9 +44,9 @@ @interface SOGoObject : NSObject { + WOContext *context; NSString *nameInContainer; id container; - NSTimeZone *userTimeZone; NSString *customOwner; } @@ -59,10 +59,6 @@ - (NSString *) nameInContainer; - (id) container; -- (NSTimeZone *) serverTimeZone; -- (NSTimeZone *) userTimeZone; -- (NSTimeZone *) userTimeZone: (NSString *) username; - /* ownership */ - (void) setOwner: (NSString *) newOwner; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 5e0ba15c4..a0be82859 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -140,7 +140,6 @@ @implementation SOGoObject static BOOL kontactGroupDAV = YES; -static NSTimeZone *serverTimeZone = nil; + (int)version { return 0; @@ -148,8 +147,6 @@ static NSTimeZone *serverTimeZone = nil; + (void) initialize { - NSString *tzName; - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; kontactGroupDAV = @@ -168,15 +165,6 @@ static NSTimeZone *serverTimeZone = nil; asDefaultForPermission: SoPerm_View]; [[self soClassSecurityInfo] declareRole: SoRole_Owner asDefaultForPermission: SoPerm_WebDAVAccess]; - - if (!serverTimeZone) - { - tzName = [ud stringForKey: @"SOGoServerTimeZone"]; - if (!tzName) - tzName = @"Canada/Eastern"; - serverTimeZone = [NSTimeZone timeZoneWithName: tzName]; - [serverTimeZone retain]; - } } + (void) _fillDictionary: (NSMutableDictionary *) dictionary @@ -237,20 +225,11 @@ static NSTimeZone *serverTimeZone = nil; } /* DAV ACL properties */ -- (NSString *) _principalForUser: (NSString *) user -{ - WOContext *context; - - context = [[WOApplication application] context]; - - return [NSString stringWithFormat: @"%@users/%@", - [self rootURLInContext: context], - user]; -} - - (NSString *) davOwner { - return [self _principalForUser: [self ownerInContext: nil]]; + return [NSString stringWithFormat: @"%@users/%@", + [self rootURLInContext: context], + [self ownerInContext: nil]]; } - (NSString *) davAclRestrictions @@ -267,9 +246,7 @@ static NSTimeZone *serverTimeZone = nil; - (SOGoDAVSet *) davPrincipalCollectionSet { NSString *usersUrl; - WOContext *context; - context = [[WOApplication application] context]; usersUrl = [NSString stringWithFormat: @"%@users", [self rootURLInContext: context]]; @@ -282,12 +259,10 @@ static NSTimeZone *serverTimeZone = nil; SOGoAuthenticator *sAuth; SoUser *user; NSArray *roles; - WOContext *context; SoClassSecurityInfo *sInfo; NSArray *davPermissions; sAuth = [SOGoAuthenticator sharedSOGoAuthenticator]; - context = [[WOApplication application] context]; user = [sAuth userInContext: context]; roles = [user rolesForObject: self inContext: context]; sInfo = [[self class] soClassSecurityInfo]; @@ -318,7 +293,7 @@ static NSTimeZone *serverTimeZone = nil; NSArray *privileges; NSMutableString *currentAce; NSMutableArray *davAces; - NSString *currentKey; + NSString *currentKey, *principal; SOGoDAVSet *privilegesDS; davAces = [NSMutableArray array]; @@ -332,9 +307,15 @@ static NSTimeZone *serverTimeZone = nil; appendFormat: @"", [currentKey substringFromIndex: 1]]; else - [currentAce - appendFormat: @"%@", - [self _principalForUser: currentKey]]; + { + principal = [NSString stringWithFormat: @"%@users/%@", + [self rootURLInContext: context], + currentKey]; + [currentAce + appendFormat: @"%@", + principal]; + } + privileges = [[aclsDictionary objectForKey: currentKey] stringsWithFormat: @""]; privilegesDS = [SOGoDAVSet davSetWithArray: privileges @@ -395,16 +376,18 @@ static NSTimeZone *serverTimeZone = nil; /* end of properties */ -- (BOOL)doesRetainContainer { +- (BOOL) doesRetainContainer +{ return YES; } - (id)initWithName:(NSString *)_name inContainer:(id)_container { if ((self = [super init])) { + context = [[WOApplication application] context]; + [context retain]; nameInContainer = [_name copy]; container = [self doesRetainContainer] ? [_container retain] : _container; - userTimeZone = nil; customOwner = nil; } return self; @@ -415,12 +398,10 @@ static NSTimeZone *serverTimeZone = nil; } - (void)dealloc { - if (customOwner) - [customOwner release]; + [context release]; + [customOwner release]; if ([self doesRetainContainer]) [container release]; - if (userTimeZone) - [userTimeZone release]; [nameInContainer release]; [super dealloc]; } @@ -709,45 +690,6 @@ static NSTimeZone *serverTimeZone = nil; return nil; } -- (NSTimeZone *) serverTimeZone -{ - return serverTimeZone; -} - -/* TODO: should be moved into SOGoUser */ -- (NSTimeZone *) userTimeZone -{ - NSUserDefaults *userPrefs; - WOContext *context; - - if (!userTimeZone) - { - context = [[WOApplication application] context]; - userPrefs = [[context activeUser] userDefaults]; - userTimeZone = [NSTimeZone - timeZoneWithName: [userPrefs stringForKey: @"timezonename"]]; - if (!userTimeZone) - userTimeZone = [self serverTimeZone]; - [userTimeZone retain]; - } - - return userTimeZone; -} - -- (NSTimeZone *) userTimeZone: (NSString *) username -{ - NSUserDefaults *userPrefs; - AgenorUserManager *am; - - am = [AgenorUserManager sharedUserManager]; - userPrefs = [am getUserDefaultsForUID: username]; - userTimeZone = [NSTimeZone timeZoneWithName: [userPrefs stringForKey: @"timezonename"]]; - if (!userTimeZone) - userTimeZone = [self serverTimeZone]; - - return userTimeZone; -} - /* description */ - (void)appendAttributesToDescription:(NSMutableString *)_ms {