From ff3e1fbb42f72a551b8164734432177bb6a3d0c7 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 11 Nov 2008 00:17:35 +0000 Subject: [PATCH] Dropped the SOGoUserManager class and moved its code to SOGoCache. Cleaned up the code a little bit. Monotone-Parent: f570fda8096334f1267b8f01d59732c4fa9943c6 Monotone-Revision: b338f502fe70efea6d0d06d3f5a745163d1dbaf7 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-11-11T00:17:35 Monotone-Branch: ca.inverse.sogo --- Main/SOGo.m | 1 - .../Appointments/SOGoAppointmentFolder.m | 5 +- .../Appointments/SOGoAppointmentObject.m | 1 - .../Appointments/SOGoCalendarComponent.m | 1 - .../SOGoUserFolder+Appointments.m | 1 - SoObjects/SOGo/GNUmakefile | 2 - SoObjects/SOGo/SOGoCache.h | 3 + SoObjects/SOGo/SOGoCache.m | 109 +++++++++- SoObjects/SOGo/SOGoDAVAuthenticator.m | 1 - SoObjects/SOGo/SOGoGCSFolder.m | 1 - SoObjects/SOGo/SOGoObject.m | 1 - SoObjects/SOGo/SOGoUser.h | 8 +- SoObjects/SOGo/SOGoUser.m | 80 ++++---- SoObjects/SOGo/SOGoUserDefaults.m | 2 +- SoObjects/SOGo/SOGoUserFolder.m | 1 - SoObjects/SOGo/SOGoUserManager.h | 47 ----- SoObjects/SOGo/SOGoUserManager.m | 189 ------------------ SoObjects/SOGo/SOGoWebAuthenticator.m | 1 - 18 files changed, 158 insertions(+), 296 deletions(-) delete mode 100644 SoObjects/SOGo/SOGoUserManager.h delete mode 100644 SoObjects/SOGo/SOGoUserManager.m diff --git a/Main/SOGo.m b/Main/SOGo.m index e3ca9f886..877e389f7 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -418,7 +418,6 @@ static BOOL debugObjectAllocation = NO; startDate = [NSDate date]; } -// sleep (1); cache = [SOGoCache sharedCache]; resp = [super dispatchRequest: _request]; [SOGoCache killCache]; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 5aaa3938a..fa0f85ad8 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -63,7 +63,6 @@ #import #import #import -#import #import #import @@ -1627,7 +1626,9 @@ static Class sogoAppointmentFolderKlass = Nil; { record = [records objectAtIndex: count]; recordURL = [cnames objectForKey: [record objectForKey: @"c_name"]]; - [components setObject: record forKey: recordURL]; + + if (recordURL) + [components setObject: record forKey: recordURL]; } return components; diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 97faf8401..bdb479026 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -40,7 +40,6 @@ #import #import #import -#import #import #import #import diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index d94176120..7973380ed 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -46,7 +46,6 @@ #import #import #import -#import #import #import diff --git a/SoObjects/Appointments/SOGoUserFolder+Appointments.m b/SoObjects/Appointments/SOGoUserFolder+Appointments.m index 1924f128d..211c72460 100644 --- a/SoObjects/Appointments/SOGoUserFolder+Appointments.m +++ b/SoObjects/Appointments/SOGoUserFolder+Appointments.m @@ -31,7 +31,6 @@ #import #import -#import #import #import diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index f79ca6692..7b9f8e670 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -53,7 +53,6 @@ SOGo_HEADER_FILES = \ SOGoWebDAVValue.h \ SOGoMailer.h \ SOGoUser.h \ - SOGoUserManager.h \ \ NSDictionary+BSJSONAdditions.h \ NSScanner+BSJSONAdditions.h \ @@ -99,7 +98,6 @@ SOGo_OBJC_FILES = \ SOGoWebDAVValue.m \ SOGoMailer.m \ SOGoUser.m \ - SOGoUserManager.m \ \ NSDictionary+BSJSONAdditions.m \ NSScanner+BSJSONAdditions.m \ diff --git a/SoObjects/SOGo/SOGoCache.h b/SoObjects/SOGo/SOGoCache.h index b170687d8..8664a2394 100644 --- a/SoObjects/SOGo/SOGoCache.h +++ b/SoObjects/SOGo/SOGoCache.h @@ -3,6 +3,7 @@ * Copyright (C) 2008 Inverse inc. * * Author: Wolfgang Sourdeau + * Ludovic Marcotte * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +28,7 @@ @class NSMutableDictionary; @class NSString; +@class NSTimer; @class SOGoObject; @class SOGoUser; @@ -35,6 +37,7 @@ { NSMutableDictionary *cache; NSMutableDictionary *users; + NSTimer *_cleanupTimer; } + (SOGoCache *) sharedCache; diff --git a/SoObjects/SOGo/SOGoCache.m b/SoObjects/SOGo/SOGoCache.m index eedc497fd..96c3bc0a0 100644 --- a/SoObjects/SOGo/SOGoCache.m +++ b/SoObjects/SOGo/SOGoCache.m @@ -3,6 +3,7 @@ * Copyright (C) 2008 Inverse inc. * * Author: Wolfgang Sourdeau + * Ludovic Marcotte * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,15 +23,24 @@ #import #import +#import +#import #import +#import +#import #import +#import #import "SOGoObject.h" #import "SOGoUser.h" #import "SOGoCache.h" +// We define the default value for cleaning up cached +// users' preferences. This value should be relatively high +// to avoid useless database calls. +static NSTimeInterval cleanupInterval = 1800; static SOGoCache *sharedCache = nil; @implementation SOGoCache @@ -53,8 +63,38 @@ static SOGoCache *sharedCache = nil; { if ((self = [super init])) { + NSString *cleanupSetting; + cache = [NSMutableDictionary new]; users = [NSMutableDictionary new]; + + // We register ourself for notifications + [[NSDistributedNotificationCenter defaultCenter] + addObserver: self + selector: @selector(_userDefaultsHaveChanged:) + name: @"SOGoUserDefaultsHaveChanged" + object: nil]; + + [[NSDistributedNotificationCenter defaultCenter] + addObserver: self + selector: @selector(_userSettingsHaveChanged:) + name: @"SOGoUserSettingsHaveChanged" + object: nil]; + + // We fire our timer that will cleanup cache entries + cleanupSetting = [[NSUserDefaults standardUserDefaults] + objectForKey: @"SOGoCacheCleanupInterval"]; + + if (cleanupSetting && [cleanupSetting doubleValue] > 0.0) + cleanupInterval = [cleanupSetting doubleValue]; + + _cleanupTimer = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval + target: self + selector: @selector(_cleanupSources) + userInfo: nil + repeats: YES]; + [self logWithFormat: @"cleanup interval set every %f seconds", + cleanupInterval]; } return self; @@ -128,16 +168,75 @@ static SOGoCache *sharedCache = nil; - (void) registerUser: (SOGoUser *) user { -// NSLog (@"registerUser: %@", user); - - [users setObject: user forKey: [user login]]; + NSDate *cleanupDate; + + cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval]; + + [users setObject: [NSMutableDictionary dictionaryWithObjectsAndKeys: user, @"user", cleanupDate, @"cleanupDate", nil] + forKey: [user login]]; } - (id) userNamed: (NSString *) name { -// NSLog (@"userNamed: %@", name); + return [[users objectForKey: name] objectForKey: @"user"]; +} - return [users objectForKey: name]; + +- (void) _userDefaultsHaveChanged: (NSNotification *) theNotification +{ + NSMutableDictionary *d; + NSString *user; + + d = [[NSMutableDictionary alloc] init]; + [d addEntriesFromDictionary: [theNotification userInfo]]; + + user = [d objectForKey: @"uid"]; + [d removeObjectForKey: @"uid"]; + + [SOGoUser setUserDefaultsFromDictionary: d user: user]; + [d release]; +} + +- (void) _userSettingsHaveChanged: (NSNotification *) theNotification +{ + NSMutableDictionary *d; + NSString *user; + + d = [[NSMutableDictionary alloc] init]; + [d addEntriesFromDictionary: [theNotification userInfo]]; + + user = [d objectForKey: @"uid"]; + [d removeObjectForKey: @"uid"]; + + [SOGoUser setUserSettingsFromDictionary: d user: user]; + [d release]; +} + +- (void) _cleanupSources +{ + NSEnumerator *userIDs; + NSString *currentID; + NSDictionary *currentUser; + NSDate *now; + unsigned int count; + + now = [NSDate date]; + count = 0; + userIDs = [[users allKeys] objectEnumerator]; + + while ((currentID = [userIDs nextObject])) + { + currentUser = [users objectForKey: currentID]; + if ([now earlierDate: + [currentUser objectForKey: @"cleanupDate"]] == now) + { + [users removeObjectForKey: currentID]; + count++; + } + } + + if (count) + [self logWithFormat: @"cleaned %d users records from cache", count]; } @end diff --git a/SoObjects/SOGo/SOGoDAVAuthenticator.m b/SoObjects/SOGo/SOGoDAVAuthenticator.m index 6c8f59ce5..0b59e1459 100644 --- a/SoObjects/SOGo/SOGoDAVAuthenticator.m +++ b/SoObjects/SOGo/SOGoDAVAuthenticator.m @@ -32,7 +32,6 @@ #import "LDAPUserManager.h" #import "SOGoPermissions.h" #import "SOGoUser.h" -#import "SOGoUserManager.h" #import "SOGoDAVAuthenticator.h" diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 6ec796f5d..80e2a8b5b 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -60,7 +60,6 @@ #import "SOGoParentFolder.h" #import "SOGoPermissions.h" #import "SOGoUser.h" -#import "SOGoUserManager.h" #import "SOGoWebDAVAclManager.h" #import "WORequest+SOGo.h" diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 952ec7379..51fcfae78 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -61,7 +61,6 @@ #import "SOGoCache.h" #import "SOGoPermissions.h" #import "SOGoUser.h" -#import "SOGoUserManager.h" #import "SOGoUserFolder.h" #import "SOGoWebDAVAclManager.h" #import "SOGoWebDAVValue.h" diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index 973896a70..a453a73a6 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -63,8 +63,6 @@ extern NSString *SOGoWeekStartFirstFullWeek; @interface SOGoUser : SoUser { - SOGoUserDefaults *userDefaults; - SOGoUserDefaults *userSettings; NSArray *allEmails; NSString *language; NSString *currentPassword; @@ -112,10 +110,12 @@ extern NSString *SOGoWeekStartFirstFullWeek; /* defaults */ -- (void) setUserDefaultsFromDictionary: (NSDictionary *) theDictionary; ++ (void) setUserDefaultsFromDictionary: (NSDictionary *) theDictionary + user: (NSString *) login; - (NSUserDefaults *) userDefaults; -- (void) setUserSettingsFromDictionary: (NSDictionary *) theDictionary; ++ (void) setUserSettingsFromDictionary: (NSDictionary *) theDictionary + user: (NSString *) login; - (NSUserDefaults *) userSettings; - (NSString *) language; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 4ba77512e..9053c1f33 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -46,6 +46,9 @@ #import "SOGoUser.h" +static NSMutableDictionary *userDefaults; +static NSMutableDictionary *userSettings; + static NSTimeZone *serverTimeZone = nil; static NSString *fallbackIMAP4Server = nil; static BOOL fallbackIsConfigured = NO; @@ -192,6 +195,9 @@ _timeValue (NSString *key) // acceptAnyUser = ([[ud stringForKey: @"SOGoAuthentificationMethod"] // isEqualToString: @"bypass"]); + + userDefaults = [[NSMutableDictionary alloc] init]; + userSettings = [[NSMutableDictionary alloc] init]; } + (NSString *) language @@ -260,8 +266,6 @@ _timeValue (NSString *key) { if ((self = [super initWithLogin: realUID roles: newRoles])) { - userDefaults = nil; - userSettings = nil; allEmails = nil; language = nil; currentPassword = nil; @@ -283,8 +287,6 @@ _timeValue (NSString *key) - (void) dealloc { - [userDefaults release]; - [userSettings release]; [allEmails release]; [language release]; [currentPassword release]; @@ -413,8 +415,8 @@ _timeValue (NSString *key) doSave = NO; } if (doSave) - [userDefaults setObject: [self mailAccounts] - forKey: @"MailAccounts"]; + [[self userDefaults] setObject: [self mailAccounts] + forKey: @"MailAccounts"]; else [self logWithFormat: @"saving mail accounts is disabled until the" @" variable(s) mentionned above are configured"]; @@ -471,54 +473,58 @@ _timeValue (NSString *key) /* defaults */ - (void) setUserDefaultsFromDictionary: (NSDictionary *) theDictionary + user: (NSString *) login { - if (!userDefaults) - userDefaults = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL - uid: login - fieldName: @"c_defaults"]; - [userDefaults setValues: theDictionary]; + [userDefaults setObject: theDictionary forKey: login]; } - (NSUserDefaults *) userDefaults { - if (!userDefaults) - { - userDefaults - = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL + id o; + + o = [userDefaults objectForKey: login]; + if (!o) + { + o = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL uid: login fieldName: @"c_defaults"]; /* Required parameters for the web interface */ - if (![[userDefaults stringForKey: @"ReplyPlacement"] length]) - [userDefaults setObject: defaultReplyPlacement forKey: @"ReplyPlacement"]; - if (![[userDefaults stringForKey: @"SignaturePlacement"] length]) - [userDefaults setObject: defaultSignaturePlacement forKey: @"SignaturePlacement"]; - if (![[userDefaults stringForKey: @"MessageForwarding"] length]) - [userDefaults setObject: defaultMessageForwarding forKey: @"MessageForwarding"]; - if (![[userDefaults stringForKey: @"MessageCheck"] length]) - [userDefaults setObject: defaultMessageCheck forKey: @"MessageCheck"]; + if (![[o stringForKey: @"ReplyPlacement"] length]) + [o setObject: defaultReplyPlacement forKey: @"ReplyPlacement"]; + if (![[o stringForKey: @"SignaturePlacement"] length]) + [o setObject: defaultSignaturePlacement forKey: @"SignaturePlacement"]; + if (![[o stringForKey: @"MessageForwarding"] length]) + [o setObject: defaultMessageForwarding forKey: @"MessageForwarding"]; + if (![[o stringForKey: @"MessageCheck"] length]) + [o setObject: defaultMessageCheck forKey: @"MessageCheck"]; + + [userDefaults setObject: o forKey: login]; } - return userDefaults; + return o; } -- (void) setUserSettingsFromDictionary: (NSDictionary *) theDictionary ++ (void) setUserSettingsFromDictionary: (NSDictionary *) theDictionary + user: (NSString *) login { - if (!userSettings) - userSettings = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL - uid: login - fieldName: @"c_settings"]; - [userSettings setValues: theDictionary]; + [userSettings setObject: theDictionary forKey: login]; } - (NSUserDefaults *) userSettings { - if (!userSettings) - userSettings - = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL - uid: login - fieldName: @"c_settings"]; + id o; + + o = [userSettings objectForKey: login]; - return userSettings; + if (!o) + { + o = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL + uid: login + fieldName: @"c_settings"]; + [userSettings setObject: o forKey: login]; + } + + return o; } - (NSString *) language @@ -626,7 +632,7 @@ _timeValue (NSString *key) NSCalendarDate *januaryFirst, *firstWeek; unsigned int dayOfWeek; - firstWeekRule = [userDefaults objectForKey: @"FirstWeek"]; + firstWeekRule = [[self userDefaults] objectForKey: @"FirstWeek"]; januaryFirst = [NSCalendarDate dateWithYear: [date yearOfCommonEra] month: 1 day: 1 hour: 0 minute: 0 second: 0 diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index bba5b9d5f..f9dd3008c 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -275,7 +275,7 @@ static NSString *uidColumnName = @"c_uid"; [d addEntriesFromDictionary: values]; [d setObject: uid forKey: @"uid"]; -#warning reenable when the code to use the SOGoUserManager is finished +#warning reenable when the code to use the SOGoCache is finished #if 0 [[NSDistributedNotificationCenter defaultCenter] postNotificationName: ([fieldName isEqualToString: @"c_defaults"] ? @"SOGoUserDefaultsHaveChanged" : @"SOGoUserSettingsHaveChanged") diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 2749aaa7d..3026658d4 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -52,7 +52,6 @@ #import "LDAPUserManager.h" #import "SOGoPermissions.h" #import "SOGoUser.h" -#import "SOGoUserManager.h" #import "SOGoUserFolder.h" diff --git a/SoObjects/SOGo/SOGoUserManager.h b/SoObjects/SOGo/SOGoUserManager.h deleted file mode 100644 index f4e016de4..000000000 --- a/SoObjects/SOGo/SOGoUserManager.h +++ /dev/null @@ -1,47 +0,0 @@ -/* SOGoUserManager.h - this file is part of SOGo - * - * Copyright (C) 2008 Inverse inc. - * - * Author: Ludovic Marcotte - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef SOGOUSERMANAGER_H -#define SOGOUSERMANAGER_H - -#import - -@class NSArray; -@class NSMutableDictionary; -@class NSString; -@class NSTimer; -@class SOGoUser; - -@interface SOGoUserManager : NSObject -{ - @private - NSMutableDictionary *_cache; - NSTimer *_cleanupTimer; -} - -+ (id) sharedManager; -- (SOGoUser *) userWithLogin: (NSString *) theLogin - roles: (NSArray *) theRoles; - -@end - -#endif diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m deleted file mode 100644 index 39a1baa44..000000000 --- a/SoObjects/SOGo/SOGoUserManager.m +++ /dev/null @@ -1,189 +0,0 @@ -/* SOGoUserManager.m - this file is part of SOGo - * - * Copyright (C) 2008 Inverse inc. - * - * Author: Ludovic Marcotte - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "SOGoUserManager.h" - -#include -#include -#include -#include -#include -#include - -#import - -#include "SOGoUser.h" - -// We define the default value for cleaning up cached -// users' preferences. This value should be relatively high -// to avoid useless database calls. -static NSTimeInterval cleanupInterval = 1800; - -@implementation SOGoUserManager - -- (id) init -{ - NSString *cleanupSetting; - - if ((self = [super init])) - { - _cache = [[NSMutableDictionary alloc] init]; - } - - // We register ourself for notifications - [[NSDistributedNotificationCenter defaultCenter] - addObserver: self - selector: @selector(_userDefaultsHaveChanged:) - name: @"SOGoUserDefaultsHaveChanged" - object: nil]; - - [[NSDistributedNotificationCenter defaultCenter] - addObserver: self - selector: @selector(_userSettingsHaveChanged:) - name: @"SOGoUserSettingsHaveChanged" - object: nil]; - - // We fire our timer that will cleanup cache entries - cleanupSetting = [[NSUserDefaults standardUserDefaults] - objectForKey: @"SOGoUserManagerCleanupInterval"]; - - if (cleanupSetting && [cleanupSetting doubleValue] > 0.0) - cleanupInterval = [cleanupSetting doubleValue]; - - _cleanupTimer = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval - target: self - selector: @selector(_cleanupSources) - userInfo: nil - repeats: YES]; - [self logWithFormat: @"cleanup interval set every %f seconds", - cleanupInterval]; - - return self; -} - -- (void) dealloc -{ - [_cache release]; - [super dealloc]; -} - -+ (id) sharedManager -{ - static id sharedManager = nil; - - if (!sharedManager) - sharedManager = [self new]; - - return sharedManager; -} - -- (SOGoUser *) userWithLogin: (NSString *) theLogin - roles: (NSArray *) theRoles -{ - NSDate *cleanupDate; - SOGoUser *user; - id entry; - - cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval]; - entry = [_cache objectForKey: theLogin]; - - if (!entry) - { - user = [SOGoUser userWithLogin: theLogin roles: theRoles]; - - entry = [NSMutableDictionary dictionaryWithObjectsAndKeys: user, @"user", cleanupDate, @"cleanupDate", nil]; - [_cache setObject: entry forKey: theLogin]; - } - else - { - [entry setObject: cleanupDate forKey: @"cleanupDate"]; - user = [entry objectForKey: @"user"]; - } - - [user setPrimaryRoles: theRoles]; - - return user; -} - -// -// Private stuff -// -- (void) _userDefaultsHaveChanged: (NSNotification *) theNotification -{ - NSMutableDictionary *d; - SOGoUser *user; - - d = [[NSMutableDictionary alloc] init]; - [d addEntriesFromDictionary: [theNotification userInfo]]; - - user = [self userWithLogin: [d objectForKey: @"uid"] - roles: nil]; - - [d removeObjectForKey: @"uid"]; - [user setUserDefaultsFromDictionary: d]; - [d release]; -} - -- (void) _userSettingsHaveChanged: (NSNotification *) theNotification -{ - NSMutableDictionary *d; - SOGoUser *user; - - d = [[NSMutableDictionary alloc] init]; - [d addEntriesFromDictionary: [theNotification userInfo]]; - - user = [self userWithLogin: [d objectForKey: @"uid"] - roles: nil]; - - [d removeObjectForKey: @"uid"]; - [user setUserSettingsFromDictionary: d]; - [d release]; -} - -- (void) _cleanupSources -{ - NSEnumerator *userIDs; - NSString *currentID; - NSDictionary *currentUser; - NSDate *now; - unsigned int count; - - now = [NSDate date]; - count = 0; - userIDs = [[_cache allKeys] objectEnumerator]; - - while ((currentID = [userIDs nextObject])) - { - currentUser = [_cache objectForKey: currentID]; - if ([now earlierDate: - [currentUser objectForKey: @"cleanupDate"]] == now) - { - [_cache removeObjectForKey: currentID]; - count++; - } - } - - if (count) - [self logWithFormat: @"cleaned %d users records from cache", count]; -} - -@end diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.m b/SoObjects/SOGo/SOGoWebAuthenticator.m index 23a0a3d61..42699608f 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.m +++ b/SoObjects/SOGo/SOGoWebAuthenticator.m @@ -40,7 +40,6 @@ #import "LDAPUserManager.h" #import "SOGoPermissions.h" #import "SOGoUser.h" -#import "SOGoUserManager.h" #import "SOGoWebAuthenticator.h"