From: znek Date: Sat, 30 Dec 2006 19:38:00 +0000 (+0000) Subject: added new user defaults registration scheme X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03ff37c172b92476e6749617619bcdb14a7a68bc;p=sope added new user defaults registration scheme git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1394 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index ec222b58..8f165993 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,21 @@ +2006-12-30 Marcus Mueller + + * WOCoreApplication.m: Removed the +_initDefaults class method and + instead added a new -registerUserDefaults method which provides a + sane hook to alter/extend registration of userDefaults in + subclasses. Registration is called very early by -init, though, so + subclassers must still act very carefully. Removed the braindead + +_initializeClass method, instead moved the proper initialization + code into -init. + + * WOCoreApplication.h: exposed -registerUserDefaults to subclassers. + + * WOApplication.m: removed +_initializeWOApp, instead moved + initialization code to the proper place in -init (after super has + been initialized and user defaults have been set in a proper manner). + + * v4.5.262 + 2006-12-17 Marcus Mueller * DynamicElements/WORepetition.m: fixed another bug when using count diff --git a/sope-appserver/NGObjWeb/NGObjWeb/WOCoreApplication.h b/sope-appserver/NGObjWeb/NGObjWeb/WOCoreApplication.h index 785c4086..98b679d7 100644 --- a/sope-appserver/NGObjWeb/NGObjWeb/WOCoreApplication.h +++ b/sope-appserver/NGObjWeb/NGObjWeb/WOCoreApplication.h @@ -113,6 +113,11 @@ int WOWatchDogApplicationMainWithServerDefaults @interface WOCoreApplication(Defaults) +/* A hook to override/plugin into the registration of user defaults. + NOTE: this is called by -init (as the first thing), so be extra cautious +*/ +- (void)registerUserDefaults; + /* WOAdaptor */ + (void)setAdaptor:(NSString *)_key; + (NSString *)adaptor; diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 149f882b..979a97c2 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -3,7 +3,7 @@ ifeq ($(GNUSTEP_HOST_VENDOR),apple) # linker overflow SUBMINOR_VERSION:=255 else -SUBMINOR_VERSION:=261 +SUBMINOR_VERSION:=262 endif # v4.5.234 requires libDOM v4.5.21 diff --git a/sope-appserver/NGObjWeb/WOApplication.m b/sope-appserver/NGObjWeb/WOApplication.m index 529ed16c..8fe5e80c 100644 --- a/sope-appserver/NGObjWeb/WOApplication.m +++ b/sope-appserver/NGObjWeb/WOApplication.m @@ -47,14 +47,15 @@ - (id)_loadComponentDefinitionWithName:(NSString *)_name language:(NSArray *)_langs; - (NSDictionary *)memoryStatistics; +- (void)_setupSNS; @end -static NSRecursiveLock *classLock = nil; -static NGLogger *perfLogger = nil; -static Class NSDateClass = Nil; -static Class WOTemplateClass = Nil; -static BOOL debugOn = NO; -static NSString *rapidTurnAroundPath = nil; +static NSRecursiveLock *classLock = nil; +static NGLogger *perfLogger = nil; +static Class NSDateClass = Nil; +static Class WOTemplateClass = Nil; +static BOOL debugOn = NO; +static NSString *rapidTurnAroundPath = nil; @interface WOSessionStore(SnStore) - (void)performExpirationCheck:(NSTimer *)_timer; @@ -87,44 +88,6 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; [[self logger] logWithFormat:@"SNS enabled"]; } -+ (void)_initializeWOApp { - static BOOL isInitialized = NO; - NSAutoreleasePool *pool; - NSUserDefaults *ud; - NGLoggerManager *lm; - - if (isInitialized) return; - - isInitialized = YES; - - pool = [[NSAutoreleasePool alloc] init]; - debugOn = [WOApplication isDebuggingEnabled]; - if (!debugOn) - [[self logger] setLogLevel:NGLogLevelInfo]; - else - NSLog(@"Note: WOApplication debugging is enabled."); - - if (classLock == nil) classLock = [[NSRecursiveLock alloc] init]; - ud = [NSUserDefaults standardUserDefaults]; - - /* setup SNSConnection */ - - if ([ud boolForKey:@"WOContactSNS"]) - [self _setupSNS]; - else - [[self logger] logWithFormat:@"SNS support disabled."]; - - NSDateClass = [NSDate class]; - WOTemplateClass = [WOTemplate class]; - - rapidTurnAroundPath = [[ud stringForKey:@"WOProjectDirectory"] copy]; - - lm = [NGLoggerManager defaultLoggerManager]; - perfLogger = [lm loggerForDefaultKey:@"WOProfileApplication"]; - - [pool release]; -} - /* old license checks */ - (NSCalendarDate *)appExpireDate { @@ -198,15 +161,15 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; lowercaseString] isEqualToString:@"yes"]; } else /* default to flattened if no GNUstep runtime is set */ - isFlattened = YES; + isFlattened = YES; ppath = [[pi arguments] objectAtIndex:0]; ppath = [ppath stringByDeletingLastPathComponent]; // del exe-name if (!isFlattened) { - ppath = [ppath stringByDeletingLastPathComponent]; // lib-combo - ppath = [ppath stringByDeletingLastPathComponent]; // os - ppath = [ppath stringByDeletingLastPathComponent]; // cpu + ppath = [ppath stringByDeletingLastPathComponent]; // lib-combo + ppath = [ppath stringByDeletingLastPathComponent]; // os + ppath = [ppath stringByDeletingLastPathComponent]; // cpu } if ([ppath hasSuffix:suffix]) result = ppath; @@ -247,16 +210,38 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; } - (id)initWithName:(NSString *)_name { - [WOApplication _initializeWOApp]; - if ((self = [super init]) != nil) { NSUserDefaults *ud; + NGLoggerManager *lm; WORequestHandler *rh; - NSString *rk; - + NSString *rk; + self->name = [_name copy]; + ud = [NSUserDefaults standardUserDefaults]; + + debugOn = [WOApplication isDebuggingEnabled]; + if (!debugOn) + [[self logger] setLogLevel:NGLogLevelInfo]; + else + [[self logger] logWithFormat:@"WOApplication debugging is enabled."]; + + if (classLock == nil) classLock = [[NSRecursiveLock alloc] init]; + + /* setup SNSConnection */ + + if ([ud boolForKey:@"WOContactSNS"]) + [self _setupSNS]; + else + [[self logger] logWithFormat:@"SNS support disabled."]; + + NSDateClass = [NSDate class]; + WOTemplateClass = [WOTemplate class]; + + rapidTurnAroundPath = [[ud stringForKey:@"WOProjectDirectory"] copy]; + + lm = [NGLoggerManager defaultLoggerManager]; + perfLogger = [lm loggerForDefaultKey:@"WOProfileApplication"]; - ud = [NSUserDefaults standardUserDefaults]; [self setPageCacheSize:[ud integerForKey:@"WOPageCacheSize"]]; [self setPermanentPageCacheSize: diff --git a/sope-appserver/NGObjWeb/WOCoreApplication.m b/sope-appserver/NGObjWeb/WOCoreApplication.m index 5cd183f1..20ec7c5d 100644 --- a/sope-appserver/NGObjWeb/WOCoreApplication.m +++ b/sope-appserver/NGObjWeb/WOCoreApplication.m @@ -48,10 +48,10 @@ NGObjWeb_DECLARE NSString *WOApplicationDidTerminateNotification = @"WOApplicationDidTerminate"; @interface WOCoreApplication(PrivateMethods) -+ (void)_initDefaults; + (id)logger; - (NSDictionary *)memoryStatistics; - (WOResponse *)handleException:(NSException *)_exc; ++ (NSString *)findNGObjWebResource:(NSString *)_name ofType:(NSString *)_ext; @end #if COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY @@ -115,29 +115,34 @@ static NSMutableArray *activeApps = nil; // THREAD } } -+ (void)_initializeClass { - /* - this must be called in -init, since the environment is not setup - properly if this is called first. - */ - static BOOL didInit = NO; - NSUserDefaults *ud; - NGLoggerManager *lm; - if (didInit) return; - didInit = YES; - [self _initDefaults]; - - lm = [NGLoggerManager defaultLoggerManager]; - logger = [lm loggerForClass:self]; - perfLogger = [lm loggerForDefaultKey:@"WOProfileApplication"]; - - ud = [NSUserDefaults standardUserDefaults]; - outputValidateOn = [ud boolForKey:@"WOOutputValidationEnabled"]; - NSDateClass = [NSDate class]; +- (void)registerUserDefaults { + NSDictionary *owDefaults = nil; + NSString *apath; + + apath = [[self class] findNGObjWebResource:@"Defaults" ofType:@"plist"]; + if (apath == nil) + [self errorWithFormat:@"Cannot find Defaults.plist resource of " + @"NGObjWeb library!"]; +#if HEAVY_DEBUG + else + [self debugWithFormat:@"Note: loading default defaults: %@", apath]; +#endif + + owDefaults = [NSDictionary dictionaryWithContentsOfFile:apath]; + if (owDefaults) { + [[NSUserDefaults standardUserDefaults] registerDefaults:owDefaults]; +#if HEAVY_DEBUG + [self debugWithFormat:@"did register NGObjWeb defaults: %@\n%@", + apath, owDefaults]; +#endif + } + else { + [self errorWithFormat:@"could not load NGObjWeb defaults: '%@'", + apath]; + } } - (id)init { - [[self class] _initializeClass]; #if COCOA_Foundation_LIBRARY /* NSKeyBinding Warning: was accessed using a capitalized key @@ -149,7 +154,16 @@ static NSMutableArray *activeApps = nil; // THREAD #endif if ((self = [super init])) { - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSUserDefaults *ud; + NGLoggerManager *lm; + + [self registerUserDefaults]; + ud = [NSUserDefaults standardUserDefaults]; + lm = [NGLoggerManager defaultLoggerManager]; + logger = [lm loggerForClass:[self class]]; + perfLogger = [lm loggerForDefaultKey:@"WOProfileApplication"]; + outputValidateOn = [ud boolForKey:@"WOOutputValidationEnabled"]; + NSDateClass = [NSDate class]; [self activateApplication]; @@ -744,36 +758,6 @@ static NSMutableArray *activeApps = nil; // THREAD #endif } -+ (void)_initDefaults { - static BOOL didInit = NO; - NSDictionary *owDefaults = nil; - NSString *apath; - - if (didInit) return; - didInit = YES; - - apath = [self findNGObjWebResource:@"Defaults" ofType:@"plist"]; - if (apath == nil) - NSLog(@"ERROR: Cannot find Defaults.plist resource of NGObjWeb library!"); -#if HEAVY_DEBUG - else - [self debugWithFormat:@"Note: loading default defaults: %@", apath]; -#endif - - owDefaults = [NSDictionary dictionaryWithContentsOfFile:apath]; - if (owDefaults) { - [[NSUserDefaults standardUserDefaults] registerDefaults:owDefaults]; -#if HEAVY_DEBUG - [self debugWithFormat:@"did register NGObjWeb defaults: %@\n%@", - apath, owDefaults]; -#endif - } - else { - [self errorWithFormat:@"could not load NGObjWeb defaults: '%@'", - apath]; - } -} - + (NSUserDefaults *)userDefaults { return [NSUserDefaults standardUserDefaults]; } diff --git a/sope-appserver/SoOFS/ChangeLog b/sope-appserver/SoOFS/ChangeLog index 2e311672..bdf8b8fb 100644 --- a/sope-appserver/SoOFS/ChangeLog +++ b/sope-appserver/SoOFS/ChangeLog @@ -1,3 +1,8 @@ +2006-12-30 Marcus Mueller + + * sope.m: changed to use the new user defaults registration mechanism + of WOCoreApplication (v4.5.23) + 2006-07-03 Helge Hess * use %p for pointer formats, fixed gcc 4.1 warnings (v4.5.22) diff --git a/sope-appserver/SoOFS/SoOFS.xcodeproj/project.pbxproj b/sope-appserver/SoOFS/SoOFS.xcodeproj/project.pbxproj index 52e27cbf..4daee1d9 100644 --- a/sope-appserver/SoOFS/SoOFS.xcodeproj/project.pbxproj +++ b/sope-appserver/SoOFS/SoOFS.xcodeproj/project.pbxproj @@ -82,53 +82,6 @@ ADE806E20789F76900633840 /* SoOFSProduct.m in Sources */ = {isa = PBXBuildFile; fileRef = AD4606EB0789911E00E8C5A3 /* SoOFSProduct.m */; }; /* End PBXBuildFile section */ -/* Begin PBXBuildStyle section */ - ADD65B6806DA32D6007161CA /* Development */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "APPLE_RUNTIME=1", - "NeXT_Foundation_LIBRARY=1", - "COCOA_Foundation_LIBRARY=1", - "NeXT_RUNTIME=1", - "COMPILE_AS_FRAMEWORK=1", - "DEBUG=1", - ); - }; - name = Development; - }; - ADD65B6906DA32D6007161CA /* Wrapper */ = { - isa = PBXBuildStyle; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEPLOYMENT_LOCATION = NO; - DEPLOYMENT_POSTPROCESSING = YES; - DSTROOT = /; - DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/"; - FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; - GCC_PREPROCESSOR_DEFINITIONS = ( - "APPLE_RUNTIME=1", - "NeXT_Foundation_LIBRARY=1", - "COCOA_Foundation_LIBRARY=1", - "NeXT_RUNTIME=1", - "COMPILE_AS_FRAMEWORK=1", - ); - SKIP_INSTALL = YES; - SYMROOT = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks"; - TEMP_DIR = "$(SYMROOT)/$(PROJECT_NAME).build"; - UNSTRIPPED_PRODUCT = NO; - ZERO_LINK = NO; - }; - name = Wrapper; - }; -/* End PBXBuildStyle section */ - /* Begin PBXFileReference section */ AD013B8706E20AC5000910D8 /* README */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = README; sourceTree = ""; }; AD013C1906E20D18000910D8 /* NGHttp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NGHttp.framework; path = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks/Wrapper/NGHttp.framework"; sourceTree = ""; }; @@ -471,20 +424,6 @@ ); buildRules = ( ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - INSTALL_PATH = /usr/local/bin; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = "sope-4.5"; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; dependencies = ( ); name = "sope-4.5"; @@ -503,55 +442,11 @@ ); buildRules = ( ); - buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.21; - FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - FRAMEWORK_VERSION = A; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = common.h; - GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; - GCC_WARN_UNKNOWN_PRAGMAS = NO; - INFOPLIST_FILE = "SoOFS-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - OTHER_CFLAGS = "-DXCODE_BUILD=1"; - OTHER_LDFLAGS = ( - "-seg1addr", - 0xC3A00000, - "-headerpad_max_install_names", - ); - OTHER_REZFLAGS = ""; - PRODUCT_NAME = SoOFS; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost"; - }; dependencies = ( ); name = SoOFS; productName = SoOFS; productReference = ADD65D5806DA372D007161CA /* SoOFS.framework */; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SoOFS - CFBundleIdentifier - org.OpenGroupware.SOPE.SoOFS - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleVersion - 1.0 - - -"; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ @@ -560,12 +455,6 @@ ADD65B6A06DA32D6007161CA /* Project object */ = { isa = PBXProject; buildConfigurationList = ADA079A5085738F100993825 /* Build configuration list for PBXProject "SoOFS" */; - buildSettings = { - }; - buildStyles = ( - ADD65B6806DA32D6007161CA /* Development */, - ADD65B6906DA32D6007161CA /* Wrapper */, - ); hasScannedForEncodings = 0; mainGroup = ADD65B6606DA32D6007161CA; productRefGroup = ADD65D5906DA372D007161CA /* Products */; @@ -633,7 +522,7 @@ buildSettings = { COPY_PHASE_STRIP = NO; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.21; + DYLIB_CURRENT_VERSION = 4.5.23; FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; FRAMEWORK_VERSION = A; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -674,7 +563,7 @@ DEPLOYMENT_POSTPROCESSING = YES; DSTROOT = /; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.21; + DYLIB_CURRENT_VERSION = 4.5.23; DYLIB_INSTALL_NAME_BASE = "@executable_path/../Frameworks/"; FRAMEWORK_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/EmbeddedFrameworks"; FRAMEWORK_VERSION = A; @@ -717,7 +606,7 @@ isa = XCBuildConfiguration; buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 4.5.21; + DYLIB_CURRENT_VERSION = 4.5.23; FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks"; FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/sope-appserver/SoOFS/Version b/sope-appserver/SoOFS/Version index 6cc7ab75..d8df2f55 100644 --- a/sope-appserver/SoOFS/Version +++ b/sope-appserver/SoOFS/Version @@ -1,3 +1,5 @@ # version file -SUBMINOR_VERSION:=22 +SUBMINOR_VERSION:=23 + +# v4.5.23 requires libNGObjWeb v4.5.263 diff --git a/sope-appserver/SoOFS/sope.m b/sope-appserver/SoOFS/sope.m index 30add867..ba559bf3 100644 --- a/sope-appserver/SoOFS/sope.m +++ b/sope-appserver/SoOFS/sope.m @@ -89,8 +89,7 @@ static BOOL debugRootObject = NO; } - (BOOL)_setupRoot { - BOOL isDir; - NSString *p; + BOOL isDir; /* setup root path */ @@ -105,7 +104,7 @@ static BOOL debugRootObject = NO; if (![self->fm fileExistsAtPath:self->rootPath isDirectory:&isDir]) { [self logWithFormat:@"SOPE storage root-path does not exist: %@", - self->rootPath]; + self->rootPath]; return NO; } if (!isDir) { @@ -122,27 +121,37 @@ static BOOL debugRootObject = NO; /* configure */ [self logWithFormat:@"starting SOPE on OFS root: %@", self->rootPath]; - + + return YES; +} + +- (void)registerUserDefaults { + NSString *p; + + [super registerUserDefaults]; p = [self->rootPath stringByAppendingPathComponent:@".sope.plist"]; if ([self->fm isReadableFileAtPath:p]) [self loadLocalDefaults:p]; - - return YES; } - (id)init { - if ((self = [super init])) { - // TODO: make root-path/fm configurable ? - self->fm = [[NSFileManager defaultManager] retain]; - self->rootPath = [[self->fm currentDirectoryPath] copy]; - - if (![self _setupRoot]) { - [self release]; - return nil; - } + // TODO: make root-path/fm configurable ? + self->fm = [[NSFileManager defaultManager] retain]; + self->rootPath = [[self->fm currentDirectoryPath] copy]; + + if (![self _setupRoot]) { + [self release]; + return nil; } + /* Q: Why is [super init] done so goddamn late? + A: In the process of setting up or root directory, we're also registering + defaults. These defaults are important for the inits done by super, + so we need to do this in advance. + */ + [super init]; return self; } + - (void)dealloc { [self->fm release]; [self->rootPath release];