Monotone-Parent: 5fa8ca8896455803ea0da4db7e5c1e18e8328871

Monotone-Revision: a6e08bd7d394d186c6f5606933ed09de2031e7bb

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-02-07T16:53:19
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2008-02-07 16:53:19 +00:00
parent c853bcf944
commit dd226e2998
6 changed files with 100 additions and 20 deletions

View File

@@ -1,3 +1,20 @@
2008-02-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/PreferencesUI/UIxPreferences.m ([UIxPreferences
-setSignature:newSignature]): invoke -[SOGoUser saveMailAccounts]
* SoObjects/SOGo/SOGoUser.m ([SOGoUser -defaultIdentity]): method
moved from UIxPreferences.m.
([SOGoUser -saveMailAccounts]): new methods that save the
"MailAccounts" preference in the user settings.
* SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager
+initialize]): issue a warning whenever "SOGoDefaultMailDomain"
is not configured in the user defaults, setting it to "localhost"
by default.
([LDAPUserManager +defaultMailDomainIsConfigured]): new method
that returns whether "SOGoDefaultMailDomain" is configured.
2008-02-06 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder -ocsFolder]):

View File

@@ -43,6 +43,8 @@
+ (id) sharedUserManager;
+ (BOOL) defaultMailDomainIsConfigured;
- (NSArray *) sourceIDs;
- (NSDictionary *) metadataForSourceID: (NSString *) sourceID;
- (NSArray *) authenticationSourceIDs;

View File

@@ -26,12 +26,14 @@
#import <Foundation/NSTimer.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
#import <NGExtensions/NSObject+Logs.h>
#import "NSArray+Utilities.h"
#import "LDAPSource.h"
#import "LDAPUserManager.h"
static NSString *defaultMailDomain = nil;
static BOOL defaultMailDomainIsConfigured = NO;
@implementation LDAPUserManager
@@ -44,7 +46,20 @@ static NSString *defaultMailDomain = nil;
{
defaultMailDomain = [ud stringForKey: @"SOGoDefaultMailDomain"];
[defaultMailDomain retain];
defaultMailDomainIsConfigured = YES;
}
if (!defaultMailDomain)
{
[self warnWithFormat:
@"no domain specified for SOGoDefaultMailDomain,"
@" value set to 'localhost'"];
defaultMailDomain = @"localhost";
}
}
+ (BOOL) defaultMailDomainIsConfigured
{
return defaultMailDomainIsConfigured;
}
+ (id) sharedUserManager

View File

@@ -77,6 +77,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
+ (SOGoUser *) userWithLogin: (NSString *) login
roles: (NSArray *) roles;
- (void) setPrimaryRoles: (NSArray *) newRoles;
- (void) setCurrentPassword: (NSString *) newPassword;
- (NSString *) currentPassword;
@@ -117,11 +120,14 @@ extern NSString *SOGoWeekStartFirstFullWeek;
- (NSArray *) mailAccounts;
- (NSArray *) allIdentities;
- (NSDictionary *) primaryIdentity;
- (NSMutableDictionary *) defaultIdentity;
- (NSString *) messageForwarding;
- (NSString *) messageCheck;
- (NSString *) signature;
- (void) saveMailAccounts;
- (BOOL) isSuperUser;
/* module access */

View File

@@ -29,6 +29,7 @@
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/SoObject.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import "AgenorUserDefaults.h"
#import "LDAPUserManager.h"
@@ -42,6 +43,7 @@
static NSTimeZone *serverTimeZone = nil;
static NSString *fallbackIMAP4Server = nil;
static BOOL fallbackIsConfigured = NO;
static NSString *defaultLanguage = nil;
static NSArray *superUsernames = nil;
static NSURL *AgenorProfileURL = nil;
@@ -92,6 +94,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
if (!fallbackIMAP4Server)
ASSIGN (fallbackIMAP4Server,
[ud stringForKey: @"SOGoFallbackIMAP4Server"]);
if (fallbackIMAP4Server)
fallbackIsConfigured = YES;
else
{
[self warnWithFormat:
@"no server specified for SOGoFallbackIMAP4Server,"
@" value set to 'localhost'"];
fallbackIMAP4Server = @"localhost";
}
if (!defaultLanguage)
{
ASSIGN (defaultLanguage, [ud stringForKey: @"SOGoDefaultLanguage"]);
@@ -122,6 +134,11 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
return lng;
}
+ (NSString *) fallbackIMAP4Server
{
return fallbackIMAP4Server;
}
+ (SOGoUser *) userWithLogin: (NSString *) newLogin
roles: (NSArray *) newRoles
{
@@ -176,6 +193,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
realUID = [[um contactInfosForUserWithUIDorEmail: newLogin]
objectForKey: @"c_uid"];
}
if (realUID)
self = [super initWithLogin: realUID roles: newRoles];
else
@@ -284,6 +302,45 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
return cn;
}
- (NSMutableDictionary *) defaultIdentity
{
NSMutableDictionary *currentIdentity, *defaultIdentity;
NSEnumerator *identities;
defaultIdentity = nil;
identities = [[self allIdentities] objectEnumerator];
while (!defaultIdentity
&& (currentIdentity = [identities nextObject]))
if ([[currentIdentity objectForKey: @"isDefault"] boolValue])
defaultIdentity = currentIdentity;
return defaultIdentity;
}
- (void) saveMailAccounts
{
BOOL doSave;
doSave = YES;
if (!fallbackIsConfigured)
{
[self logWithFormat: @"'SOGoFallbackIMAP4Server' is not set"];
doSave = NO;
}
if (![LDAPUserManager defaultMailDomainIsConfigured])
{
[self logWithFormat: @"'SOGoDefaultMailDomain' is not set"];
doSave = NO;
}
if (doSave)
[userDefaults setObject: [self mailAccounts]
forKey: @"MailAccounts"];
else
[self logWithFormat: @"saving mail accounts is disabled until the"
@" variable(s) mentionned above are configured"];
}
// - (NSString *) primaryMailServer
// {
// return [[self userManager] getServerForUID: [self login]];

View File

@@ -486,33 +486,16 @@ static BOOL shouldDisplayPasswordChange = NO;
return [(NSDictionary *) item keysWithFormat: @"%{fullName} <%{email}>"];
}
- (NSMutableDictionary *) defaultIdentity
{
NSMutableDictionary *currentIdentity, *defaultIdentity;
NSEnumerator *identities;
defaultIdentity = nil;
identities = [[user allIdentities] objectEnumerator];
while (!defaultIdentity
&& (currentIdentity = [identities nextObject]))
if ([[currentIdentity objectForKey: @"isDefault"] boolValue])
defaultIdentity = currentIdentity;
return defaultIdentity;
}
- (NSString *) signature
{
return [[self defaultIdentity] objectForKey: @"signature"];
return [[user defaultIdentity] objectForKey: @"signature"];
}
- (void) setSignature: (NSString *) newSignature
{
[[self defaultIdentity] setObject: newSignature
[[user defaultIdentity] setObject: newSignature
forKey: @"signature"];
[userDefaults setObject: [user mailAccounts]
forKey: @"MailAccounts"];
[user saveMailAccounts];
}
- (id <WOActionResults>) defaultAction