From d36fb810d58ea84fdb4cb7d4408c37a2ec7b8da7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 16 Jan 2008 18:57:58 +0000 Subject: [PATCH] Monotone-Parent: 54ec8c39f5bb2075a087aabb062d28af978421de Monotone-Revision: 36eb21ac828a920f7994e922c1c7e6fe481c62ac Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-01-16T18:57:58 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ Main/SOGo.m | 4 ++++ .../Appointments/SOGoAppointmentFolder.m | 6 ++++++ SoObjects/SOGo/SOGoObject.m | 16 ++++++++++++--- SoObjects/SOGo/SOGoUser.m | 20 ++++++++++++++++--- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8be2a8df7..09f2ec57c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-01-16 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoUser.m ([SOGoUser + +userWithLogin:newLoginroles:newRoles]): try to retrieve the + specified user from the SOGoCache. + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -lookupName:lookupNameinContext:localContextacquire:acquire]): try to retrieve the object specified from the cache and returns it if diff --git a/Main/SOGo.m b/Main/SOGo.m index ac530d561..afb19b095 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -42,6 +42,7 @@ #import +#import #import #import #import @@ -56,6 +57,7 @@ @interface SOGo : SoApplication { NSMutableDictionary *localeLUT; + SOGoCache *cache; } - (NSDictionary *) currentLocaleConsideringLanguages:(NSArray *)_langs; @@ -390,7 +392,9 @@ static BOOL debugObjectAllocation = NO; static NSArray *runLoopModes = nil; WOResponse *resp; + cache = [SOGoCache sharedCache]; resp = [super dispatchRequest: _request]; + [SOGoCache killCache]; if (![self isTerminating]) { diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 5be6e5588..da40ac840 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -48,6 +48,7 @@ #import // #import +#import #import #import #import @@ -403,6 +404,11 @@ static NSNumber *sharedYes = nil; obj = [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } + if (obj) + [[SOGoCache sharedCache] registerObject: obj + withName: _key + inContainer: container]; + return obj; } diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 8bb510661..9c5fbcee6 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -62,6 +62,7 @@ #import "NSDictionary+Utilities.h" #import "NSString+Utilities.h" +#import "SOGoCache.h" #import "SOGoObject.h" @interface SOGoObject(Content) @@ -560,10 +561,19 @@ static BOOL kontactGroupDAV = YES; acquire: (BOOL) acquire { id obj; + SOGoCache *cache; - obj = [[self soClass] lookupKey: lookupName inContext: localContext]; - if (obj) - [obj bindToObject: self inContext: localContext]; + cache = [SOGoCache sharedCache]; + obj = [cache objectNamed: lookupName inContainer: self]; + if (!obj) + { + obj = [[self soClass] lookupKey: lookupName inContext: localContext]; + if (obj) + { + [obj bindToObject: self inContext: localContext]; + [cache registerObject: obj withName: lookupName inContainer: self]; + } + } return obj; } diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 9c7bd9d3d..fe0aa2a6a 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -32,10 +32,11 @@ #import "AgenorUserDefaults.h" #import "LDAPUserManager.h" +#import "NSArray+Utilities.h" +#import "SOGoCache.h" #import "SOGoDateFormatter.h" #import "SOGoObject.h" #import "SOGoPermissions.h" -#import "NSArray+Utilities.h" #import "SOGoUser.h" @@ -124,10 +125,18 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; + (SOGoUser *) userWithLogin: (NSString *) newLogin roles: (NSArray *) newRoles { + SOGoCache *cache; SOGoUser *user; - user = [[self alloc] initWithLogin: newLogin roles: newRoles]; - [user autorelease]; + cache = [SOGoCache sharedCache]; + user = [cache userNamed: newLogin]; + if (!user) + { + user = [[self alloc] initWithLogin: newLogin roles: newRoles]; + [user autorelease]; + [cache registerUser: user]; + } + [user setPrimaryRoles: newRoles]; return user; } @@ -181,6 +190,11 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; [super dealloc]; } +- (void) setPrimaryRoles: (NSArray *) newRoles +{ + ASSIGN (roles, newRoles); +} + - (void) setCurrentPassword: (NSString *) newPassword { ASSIGN (currentPassword, newPassword);