annotate src/tooltalk.doc @ 331:c9ae480b1fff r21-0-63

Import from CVS: tag r21-0-63
author cvs
date Mon, 13 Aug 2007 10:49:07 +0200
parents c5d627a313b1
children 8626e4521993
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Emacs Tooltalk API Summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
4 The Emacs Lisp interface to Tooltalk is similar, at least in spirit,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 to the standard C Tootalk API. Only the message and pattern parts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 of the API are supported at present, more of the API could be added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 if needed. The Lisp interface departs from the C API in a few ways:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 - Tooltalk is initialized automatically at emacs startup-time. Messages
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
10 can only be sent other Tooltalk applications connected to the same
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
11 X11 server that emacs is running on.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 - There are fewer entry points, polymorphic functions with keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 arguments are used instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 - The callback interface is simpler and marginally less functional.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
17 A single callback may be associated with a message or a pattern,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the callback is specified with a Lisp symbol (the symbol should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 have a function binding).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
21 - The session attribute for messages and patterns is always
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 initialized to the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 - Anywhere a Tooltalk enum constant, e.g. TT_SESSION, is valid one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 can substitute the corresponding symbol, e.g. 'TT_SESSION. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 simplifies building lists that represent messages and patterns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * Example: Receiving Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 Here's a simple example of a handler for a message that tells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 emacs to display a string in the mini-buffer area. The message
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
33 operation is called "emacs-display-string", its first (0th) argument
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 is the string to display:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defun tooltalk-display-string-handler (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (message (get-tooltalk-message-attribute msg 'arg_val 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defvar display-string-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 '(category TT_HANDLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 op "emacs-display-string"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 callback tooltalk-display-string-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (let ((p (make-tooltalk-pattern display-string-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (register-tooltalk-pattern p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 * Example: Sending Messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Here's a simple example that sends a query to another application
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
52 and then displays its reply. Both the query and the reply are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 stored in the first argument of the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defun tooltalk-random-query-handler (msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((state (get-tooltalk-message-attribute msg 'state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ((eq state 'TT_HANDLED)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (message (get-tooltalk-message-attribute msg arg_val 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ((memq state '(TT_FAILED TT_REJECTED))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (message "Random query turns up nothing")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar random-query-message
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
64 '( class TT_REQUEST
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
65 scope TT_SESSION
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 address TT_PROCEDURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 op "random-query"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 args '((TT_INOUT "?" "string"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 callback tooltalk-random-query-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((m (make-tooltalk-message random-query-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (send-tooltalk-message m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 * Emacs Lisp Tooltalk API
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ** Sending Messages:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (make-tooltalk-message attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Create a tooltalk message and initialize its attributes.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
82 The value of attributes must be a list of alternating keyword/values,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
83 where keywords are symbols that name valid message attributes.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
86 (make-tooltalk-message
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 '(class TT_NOTICE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 address TT_PROCEDURE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 op "do-something"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 args ("arg1" 12345 (TT_INOUT "arg3" "string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Values must always be strings, integers, or symbols that
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
94 represent Tooltalk constants. Attribute names are the same as
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 those supported by set-tooltalk-message-attribute, plus 'args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 The value of args should be a list of message arguments where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 each message argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (mode [value [type]]) or just value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
102 Where mode is one of TT_IN, TT_OUT, TT_INOUT and type is a string.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
103 If type isn't specified then "int" is used if the value is a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 number otherwise "string" is used. If type is "string" then value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 converted to a string (if it isn't a string already) with
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
106 prin1-to-string. If only a value is specified then mode defaults
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 to TT_IN. If mode is TT_OUT then value and type don't need
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
108 to be specified. You can find out more about the semantics and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 uses of ToolTalk message arguments in chapter 4 of the Tooltalk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 Programmers Guide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (send-tooltalk-message msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
116 Send the message on its way. Once the message has been sent it's
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 almost always a good idea to get rid of it with destroy-tooltalk-message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (return-tooltalk-message msg &optional mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Send a reply to this message. The second argument can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 'reply, 'reject or 'fail, the default is 'reply. Before sending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 a reply all message arguments whose mode is TT_INOUT or TT_OUT should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 have been filled in - see set-tooltalk-message-attribute."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (get-tooltalk-message-attribute msg attribute &optional argn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Returns the indicated Tooltalk message attribute. Attributes are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 identified by symbols with the same name (underscores and all) as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 suffix of the Tooltalk tt_message_<attribute> function that extracts the value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 String attribute values are copied, enumerated type values (except disposition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 are converted to symbols - e.g. TT_HANDLER is 'TT_HANDLER, uid and gid are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 represented by fixnums (small integers), opnum is converted to a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 and disposition is converted to a fixnum. We convert opnum (a C int) to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 string, e.g. 123 => \"123\" because there's no guarantee that opnums will fit
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
140 within the range of Emacs Lisp integers.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 [TBD] Use the 'plist attribute instead of C API 'user attribute
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
143 for user defined message data. To retrieve the value of a message property
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
144 specify the indicator for argn. For example to get the value of a property
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 called 'rflagg, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (get-tooltalk-message-attribute msg 'plist 'rflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 To get the value of a message argument use one of the 'arg_val (strings),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 'arg_ival (integers), or 'arg_bval (strings with embedded nulls), attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Because integer valued arguments can be larger than Emacs Lisp integers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 'arg_ival yields a string. If the value is will fit within 24 bits then
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
153 convert it to an integer with string-to-int. For example to get the integer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 value of the third argument:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (string-to-int (get-tooltalk-message-attribute msg 'arg_ival 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 As you can see, argument numbers are zero based. The type of each arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 can be retrieved, with the 'arg_type attribute, however Tooltalk doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 define any semantics for the string value of 'arg_type. Conventionally
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
161 "string" is used for strings and "int" for 32 bit integers. Note that
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Emacs Lisp stores the lengths of strings explicitly (unlike C) so treating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 value returned by 'arg_bval like a string is fine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (set-tooltalk-message-attribute value msg attribute &optional argn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 Initialize one ToolTalk message attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
172 Attribue names and values are the same as for get-tooltalk-message-attribute.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 A property list is provided for user data (instead of the 'user message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 attribute), see get-tooltalk-message-attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 Callbacks are handled slightly differently than in the C Tooltalk API.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 The value of callback should be the name of a function of one argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 It will be called each time the state of the message changes. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 is usually used to notice when the messages state has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 changed to TT_HANDLED (or TT_FAILED), so that reply argument values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 can be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
183 If one of the argument attributes is specified, 'arg_val, 'arg_ival, or
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 'arg_bval then argn must be the number of an already created argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 Arguments can be added to a message with add-tooltalk-message-arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (add-tooltalk-message-arg msg mode type &optional value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 Append one new argument to the message. Mode must be one of: TT_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 TT_INOUT, or TT_OUT, type must be a string, and value can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 be a string or an integer. Tooltalk doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 define any semantics for type, so only the participants in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 protocol you're using need to agree what types mean (if anything).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 Conventionally "string" is used for strings and "int" for 32 bit integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 Arguments can initialized by providing a value or with
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
198 set-tooltalk-message-attribute, the latter is necessary if you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 want to initialize the argument with a string that can contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 embedded nulls (use 'arg_bval).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (create-tooltalk-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 Create a new tooltalk message. The messages session attribute is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 initialized to the default session. Other attributes can be intialized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 with set-tooltalk-message-attribute. Make-tooltalk-message is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 preferred to create and initialize a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (destroy-tooltalk-message msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
213 Apply tt_message_destroy to the message. It's not necessary
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
214 to destroy messages after they've been proccessed by a message or
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 pattern callback, the Lisp/Tooltalk callback machinery does this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ** Receiving Messages:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (make-tooltalk-pattern attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 Create a tooltalk pattern and initialize its attributes.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
226 The value of attributes must be a list of alternating keyword/values,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 where keywords are symbols that name valid pattern attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 or lists of valid attributes. For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
230 (make-tooltalk-pattern
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 '(category TT_OBSERVE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 scope TT_SESSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 op ("operation1" "operation2")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 args ("arg1" 12345 (TT_INOUT "arg3" "string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
236 Attribute names are the same as those supported by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 add-tooltalk-pattern-attribute, plus 'args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 Values must always be strings, integers, or symbols that
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
240 represent Tooltalk constants or lists of same. When a list
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
241 of values is provided all of the list elements are added to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 the attribute. In the example above, messages whose op
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 attribute is "operation1" or "operation2" would match the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
245 The value of args should be a list of pattern arguments where
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 each pattern argument has the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (mode [value [type]]) or just value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
250 Where mode is one of TT_IN, TT_OUT, TT_INOUT and type is a string.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
251 If type isn't specified then "int" is used if the value is a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 number otherwise "string" is used. If type is "string" then value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 converted to a string (if it isn't a string already) with
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
254 prin1-to-string. If only a value is specified then mode defaults
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 to TT_IN. If mode is TT_OUT then value and type don't need
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
256 to be specified. You can find out more about the semantics and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 uses of ToolTalk pattern arguments in chapter 3 of the Tooltalk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 Programmers Guide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (register-tooltalk-pattern pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Emacs will begin receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (unregister-tooltalk-pattern pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 Emacs will stop receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (add-tooltalk-pattern-attribute value pat indicator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 Add one value to the indicated pattern attribute. The names of attributes
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
276 are the same as the Tooltalk accessors used to set them less the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
277 "tooltalk_pattern_" prefix and the "_add" suffix). For example
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
278 the name of the attribute for tt_pattern_dispostion_add attribute
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
279 is 'disposition. The 'category attribute is handled specially,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 since a pattern can only be a member of one category (TT_OBSERVE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 or TT_HANDLE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 Callbacks are handled slightly differently than in the C Tooltalk API.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 The value of callback should be the name of a function of one argument.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
285 It will be called each time the pattern matches an incoming message.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (add-tooltalk-pattern-arg pat mode type value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
291 Add one, fully specified, argument to a tooltalk pattern. Mode must
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 be one of TT_IN, TT_INOUT, or TT_OUT, type must be a string.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
293 Value can be an integer, string or nil. If value is an integer then
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 an integer argument (tt_pattern_iarg_add) added otherwise a string argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 is added. At present there's no way to add a binary data argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (create-tooltalk-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Create a new Tooltalk pattern and initialize its session attribute to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 be the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (destroy-tooltalk-pattern pat)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 Apply tt_pattern_destroy to the pattern. This effecticely unregisters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (describe-tooltalk-message msg &optional stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 Print the messages attributes and arguments to stream. This is often
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 useful for debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 * Things to be Done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 - At the moment there is almost no support for detecting and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 handling ToolTalk errors. This should be added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 - Message and patterns should support a plist attribute. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 would be based on one more Tooltalk user data key. This would also make
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 108
diff changeset
326 it useful to apply the message and pattern callbacks to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 both the message and the matching pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330