Monotone-Parent: 659def76b8868bdc540986987d61b39410737054

Monotone-Revision: 6eed7e248c203a0103250e46033fc47b929ee536

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-02-03T16:12:22
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-02-03 16:12:22 +00:00
parent f3e23ff651
commit bb2373ebe6
12 changed files with 176 additions and 108 deletions
-2
View File
@@ -33,12 +33,10 @@
@interface SOGo : SoApplication
{
NSMutableDictionary *localeLUT;
SOGoCache *cache;
}
- (NSDictionary *) currentLocaleConsideringLanguages:(NSArray *)_langs;
- (NSDictionary *) localeForLanguageNamed:(NSString *)_name;
- (NSString *) davURLAsString;
@end
+3 -80
View File
@@ -60,6 +60,7 @@
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoWebAuthenticator.h>
#import <SOGo/WORequest+SOGo.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import <SOGo/NSObject+DAV.h>
#import "NSException+Stacktrace.h"
@@ -125,9 +126,6 @@ static BOOL debugLeaks;
[$(@"SOGoContentObject") soClass];
[$(@"SOGoFolder") soClass];
/* setup locale cache */
localeLUT = [[NSMutableDictionary alloc] initWithCapacity:2];
/* load products */
[[SOGoProductLoader productLoader] loadAllProducts];
@@ -140,12 +138,6 @@ static BOOL debugLeaks;
return self;
}
- (void) dealloc
{
[localeLUT release];
[super dealloc];
}
#warning the following methods should be replaced with helpers in GCSSpecialQueries
- (NSString *) _sqlScriptForTable: (NSString *) tableName
withType: (NSString *) tableType
@@ -497,86 +489,17 @@ static BOOL debugLeaks;
lname = [enumerator nextObject];
while (lname && !locale)
{
locale = [self localeForLanguageNamed: lname];
locale = [[self resourceManager] localeForLanguageNamed: lname];
lname = [enumerator nextObject];
}
if (!locale)
locale = [self localeForLanguageNamed: @"English"];
locale = [[self resourceManager] localeForLanguageNamed: @"English"];
/* no appropriate language, fallback to default */
return locale;
}
- (NSString *) pathToLocaleForLanguageNamed: (NSString *) _name
{
static Class MainProduct = Nil;
NSString *lpath;
lpath = [[self resourceManager] pathForResourceNamed: @"Locale"
inFramework: nil
languages: [NSArray arrayWithObject:_name]];
if (![lpath length])
{
if (!MainProduct)
{
MainProduct = $(@"MainUIProduct");
if (!MainProduct)
[self errorWithFormat: @"did not find MainUIProduct class!"];
}
lpath = [(id) MainProduct pathToLocaleForLanguageNamed: _name];
if (![lpath length])
lpath = nil;
}
return lpath;
}
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name
{
NSString *lpath;
id data;
NSDictionary *locale;
locale = nil;
if ([_name length] > 0)
{
locale = [localeLUT objectForKey: _name];
if (!locale)
{
lpath = [self pathToLocaleForLanguageNamed:_name];
if (lpath)
{
data = [NSData dataWithContentsOfFile: lpath];
if (data)
{
data = [[[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding] autorelease];
locale = [data propertyList];
if (locale)
[localeLUT setObject: locale forKey: _name];
else
[self logWithFormat:@"%s couldn't load locale with name:%@",
__PRETTY_FUNCTION__,
_name];
}
else
[self logWithFormat:@"%s didn't find locale with name: %@",
__PRETTY_FUNCTION__,
_name];
}
else
[self errorWithFormat:@"did not find locale for language: %@", _name];
}
}
else
[self errorWithFormat:@"%s: name parameter must not be nil!",
__PRETTY_FUNCTION__];
return locale;
}
- (NSURL *) _urlPreferringParticle: (NSString *) expected
overThisOne: (NSString *) possible
{