improve defaults handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@39065 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-10-14 11:25:48 +00:00
parent d13acdff08
commit 4ce12c8d08
5 changed files with 49 additions and 9 deletions

View file

@ -1,3 +1,14 @@
2015-10-14 Richard Frith-Macdonald <rfm@gnu.org>
* EcUserDefaults.h:
* EcUserDefaults.m:
New -revertSettings method to revert all local config settings.
* EcProcess.h:
* EcProcess.m:
Change cmdDefaultDbg to cmdBasicDbg to avoid confusion of the debug
mode with default settings.
Add 'defaults revert' command for Console to use.
2015-10-09 Richard Frith-Macdonald <rfm@gnu.org>
* EcProcess.h: declare new -launch: method

View file

@ -601,12 +601,12 @@ extern NSString* cmdVersion(NSString *ver);
- (void) cmdDbg: (NSString*)type
msg: (NSString*)fmt, ... NS_FORMAT_FUNCTION(2,3);
/** Send a debug message with debug mode 'defaultMode'.<br />
/** Send a debug message with debug mode 'basicMode'.<br />
* Calls the -cmdDbg:msg:arguments: method.
*/
- (void) cmdDebug: (NSString*)fmt arguments: (va_list)args;
/** Send a debug message with debug mode 'defaultMode'.<br />
/** Send a debug message with debug mode 'basicMode'.<br />
* Operates by calling the -cmdDebug:arguments: method.
*/
- (void) cmdDebug: (NSString*)fmt, ... NS_FORMAT_FUNCTION(1,2);
@ -1045,9 +1045,9 @@ extern NSString* cmdVersion(NSString *ver);
extern EcProcess *EcProc; /* Single instance or nil */
extern NSString* cmdConnectDbg; /* Debug connection attempts. */
extern NSString* cmdDefaultDbg; /* Debug normal stuff. */
extern NSString* cmdDetailDbg; /* Debug stuff in more detail. */
extern NSString *cmdBasicDbg; /* Debug normal stuff. */
extern NSString *cmdConnectDbg; /* Debug connection attempts. */
extern NSString *cmdDetailDbg; /* Debug stuff in more detail. */
#endif /* INCLUDED_ECPROCESS_H */

View file

@ -625,7 +625,7 @@ ecCommandName()
}
NSString *cmdDefaultDbg = @"defaultMode";
NSString *cmdBasicDbg = @"basicMode";
NSString *cmdConnectDbg = @"connectMode";
NSString *cmdDetailDbg = @"detailMode";
@ -1797,11 +1797,11 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
[cmdDebugKnown setObject: @"Mode for distributed object connections"
forKey: cmdConnectDbg];
[cmdDebugKnown setObject: @"Standard mode for basic debug information"
forKey: cmdDefaultDbg];
forKey: cmdBasicDbg];
[cmdDebugKnown setObject: @"Detailed but general purpose debugging"
forKey: cmdDetailDbg];
[cmdDebugModes addObject: cmdDefaultDbg];
[cmdDebugModes addObject: cmdBasicDbg];
[self ecRegisterDefault: @"Memory"
withTypeText: @"YES/NO"
@ -2003,7 +2003,7 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
- (void) cmdDebug: (NSString*)fmt arguments: (va_list)args
{
if (nil != [cmdDebugModes member: cmdDefaultDbg])
if (nil != [cmdDebugModes member: cmdBasicDbg])
{
if (nil == debugLogger)
{
@ -3023,7 +3023,14 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
[self cmdPrintf: @"and value, the command sets a default.\n"];
[self cmdPrintf: @"With the 'read' parameter followed by a name,"];
[self cmdPrintf: @"the command is used to show a default.\n"];
[self cmdPrintf: @"With the 'revert' parameter,"];
[self cmdPrintf: @"the command is used to revert all defaults.\n"];
}
else if ([msg count] > 1 && [[msg objectAtIndex: 1] isEqual: @"revert"])
{
[cmdDefs revertSettings];
[self cmdPrintf: @"All settings are reverted to default.\n"];
}
else if ([msg count] > 2)
{
NSString *mode = (NSString*)[msg objectAtIndex: 1];

View file

@ -67,6 +67,11 @@
*/
- (NSString*) key: (NSString*)aKey;
/** Removes all settings previously set up using the -setCommand:forKey:
* method.
*/
- (void) revertSettings;
/** Sets a value to take precedence over others (in the volatile domain
* reserved for commands issued to the current process by an operator).<br />
* Setting a nil value removes any previously set value so that behavior

View file

@ -208,6 +208,11 @@ static NSLock *lock = nil;
return [defs removeObjectForKey: [self _getKey: aKey]];
}
- (void) revertSettings
{
[defs revertSettings];
}
- (void) setBool: (BOOL)value forKey: (NSString*)aKey
{
[defs setBool: value forKey: [self key: aKey]];
@ -301,6 +306,18 @@ static NSLock *lock = nil;
return aKey;
}
- (void) revertSettings
{
NSDictionary *old = [self volatileDomainForName: @"EcCommand"];
if (nil != old)
{
[self removeVolatileDomainForName: @"EcCommand"];
[[NSNotificationCenter defaultCenter] postNotificationName:
NSUserDefaultsDidChangeNotification object: self];
}
}
- (BOOL) setCommand: (id)val forKey: (NSString*)key
{
NSDictionary *old = [self volatileDomainForName: @"EcCommand"];