From 8327699982a5217ecc333eeaba6fe69cd5067dc1 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Dec 2008 14:33:14 +0000 Subject: [PATCH] Monotone-Parent: 2ae53e4d24cdb745c3a8c8e246d99d096538c2e3 Monotone-Revision: 72200746a9f7ee37d797519783476d88536f267d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-12-17T14:33:14 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ SoObjects/SOGo/SOGoParentFolder.h | 1 + SoObjects/SOGo/SOGoParentFolder.m | 23 ++++++++++++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 291905595..557baaff5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-12-17 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder + -lookupName:nameinContext:lookupContextacquire:acquire]): we avoid + getting subscribed sources if not needed, which reduces the amount + of requests to the database. + * UI/Scheduler/UIxAppointmentEditor.m ([UIxAppointmentEditor -dealloc]): we release componentCalendar here to avoid a leak (since if set, it was through a call to ASSIGN()). diff --git a/SoObjects/SOGo/SOGoParentFolder.h b/SoObjects/SOGo/SOGoParentFolder.h index b98b9366e..965b2cf2e 100644 --- a/SoObjects/SOGo/SOGoParentFolder.h +++ b/SoObjects/SOGo/SOGoParentFolder.h @@ -34,6 +34,7 @@ NSMutableDictionary *subFolders; NSString *OCSPath; Class subFolderClass; + BOOL hasSubscribedSources; } + (NSString *) gcsFolderType; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 35210485d..ae5b58969 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -107,6 +107,7 @@ static SoSecurityManager *sm = nil; subFolders = nil; OCSPath = nil; subFolderClass = Nil; + hasSubscribedSources = NO; } return self; @@ -317,19 +318,24 @@ static SoSecurityManager *sm = nil; - (void) initSubFolders { - NSString *login; - if (!subFolders) { subFolders = [NSMutableDictionary new]; [self appendPersonalSources]; [self appendSystemSources]; - login = [[context activeUser] login]; - if ([login isEqualToString: owner]) - [self appendSubscribedSources]; } } +- (void) _appendSubscribedSourcesIfNeeded +{ + NSString *login; + + login = [[context activeUser] login]; + if ([login isEqualToString: owner]) + [self appendSubscribedSources]; + hasSubscribedSources = YES; +} + - (id) lookupName: (NSString *) name inContext: (WOContext *) lookupContext acquire: (BOOL) acquire @@ -344,6 +350,11 @@ static SoSecurityManager *sm = nil; [self initSubFolders]; obj = [subFolders objectForKey: name]; + if (!obj && !hasSubscribedSources) + { + [self _appendSubscribedSourcesIfNeeded]; + obj = [subFolders objectForKey: name]; + } } return obj; @@ -353,6 +364,8 @@ static SoSecurityManager *sm = nil; { if (!subFolders) [self initSubFolders]; + if (!!hasSubscribedSources) + [self _appendSubscribedSourcesIfNeeded]; return [[subFolders allValues] sortedArrayUsingSelector: @selector (compare:)];