Backward compatibility user default name fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/devmodules/dev-libs/ec@35633 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-10-05 11:31:23 +00:00
parent 3b2364cc67
commit b610b9b7b9
4 changed files with 28 additions and 33 deletions

View file

@ -32,6 +32,7 @@
#import "EcProcess.h"
#import "EcAlarm.h"
#import "EcClientI.h"
#import "EcHost.h"
#import "NSFileHandle+Printf.h"
#import "config.h"
@ -2053,8 +2054,8 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
{
ctlName = @"Control";
}
ctlHost = [defs stringForKey: @"ControlHost"];
if (ctlHost == nil)
ctlHost = [NSHost controlWellKnownName];
if (nil == ctlHost)
{
ctlHost = @"*";
}

View file

@ -30,6 +30,7 @@
#import <Foundation/Foundation.h>
#import "EcProcess.h"
#import "EcHost.h"
#import "NSFileHandle+Printf.h"
#import "config.h"
@ -706,8 +707,8 @@ static BOOL commandIsRepeat (NSString *string)
{
name = @"Control";
}
host = [defs stringForKey: @"ControlHost"];
if (host == nil)
host = [NSHost controlWellKnownName];
if (nil == host)
{
host = @"*";
}

View file

@ -47,15 +47,16 @@
* <p>The well known name methods are thread-safe, and on initial use the
* NSUserDefaults system is queried to set up two well known names
* automatically:<br />
* The value of EcHostCurrentName specifies the well known name for the
* The value of EcCurrentHost specifies the well known name for the
* current host (the machine on which the software is running).<br />
* The value of EcHostControlName specifies the well known name for the
* The value of EcControlHost specifies the well known name for the
* control host (the machine on which control functions for your software
* are centralised). If this is specified without EcHostControlDomain,
* it is ignored and the well known name of the current host is used.<br />
* The value of EcHostControlDomain specifies the fully qualified domain
* name of the control host. If it is specified without EcHostControlName,
* then it is used as the well known name for the control host.<br />
* are centralised). If this is specified without EcControlDomain,
* it is used as both the well known name and the domain name.<br />
* The value of EcControlDomain specifies the fully qualified domain
* name (ie the name provided by the operating system) of the control host.
* If it is specified without EcControlHost, then it is used as the
* well known name for the control host.<br />
* NB. the defaults system is accessed via EcUserDefaults, so if a
* defaults prefix other than Ec has been set, these keys will use that
* alternative prefix.
@ -65,14 +66,11 @@
/** Returns the well known name of the 'control' host as obtained from the
* NSUserDefaults system.<br />
* If EcHostControlName and EcHostControlDomain are both defined,
* the well known name is the string specified by EcHostControlName.<br />
* If EcHostControlDomain is defined, the well known name is the string
* specified by it.<br />
* If neither is defined, but EcHostCurrentName is defined, then the well
* known name is the string specified by that default.<br />
* Otherwise, the well known name is set to an arbitrarily selected name
* of the current machine.
* If EcControlHost is defined, the well known name is the string specified
* by EcControlHost.<br />
* If EcControlHost is undefined but EcHostControlDomain is defined,
* the well known name is the value of EcHostControlDomain.<br />
* If neither is defined, this method returns nil.
*/
+ (NSString*) controlWellKnownName;

View file

@ -75,15 +75,16 @@ static NSString *controlName = nil;
defs = [NSUserDefaults userDefaultsWithPrefix: nil
strict: NO];
}
name = [defs stringForKey: @"HostControlName"];
if (nil != name && nil != [defs stringForKey: @"HostControlDomain"])
name = [defs stringForKey: @"ControlHost"];
if (nil != name)
{
/* Use mapping from domain name to well known name.
*/
controlName = [name copy];
name = [defs stringForKey: @"HostControlDomain"];
controlName = [name copy];
/* Use mapping from domain name to well known name.
*/
name = [defs stringForKey: @"ControlDomain"];
}
else if (nil != (name = [defs stringForKey: @"HostControlDomain"]))
else if (nil != (name = [defs stringForKey: @"ControlDomain"]))
{
/* Use domain name as the known name.
*/
@ -106,7 +107,7 @@ static NSString *controlName = nil;
}
}
host = [self currentHost];
name = [defs stringForKey: @"HostCurrentName"];
name = [defs stringForKey: @"CurrentHost"];
if (nil == name)
{
/* If the current host is the control host, we may have the
@ -116,12 +117,6 @@ static NSString *controlName = nil;
name = [host wellKnownName];
}
[host setWellKnownName: name];
if (nil == controlName)
{
/* use current host as the control host.
*/
controlName = [name copy];
}
[lock unlock];
}
else