ftp.nice.ch/pub/next/tools/dock/Performance.0.6d.Examples.NIHS.bd.tar.gz#/Performance/Directors/DirectorSource/serverDirector/serverDirector.m

This is serverDirector.m in view mode; [Download] [Up]

#import "serverDirector.h"
#import "UnderstudyAgent.h"
#import "PAStringList.h"

@implementation serverDirector

+ (BOOL)allowMultipleLoads
{
  return NO ;
}

- initWithController:aController andTag:(int)aTag 
{
  char nibPath[MAXPATHLEN+1] ;
  char actorPath[MAXPATHLEN+1] ;

  [super initWithController:aController andTag:aTag] ;

  if ([[NXBundle bundleForClass:[self class]] getPath:nibPath 
       forResource:"serverDirector" ofType:"nib"])
  {
    [NXApp loadNibFile:nibPath owner:self] ;
  }

  /* add a new actor */
  sprintf(actorPath, "%s/Library/Actors/IBIX.actor", getenv("HOME")) ;
  theServer=[self createNewActorFrom:actorPath] ;

  /* have the client advertise the demoService */
  [theServer advertise:"demoService"] ;

  return self ;
}

- activationOccurredOn:anActor 
{
  return self ;
}

- clearOccurredOn:anActor 
{
  return self ;
}

- didAddActor:anActor 
{
  return self ;
}

- documentWillClose 
{
  return self ;
}

- dragOccurredOn:anActor 
{
  return self ;
}

- dropOccurredOn:anActor 
{
  int count ;
  id theList ;
  char theTitle[100] ;

  /* if the actor is advertising, put all the clients in the attachments panel and bring it up */
  if (![anActor advertisedService]) ;
  {
    return self ;
  }

  /* get the client list */
  theList=[anActor subscriberList] ;
  count=[theList count] ;

  /* empty the string handler */
  [stringHandler freeStrings] ;

  /* fill the string handler */
  while (count--)
  {
    [stringHandler addString:[[theList objectAt:count] alias]] ;
  }

  /* have the browser reload */
  [attachmentsBrowser loadColumnZero] ;

  /* set the title on the panel */
  sprintf(theTitle, "%s:Clients for service (%s)", [[self class] name], [anActor advertisedService]) ;

  /* bring up the panel */
  [attachmentsPanel makeKeyAndOrderFront:self] ;

  return self ;
}

- launchOccurredOn:anActor 
{ 
  return self ;
}

- specialActivationOccurredOn:anActor
{
  char **theAttachments ;
  int looper=-1 ;
  char theTitle[100] ;
  id subscriberList ;

  /* get the attachments on the actor */
  if (!(theAttachments=[anActor droppedFiles]))
  {				/* no attachments, so just show alert panel */
    NXRunAlertPanel([[self class] name], "Special Activation Occurred for %s", NULL, NULL, NULL,
		    [anActor alias]) ;
    return self ;
  }

  /* empty the stringHandler */
  [stringHandler freeStrings] ;

  /* fill the string handler with the attachment names */
  while (theAttachments[++looper])
  {
    [stringHandler addString:theAttachments[looper]] ;
  }

  /* add the client names */
  subscriberList=[anActor subscriberList] ;
  looper=[subscriberList count] ;
  while (looper--)
  {
    sprintf(theTitle, "Client: %s", [[subscriberList objectAt:looper] alias]) ;
    [stringHandler addString:theTitle] ;
  }

  /* have the attachmentsBrowser fill itself */
  [attachmentsBrowser loadColumnZero] ;

  /* change the title on the attachmentsPanel */
  sprintf(theTitle, "%s:Attachments and clients for %s", [[self class] name], [anActor alias]) ;
  [attachmentsPanel setTitle:theTitle] ;

  /* bring up the attachmentsPanel */
  [attachmentsPanel makeKeyAndOrderFront:self] ;

  return self ;
}

- willEnterScreenSaverMode 
{
  return self ;
}

- willExitScreenSaverMode 
{
  return self ;
}

- willRemoveActor:anActor 
{
  return self ;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.