Proper system defaults fallback for preferences

(Bug #145)

Monotone-Parent: 86d5fda1266a9ae6071c1b0c48daa229594679fb
Monotone-Revision: 33a4befb91778f46b962f6c895f7697b0d1df722

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-10-06T18:12:07
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2009-10-06 18:12:07 +00:00
parent a9f4d77c2c
commit 725878ebdb
8 changed files with 99 additions and 36 deletions
+53 -7
View File
@@ -58,6 +58,7 @@ static NSString *defaultReplyPlacement = nil;
static NSString *defaultSignaturePlacement = nil;
static NSString *defaultMessageForwarding = nil;
static NSString *defaultMessageCheck = nil;
static NSString *defaultTimeFormat = nil;
static NSArray *superUsernames = nil;
static NSURL *SOGoProfileURL = nil;
// static BOOL acceptAnyUser = NO;
@@ -89,13 +90,19 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
static int
_timeValue (NSString *key)
{
int time;
int i, time;
if (key && [key length] > 1)
time = [[key substringToIndex: 2] intValue];
if (key && [key length] > 0)
{
i = [key rangeOfString: @":"].location;
if (i != NSNotFound)
time = [[key substringToIndex: i] intValue];
else
time = [key intValue];
}
else
time = -1;
return time;
}
@@ -191,6 +198,12 @@ _timeValue (NSString *key)
if (!defaultMessageCheck)
ASSIGN (defaultMessageCheck, @"manually");
}
if (!defaultTimeFormat)
{
ASSIGN (defaultTimeFormat, [ud stringForKey: @"SOGoTimeFormat"]);
if (!defaultTimeFormat)
ASSIGN (defaultTimeFormat, @"%H:00");
}
if (!superUsernames)
ASSIGN (superUsernames, [ud arrayForKey: @"SOGoSuperUsernames"]);
@@ -662,6 +675,17 @@ _timeValue (NSString *key)
return limit;
}
- (NSString *) timeFormat
{
NSString *timeFormat;
timeFormat = [[self userDefaults] stringForKey: @"TimeFormat"];
if (!timeFormat)
timeFormat = defaultTimeFormat;
return timeFormat;
}
- (NSCalendarDate *) firstWeekOfYearForDate: (NSCalendarDate *) date
{
NSString *firstWeekRule;
@@ -891,17 +915,39 @@ _timeValue (NSString *key)
- (NSString *) replyPlacement
{
return [[self userDefaults] stringForKey: @"ReplyPlacement"];
NSString *replyPlacement = [[self userDefaults] stringForKey: @"ReplyPlacement"];
if (!replyPlacement)
replyPlacement = defaultReplyPlacement;
return replyPlacement;
}
- (NSString *) signaturePlacement
{
return [[self userDefaults] stringForKey: @"SignaturePlacement"];
NSString *signaturePlacement;
if ([[self replyPlacement] isEqualToString: @"below"])
// When replying to an email, if the reply is below the quoted text,
// the signature must also be below the quoted text.
signaturePlacement = @"below";
else
{
signaturePlacement = [[self userDefaults] stringForKey: @"SignaturePlacement"];
if (!signaturePlacement)
signaturePlacement = defaultSignaturePlacement;
}
return signaturePlacement;
}
- (NSString *) messageForwarding
{
return [[self userDefaults] stringForKey: @"MessageForwarding"];
NSString *messageForwarding = [[self userDefaults] stringForKey: @"MessageForwarding"];
if (!messageForwarding)
messageForwarding = defaultMessageForwarding;
return messageForwarding;
}
/* folders */