From 61ded01171806595da1c03b686a5bd1dc5cd45ed Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Thu, 24 Jan 2013 20:35:03 -0500 Subject: [PATCH 1/3] whitespace - tabkill --- SoObjects/SOGo/SOGoSystemDefaults.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 31f96f02c..3adfa2635 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -62,9 +62,9 @@ BootstrapNSUserDefaults () if (handle) { SOGoNSUserDefaultsBootstrap = dlsym (handle, - "SOGoNSUserDefaultsBootstrap"); + "SOGoNSUserDefaultsBootstrap"); if (SOGoNSUserDefaultsBootstrap) - SOGoNSUserDefaultsBootstrap (); + SOGoNSUserDefaultsBootstrap (); } } @@ -98,10 +98,10 @@ _injectConfigurationFromFile (NSUserDefaults *ud, if (![fileAttrs objectForKey: @"NSFileSize"]) { [logger errorWithFormat: - @"Can't get file attributes from '%@'", - filename]; + @"Can't get file attributes from '%@'", + filename]; exit(1); - } + } if ([[fileAttrs objectForKey: @"NSFileSize"] intValue] == 0 ) { [logger warnWithFormat: From 6093c4dd2e9095e0288992fe92ccb1b93fb9435a Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Thu, 24 Jan 2013 20:37:30 -0500 Subject: [PATCH 2/3] Axe handling of sogo 0.9 gnustep domain migration --- SoObjects/SOGo/SOGoSystemDefaults.m | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 3adfa2635..27bdf0d6e 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -68,21 +68,6 @@ BootstrapNSUserDefaults () } } -static void -_migrateSOGo09Configuration (NSUserDefaults *ud, NSObject *logger) -{ - NSDictionary *domain; - - domain = [ud persistentDomainForName: @"sogod-0.9"]; - if ([domain count]) - { - [logger logWithFormat: @"migrating user defaults from sogod-0.9"]; - [ud setPersistentDomain: domain forName: @"sogod"]; - [ud removePersistentDomainForName: @"sogod-0.9"]; - [ud synchronize]; - } -} - static void _injectConfigurationFromFile (NSUserDefaults *ud, NSString *filename, NSObject *logger) @@ -139,11 +124,6 @@ _injectConfigurationFromFile (NSUserDefaults *ud, /* we load the configuration from the standard user default files */ ud = [NSUserDefaults standardUserDefaults]; - /* if "sogod" does not exist, maybe "sogod-0.9" still exists from an old - configuration */ - if (![[ud persistentDomainForName: @"sogod"] count]) - _migrateSOGo09Configuration (ud, logger); - /* reregister defaults from domain "sogod" into default domain, for non-sogod processes */ [ud addSuiteNamed: @"sogod"]; From 46b53b31fd417e6349304609920e36fb9869f9e3 Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Thu, 24 Jan 2013 22:43:38 -0500 Subject: [PATCH 3/3] Fix order of precedence for options Fixes #2066 and #2166 Enforce the following order of precedence for options, first match wins: 1. Command line arguments 2. .GNUstepDefaults 3. /etc/sogo/{debconf,sogo}.conf 4. SOGoDefaults.plist --- SoObjects/SOGo/SOGoSystemDefaults.m | 45 +++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index 27bdf0d6e..bd8547b2a 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -79,7 +79,7 @@ _injectConfigurationFromFile (NSUserDefaults *ud, if ([fm fileExistsAtPath: filename]) { fileAttrs = [fm fileAttributesAtPath: filename - traverseLink: YES]; + traverseLink: YES]; if (![fileAttrs objectForKey: @"NSFileSize"]) { [logger errorWithFormat: @@ -111,6 +111,25 @@ _injectConfigurationFromFile (NSUserDefaults *ud, + (void) prepareUserDefaults { + /* Load settings from configuration files and + * enforce the following order of precedence. + * First match wins + * 1. Command line arguments + * 2. .GNUstepDefaults + * 3. /etc/sogo/{debconf,sogo}.conf + * 4. SOGoDefaults.plist + * + * The default standardUserDefaults search list is as follows: + * GSPrimaryDomain + * NSArgumentDomain (command line arguments) + * applicationDomain (sogod) + * NSGlobalDomain + * GSConfigDomain + * (languages) + * NSRegistrationDomain + */ + + NSDictionary *sogodDomain; NSUserDefaults *ud; SOGoStartupLogger *logger; NSBundle *bundle; @@ -121,24 +140,32 @@ _injectConfigurationFromFile (NSUserDefaults *ud, logger = [SOGoStartupLogger sharedLogger]; - /* we load the configuration from the standard user default files */ + /* Load the configuration from the standard user default files + * into the 'sogod' domain */ ud = [NSUserDefaults standardUserDefaults]; - /* reregister defaults from domain "sogod" into default domain, for - non-sogod processes */ - [ud addSuiteNamed: @"sogod"]; - - /* we populate the configuration with the values from SOGoDefaults.plist */ + /* Populate NSRegistrationDomain with default values from SOGoDefaults.plist */ bundle = [NSBundle bundleForClass: self]; filename = [bundle pathForResource: @"SOGoDefaults" ofType: @"plist"]; if (filename) _injectConfigurationFromFile (ud, filename, logger); - /* fill the possibly missing values with the configuration stored - in "/etc" */ + /* Fill/Override NSRegistrationDomain values with configuration stored + * in "/etc" */ for (count = 0; count < sizeof(confFiles)/sizeof(confFiles[0]); count++) _injectConfigurationFromFile (ud, confFiles[count], logger); + /* This dance is required to let other appplications (sogo-tool) use + * options from the sogod domain while preserving the order of precedence + * - remove the 'sogod' domain from the user defaults search list + * - register the content of the sogod domain into the NSRegistrationDomain + * Thereby overriding values from the config files loaded above + */ + [ud removeSuiteNamed: @"sogod"]; + sogodDomain = [ud persistentDomainForName: @"sogod"]; + if ([sogodDomain count]) + [ud registerDefaults: sogodDomain]; + /* issue a warning if WOApplicationRedirectURL is used */ redirectURL = [ud stringForKey: @"WOApplicationRedirectURL"]; if (redirectURL)