mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 02:01:03 +00:00
Add auto shutdown for gdnc and filesystem fixup for spelling dictionaries
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24787 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
88059b226b
commit
cbcf93e905
4 changed files with 42 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
2007-03-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSpellServer.m: Use Library directory in user domain for
|
||||
local dictionaries.
|
||||
* Source/NSDistributedNotificationCenter.m: autolaunch gdnc with the
|
||||
--auto option.
|
||||
* Tools/gdnc.m: Understand --auto to mean that we should shut down
|
||||
automatically when all connections in to us are dropped.
|
||||
|
||||
2007-03-06 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* configure.ac: Added GNUSTEP_SYSTEM_USERS_DIR,
|
||||
|
|
|
@ -710,17 +710,29 @@ static NSDistributedNotificationCenter *netCenter = nil;
|
|||
if (_type == GSNetworkNotificationCenterType)
|
||||
{
|
||||
args = [NSArray arrayWithObjects:
|
||||
@"-GSNetwork", @"YES", nil];
|
||||
@"-GSNetwork", @"YES",
|
||||
@"--auto",
|
||||
nil];
|
||||
}
|
||||
else if (_type == GSPublicNotificationCenterType)
|
||||
{
|
||||
args = [NSArray arrayWithObjects:
|
||||
@"-GSPublic", @"YES", nil];
|
||||
@"-GSPublic", @"YES",
|
||||
@"--auto",
|
||||
nil];
|
||||
}
|
||||
else if ([host length] > 0)
|
||||
{
|
||||
args = [NSArray arrayWithObjects:
|
||||
@"-NSHost", host, nil];
|
||||
@"-NSHost", host,
|
||||
@"--auto",
|
||||
nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
args = [NSArray arrayWithObjects:
|
||||
@"--auto",
|
||||
nil];
|
||||
}
|
||||
[NSTask launchedTaskWithLaunchPath: cmd arguments: args];
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ GSSpellServerName(NSString *vendor, NSString *language)
|
|||
NSString *path = nil;
|
||||
NSString *user_gsroot = nil;
|
||||
|
||||
user_gsroot = [NSSearchPathForDirectoriesInDomains(NSUserDirectory,
|
||||
user_gsroot = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSUserDomainMask, YES) lastObject];
|
||||
|
||||
if (currentLanguage != nil)
|
||||
|
@ -182,7 +182,8 @@ GSSpellServerName(NSString *vendor, NSString *language)
|
|||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
|
||||
// Build the path and try to get the dictionary
|
||||
dirPath = [user_gsroot stringByAppendingPathComponent: GNU_UserDictionariesDir];
|
||||
dirPath = [user_gsroot stringByAppendingPathComponent:
|
||||
GNU_UserDictionariesDir];
|
||||
path = [dirPath stringByAppendingPathComponent: currentLanguage];
|
||||
|
||||
if (![mgr fileExistsAtPath: path ])
|
||||
|
@ -236,6 +237,7 @@ GSSpellServerName(NSString *vendor, NSString *language)
|
|||
if ((path = [self _pathToDictionary: language]) != nil)
|
||||
{
|
||||
NSArray *wordarray = [NSArray arrayWithContentsOfFile: path];
|
||||
|
||||
if (wordarray == nil)
|
||||
{
|
||||
NSLog(@"Unable to load user dictionary from path %@",path);
|
||||
|
@ -351,6 +353,7 @@ is a set of words learned by the spell service for that particular user.
|
|||
if ((path = [self _pathToDictionary: language]) != nil)
|
||||
{
|
||||
NSMutableSet *set = [_userDictionaries objectForKey: language];
|
||||
|
||||
if (![[set allObjects] writeToFile: path atomically: YES])
|
||||
{
|
||||
NSLog(@"Unable to save dictionary to path %@",path);
|
||||
|
|
13
Tools/gdnc.m
13
Tools/gdnc.m
|
@ -40,6 +40,7 @@
|
|||
#endif
|
||||
|
||||
static BOOL is_daemon = NO; /* Currently running as daemon. */
|
||||
static BOOL auto_stop = NO; /* Should we shut down when unused? */
|
||||
static char ebuf[2048];
|
||||
|
||||
#ifdef HAVE_SYSLOG
|
||||
|
@ -642,6 +643,14 @@ ihandler(int sig)
|
|||
[self removeObserversForClients: table];
|
||||
NSFreeMapTable(table);
|
||||
}
|
||||
|
||||
if (auto_stop == YES && NSCountMapTable(connections) == 0)
|
||||
{
|
||||
/* If there is nothing else using this process, and this is not
|
||||
* a daemon, then we can quietly terminate.
|
||||
*/
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
@ -1047,6 +1056,10 @@ main(int argc, char** argv, char** env)
|
|||
printf("--verbose\tMore verbose debug output\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if ([[pInfo arguments] containsObject: @"--auto"] == YES)
|
||||
{
|
||||
auto_stop = YES;
|
||||
}
|
||||
if ([[pInfo arguments] containsObject: @"--daemon"] == YES)
|
||||
{
|
||||
subtask = NO;
|
||||
|
|
Loading…
Reference in a new issue