merge of '887c25db6d397495f0b51cedfe52e01f2315a1db'

and 'a830e73fbed57c6ef30ede64ea5bfa6d85af8f74'

Monotone-Parent: 887c25db6d397495f0b51cedfe52e01f2315a1db
Monotone-Parent: a830e73fbed57c6ef30ede64ea5bfa6d85af8f74
Monotone-Revision: 6d0fa6e2fd8ea58ea9fdb11b3d3140f9f8c58538

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2011-02-03T18:51:16
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2011-02-03 18:51:16 +00:00
commit 244fab36d6
16 changed files with 185 additions and 113 deletions

View File

@ -1,3 +1,14 @@
2011-02-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/WOResourceManager+SOGo.m: new category module
defining methods useful to the vanilla and OpenChange frontends.
(-localeForLanguageNamed:): method moved from SOGo.m.
2011-02-01 Ludovic Marcotte <lmarcotte@inverse.ca>
* SoObjects/SOGo/NSString+Utilities.h,m: Fixed
the salt for crypt-based encoding
2011-02-01 Francis Lachapelle <flachapelle@inverse.ca>
* UI/WebServerResources/scriptaculous/dragdrop.js (-updateDrag:):

View File

@ -33,12 +33,10 @@
@interface SOGo : SoApplication
{
NSMutableDictionary *localeLUT;
SOGoCache *cache;
}
- (NSDictionary *) currentLocaleConsideringLanguages:(NSArray *)_langs;
- (NSDictionary *) localeForLanguageNamed:(NSString *)_name;
- (NSString *) davURLAsString;
@end

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
{

View File

@ -56,7 +56,6 @@
forKey: (NSString *) childKey
withTag: (enum MAPITAGS) propTag
{
// id child;
NSTimeInterval timeValue;
id event;
int rc;

View File

@ -46,7 +46,7 @@ SOGo_HEADER_FILES = \
NSURL+DAV.h \
\
SOGoAuthenticator.h \
SOGoSession.h \
SOGoSession.h \
SOGoCASSession.h \
SOGoDAVAuthenticator.h \
SOGoProxyAuthenticator.h \
@ -60,6 +60,7 @@ SOGo_HEADER_FILES = \
DOMNode+SOGo.h \
\
WORequest+SOGo.h \
WOResourceManager+SOGo.h \
WOResponse+SOGo.h \
WOContext+SOGo.h
@ -123,6 +124,7 @@ SOGo_OBJC_FILES = \
DOMNode+SOGo.m \
\
WORequest+SOGo.m \
WOResourceManager+SOGo.m \
WOResponse+SOGo.m \
WOContext+SOGo.m

View File

@ -68,7 +68,7 @@
- (id) objectFromJSONString;
- (NSString *) asCryptString;
- (NSString *) asCryptStringUsingSalt: (NSString *) theSalt;
- (NSString *) asMD5String;
- (NSString *) asSHA1String;

View File

@ -545,13 +545,13 @@ static NSMutableCharacterSet *safeLDIFStartChars = nil;
return object;
}
- (NSString *) asCryptString
- (NSString *) asCryptStringUsingSalt: (NSString *) theSalt
{
char *buf;
// The salt is weak here, but who cares anyway, crypt should not
// be used anymore
buf = (char *)crypt([self UTF8String], [self UTF8String]);
buf = (char *)crypt([self UTF8String], [theSalt UTF8String]);
return [NSString stringWithUTF8String: buf];
}

View File

@ -50,8 +50,7 @@
#import "SOGoUserManager.h"
#import "SOGoUserProfile.h"
#import "SOGoUserSettings.h"
#import "../../Main/SOGo.h"
#import "WOResourceManager+SOGo.h"
#import "SOGoUser.h"
@ -283,12 +282,14 @@
NSString *format;
SOGoUserDefaults *ud;
NSDictionary *locale;
WOResourceManager *resMgr;
dateFormatter = [SOGoDateFormatter new];
[dateFormatter autorelease];
ud = [self userDefaults];
locale = [[WOApplication application] localeForLanguageNamed: [ud language]];
resMgr = [[WOApplication application] resourceManager];
locale = [resMgr localeForLanguageNamed: [ud language]];
[dateFormatter setLocale: locale];
format = [ud shortDateFormat];
if (format)

View File

@ -139,7 +139,7 @@
}
else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"crypt"] == NSOrderedSame)
{
return [[plainPassword asCryptString] isEqualToString: encryptedPassword];
return [[plainPassword asCryptStringUsingSalt: encryptedPassword] isEqualToString: encryptedPassword];
}
else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"md5"] == NSOrderedSame)
{

View File

@ -0,0 +1,34 @@
/* WOResourceManager+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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 WORESOURCEMANAGER_SOGO_H
#define WORESOURCEMANAGER_SOGO_H
#import <NGObjWeb/WOResourceManager.h>
@interface WOResourceManager (SOGoExtensions)
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name;
@end
#endif /* WORESOURCEMANAGER_SOGO_H */

View File

@ -0,0 +1,106 @@
/* WOResourceManager+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* 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.
*/
#import <Foundation/NSData.h>
#import <Foundation/NSDictionary.h>
#import <NGExtensions/NSObject+Logs.h>
#import "WOResourceManager+SOGo.h"
@implementation WOResourceManager (SOGoExtensions)
- (NSString *) pathToLocaleForLanguageNamed: (NSString *) _name
{
static Class MainProduct = Nil;
NSString *lpath;
lpath = [self pathForResourceNamed: @"Locale"
inFramework: nil
languages: [NSArray arrayWithObject:_name]];
if (![lpath length])
{
if (!MainProduct)
{
MainProduct = NSClassFromString (@"MainUIProduct");
if (!MainProduct)
[self errorWithFormat: @"did not find MainUIProduct class!"];
}
lpath = [(id) MainProduct performSelector: NSSelectorFromString (@"pathToLocaleForLanguageNamed:")
withObject: _name];
if (![lpath length])
lpath = nil;
}
return lpath;
}
- (NSDictionary *) localeForLanguageNamed: (NSString *) _name
{
NSString *lpath;
id data;
NSDictionary *locale;
static NSMutableDictionary *localeLUT = nil;
locale = nil;
if ([_name length] > 0)
{
if (!localeLUT)
localeLUT = [NSMutableDictionary new];
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;
}
@end

View File

@ -47,17 +47,16 @@
#import <NGMime/NGMimeType.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SoObjects/Mailer/SOGoDraftObject.h>
#import <SoObjects/Mailer/SOGoMailFolder.h>
#import <SoObjects/Mailer/SOGoMailAccount.h>
#import <SoObjects/Mailer/SOGoMailAccounts.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import <Mailer/SOGoDraftObject.h>
#import <Mailer/SOGoMailFolder.h>
#import <Mailer/SOGoMailAccount.h>
#import <Mailer/SOGoMailAccounts.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import <SOGoUI/UIxComponent.h>
#import "../../Main/SOGo.h"
/*
UIxMailEditor
@ -210,8 +209,8 @@ static NSArray *infoKeys = nil;
NSDictionary *locale;
ud = [[context activeUser] userDefaults];
locale = [[WOApplication application]
localeForLanguageNamed: [ud language]];
locale = [[self resourceManager]
localeForLanguageNamed: [ud language]];
// WARNING : NSLocaleCode is not defined in <Foundation/NSUserDefaults.h>
return [locale objectForKey: @"NSLocaleCode"];

View File

@ -40,8 +40,8 @@
#import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUserFolder.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import <Mailer/SOGoMailAccount.h>
#import "../../Main/SOGo.h"
#import "UIxPreferences.h"
@ -77,7 +77,7 @@
category = nil;
ASSIGN (locale,
[[WOApplication application] localeForLanguageNamed: language]);
[[self resourceManager] localeForLanguageNamed: language]);
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
dd = [user domainDefaults];

View File

@ -35,8 +35,7 @@
#import <SOGo/SOGoDateFormatter.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import "../../Main/SOGo.h"
#import <SOGo/WOResourceManager+SOGo.h>
#import "UIxCalDayTable.h"
@ -57,7 +56,7 @@
ud = [user userDefaults];
ASSIGN (timeFormat, [ud timeFormat]);
language = [ud language];
locale = [[WOApplication application] localeForLanguageNamed: language];
locale = [[self resourceManager] localeForLanguageNamed: language];
daysToDisplay = nil;
hoursToDisplay = nil;

View File

@ -30,10 +30,9 @@
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SOGoUI/SOGoAptFormatter.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoUserDefaults.h>
#import "../../Main/SOGo.h"
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import "UIxCalMonthView.h"
@ -52,7 +51,7 @@
// dateFormatter = [[SOGoDateFormatter alloc]
// initWithLocale: [self locale]];
ud = [[context activeUser] userDefaults];
locale = [[WOApplication application] localeForLanguageNamed: [ud language]];
locale = [[self resourceManager] localeForLanguageNamed: [ud language]];
dayNames = [locale objectForKey: NSWeekDayNameArray];
[dayNames retain];
monthNames = [locale objectForKey: NSMonthNameArray];

View File

@ -63,6 +63,7 @@
#import <SOGo/SOGoUserManager.h>
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import "../../Main/SOGo.h"
@ -1869,7 +1870,7 @@ RANGE(2);
NSDictionary *locale;
ud = [[context activeUser] userDefaults];
locale = [[WOApplication application]
locale = [[self resourceManager]
localeForLanguageNamed: [ud language]];
date = [NSCalendarDate dateWithString: [self range2]
calendarFormat: dateFormat