home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / atari / st / tech / 6364 < prev    next >
Encoding:
Text File  |  1992-12-21  |  23.8 KB  |  511 lines

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!Sirius.dfn.de!zam103!djukfa11!hac041
  2. From: HAC041@DJUKFA11.BITNET (Konrad Hinsen)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: XAcc protocol definition
  5. Message-ID: <92356.104533HAC041@DJUKFA11.BITNET>
  6. Date: 21 Dec 92 09:45:33 GMT
  7. Organization: Forschungszentrum Juelich
  8. Lines: 501
  9.  
  10. XAcc: a communication protocol for GEM applications
  11. ===================================================
  12.  
  13. (last revision: November 28, 1992)
  14.  
  15.  
  16. The XAcc protocol was originally designed for non-multitasking versions of
  17. GEM to allow data exchange between the main application and any number of
  18. accessories. Since the AES did not provide a function to find the
  19. application ids (apids) of other applications without knowing their names,
  20. XAcc had to rely on the undocumented feature that the main application
  21. always has the apid 0. Therefore XAcc in its present form does not work in
  22. a multitasking environment. However, AES 4.0 provides the new function
  23. appl_search(), which allows any application to find the apids of all other
  24. applications running concurrently. This makes it possible to design a
  25. modified XAcc that does not use any 'dirty tricks'. This document contains
  26. a proposal for such a modified XAcc; the changes with respect to the
  27. previous definition are small and modifying an existing XAcc-based
  28. application should be a matter of minutes. Since single-tasking TOS will
  29. still be with us for a while, applications are encouraged to implement both
  30. 'traditional' and 'modern' XAcc, depending on the version number of the AES.
  31.  
  32.  
  33. Purpose
  34. -------
  35.  
  36. The GEM AES functions appl_write() and appl_read() can be used to exchange
  37. data between GEM applications running concurrently. In practice however,
  38. some problems need to be solved to make good use of these two functions:
  39.  
  40. - There are no standard messages for exchanging data. Their definition is
  41.   the main goal of XAcc.
  42.  
  43. - appl_write() needs the receiver's application identifier (apid). The
  44.   only way to get this (before AES 4.0) is to call appl_find(), which
  45.   needs the receiver's name. Thus communication is only possible if
  46.   the sender knows the receiver's name.
  47.   This problem is solved in AES 4.0 by the introduction of the function
  48.   appl_search().
  49.  
  50. - The main application does not know when an accessory is activated or
  51.   deactivated. This would often be useful, for example if the main
  52.   application changes system variables that could affect the accessory's
  53.   behaviour. If the main application were informed before the accessory
  54.   gains control, it could reset those to their old values and change
  55.   them back after the accessory is finished.
  56.   Another advantage would be that after an accessory has been called,
  57.   the main application could check if something has been written to the
  58.   clipboard or if other changes to the environment have been made.
  59.  
  60.   With multitasking GEM, the situation has changed in several important
  61.   ways. The possibility of using several 'main' applications in parallel
  62.   makes it even more undesirable to let them directly manipulate system
  63.   variables and the like; nevertheless there will probably always remain
  64.   some purposes that require such methods. On the other hand, at least
  65.   for applications using windows (the preferred method to get the most
  66.   out of a multitasking system) it is now possible to detect changes
  67.   of the active application by interpreting the new AES messages
  68.   WM_ONTOP and WM_UNTOPPED. Therefore it is not considered necessary
  69.   for XAcc to provide additional means to achieve this.
  70.  
  71. The communications protocol described in this document solves all these
  72. problems. It was designed for two distinct purposes:
  73.  
  74. - Exchanging data of standard types between programs that have no
  75.   information about each other.
  76.  
  77. - Exchanging data between specific applications known to each other.
  78.   The standard protocol ensures that program combinations from
  79.   different vendors do not interfere with each other.
  80.  
  81. A potential problem caused by this protocol should be mentioned at this
  82. point: for single-tasking GEM versions, it relies on the currently
  83. undocumented fact that the main application's apid is always zero. Without
  84. this assumption there is no way to exchange data without using appl_find().
  85. Although this fact is not documented, it holds for all single-tasking
  86. versions of GEM in existence until now, both for MS-DOS and the Atari ST
  87. (this information was confirmed by Digital Research Germany). Of course
  88. the main application's apid may be different in future versions, although
  89. there is no reason to change the current behaviour for single-tasking
  90. systems. For AES 4.0 (and later) the above assumption is not needed anyway,
  91. so no compatibility problems are to be expected in the future.
  92.  
  93. A further requirement is that all programs not using this protocol must
  94. ignore its messages. This should not be a serious problem, as all GEM
  95. applications should ignore messages they do not understand. At the time
  96. of writing no programs are known to violate this rule.
  97.  
  98.  
  99. XAcc message groups
  100. -------------------
  101.  
  102. [Note: The "levels" used in previous XAcc versions have been replaced
  103.  by this new concept. Compatibility issues are discussed in a special
  104.  section at the end of this document.]
  105.  
  106. Both main applications and accessories can have widely different needs for
  107. communication with other programs. Therefore XAcc defines several groups
  108. of related messages that deal with a certain range of data types.
  109. The message groups always indicate the messages understood by a
  110. program, not the messages it might send to other ones. If a program
  111. supports a certain message group, it must correctly respond to all
  112. corresponding messages, whether it can actually use the supplied data
  113. or not.
  114.  
  115. In addition to message groups, there are the so-called "basic messages",
  116. which must be supported by any XAcc-aware program, and program-specific
  117. so-called "special messages".
  118.  
  119. The basic messages deal solely with identification, but no real data
  120. exchange. They are already sufficient for programs that either do not
  121. exchange data with others at all or use only special messages to
  122. communicate with a number of other specific programs.
  123.  
  124. Message group 1 specifies the exchange of ASCII-format character data.
  125.  
  126. Message group 2 deals with the exchange of drawings and pictures using
  127. the GEM metafile format and the GEM bit-image file format.
  128.  
  129. Future extensions might include sound or spreadsheet data. In addition,
  130. a message group could be defined to handle command interchange between
  131. applications, e.g. for a "drag&drop" protocol.
  132.  
  133.  
  134. XAcc messages
  135. -------------
  136.  
  137. There are two kinds of XAcc messages: standard messages, which must be
  138. understood by every participating program, and special messages intended
  139. for communications between specific program combinations. The standard
  140. messages have numbers ranging from 0x400 to 0x7ff, special messages start
  141. from 0x800. The latter ones may only be sent after the receiver has been
  142. identified and is known to understand them. The following description is
  143. only concerned with standard messages.
  144. In addition to XAcc standard messages, the AES messages normally sent
  145. by the screen manager may be used. The most useful ones are AC_OPEN
  146. and MN_SELECTED; the latter one requires a knowledge of the receiver
  147. and therefore belongs to the special messages.
  148.  
  149.  
  150. Basic messages
  151. --------------
  152.  
  153. ACC_ID = 0x400
  154. ACC_OPEN = 0x401
  155. ACC_CLOSE = 0x402
  156. ACC_ACC = 0x403
  157. ACC_EXIT = 0x404
  158.  
  159. These messages provide XAcc initialization and organization. This is
  160. the only part of XAcc which has to be implemented in a different way for
  161. single- and multi-tasking GEM versions. Note that the procedure
  162. described for 'multitasking' actually only depends on the existence of
  163. appl_search() and hence on an AES version number >= 4.0. If some
  164. future single-tasking AES supports appl_search(), the "multitasking"
  165. initialization should be used. Multitasking AES versions with a version
  166. number < 4.0 should never exist; to be on the safe side, applications
  167. should not attempt to use XAcc if such a situation is detected.
  168.  
  169. I) Single-tasking GEM versions
  170.  
  171. The communication between the main application and the accessories is
  172. initiated in the following way:
  173.  
  174. 1) When a main application is started (or terminated), all accessories
  175.    receive an AC_CLOSE message from the AES screen manager. In response
  176.    they must send an identification to the main application according
  177.    to the following format:
  178.      msgbuf[0]:  ACC_ID
  179.      msgbuf[1]:  sender's apid
  180.      msgbuf[2]:  length of the message - 16, giving 0
  181.      msgbuf[3]:  program version number and message groups
  182.      msgbuf[4] and msgbuf[5]:   pointer to sender's name
  183.      msgbuf[6]:  menu number (menu_id) as returned by menu_register()
  184.      msgbuf[7]:  reserved (see ACC_ACC)
  185.    The low byte of msgbuf[3] contains a bitmap indicating which message
  186.    groups are understood by the sender. Bit zero is set for message
  187.    group 1, bit one for message group 2, and so on. This is independent
  188.    of the message types which the sender might itself send to others. The
  189.    sender of a message must ensure that it is understood by the receiver.
  190.    The high byte is used to indicate a program version number using an
  191.    arbitrary encoding scheme.
  192.    The pointer to the sender's name is stored in a machine-dependent
  193.    format. The name itself is a character string following C conventions,
  194.    i.e. a string of characters terminated by a zero byte. To avoid name
  195.    conflicts, long names are preferred to short abbreviations. The name
  196.    must be available at the given address at any time, it may not be
  197.    removed after initialisation. As the version number is stored in
  198.    msgbuf[3], it should not occur again in the name.
  199.    [Note: see the section "Extended names" for more details on names.]
  200.    Accessories using more than one menu entry must issue one ACC_ID
  201.    message for each entry used. Accessories without a menu entry must
  202.    use a number of -1.
  203.  
  204. Since msgbuf[1] and msgbuf[2] have the same meaning for all message
  205. types, they are no longer mentioned from now on.
  206.  
  207. 2) In response to an ACC_ID message the main application sends an
  208.    identification back to the accessory. The format is identical, except
  209.    that there ist no menu number and thus msgbuf[6] can be used for any
  210.    other purpose if neccessary. The same applies to msgbuf[7].
  211.  
  212. 3) In addition to the ACC_ID message, the main application informs all
  213.    previously registered accessories about the new one by sending them
  214.    the message
  215.      msgbuf[0]:  ACC_ACC
  216.      msgbuf[3]:  program version number and message groups
  217.      msgbuf[4] and msgbuf[5]:   pointer to accessory's name
  218.      msgbuf[6]:  accessory's menu number (menu_id)
  219.      msgbuf[7]:  accessory's apid
  220.  
  221. 4) An accessory receiving the ACC_ACC message from the main application
  222.    sends an ACC_ID message to the thereby registered accessory, identical
  223.    to the one previously sent to the main application.
  224.  
  225. 5) When an accessory is activated by receiving an AC_OPEN message, it
  226.    sends the following message to the main application:
  227.      msgbuf[0]:  ACC_OPEN
  228.    Just before the accessory returns control to another program, it
  229.    sends the message
  230.      msgbuf[0]:  ACC_CLOSE
  231.    When receiving ACC_OPEN, the main application restores all system
  232.    variables it has changed to their original values (if possible and
  233.    neccessary). After receiving ACC_CLOSE, it may set them again to any
  234.    desired value.
  235.    Accessories should change system variables only after sending
  236.    ACC_OPEN and restore them before ACC_CLOSE.
  237.  
  238.    There have been some problems with the implementation of ACC_OPEN and
  239.    ACC_CLOSE that should be mentioned. The system was designed with
  240.    window-less accessories in mind, i.e. accessories that only display
  241.    a dialog box. For these accessories, the above procedure is
  242.    well-defined. Accessories that use windows however have no way to
  243.    find out if they have been activated or deactivated, because they
  244.    do not receive a message to indicate this (starting from AES 4.0,
  245.    this problem is solved). Therefore such accessories must be careful
  246.    with ACC_OPEN and ACC_CLOSE. The most important thing is to guarantee
  247.    that ACC_OPEN and ACC_CLOSE always occur in pairs, and that in between
  248.    no other program gains control. How exactly this is implemented
  249.    depends on the specific application. Sometimes the best implementation
  250.    is not to use ACC_OPEN and ACC_CLOSE at all.
  251.  
  252. After initialization is completed, all participating programs know the
  253. identity of all other ones, either by receiving an ACC_ID message or by
  254. receiving an ACC_ACC message. The main application is always informed
  255. about accessory activities. If in addition it proves neccessary to
  256. inform one accessory about the activation of another one, this can be
  257. accomplished by sending special messages (starting from 0x800).
  258.  
  259. II) Multitasking GEM versions
  260.  
  261. The initialization procedure is much simpler in this case. Any application,
  262. i.e. both 'standard' applications and accessories, uses appl_search() to
  263. detect all currently running AES processes when it is started. To each
  264. application or accessory (i.e. everything but system processes) it sends
  265. an ACC_ID message:
  266.   msgbuf[0]:  ACC_ID
  267.   msgbuf[1]:  sender's apid
  268.   msgbuf[2]:  length of the message - 16, giving 0
  269.   msgbuf[3]:  program version number and message groups
  270.   msgbuf[4] and msgbuf[5]:   pointer to sender's name
  271.   msgbuf[6]:  menu number (menu_id) as returned by menu_register()
  272.   msgbuf[7]:  reserved
  273. The low byte of msgbuf[3] contains a bitmap indicating which message
  274. groups are understood by the sender. Bit zero is set for message
  275. group 1, bit one for message group 2, and so on. This is independent
  276. of the message types which the sender might itself send to others. The
  277. sender of message must ensure that it is understood by the receiver. The
  278. high byte is used to indicate a program version number using an
  279. arbitrary encoding scheme.
  280. The pointer to the sender's name is stored in a processor-dependent
  281. format. The name itself is a string of characters terminated by two zero
  282. byte. To avoid name conflicts, long names are preferred to short
  283. abbreviations. The name must be available at the given address at any time,
  284. it may not be removed after initialization. It must also reside in
  285. globally accessible memory. As the version number is stored in msgbuf[3],
  286. it should not occur again in the name.
  287. [Note: see the section "Extended names" for more details on names.]
  288. Applications using more than one menu entry must issue one ACC_ID
  289. message for each entry used. Accessories without a menu entry must
  290. use a number of -1.
  291.  
  292. When receiving an ACC_ID message, an application replies by sending a
  293. message of the same format to the original sender, the only difference
  294. being that ACC_ACC is used instead of ACC_ID. Applications with
  295. several menu entries must again send one message for each entry.
  296.  
  297. The messages ACC_OPEN and ACC_CLOSE are not used in multitasking
  298. systems.
  299.  
  300. Note: The only difference between ACC_ID and ACC_ACC for multitasking
  301. systems is that an application receiving ACC_ID sends ACC_ACC as a
  302. reply, whereas no reply is sent on receiving ACC_ACC. This prevents
  303. applications from sending ACC_ID to each other indefinitely.
  304. Obviously the name ACC_ACC has lost its original meaning and
  305. probably should be changed. But since the symbolic names do not influence
  306. the actual behaviour of any program, this is not really important at all.
  307.  
  308. Since in a multitasking environment every participating application
  309. can terminate, some means must be provided to tell other applications
  310. about this. Therefore the message ACC_EXIT has been added to the list
  311. of level 0 messages. Before terminating, any application sends
  312.   msgbuf[0]:  ACC_ID
  313.   msgbuf[1]:  sender's apid
  314.   msgbuf[2]:  length of the message - 16, giving 0
  315. to all applications that have ever registered themselves by sending
  316. ACC_ID or ACC_ACC.
  317.  
  318.  
  319. Extended names
  320. --------------
  321.  
  322. Experience with XAcc has shown that it would often be useful to have more
  323. information about an application than specified with ACC_ID messages.
  324. For example it is sometimes useful to check for a special feature that
  325. is not unique to a single program, but to several similar ones. This
  326. was the motivation for the introduction of "extended names".
  327.  
  328. An "extended name" is a character string of the format
  329. 'name'\0XDSC\0'string'\0'string'\0...'string'\0\0
  330. i.e. a "standard" name followed by the string "XDSC" (for "eXtended
  331. DeSCription"), followed by a list of strings containing additional
  332. information. The end of the list is marked by an additional zero byte.
  333.  
  334. Each information string indicates by its first byte what kind of
  335. information it contains. Currently the following types are defined:
  336.  
  337. '1' - application type (human-readable)
  338.       The text following this byte (an ASCII-1, 0x31) should roughly
  339.       specify the type of application, e.g. "word processor" or
  340.       "spreadsheet". The purpose is for applications to present
  341.       this information to the user to let him/her decide where data
  342.       should go. This is not the place for advertising hype; a word
  343.       processor should call itself "word processor" and not "document
  344.       editing and design system".
  345.       It should be clear that the text should be understandable for end
  346.       users, especially it should be in the language used for the user
  347.       interface.
  348.  
  349. '2' - application type (machine-readable)
  350.       Currently defined are:
  351.       "WP" - word processor
  352.       "DP" - DTP
  353.       "ED" - text editor
  354.       "DB" - database
  355.       "SS" - spreadsheet
  356.       "RG" - raster graphics application
  357.       "VG" - vector graphics application
  358.       "GG" - general graphics application
  359.       "MU" - music application
  360.       "CD" - CAD
  361.       "DC" - data communication
  362.       "DT" - desktop
  363.       "PE" - programming environment
  364.  
  365. 'X' - extended features
  366.       This string is used to indicate special communication capabilities
  367.       of an application. It can be used to give more specific information
  368.       than the message groups understood. Since this information is meant
  369.       to be used by other applications rather than end users, short
  370.       abbreviations are sufficient.
  371.  
  372. 'N' - generic name
  373.       Often several related, but not completely identical, applications
  374.       have different names. Marketing requirements may even dictate
  375.       changes of the "official" brand names, making them unsuitable
  376.       for a "technical" identification. In such cases a "generic" name
  377.       for all these programs can be specified, which is mainly used
  378.       by other programs wishing to use special messages.
  379.  
  380. The "normal" name should be the "official" name of the program, just as it
  381. is used on the package, in the manual, and in similar places. It should
  382. be presentable to the user to let him/her decide where to send data.
  383.  
  384. Example: The address database "That's Address" identifies itself with the
  385. extended name (in C syntax)
  386. "That's Address\0XDSC\01database\02DB\0XMM\0XSU\0",
  387. indicating that it is a database with features "MM" and "SU". The first
  388. one indicates a special mail merge mode, the second one the possibility
  389. of retrieving data by sending the key via ACC_TEXT.
  390. (Further information on this program can be obtained from its manual.)
  391.  
  392.  
  393. Message group 1
  394. ---------------
  395.  
  396. ACC_ACK = 0x500
  397. ACC_TEXT = 0x501
  398. ACC_KEY = 0x502
  399.  
  400.  
  401. 1) Transmitting text data:
  402.      msgbuf[0]:  ACC_TEXT
  403.      msgbuf[4] and msgbuf[5]:   pointer to text
  404.    The text may contain all printable ASCII characters (code >= 32) and the
  405.    following control codes:
  406.      0x09  TAB (may be interpreted as a space by the receiver)
  407.      0x0A  LF  (usually ignored by receiver)
  408.      0x0D  CR  (used to mark an end-of-line (or end-of paragraph)
  409.    Other control codes may only be used if the receiver is known to
  410.    understand them. The text is terminated by a zero byte.
  411.    After the text has been interpreted completely, the receiver
  412.    acknowledges by sending
  413.      msgbuf[0]:  ACC_ACK
  414.      msgbuf[3]:  0 if the text was simply ignored, 1 if it was used in
  415.                  some sensible way
  416.    The sender of a text message may not change the text nor send any
  417.    other text messages to the same receiver until is has received the
  418.    acknowledge.
  419.    The sender must make sure that the memory used to store the text
  420.    is globally accessible.
  421.    The receiver should normally interpret the text as if it were typed
  422.    from the keyboard. A word processor would for example insert it into
  423.    the currently edited document (this implies using CR as an end-of-
  424.    paragraph mark), a command line interpreter would interpret the text
  425.    as a command (which implies using CR as an end-of-line mark).
  426.  
  427. 2) Simulation of a key press:
  428.      msgbuf[0]:  ACC_KEY
  429.      msgbuf[3]:  scan code of the simulated key and corresponding
  430.                  ASCII code (as returned by evnt_keybd())
  431.      msgbuf[4]:  state of the SHIFT keys (as returned by Kbshift())
  432.    This message should be regarded identical to a keyboard event. It can
  433.    be used to send control commands to a receiver which might have
  434.    been issued from the keyboard. Of course this requires a knowledge
  435.    of the receiver as no standard keyboard command sets exist. It should
  436.    be noted that the receiver is free to use only the ASCII code or the
  437.    scan code, or both of them.
  438.    This message is acknowledged after its interpretation with
  439.      msgbuf[0]:  ACC_ACK
  440.      msgbuf[3]:  0 if ACC_KEY was ignored or a given command was not
  441.                  understood, 1 if some action was taken.
  442.  
  443. To prevent a deadlock if a program does not properly acknowledge a
  444. message, the sender should have some way to recover. An accessory
  445. could for example stop waiting for an acknowledgement after the next
  446. AC_OPEN, a main application might time out after a sufficiently long
  447. period.
  448.  
  449.  
  450. Message group 2
  451. ---------------
  452.  
  453. ACC_META = 0x503
  454. ACC_IMG = 0x504
  455.  
  456. These message are used to exchange drawings and pictures. Only the file
  457. formats defined in the GEM documentation are used; they are sufficient
  458. to meet most requirements, and any GEM application should be able to
  459. handle them anyway.
  460.  
  461. 1) Sending a metafile:
  462.      msgbuf[0]:  ACC_META
  463.      msgbuf[3]:  1 for the final part, 0 otherwise
  464.      msgbuf[4] and msgbuf[5]:   pointer to data
  465.      msgbuf[6] and msgbuf[7]:   length of data (32 bit longword)
  466.    The metafile data is sent in the same format as they would be stored
  467.    on disk. As metafiles can become quite large and especially
  468.    accessories often do not have sufficient memory to store them, a
  469.    file can be sent in several pieces. The receiver has to take care
  470.    of assembling all parts to restore the original data, if neccessary
  471.    by writing the parts to a file. The last part of a file is marked
  472.    by msgbuf[3]=1. The sender may send no other data between the parts
  473.    of a file. msgbuf[6] and msgbuf[7] contain the length of the part
  474.    being sent, not the total length.
  475.    The receiver acknowledges each part as described for level 1.
  476.    As for text messages, the sender must make sure that the data to
  477.    be transferred is stored in globally accessible memory.
  478.  
  479. 2) Sending a bit image file:
  480.      msgbuf[0]: ACC_IMG
  481.    otherwise identical to 1)
  482.  
  483.  
  484.  
  485. Compatibility considerations
  486. ----------------------------
  487.  
  488. There are two major changes with respect to the original XAcc definition:
  489.  
  490. 1) "Levels" have been replaced by "message groups".
  491.    The motivation for this change was that the classification according
  492.    to exchangeable data types was not really a hierarchical one; there
  493.    is no reason why a programm accepting graphics should also be able to
  494.    understand text. The new scheme makes no such arbitrary assumptions.
  495.  
  496.    There is only one situation in which a possible incompatibility could
  497.    occur: an application following the "old" convention encounters a
  498.    "new" application and one of them indicates 2 in the level/message
  499.    group byte. This would be interpretes as "graphics only" by one and
  500.    as "graphics and text" by the other. Since the number of level-2
  501.    applications was always extremely small (in fact, the author knows
  502.    only of a single one), this should be no problem in practice.
  503.  
  504. 2) Extended names have been introduced.
  505.    This could lead to a problem in the extremely unlikely case of an
  506.    "old" application using a name string which is accidentally followed
  507.    by "XDSC".
  508.  
  509. In any case it is expected that most applications will be converted to
  510. the new rules soon, if only to support MultiTOS.
  511.