? gdnc.diff
Index: gdnc.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Tools/gdnc.m,v
retrieving revision 1.24
diff -u -r1.24 gdnc.m
--- gdnc.m	13 May 2003 16:00:21 -0000	1.24
+++ gdnc.m	18 Jun 2003 08:07:50 -0000
@@ -852,6 +852,70 @@
 
 @end
 
+@interface GSAppInfoCenter : NSObject
+{
+NSDistributedNotificationCenter       *appInfoCenter;
+NSMutableArray                        *_launchedApplications;
+NSConnection                          *appInfoConn;
+}
+-(void)_handleLaunchNotification:(NSNotification*)notif;
+-(void)_handleTerminateNotification:(NSNotification*)notif;
+
+@end
+
+@implementation GSAppInfoCenter
+- (void) dealloc
+{
+  RELEASE(appInfoCenter);
+  RELEASE(_launchedApplications);
+  RELEASE(appInfoConn);
+  [super dealloc];
+}
+- (id) init
+{
+  self = [super init];
+  if (self != nil)
+   {
+     _launchedApplications = RETAIN([NSMutableArray new]);
+     appInfoConn = RETAIN([NSConnection 
+                            connectionWithReceivePort: (NSPort*)[NSPort port]
+                                             sendPort: (NSPort*)[NSPort port]]);
+
+     [appInfoConn setRootObject: _launchedApplications];
+
+     if (![appInfoConn registerName: @"appinfo"])
+     {
+        NSLog(@"could not register name appinfo.");
+     }
+
+     appInfoCenter = RETAIN([NSDistributedNotificationCenter defaultCenter]);
+
+     [appInfoCenter addObserver: self
+                     selector: @selector(_handleLaunchNotification:)
+                         name: @"NSWorkspaceDidLaunchApplicationNotification" 
+                       object: nil];
+
+     [appInfoCenter addObserver: self
+                     selector: @selector(_handleTerminateNotification:)
+                         name: @"NSWorkspaceDidTerminateApplicationNotification"
+                       object: nil];
+    }
+return self;
+}
+
+-(void)_handleLaunchNotification:(NSNotification*)notif
+{
+[_launchedApplications addObject: [notif userInfo]];
+
+}
+
+-(void)_handleTerminateNotification:(NSNotification*)notif
+{
+[_launchedApplications addObject: [notif userInfo]];
+}
+
+@end
+
 int
 main(int argc, char** argv, char** env)
 {
@@ -859,6 +923,7 @@
   NSString		*str;
   BOOL			shouldFork = YES;
   BOOL			debugging = NO;
+  GSAppInfoCenter	*appInfoCenter;
   CREATE_AUTORELEASE_POOL(pool);
 
 #ifdef GS_PASS_ARGUMENTS
@@ -962,6 +1027,7 @@
   if (server != nil)
     {
       CREATE_AUTORELEASE_POOL(pool);
+      appInfoCenter = [GSAppInfoCenter new];
       [[NSRunLoop currentRunLoop] run];
       RELEASE(pool);
     }
