home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP Advantage / NeXTstep_Advantage.img / YourCallService / CallService.m < prev    next >
Text File  |  1993-04-14  |  2KB  |  64 lines

  1. /* You may freely copy, distribute and reuse the code in this example.
  2.  * NeXT disclaims any warranty of any kind, expressed or implied, as to
  3.  * its fitness for any particular use.
  4.  */ 
  5.  
  6. #import "CallService.h"
  7.  
  8. @implementation CallService : CallController
  9.  
  10. /*
  11.  * Purpose: notifies the application's delegate that the application
  12.  * is ready to start.
  13.  *
  14.  * CallService implements this method to register itself as
  15.  * the services delegate: the object that will handle requests
  16.  * for the application's registered service.
  17.  *
  18.  */
  19.  
  20. - appDidInit:sender
  21. {
  22.     [[NXApp appListener] setServicesDelegate:self];
  23.     return self;
  24. }
  25.  
  26. /* 
  27.  * Purpose: responds to a request for the application's service
  28.  * 
  29.  * Implemented by the application's services delegate to 
  30.  * respond to requests for the registered service, "Find Caller."
  31.  *
  32.  */
  33.  
  34. - requestCall:pasteboard userData:(const char *)userData error:(char **)errorMessage 
  35. {
  36.     id      success;
  37.     char *data;
  38.     int   dataLength;
  39.     char *theName;
  40.  
  41.     [pasteboard types];
  42.     success = 
  43.     [pasteboard readType:NXAsciiPboardType data:&data length:&dataLength];
  44.     if (success) {
  45.     if (data && dataLength) {
  46.         theName = malloc(dataLength+1);
  47.         strncpy(theName, data, dataLength);
  48.         theName[dataLength]='\0';
  49.         [customerForm setStringValue:theName at:0];
  50.         [self retrieveCall:self];
  51.         [pasteboard deallocatePasteboardData:data length:dataLength];
  52.         free(theName); 
  53.     }
  54.     else {
  55.         NXRunAlertPanel("Search Failed", "Please select a customer name", 
  56.         NULL, NULL, NULL);
  57.     }
  58.     }
  59.     else *errorMessage = "Please select a customer name";
  60.     return self;
  61. }
  62.  
  63. @end
  64.