From 5100d6611d8422477e080adc2006fb9f5a621bbd Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 5 Nov 2008 17:26:02 +0000 Subject: [PATCH] Fix for feature #3079 Monotone-Parent: 1de4349e78aa0e2e7b5b5f1107576ae89d90f64e Monotone-Revision: 56b6e4ca9c570a4e36d00e32127d539e82da7293 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2008-11-05T17:26:02 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/GNUmakefile | 6 ++- SoObjects/SOGo/WOContext+SOGo.h | 34 +++++++++++++ SoObjects/SOGo/WOContext+SOGo.m | 53 +++++++++++++++++++++ SoObjects/SOGo/WORequest+SOGo.m | 1 + UI/MainUI/Dutch.lproj/Localizable.strings | 16 +++++++ UI/MainUI/English.lproj/Localizable.strings | 8 ++++ UI/MainUI/French.lproj/Localizable.strings | 8 ++++ UI/MainUI/German.lproj/Localizable.strings | 16 +++++++ UI/MainUI/Italian.lproj/Localizable.strings | 8 ++++ UI/MainUI/SOGoRootPage.h | 3 ++ UI/MainUI/SOGoRootPage.m | 49 ++++++++++++++++++- UI/MainUI/Spanish.lproj/Localizable.strings | 8 ++++ UI/Templates/MainUI/SOGoRootPage.wox | 9 ++++ UI/WebServerResources/SOGoRootPage.js | 7 ++- 14 files changed, 221 insertions(+), 5 deletions(-) create mode 100644 SoObjects/SOGo/WOContext+SOGo.h create mode 100644 SoObjects/SOGo/WOContext+SOGo.m diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 2aaf6e438..7b9f8e670 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -57,7 +57,8 @@ SOGo_HEADER_FILES = \ NSDictionary+BSJSONAdditions.h \ NSScanner+BSJSONAdditions.h \ \ - WORequest+SOGo.h + WORequest+SOGo.h \ + WOContext+SOGo.h # SOGoCustomGroupFolder.m \ # SOGoGroupsFolder.m \ @@ -101,7 +102,8 @@ SOGo_OBJC_FILES = \ NSDictionary+BSJSONAdditions.m \ NSScanner+BSJSONAdditions.m \ \ - WORequest+SOGo.m + WORequest+SOGo.m \ + WOContext+SOGo.m SOGo_RESOURCE_FILES = \ DAVReportMap.plist diff --git a/SoObjects/SOGo/WOContext+SOGo.h b/SoObjects/SOGo/WOContext+SOGo.h new file mode 100644 index 000000000..69b4db760 --- /dev/null +++ b/SoObjects/SOGo/WOContext+SOGo.h @@ -0,0 +1,34 @@ +/* WOContext+SOGo.h - this file is part of SOGo + * + * Copyright (C) 2008 Inverse inc. + * + * Author: Francis Lachapelle + * + * 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 WOCONTEXT_SOGo_H +#define WOCONTEXT_SOGo_H + +#import + +@interface WOContext (SOGoSOPEUtilities) + +- (NSArray *)resourceLookupLanguages; + +@end + +#endif /* WOcontext_SOGo_H */ diff --git a/SoObjects/SOGo/WOContext+SOGo.m b/SoObjects/SOGo/WOContext+SOGo.m new file mode 100644 index 000000000..cadcbaf3c --- /dev/null +++ b/SoObjects/SOGo/WOContext+SOGo.m @@ -0,0 +1,53 @@ +/* WOContext+SOGo.m - this file is part of SOGo + * + * Copyright (C) 2008 Inverse inc. + * + * Author: Francis Lachapelle + * + * 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 +#import + +#import +#import +#import + +#import + +#import "WOContext+SOGo.h" + +@implementation WOContext (SOGoSOPEUtilities) + +- (NSArray *) resourceLookupLanguages +{ + NSMutableArray *languages; + + languages = [NSMutableArray array]; + + if (activeUser && [activeUser language]) + [languages addObject: [activeUser language]]; + + if ([self hasSession]) + [languages addObjectsFromArray: [[self session] languages]]; + else + [languages addObjectsFromArray: [[self request] browserLanguages]]; + + return languages; +} + +@end diff --git a/SoObjects/SOGo/WORequest+SOGo.m b/SoObjects/SOGo/WORequest+SOGo.m index ab4e9b10b..46264e12c 100644 --- a/SoObjects/SOGo/WORequest+SOGo.m +++ b/SoObjects/SOGo/WORequest+SOGo.m @@ -20,6 +20,7 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import diff --git a/UI/MainUI/Dutch.lproj/Localizable.strings b/UI/MainUI/Dutch.lproj/Localizable.strings index 8734c1558..f9d91c3bd 100644 --- a/UI/MainUI/Dutch.lproj/Localizable.strings +++ b/UI/MainUI/Dutch.lproj/Localizable.strings @@ -6,3 +6,19 @@ "Password:" = "Wachtwoord:"; "Connect" = "Inloggen"; + +"Wrong username or password." = "Wrong username or password."; +"cookiesNotEnabled" = "You cannot login because your browser's cookies are disabled. Please enable cookies in your browser's settings and try again."; + +"browserNotCompatible" = "We've detected that your browser version is currently not supported on this site. Our recommendation is to use Firefox. Click on the link bellow to download the most current version of this browser."; +"alternativeBrowsers" = "Alternatively, you can also use the following compatible browsers"; +"alternativeBrowserSafari" = "Alternatively, you can also use Safari."; +"Download" = "Download"; + +"Language:" = "Language:"; +"choose" = "Choose ..."; +"English" = "English"; +"French" = "French"; +"German" = "German"; +"Italian" = "Italian"; +"Spanish" = "Spanish"; \ No newline at end of file diff --git a/UI/MainUI/English.lproj/Localizable.strings b/UI/MainUI/English.lproj/Localizable.strings index ca44c6cf2..490df4d53 100644 --- a/UI/MainUI/English.lproj/Localizable.strings +++ b/UI/MainUI/English.lproj/Localizable.strings @@ -14,3 +14,11 @@ "alternativeBrowsers" = "Alternatively, you can also use the following compatible browsers"; "alternativeBrowserSafari" = "Alternatively, you can also use Safari."; "Download" = "Download"; + +"Language:" = "Language:"; +"choose" = "Choose ..."; +"English" = "English"; +"French" = "French"; +"German" = "German"; +"Italian" = "Italian"; +"Spanish" = "Spanish"; \ No newline at end of file diff --git a/UI/MainUI/French.lproj/Localizable.strings b/UI/MainUI/French.lproj/Localizable.strings index 29a59a715..4681e91d5 100644 --- a/UI/MainUI/French.lproj/Localizable.strings +++ b/UI/MainUI/French.lproj/Localizable.strings @@ -14,3 +14,11 @@ "alternativeBrowsers" = "Comme alternative, vous pouvez aussi utiliser les navigateurs suivants:"; "alternativeBrowserSafari" = "Comme alternative, vous pouvez aussi utiliser Safari."; "Download" = "Télécharger"; + +"Language:" = "Langue:"; +"choose" = "Choisir ..."; +"English" = "Anglais"; +"French" = "Français"; +"German" = "Allemand"; +"Italian" = "Italien"; +"Spanish" = "Espagnol"; \ No newline at end of file diff --git a/UI/MainUI/German.lproj/Localizable.strings b/UI/MainUI/German.lproj/Localizable.strings index 790286f09..9c09bd543 100644 --- a/UI/MainUI/German.lproj/Localizable.strings +++ b/UI/MainUI/German.lproj/Localizable.strings @@ -6,3 +6,19 @@ "Password:" = "Passwort:"; "Connect" = "Verbinden"; + +"Wrong username or password." = "Wrong username or password."; +"cookiesNotEnabled" = "You cannot login because your browser's cookies are disabled. Please enable cookies in your browser's settings and try again."; + +"browserNotCompatible" = "We've detected that your browser version is currently not supported on this site. Our recommendation is to use Firefox. Click on the link bellow to download the most current version of this browser."; +"alternativeBrowsers" = "Alternatively, you can also use the following compatible browsers"; +"alternativeBrowserSafari" = "Alternatively, you can also use Safari."; +"Download" = "Download"; + +"Language:" = "Language:"; +"choose" = "Choose ..."; +"English" = "English"; +"French" = "French"; +"German" = "German"; +"Italian" = "Italian"; +"Spanish" = "Spanish"; \ No newline at end of file diff --git a/UI/MainUI/Italian.lproj/Localizable.strings b/UI/MainUI/Italian.lproj/Localizable.strings index a4f717445..44edad14b 100644 --- a/UI/MainUI/Italian.lproj/Localizable.strings +++ b/UI/MainUI/Italian.lproj/Localizable.strings @@ -13,3 +13,11 @@ "alternativeBrowsers" = "Alternativamente, puoi utilizzare questi browser compatibili"; "alternativeBrowserSafari" = "Alternativamente, puoi utilizzare Safari."; "Download" = "Scarica"; + +"Language:" = "Language:"; +"choose" = "Choose ..."; +"English" = "English"; +"French" = "French"; +"German" = "German"; +"Italian" = "Italian"; +"Spanish" = "Spanish"; \ No newline at end of file diff --git a/UI/MainUI/SOGoRootPage.h b/UI/MainUI/SOGoRootPage.h index 265d9f905..d7955dd4b 100644 --- a/UI/MainUI/SOGoRootPage.h +++ b/UI/MainUI/SOGoRootPage.h @@ -26,6 +26,9 @@ #import @interface SOGoRootPage : UIxComponent +{ + id item; +} @end diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 2fe6504cc..e229ee191 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -38,6 +38,8 @@ #import "SOGoRootPage.h" +static NSArray *supportedLanguages = nil; + @interface SOGoRootPage (crashAdditions) - (void) segfault; @@ -46,6 +48,12 @@ @implementation SOGoRootPage ++ (void) initialize +{ + if (!supportedLanguages) + supportedLanguages = [NSArray arrayWithObjects: @"English", @"French", @"German", @"Italian", @"Spanish", nil]; +} + /* accessors */ - (NSString *) connectURL @@ -60,14 +68,16 @@ WORequest *request; WOCookie *authCookie; SOGoWebAuthenticator *auth; + SOGoUser *user; NSString *cookieValue, *cookieString; - NSString *userName, *password; + NSString *userName, *password, *language; auth = [[WOApplication application] authenticatorInContext: context]; request = [context request]; userName = [request formValueForKey: @"userName"]; password = [request formValueForKey: @"password"]; + language = [request formValueForKey: @"language"]; if ([auth checkLogin: userName password: password]) { [self logWithFormat: @"successful login for user '%@'", userName]; @@ -80,6 +90,13 @@ value: cookieValue]; [authCookie setPath: @"/"]; [response addCookie: authCookie]; + + if (language) + { + user = [SOGoUser userWithLogin: userName roles: nil]; + [[user userDefaults] setObject: language forKey: @"Language"]; + [[user userDefaults] synchronize]; + } } else { @@ -151,4 +168,34 @@ return ([[self loginSuffix] length]); } +- (void) setItem: (id) _item +{ + ASSIGN (item, _item); +} + +- (id) item +{ + return item; +} + +- (NSArray *) languages +{ + return supportedLanguages; +} + +- (NSString *) language +{ + return [SOGoUser language]; +} + +- (NSString *) languageText +{ + NSString *text; + + text = [self labelForKey: item]; + + return text; +} + + @end /* SOGoRootPage */ diff --git a/UI/MainUI/Spanish.lproj/Localizable.strings b/UI/MainUI/Spanish.lproj/Localizable.strings index 5d37a3d5c..454f6364c 100644 --- a/UI/MainUI/Spanish.lproj/Localizable.strings +++ b/UI/MainUI/Spanish.lproj/Localizable.strings @@ -16,3 +16,11 @@ "alternativeBrowsers" = "Alternativamente, también puede usar uno se los siguientes navegadores compatibles: "; "alternativeBrowserSafari" = "Alternativamente, puede usar Safari."; "Download" = "Descarga"; + +"Language:" = "Language:"; +"choose" = "Choose ..."; +"English" = "English"; +"French" = "French"; +"German" = "German"; +"Italian" = "Italian"; +"Spanish" = "Spanish"; \ No newline at end of file diff --git a/UI/Templates/MainUI/SOGoRootPage.wox b/UI/Templates/MainUI/SOGoRootPage.wox index d3fd66106..e67108fcd 100644 --- a/UI/Templates/MainUI/SOGoRootPage.wox +++ b/UI/Templates/MainUI/SOGoRootPage.wox @@ -23,6 +23,15 @@ +
diff --git a/UI/WebServerResources/SOGoRootPage.js b/UI/WebServerResources/SOGoRootPage.js index 517114e91..5f8a669b1 100644 --- a/UI/WebServerResources/SOGoRootPage.js +++ b/UI/WebServerResources/SOGoRootPage.js @@ -19,7 +19,8 @@ function onLoginClick(event) { var userNameField = $("userName"); var userName = userNameField.value; var password = $("password").value; - + var language = $("language").value; + if (userName.length > 0) { startAnimation($("loginButton"), $("submit")); @@ -28,7 +29,9 @@ function onLoginClick(event) { && !userName.endsWith(loginSuffix)) userName += loginSuffix; var url = $("connectForm").getAttribute("action"); - var parameters = ("userName=" + encodeURIComponent(userName) + "&password=" + encodeURIComponent(password)); + var parameters = ("userName=" + encodeURIComponent(userName) + + "&password=" + encodeURIComponent(password) + + ((language == "WONoSelectionString")?"":("&language=" + language))); document.cookie = ""; triggerAjaxRequest(url, onLoginCallback, null, parameters, { "Content-type": "application/x-www-form-urlencoded",