In addition to message groups, there are the so-called "basic messages", which must be supported by any XAcc-aware program, and program-specific so-called "special messages".
The basic messages deal solely with identification, but no real data exchange. They are already sufficient for programs that either do not exchange data with others at all or use only special messages to communicate with a number of other specific programs.
Message group 1 specifies the exchange of ASCII-format character data.
Message group 2 deals with the exchange of drawings and pictures using the GEM metafile format and the GEM bit-image file format.
Future extensions might include sound or spreadsheet data. In addition, a message group could be defined to handle command interchange between applications, e.g. for a "drag&drop" protocol (4).
In addition to XAcc standard messages, the AES messages normally sent by the screen manager may be used. The most useful ones are AC_OPEN and MN_SELECTED; the latter one requires a knowledge of the receiver and therefore belongs to the special messages.
ACC_ID = 0x400 ACC_OPEN = 0x401 ACC_CLOSE = 0x402 ACC_ACC = 0x403 ACC_EXIT = 0x404
These messages provide XAcc initialization and organization. This is the only part of XAcc which has to be implemented in a different way for single- and multitasking GEM versions. Note that the procedure described for 'multitasking' actually only depends on the existence of appl_search() and hence on an AES version number >= 4.0. If some future single-tasking AES supports appl_search(), the "multitasking" initialization should be used. Multitasking AES versions with a version number < 4.0 should never exist; to be on the safe side, applications should not attempt to use XAcc if such a situation is detected (5).
msgbuf[0]: ACC_ID msgbuf[1]: sender's apid msgbuf[2]: length of the message - 16, giving 0 msgbuf[3]: program version number and message groups msgbuf[4] and msgbuf[5]: pointer to sender's name msgbuf[6]: menu number (menu_id) as returned by menu_register() msgbuf[7]: reserved (see ACC_ACC)
The low byte of msgbuf[3] contains a bitmap indicating which message groups are understood by the sender. Bit zero is set for message group 1, bit one for message group 2, and so on. This is independent of the message types which the sender might itself send to others. The sender of a message must ensure that it is understood by the receiver. The high byte is used to indicate a program version number using an arbitrary encoding scheme.
The pointer to the sender's name is stored in a machine-dependent format. The name itself is a character string following C conventions, i.e. a string of characters terminated by a zero byte. To avoid name conflicts, long names are preferred to short abbreviations. The name must be available at the given address at any time, it may not be removed after initialisation. As the version number is stored in msgbuf[3], it should not occur again in the name. (6)
Accessories using more than one menu entry must issue one ACC_ID message for each entry used. Accessories without a menu entry must use a number of -1.
Since msgbuf[1] and msgbuf[2] have the same meaning for all message types, they are no longer mentioned from now on.
msgbuf[0]: ACC_ACC msgbuf[3]: program version number and message groups msgbuf[4] and msgbuf[5]: pointer to accessory's name msgbuf[6]: accessory's menu number (menu_id) msgbuf[7]: accessory's apid
msgbuf[0]: ACC_OPEN
Just before the accessory returns control to another program, it sends the message
msgbuf[0]: ACC_CLOSE
When receiving ACC_OPEN, the main application restores all system variables it has changed to their original values (if possible and neccessary). After receiving ACC_CLOSE, it may set them again to any desired value.
Accessories should change system variables only after sending ACC_OPEN and restore them before ACC_CLOSE.
There have been some problems with the implementation of ACC_OPEN and ACC_CLOSE that should be mentioned. The system was designed with window-less accessories in mind, i.e. accessories that only display a dialog box. For these accessories, the above procedure is well-defined. Accessories that use windows however have no way to find out if they have been activated or deactivated, because they do not receive a message to indicate this (starting from AES 4.0, this problem is solved). Therefore such accessories must be careful with ACC_OPEN and ACC_CLOSE. The most important thing is to guarantee that ACC_OPEN and ACC_CLOSE always occur in pairs, and that in between no other program gains control. How exactly this is implemented depends on the specific application. Sometimes the best implementation is not to use ACC_OPEN and ACC_CLOSE at all.
msgbuf[0]: ACC_ID msgbuf[1]: sender's apid msgbuf[2]: length of the message - 16, giving 0 msgbuf[3]: program version number and message groups msgbuf[4] and msgbuf[5]: pointer to sender's name msgbuf[6]: menu number (menu_id) as returned by menu_register() msgbuf[7]: reserved
The low byte of msgbuf[3] contains a bitmap indicating which message groups are understood by the sender. Bit zero is set for message group 1, bit one for message group 2, and so on. This is independent of the message types which the sender might itself send to others. The sender of message must ensure that it is understood by the receiver. The high byte is used to indicate a program version number using an arbitrary encoding scheme.
The pointer to the sender's name is stored in a processor-dependent format. The name itself is a string of characters terminated by two zero byte. To avoid name conflicts, long names are preferred to short abbreviations. The name must be available at the given address at any time, it may not be removed after initialization. It must also reside in globally accessible memory. As the version number is stored in msgbuf[3], it should not occur again in the name. (6)
Applications using more than one menu entry must issue one ACC_ID message for each entry used. Accessories without a menu entry must use a number of -1.
When receiving an ACC_ID message, an application replies by sending a message of the same format to the original sender, the only difference being that ACC_ACC is used instead of ACC_ID. Applications with several menu entries must again send one message for each entry.
The messages ACC_OPEN and ACC_CLOSE are not used in multitasking systems.
Note: The only difference between ACC_ID and ACC_ACC for multitasking systems is that an application receiving ACC_ID sends ACC_ACC as a reply, whereas no reply is sent on receiving ACC_ACC. This prevents applications from sending ACC_ID to each other indefinitely. Obviously the name ACC_ACC has lost its original meaning and probably should be changed. But since the symbolic names do not influence the actual behaviour of any program, this is not really important at all.
Since in a multitasking environment every participating application can terminate, some means must be provided to tell other applications about this. Therefore the message ACC_EXIT has been added to the list of level 0 messages. Before terminating, any application sends
msgbuf[0]: ACC_EXIT msgbuf[1]: sender's apid msgbuf[2]: length of the message - 16, giving 0
to all applications that have ever registered themselves by sending ACC_ID or ACC_ACC.
An "extended name" is a character string of the format
'name'\0XDSC\0'string'\0'string'\0...'string'\0\0
i.e. a "standard" name followed by the string "XDSC" (for "eXtended DeSCription"), followed by a list of strings containing additional information. The end of the list is marked by an additional zero byte.
Each information string indicates by its first byte what kind of information it contains. Currently the following types are defined:
The text following this byte (an ASCII-1, 0x31) should roughly specify the type of application, e.g. "word processor" or "spreadsheet". The purpose is for applications to present this information to the user to let him/her decide where data should go. This is not the place for advertising hype; a word processor should call itself "word processor" and not "document editing and design system".
It should be clear that the text should be understandable for end users, especially it should be in the language used for the user interface.
Currently defined are:
This string is used to indicate special communication capabilities of an application. It can be used to give more specific information than the message groups understood. Since this information is meant to be used by other applications rather than end users, short abbreviations are sufficient.
Often several related, but not completely identical, applications have different names. Marketing requirements may even dictate changes of the "official" brand names, making them unsuitable for a "technical" identification. In such cases a "generic" name for all these programs can be specified, which is mainly used by other programs wishing to use special messages.
Example: The address database "That's Address" identifies itself with the extended name (in C syntax)
"That's Address\0XDSC\01database\02DB\0XMM\0XSU\0"
indicating that it is a database with features "MM" and "SU". The first one indicates a special mail merge mode, the second one the possibility of retrieving data by sending the key via ACC_TEXT. (Further information on this program can be obtained from its manual.)
ACC_ACK = 0x500 ACC_TEXT = 0x501 ACC_KEY = 0x502
msgbuf[0]: ACC_TEXT msgbuf[4] and msgbuf[5]: pointer to text
The text may contain all printable ASCII characters (code >= 32) and the following control codes:
After the text has been interpreted completely, the receiver acknowledges by sending
msgbuf[0]: ACC_ACK msgbuf[3]: 0 if the text was simply ignored, 1 if it was used in some sensible way
The sender of a text message may not change the text nor send any other text messages to the same receiver until is has received the acknowledge.
The sender must make sure that the memory used to store the text is globally accessible.
The receiver should normally interpret the text as if it were typed from the keyboard. A word processor would for example insert it into the currently edited document (this implies using CR as an end-of- paragraph mark), a command line interpreter would interpret the text as a command (which implies using CR as an end-of-line mark).
msgbuf[0]: ACC_KEY msgbuf[3]: scan code of the simulated key and corresponding ASCII code (as returned by evnt_keybd()) msgbuf[4]: state of the SHIFT keys (as returned by Kbshift())
This message should be regarded identical to a keyboard event (7). It can be used to send control commands to a receiver which might have been issued from the keyboard. Of course this requires a knowledge of the receiver as no standard keyboard command sets exist. It should be noted that the receiver is free to use only the ASCII code or the scan code, or both of them.
This message is acknowledged after its interpretation with
msgbuf[0]: ACC_ACK msgbuf[3]: 0 if ACC_KEY was ignored or a given command was not understood, 1 if some action was taken.
ACC_META = 0x503 ACC_IMG = 0x504
These message are used to exchange drawings and pictures. Only the file formats defined in the GEM documentation are used; they are sufficient to meet most requirements, and any GEM application should be able to handle them anyway.
msgbuf[0]: ACC_META msgbuf[3]: 1 for the final part, 0 otherwise msgbuf[4] and msgbuf[5]: pointer to data msgbuf[6] and msgbuf[7]: length of data (32 bit longword)
The metafile data is sent in the same format as they would be stored on disk. As metafiles can become quite large and especially accessories often do not have sufficient memory to store them, a file can be sent in several pieces. The receiver has to take care of assembling all parts to restore the original data, if neccessary by writing the parts to a file. The last part of a file is marked by msgbuf[3]=1. The sender may send no other data between the parts of a file. msgbuf[6] and msgbuf[7] contain the length of the part being sent, not the total length.
The receiver acknowledges each part as described for level 1. As for text messages, the sender must make sure that the data to be transferred is stored in globally accessible memory.
msgbuf[0]: ACC_IMG
otherwise identical to 1)
The motivation for this change was that the classification according to exchangeable data types was not really a hierarchical one; there is no reason why a programm accepting graphics should also be able to understand text. The new scheme makes no such arbitrary assumptions.
There is only one situation in which a possible incompatibility could occur: an application following the "old" convention encounters a "new" application and one of them indicates 2 in the level/message group byte. This would be interpretes as "graphics only" by one and as "graphics and text" by the other. Since the number of level-2 applications was always extremely small (in fact, the author (8) knows only of a single one), this should be no problem in practice.
This could lead to a problem in the extremely unlikely case of an "old" application using a name string which is accidentally followed by "XDSC".