Monotone-Parent: fc73a7910531c479a442d9feae0af3acaaebaa52
Monotone-Revision: a74b906d58327f02724a366df126c83b4bdcc4c9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-09-02T02:48:18 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
95643f0e3a
commit
95ec0e4a19
|
@ -87,7 +87,8 @@ static BOOL forceImapLoginWithEmail = NO;
|
||||||
if (sourceID)
|
if (sourceID)
|
||||||
[sources setObject: ldapSource forKey: sourceID];
|
[sources setObject: ldapSource forKey: sourceID];
|
||||||
else
|
else
|
||||||
NSLog(@"LDAPUserManager.m: WARNING: id field missing in a LDAP source, check the SOGoLDAPSources default");
|
[self errorWithFormat: @"id field missing in a LDAP source,"
|
||||||
|
@" check the SOGoLDAPSources defaults"];
|
||||||
metadata = [NSMutableDictionary dictionary];
|
metadata = [NSMutableDictionary dictionary];
|
||||||
value = [udSource objectForKey: @"canAuthenticate"];
|
value = [udSource objectForKey: @"canAuthenticate"];
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -121,6 +122,7 @@ static BOOL forceImapLoginWithEmail = NO;
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
NSUserDefaults *ud;
|
NSUserDefaults *ud;
|
||||||
|
NSString *cleanupSetting;
|
||||||
|
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
|
@ -129,14 +131,24 @@ static BOOL forceImapLoginWithEmail = NO;
|
||||||
sources = nil;
|
sources = nil;
|
||||||
sourcesMetadata = nil;
|
sourcesMetadata = nil;
|
||||||
users = [NSMutableDictionary new];
|
users = [NSMutableDictionary new];
|
||||||
cleanupInterval
|
cleanupSetting
|
||||||
= [ud integerForKey: @"SOGoLDAPUserManagerCleanupInterval"];
|
= [ud objectForKey: @"SOGoLDAPUserManagerCleanupInterval"];
|
||||||
if (cleanupInterval)
|
if (cleanupSetting)
|
||||||
cleanupTimer = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval
|
cleanupInterval = [cleanupSetting doubleValue];
|
||||||
target: self
|
else
|
||||||
selector: @selector(cleanupSources)
|
cleanupInterval = 0.0;
|
||||||
userInfo: nil
|
if (cleanupInterval > 0.0)
|
||||||
repeats: YES];
|
{
|
||||||
|
cleanupTimer = [NSTimer scheduledTimerWithTimeInterval: cleanupInterval
|
||||||
|
target: self
|
||||||
|
selector: @selector (_cleanupSources)
|
||||||
|
userInfo: nil
|
||||||
|
repeats: YES];
|
||||||
|
[self logWithFormat: @"cleanup interval set every %f seconds",
|
||||||
|
cleanupInterval];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self logWithFormat: @"no cleanup interval set: memory usage will grow"];
|
||||||
[self _prepareLDAPSourcesWithDefaults: ud];
|
[self _prepareLDAPSourcesWithDefaults: ud];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,12 +396,8 @@ static BOOL forceImapLoginWithEmail = NO;
|
||||||
if (key)
|
if (key)
|
||||||
[users setObject: newUser forKey: key];
|
[users setObject: newUser forKey: key];
|
||||||
emails = [[newUser objectForKey: @"emails"] objectEnumerator];
|
emails = [[newUser objectForKey: @"emails"] objectEnumerator];
|
||||||
key = [emails nextObject];
|
while ((key = [emails nextObject]))
|
||||||
while (key)
|
[users setObject: newUser forKey: key];
|
||||||
{
|
|
||||||
[users setObject: newUser forKey: key];
|
|
||||||
key = [emails nextObject];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid
|
- (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid
|
||||||
|
@ -532,22 +540,32 @@ static BOOL forceImapLoginWithEmail = NO;
|
||||||
matching: filter];
|
matching: filter];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) cleanupSources
|
- (void) _cleanupSources
|
||||||
{
|
{
|
||||||
NSEnumerator *userIDs;
|
NSEnumerator *userIDs;
|
||||||
NSString *currentID;
|
NSString *currentID;
|
||||||
NSDictionary *currentUser;
|
NSDictionary *currentUser;
|
||||||
NSDate *now;
|
NSDate *now;
|
||||||
|
unsigned int count;
|
||||||
|
|
||||||
now = [NSDate date];
|
now = [NSDate date];
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
|
||||||
userIDs = [[users allKeys] objectEnumerator];
|
userIDs = [[users allKeys] objectEnumerator];
|
||||||
while ((currentID = [userIDs nextObject]))
|
while ((currentID = [userIDs nextObject]))
|
||||||
{
|
{
|
||||||
currentUser = [users objectForKey: currentID];
|
currentUser = [users objectForKey: currentID];
|
||||||
if ([now earlierDate:
|
if ([now earlierDate:
|
||||||
[currentUser objectForKey: @"cleanupDate"]] == now)
|
[currentUser objectForKey: @"cleanupDate"]] == now)
|
||||||
[users removeObjectForKey: currentID];
|
{
|
||||||
|
[users removeObjectForKey: currentID];
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
[self logWithFormat: @"cleaned %d users records from cache", count];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue