home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / appkit / Listener.h < prev    next >
Text File  |  1992-05-22  |  6KB  |  180 lines

  1. /*
  2.     Listener.h
  3.     Application Kit, Release 2.0
  4.     Copyright (c) 1988, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #import <objc/Object.h>
  8. #import <mach/port.h>
  9. #import <mach/message.h>
  10. #import "Pasteboard.h"
  11.  
  12. /*
  13.  * Functions to enable/disable Services Menu items.  These should usually
  14.  * only be called by service PROVIDERS (since they are the only ones who
  15.  * know the name of the services, requestors don't).  The itemName in the
  16.  * two functions below is the language-independent "Menu Item:" entry in
  17.  * the __services section (which all provided services must have).  The
  18.  * set function returns whether it was successful.
  19.  * NXUpdateDynamicServices() causes the services information for the
  20.  * system to be updated.  This will only be necessary if your program
  21.  * adds dynamic services to the system (i.e. services not found in macho
  22.  * segments oUE#ecutables).
  23.  */
  24.  
  25. extern BOOL NXIsServicesMenuItemEnabled(const char *itemName);
  26. extern int NXSetServicesMenuItemEnabled(const char *itemName, BOOL enabled);
  27. extern void NXUpdateDynamicServices(void);
  28. extern BOOL NXPerformService(const char *itemName, Pasteboard *pboard);
  29.  
  30. /*
  31.  * Names of workspace ports for requests and for acknowledging machlaunch
  32.  * from the Workspace Manager.
  33.  */
  34.  
  35. extern const char *NXWorkspaceName;
  36. extern const char *const NXWorkspaceReplyName;
  37. #define NX_WORKSPACEREQUEST NXWorkspaceName
  38. #define NX_WORKSPACEREPLY NXWorkspaceReplyName
  39.  
  40. /* reserved message numbers */
  41.  
  42. #define NX_SELECTORPMSG 35555
  43. #define NX_SELECTORFMSG 35556
  44. #define NX_RESPONSEMSG 35557
  45. #define NX_ACKNOWLEDGE 35558
  46.  
  47. /* rpc return result error returns */
  48.  
  49. #define NX_INCORRECTMESSAGE -20000
  50.  
  51. /* maximum number of remote method parameters allowed */
  52.  
  53. #define NX_MAXMSGPARAMS 20
  54.  
  55. /* default timeouts in milliseconds */
  56.  
  57. #define NX_SENDTIMEOUT 10000
  58. #define NX_RCVTIMEOUT 10000
  59.  
  60. #define NX_MAXMESSAGE    (2048-sizeof(msg_header_t)-\
  61.              sizeof(msg_type_t)-sizeof(int)-\
  62.              sizeof(msg_type_t)-8)
  63.              
  64. typedef struct _NXMessage {    /* a message via mach */
  65.     msg_header_t header;    /* every message has one of these */
  66.     msg_type_t sequenceType;    /* sequence number type */
  67.     int sequence;        /* sequence number */
  68.     msg_type_t actionType;    /* selector string */
  69.     char action[NX_MAXMESSAGE];
  70. } NXMessage;
  71.  
  72. typedef struct _NXResponse {    /* a message via mach */
  73.     msg_header_t header;    /* every message has one of these */
  74.     msg_type_t sequenceType;    /* sequence number type */
  75.     int sequence;        /* sequence number */
  76. } NXResponse;
  77.  
  78. typedef struct _NXAcknowledge {    /* a message via mach */
  79.     msg_header_t header;    /* every message has one of these */
  80.     msg_type_t sequenceType;    /* sequence number type */
  81.     int sequence;        /* sequence number */
  82.     msg_type_t errorType;    /* error number type */
  83.     int error;            /* error number, 0 is ok */
  84. } NXAcknowledge;
  85.  
  86. typedef struct _NXRemoteMethod {/* defines method understood by Listener */
  87.     SEL key;            /* obj-c selector */
  88.     char *types;        /* defines types of parameters */
  89. } NXRemoteMethod;
  90.  
  91. typedef union {            /* used to pass parameters to method */
  92.     int ival;
  93.     double dval;
  94.     port_t pval;
  95.     struct _bval {
  96.         char *p;
  97.         int len;
  98.     } bval;
  99. } NXParamValue;
  100.  
  101. extern char *NXCopyInpuUE$a(int parameter);
  102. extern char *NXCopyOutputData(int parameter);
  103. extern port_t NXPortFromName(const char *portName, const char *hostName);
  104. extern port_t NXPortNameLookup(const char *portName, const char *hostName);
  105. extern NXRemoteMethod *NXRemoteMethodFromSel(SEL s, NXRemoteMethod *pt);
  106. extern id NXResponsibleDelegate(id self, SEL selector);
  107.  
  108. /*
  109.  * permissible values of posType for setPosition:posType:andSelect:
  110.  * and postion:posType:
  111.  */
  112.  
  113. #define NX_TEXTPOSTYPE 0
  114. #define NX_REGEXPRPOSTYPE 1
  115. #define NX_LINENUMPOSTYPE 2
  116. #define NX_CHARNUMPOSTYPE 3
  117. #define NX_APPPOSTYPE 4
  118.  
  119. @interface Listener : Object
  120. {
  121.     char               *portName;
  122.     port_t              listenPort;
  123.     port_t              signaturePort;
  124.     id                  delegate;
  125.     int                 timeout;
  126.     int                 priority;
  127.     id                  _delegate2;
  128.     id                  _requestDelegate;
  129.     int                 _reservedListener2;
  130. }
  131.  
  132. + initialize;
  133. + run;
  134.  
  135. - init;
  136. - free;
  137. - (int)timeout;
  138. - setTimeout:(int)ms;
  139. - (int)priority;
  140. - setPriority:(int)level;
  141. - (port_t)listenPort;
  142. - (port_t)signaturePort;
  143. - delegate;
  144. - setDelegate:anObject;
  145. - setServicesDelegate:anObject;
  146. - servicesDelegate;
  147. - (const char *)portName;
  148. - (int)checkInAs:(const char *)name;
  149. - (int)usePrivatePort;
  150. - (int)checkOut;
  151. - addPort;
  152. - removePort;
  153. - (NXRemoteMethod *)remoteMethodFor:(SEL)aSelector;
  154. - messageReceived:(NXMessage *)msg;
  155. - write:(NXTypedStream *)stream;
  156. - read:(NXTypedStream *)stream;
  157.  
  158. - (int)msgQuit:(int *)flag;
  159. - (int)msgCalc:(int *)flag;
  160. - (int)msgDirectory:(char * const *)fullPath ok:(int *)flag;
  161. - (int)msgVersion:(char * const *)aString ok:(int *)flag;
  162. - (int)msgFile:(char * const *)fullPath ok:(int *)flag;
  163. - (int)msgPrint:(const char *)fullPath ok:(int *)flag;
  164. - (int)msgSelection:(char * const *)bytes length:(int *)len asType:(const char *)aType ok:(int *)flag;
  165. - (int)msgSetPosition:(const char *)aString posType:(int)anInt andSelect:(int)sflag ok:(int *)flag;
  166. - (int)msgPosition:(char * const *)aString posType:(int *)anInt ok:(int *)flag;
  167. - (int)msgCopyAsType:(const char *)aType ok:(int *)flag;
  168. - (int)msgCutAsType:(const char *)aType ok:(int *)flag;
  169. - (int)msgPaste:(int *)flag;
  170. - (int)performRemoteMethod:(NXRemoteMethod *)method paramList:(NXParamValue *)params;
  171.  
  172. /* 
  173.  * The following new... methods are now obsolete.  They remain iUE%is  
  174.  * interface file for backward compatibility only.  Use Object's alloc method  
  175.  * and the init... methods defined in this class instead.
  176.  */
  177. + new;
  178.  
  179. @end
  180.