From b62fcf8652253c5c94ac17cc54eb49807749878e Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 10 Feb 2005 14:36:44 +0000 Subject: [PATCH] some work on tool daemon support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@539 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/Main/ChangeLog | 7 +++- SOGo/Main/GNUmakefile | 24 ++++++++--- SOGo/Main/SOGo.m | 75 +++++++++++++++++++---------------- SOGo/Main/SOGoProductLoader.m | 7 ++-- SOGo/Main/Version | 2 +- 5 files changed, 70 insertions(+), 45 deletions(-) diff --git a/SOGo/Main/ChangeLog b/SOGo/Main/ChangeLog index 66155c52..cba9d507 100644 --- a/SOGo/Main/ChangeLog +++ b/SOGo/Main/ChangeLog @@ -1,4 +1,9 @@ -2005-02-10 Helge Hess +2005-02-10 Helge Hess + + * SOGo.m: minor cleanup in locale code, removed some dead code + (v0.9.20) + + * GNUmakefile: some support for tool compilation (does not work yet) * sogod.m: moved application class to own file, started to work on daemon/product separation (v0.9.19) diff --git a/SOGo/Main/GNUmakefile b/SOGo/Main/GNUmakefile index e66147a7..f589055e 100644 --- a/SOGo/Main/GNUmakefile +++ b/SOGo/Main/GNUmakefile @@ -3,6 +3,7 @@ include $(GNUSTEP_MAKEFILES)/common.make WOAPP_NAME = sogod +TOOL_NAME = sogod BUNDLE_NAME = MainUI BUNDLE_EXTENSION = .SOGo BUNDLE_INSTALL_DIR = $(GNUSTEP_USER_ROOT)/Library/SOGo @@ -19,16 +20,16 @@ sogod_OBJC_FILES += \ MainUI_PRINCIPAL_CLASS = MainUIProduct -sogod_LANGUAGES = English French +MainUI_LANGUAGES = English French -sogod_OBJC_FILES += \ +MainUI_OBJC_FILES += \ MainUIProduct.m \ SOGoRootPage.m \ SOGoUserHomePage.m \ SOGoGroupPage.m \ SOGoGroupsPage.m \ -sogod_RESOURCE_FILES += \ +MainUI_RESOURCE_FILES += \ Version \ product.plist \ \ @@ -37,10 +38,23 @@ sogod_RESOURCE_FILES += \ SOGoGroupPage.wox \ SOGoGroupsPage.wox \ -sogod_LOCALIZED_RESOURCE_FILES += \ +MainUI_LOCALIZED_RESOURCE_FILES += \ Locale default.strings +# woapp support + +ifneq ($(tool),yes) +sogod_OBJC_FILES += $(MainUI_OBJC_FILES) +sogod_RESOURCE_FILES += $(MainUI_RESOURCE_FILES) +sogod_LOCALIZED_RESOURCE_FILES += $(MainUI_LOCALIZED_RESOURCE_FILES) +endif + + -include GNUmakefile.preamble +ifeq ($(tool),yes) +include $(GNUSTEP_MAKEFILES)/bundle.make +include $(GNUSTEP_MAKEFILES)/tool.make +else include $(GNUSTEP_MAKEFILES)/woapp.make -#include $(GNUSTEP_MAKEFILES)/bundle.make +endif -include GNUmakefile.postamble diff --git a/SOGo/Main/SOGo.m b/SOGo/Main/SOGo.m index eeb869e4..2fcec749 100644 --- a/SOGo/Main/SOGo.m +++ b/SOGo/Main/SOGo.m @@ -104,25 +104,23 @@ static BOOL doCrashOnSessionCreate = NO; autorelease]; } +- (void)_setupLocaleInContext:(WOContext *)_ctx { + NSArray *langs; + NSDictionary *locale; + + if ([[_ctx valueForKey:@"locale"] isNotNull]) + return; + + langs = [[(WOContext *)_ctx request] browserLanguages]; + locale = [self currentLocaleConsideringLanguages:langs]; + [_ctx takeValue:locale forKey:@"locale"]; +} + - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { id obj; /* put locale info into the context in case it's not there */ - if (![_ctx valueForKey:@"locale"]) { - NSArray *langs; - NSDictionary *locale; - - langs = [[(WOContext *)_ctx request] browserLanguages]; - locale = [self currentLocaleConsideringLanguages:langs]; - [_ctx takeValue:locale forKey:@"locale"]; - } - -#if 0 // znek: explain why you did that? - /* set SoRootURL */ - if ([_ctx valueForKey:@"SoRootURL"] == nil) { - [_ctx takeValue:@"/sogod.woa/so/" forKey:@"SoRootURL"]; - } -#endif + [self _setupLocaleInContext:_ctx]; /* first check attributes directly bound to the application */ if ((obj = [super lookupName:_key inContext:_ctx acquire:_flag])) @@ -222,7 +220,7 @@ static BOOL doCrashOnSessionCreate = NO; lname = [_langs objectAtIndex:i]; locale = [self localeForLanguageNamed:lname]; - if (locale) + if (locale != nil) return locale; } /* no appropriate language, fallback to default */ @@ -230,32 +228,41 @@ static BOOL doCrashOnSessionCreate = NO; } - (NSDictionary *)localeForLanguageNamed:(NSString *)_name { - NSString *lpath; - id data; + NSString *lpath; + id data; NSDictionary *locale; - - NSAssert(_name != nil, @"_name MUST NOT be nil!"); - if((locale = [self->localeLUT objectForKey:_name]) != nil) + + if (![_name isNotNull]) { + [self logWithFormat:@"ERROR(%s): name parameter must not be nil!", + __PRETTY_FUNCTION__]; + return nil; + } + + if ((locale = [self->localeLUT objectForKey:_name]) != nil) return locale; + lpath = [[self resourceManager] - pathForResourceNamed:@"Locale" - inFramework:nil - languages:[NSArray arrayWithObject:_name]]; - - data = [NSData dataWithContentsOfFile:lpath]; - if(data == nil) { - NSLog(@"%s didn't find locale with name:%@", - __PRETTY_FUNCTION__, - _name); + pathForResourceNamed:@"Locale" + inFramework:nil + languages:[NSArray arrayWithObject:_name]]; + if (![lpath isNotNull]) { + [self logWithFormat:@"ERROR: did not find Locale for language: %@", _name]; + return nil; + } + + if ((data = [NSData dataWithContentsOfFile:lpath]) == nil) { + [self logWithFormat:@"%s didn't find locale with name:%@", + __PRETTY_FUNCTION__, + _name]; return nil; } data = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; locale = [data propertyList]; - if(locale == nil) { - NSLog(@"%s couldn't load locale with name:%@", - __PRETTY_FUNCTION__, - _name); + if (locale == nil) { + [self logWithFormat:@"%s couldn't load locale with name:%@", + __PRETTY_FUNCTION__, + _name]; return nil; } [self->localeLUT setObject:locale forKey:_name]; diff --git a/SOGo/Main/SOGoProductLoader.m b/SOGo/Main/SOGoProductLoader.m index abc6001c..8c4d545c 100644 --- a/SOGo/Main/SOGoProductLoader.m +++ b/SOGo/Main/SOGoProductLoader.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "SOGoProductLoader.h" #include "common.h" @@ -108,13 +107,13 @@ fm = [NSFileManager defaultManager]; pathes = [[self productSearchPathes] objectEnumerator]; - while ((lpath = [pathes nextObject])) { + while ((lpath = [pathes nextObject]) != nil) { NSEnumerator *productNames; NSString *productName; productNames = [[fm directoryContentsAtPath:lpath] objectEnumerator]; - while ((productName = [productNames nextObject])) { + while ((productName = [productNames nextObject]) != nil) { NSString *bpath; bpath = [lpath stringByAppendingPathComponent:productName]; diff --git a/SOGo/Main/Version b/SOGo/Main/Version index 7ad8ae0c..6cdceca8 100644 --- a/SOGo/Main/Version +++ b/SOGo/Main/Version @@ -1,5 +1,5 @@ # Version file -SUBMINOR_VERSION:=19 +SUBMINOR_VERSION:=20 # v0.9.16 requires NGExtensions v4.5.136 -- 2.39.5