mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 23:50:49 +00:00
iPermit provision of services to self.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9618 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
107563cc76
commit
9e852273e7
2 changed files with 64 additions and 44 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2001-04-18 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Source/GSServicesManager.m: Save the name of the port on which we
|
||||||
|
register services, and use it when we are looking for a service to
|
||||||
|
see if we can handle it ourself. Should make it possible for an
|
||||||
|
application to provide services to itsself.
|
||||||
|
Also tidied to use memory management macros.
|
||||||
|
|
||||||
Wed Apr 18 00:14:33 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
Wed Apr 18 00:14:33 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Model/IMConnectors.m: Use #import rather than #include.
|
* Model/IMConnectors.m: Use #import rather than #include.
|
||||||
|
|
|
@ -91,11 +91,12 @@
|
||||||
static NSConnection *listenerConnection = nil;
|
static NSConnection *listenerConnection = nil;
|
||||||
static GSListener *listener = nil;
|
static GSListener *listener = nil;
|
||||||
static id servicesProvider = nil;
|
static id servicesProvider = nil;
|
||||||
|
static NSString *providerName = nil;
|
||||||
|
|
||||||
void
|
void
|
||||||
NSUnregisterServicesProvider(NSString *name)
|
NSUnregisterServicesProvider(NSString *name)
|
||||||
{
|
{
|
||||||
if (listenerConnection)
|
if (listenerConnection != nil)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Ensure there is no previous listener and nothing else using
|
* Ensure there is no previous listener and nothing else using
|
||||||
|
@ -106,16 +107,16 @@ NSUnregisterServicesProvider(NSString *name)
|
||||||
removeObserver: [GSListener class]
|
removeObserver: [GSListener class]
|
||||||
name: NSConnectionDidDieNotification
|
name: NSConnectionDidDieNotification
|
||||||
object: listenerConnection];
|
object: listenerConnection];
|
||||||
[listenerConnection release];
|
DESTROY(listenerConnection);
|
||||||
listenerConnection = nil;
|
|
||||||
}
|
}
|
||||||
ASSIGN(servicesProvider, nil);
|
ASSIGN(servicesProvider, nil);
|
||||||
|
ASSIGN(providerName, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NSRegisterServicesProvider(id provider, NSString *name)
|
NSRegisterServicesProvider(id provider, NSString *name)
|
||||||
{
|
{
|
||||||
if (listenerConnection)
|
if (listenerConnection != nil)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Ensure there is no previous listener and nothing else using
|
* Ensure there is no previous listener and nothing else using
|
||||||
|
@ -126,16 +127,15 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
||||||
removeObserver: [GSListener class]
|
removeObserver: [GSListener class]
|
||||||
name: NSConnectionDidDieNotification
|
name: NSConnectionDidDieNotification
|
||||||
object: listenerConnection];
|
object: listenerConnection];
|
||||||
[listenerConnection release];
|
DESTROY(listenerConnection);
|
||||||
listenerConnection = nil;
|
|
||||||
}
|
}
|
||||||
if (name && provider)
|
if (name != nil && provider != nil)
|
||||||
{
|
{
|
||||||
listenerConnection = [NSConnection newRegisteringAtName: name
|
listenerConnection = [NSConnection newRegisteringAtName: name
|
||||||
withRootObject: [GSListener listener]];
|
withRootObject: [GSListener listener]];
|
||||||
if (listenerConnection)
|
if (listenerConnection != nil)
|
||||||
{
|
{
|
||||||
[listenerConnection retain];
|
RETAIN(listenerConnection);
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: [GSListener class]
|
addObserver: [GSListener class]
|
||||||
selector: @selector(connectionBecameInvalid:)
|
selector: @selector(connectionBecameInvalid:)
|
||||||
|
@ -143,10 +143,13 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
||||||
object: listenerConnection];
|
object: listenerConnection];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[NSException raise: NSGenericException
|
{
|
||||||
format: @"unable to register %@", name];
|
[NSException raise: NSGenericException
|
||||||
|
format: @"unable to register %@", name];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASSIGN(servicesProvider, provider);
|
ASSIGN(servicesProvider, provider);
|
||||||
|
ASSIGN(providerName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -166,8 +169,7 @@ NSRegisterServicesProvider(id provider, NSString *name)
|
||||||
removeObserver: self
|
removeObserver: self
|
||||||
name: NSConnectionDidDieNotification
|
name: NSConnectionDidDieNotification
|
||||||
object: listenerConnection];
|
object: listenerConnection];
|
||||||
[listenerConnection release];
|
DESTROY(listenerConnection);
|
||||||
listenerConnection = nil;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,10 +339,12 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
NSString *str;
|
NSString *str;
|
||||||
NSString *path;
|
NSString *path;
|
||||||
|
|
||||||
if (manager)
|
if (manager != nil)
|
||||||
{
|
{
|
||||||
if (manager->application == nil)
|
if (manager->application == nil)
|
||||||
manager->application = app;
|
{
|
||||||
|
manager->application = app;
|
||||||
|
}
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,9 +354,9 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
NSUserDomainMask, YES) objectAtIndex: 0];
|
NSUserDomainMask, YES) objectAtIndex: 0];
|
||||||
str = [str stringByAppendingPathComponent: @"Services"];
|
str = [str stringByAppendingPathComponent: @"Services"];
|
||||||
path = [str stringByAppendingPathComponent: servicesName];
|
path = [str stringByAppendingPathComponent: servicesName];
|
||||||
manager->servicesPath = [path retain];
|
manager->servicesPath = [path copy];
|
||||||
path = [str stringByAppendingPathComponent: disabledName];
|
path = [str stringByAppendingPathComponent: disabledName];
|
||||||
manager->disabledPath = [path retain];
|
manager->disabledPath = [path copy];
|
||||||
/*
|
/*
|
||||||
* Don't retain application object - that would reate a cycle.
|
* Don't retain application object - that would reate a cycle.
|
||||||
*/
|
*/
|
||||||
|
@ -389,18 +393,18 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
appName = [[NSProcessInfo processInfo] processName];
|
appName = [[NSProcessInfo processInfo] processName];
|
||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
NSUnregisterServicesProvider(appName);
|
NSUnregisterServicesProvider(appName);
|
||||||
[languages release];
|
RELEASE(languages);
|
||||||
[returnInfo release];
|
RELEASE(returnInfo);
|
||||||
[combinations release];
|
RELEASE(combinations);
|
||||||
[title2info release];
|
RELEASE(title2info);
|
||||||
[menuTitles release];
|
RELEASE(menuTitles);
|
||||||
[servicesMenu release];
|
RELEASE(servicesMenu);
|
||||||
[disabledPath release];
|
RELEASE(disabledPath);
|
||||||
[servicesPath release];
|
RELEASE(servicesPath);
|
||||||
[disabledStamp release];
|
RELEASE(disabledStamp);
|
||||||
[servicesStamp release];
|
RELEASE(servicesStamp);
|
||||||
[allDisabled release];
|
RELEASE(allDisabled);
|
||||||
[allServices release];
|
RELEASE(allServices);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +635,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
return;
|
return;
|
||||||
|
|
||||||
defs = [NSUserDefaults standardUserDefaults];
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
newLang = [[[defs arrayForKey: @"Languages"] mutableCopy] autorelease];
|
newLang = AUTORELEASE([[defs arrayForKey: @"Languages"] mutableCopy]);
|
||||||
if (newLang == nil)
|
if (newLang == nil)
|
||||||
{
|
{
|
||||||
newLang = [NSMutableArray arrayWithCapacity: 1];
|
newLang = [NSMutableArray arrayWithCapacity: 1];
|
||||||
|
@ -696,7 +700,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
|
|
||||||
- (void) rebuildServicesMenu
|
- (void) rebuildServicesMenu
|
||||||
{
|
{
|
||||||
if (servicesMenu)
|
if (servicesMenu != nil)
|
||||||
{
|
{
|
||||||
NSArray *itemArray;
|
NSArray *itemArray;
|
||||||
NSMutableSet *keyEquivalents;
|
NSMutableSet *keyEquivalents;
|
||||||
|
@ -706,13 +710,13 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
SEL sel = @selector(doService:);
|
SEL sel = @selector(doService:);
|
||||||
NSMenu *submenu = nil;
|
NSMenu *submenu = nil;
|
||||||
|
|
||||||
itemArray = [[servicesMenu itemArray] retain];
|
itemArray = [[servicesMenu itemArray] copy];
|
||||||
pos = [itemArray count];
|
pos = [itemArray count];
|
||||||
while (pos > 0)
|
while (pos > 0)
|
||||||
{
|
{
|
||||||
[servicesMenu removeItem: [itemArray objectAtIndex: --pos]];
|
[servicesMenu removeItem: [itemArray objectAtIndex: --pos]];
|
||||||
}
|
}
|
||||||
[itemArray release];
|
RELEASE(itemArray);
|
||||||
|
|
||||||
keyEquivalents = [NSMutableSet setWithCapacity: 4];
|
keyEquivalents = [NSMutableSet setWithCapacity: 4];
|
||||||
for (loc0 = pos = 0; pos < [menuTitles count]; pos++)
|
for (loc0 = pos = 0; pos < [menuTitles count]; pos++)
|
||||||
|
@ -777,7 +781,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
menu = [[NSMenu alloc] initWithTitle: parentTitle];
|
menu = [[NSMenu alloc] initWithTitle: parentTitle];
|
||||||
[servicesMenu setSubmenu: menu
|
[servicesMenu setSubmenu: menu
|
||||||
forItem: item];
|
forItem: item];
|
||||||
[menu release];
|
RELEASE(menu);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -827,7 +831,9 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
registered = YES;
|
registered = YES;
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
registered = NO;
|
{
|
||||||
|
registered = NO;
|
||||||
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
|
||||||
if (registered == NO)
|
if (registered == NO)
|
||||||
|
@ -957,7 +963,7 @@ static NSString *disabledName = @".GNUstepDisabled";
|
||||||
|
|
||||||
[self loadServices];
|
[self loadServices];
|
||||||
if (allDisabled == nil)
|
if (allDisabled == nil)
|
||||||
allDisabled = [[NSMutableSet setWithCapacity: 1] retain];
|
allDisabled = [[NSMutableSet alloc] initWithCapacity: 1];
|
||||||
if (enable)
|
if (enable)
|
||||||
[allDisabled removeObject: item];
|
[allDisabled removeObject: item];
|
||||||
else
|
else
|
||||||
|
@ -1143,17 +1149,23 @@ GSContactApplication(NSString *appName, NSString *port, NSDate *expire)
|
||||||
{
|
{
|
||||||
id app;
|
id app;
|
||||||
|
|
||||||
NS_DURING
|
if (providerName != nil && [port isEqual: providerName] == YES)
|
||||||
{
|
{
|
||||||
app = [NSConnection rootProxyForConnectionWithRegisteredName: port
|
app = servicesProvider;
|
||||||
host: @""];
|
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
else
|
||||||
{
|
{
|
||||||
return nil; /* Fatal error in DO */
|
NS_DURING
|
||||||
|
{
|
||||||
|
app = [NSConnection rootProxyForConnectionWithRegisteredName: port
|
||||||
|
host: @""];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
return nil; /* Fatal error in DO */
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
|
||||||
|
|
||||||
if (app == nil)
|
if (app == nil)
|
||||||
{
|
{
|
||||||
if ([[NSWorkspace sharedWorkspace] launchApplication: appName] == NO)
|
if ([[NSWorkspace sharedWorkspace] launchApplication: appName] == NO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue