2003-10-14 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / doc / dbus-specification.xml
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
4 [
5 ]>
6
7 <article id="index">
8   <articleinfo>
9     <title>D-BUS Specification</title>
10     <releaseinfo>Version 0.8</releaseinfo>
11     <date>06 September 2003</date>
12     <authorgroup>
13       <author>
14         <firstname>Havoc</firstname>
15         <surname>Pennington</surname>
16         <affiliation>
17           <orgname>Red Hat, Inc.</orgname>
18           <address>
19             <email>hp@pobox.com</email>
20           </address>
21         </affiliation>
22       </author>
23       <author>
24         <firstname>Anders</firstname>
25         <surname>Carlsson</surname>
26         <affiliation>
27           <orgname>CodeFactory AB</orgname>
28           <address>
29             <email>andersca@codefactory.se</email>
30           </address>
31         </affiliation>
32       </author>
33       <author>
34         <firstname>Alexander</firstname>
35         <surname>Larsson</surname>
36         <affiliation>
37           <orgname>Red Hat, Inc.</orgname>
38           <address>
39             <email>alexl@redhat.com</email>
40           </address>
41         </affiliation>
42       </author>
43     </authorgroup>
44   </articleinfo>
45
46   <sect1 id="introduction">
47     <title>Introduction</title>
48     <para>
49       D-BUS is a system for low-latency, low-overhead, easy to use
50       interprocess communication (IPC). In more detail:
51       <itemizedlist>
52         <listitem>
53           <para>
54             D-BUS is <emphasis>low-latency</emphasis> because it is designed 
55             to avoid round trips and allow asynchronous operation, much like 
56             the X protocol.
57           </para>
58         </listitem>
59         <listitem>
60           <para>
61             D-BUS is <emphasis>low-overhead</emphasis> because it uses a
62             binary protocol, and does not have to convert to and from a text
63             format such as XML. Because D-BUS is intended for potentially
64             high-resolution same-machine IPC, not primarily for Internet IPC,
65             this is an interesting optimization.
66           </para>
67         </listitem>
68         <listitem>
69           <para>
70             D-BUS is <emphasis>easy to use</emphasis> because it works in terms
71             of <firstterm>messages</firstterm> rather than byte streams, and
72             automatically handles a lot of the hard IPC issues. Also, the D-BUS
73             library is designed to be wrapped in a way that lets developers use
74             their framework's existing object/type system, rather than learning
75             a new one specifically for IPC.
76           </para>
77         </listitem>
78       </itemizedlist>
79     </para>
80     <para>
81       The base D-BUS protocol is a peer-to-peer protocol, specified in <xref
82       linkend="message-protocol"/>. That is, it is a system for one application
83       to talk to a single other application. However, the primary intended
84       application of D-BUS is the D-BUS <firstterm>message bus</firstterm>,
85       specified in <xref linkend="message-bus"/>. The message bus is a special
86       application that accepts connections from multiple other applications, and
87       forwards messages among them.
88     </para>
89     <para>
90       Uses of D-BUS include notification of system changes (notification of when
91       a camera is plugged in to a computer, or a new version of some software
92       has been installed), or desktop interoperablity, for example a file
93       monitoring service or a configuration service.
94     </para>
95   </sect1>
96
97   <sect1 id="message-protocol">
98     <title>Message Protocol</title>
99     <para>
100       A <firstterm>message</firstterm> consists of a
101       <firstterm>header</firstterm> and a <firstterm>body</firstterm>. If you
102       think of a message as a package, the header is the address, and the body
103       contains the package contents. The message delivery system uses the header
104       information to figure out where to send the message and how to interpret
105       it; the recipient inteprets the body of the message.
106     </para>
107     
108     <para>
109       The body of the message is made up of zero or more
110       <firstterm>arguments</firstterm>, which are typed 
111       values, such as an integer or a byte array.
112     </para>
113
114     <sect2 id="message-protocol-header-encoding">
115       <title>Header Encoding</title>
116       <para>
117         Following the mandatory fields, there are zero or more named fields (see
118         <xref linkend="message-protocol-header-fields"/>), and then nul bytes
119         padding the header such that its total length in bytes is a multiple of
120         8.
121       </para>
122       <para>
123         The header MUST begin with the following mandatory fields in the following
124         order:
125         <informaltable>
126           <tgroup cols="2">
127             <thead>
128               <row>
129                 <entry>Size</entry>
130                 <entry>Description</entry>
131               </row>
132             </thead>
133             <tbody>
134               <row>
135                 <entry>1 byte</entry>
136                 <entry>Endianness flag; ASCII 'l' for little-endian 
137                   or ASCII 'B' for big-endian.</entry>
138               </row>
139               <row>
140                 <entry>1 byte</entry>
141                 <entry>Type of message. Unknown types MUST be ignored. 
142                   Currently-defined types are described below.
143                 </entry>
144               </row>
145               <row>
146                 <entry>1 byte</entry>
147                 <entry>Bitwise OR of flags. Unknown flags
148                   MUST be ignored. Currently-defined flags are described below.
149                 </entry>
150               </row>
151               <row>
152                 <entry>1 byte</entry>
153                 <entry>Major protocol version of the sending application.  If
154                 the major protocol version of the receiving application does not
155                 match, the applications will not be able to communicate and the
156                 D-BUS connection MUST be disconnected. The major protocol
157                 version for this version of the specification is 0.
158                 </entry>
159               </row>
160               <row>
161                 <entry>4 bytes</entry>
162                 <entry>An unsigned 32-bit integer in the
163                   message's byte order, indicating the total length in bytes of
164                   the header including named fields and any alignment padding.
165                   MUST be a multiple of 8.
166                 </entry>
167               </row>
168               <row>
169                 <entry>4 bytes</entry>
170                 <entry>An unsigned 32-bit integer in the
171                   message's byte order, indicating the total length in bytes of
172                   the message body.
173                 </entry>
174               </row>      
175               <row>
176                 <entry>4 bytes</entry>
177                 <entry>The message's serial number, an unsigned 32-bit integer in
178                   the message's byte order. The serial number is a cookie used to 
179                   identify message replies; thus all outstanding unreplied-to messages 
180                   from the same connection MUST have a different serial number.
181                   Zero is not a valid serial number, but all other numbers are 
182                   allowed.
183                 </entry>
184               </row>
185             </tbody>
186           </tgroup>
187         </informaltable>
188       </para>
189       <para>
190         Types that can appear in the second byte of the header:
191         <informaltable>
192           <tgroup cols="3">
193             <thead>
194               <row>
195                 <entry>Conventional name</entry>
196                 <entry>Decimal value</entry>
197                 <entry>Description</entry>
198               </row>
199             </thead>
200             <tbody>
201               <row>
202                 <entry>INVALID</entry>
203                 <entry>0</entry>
204                 <entry>This is an invalid type, if seen in a message 
205                   the connection should be dropped immediately.</entry>
206               </row>
207               <row>
208                 <entry>METHOD_CALL</entry>
209                 <entry>1</entry>
210                 <entry>Method call.</entry>
211               </row>
212               <row>
213                 <entry>METHOD_RETURN</entry>
214                 <entry>2</entry>
215                 <entry>Method reply with returned data.</entry>
216               </row>
217               <row>
218                 <entry>ERROR</entry>
219                 <entry>3</entry>
220                 <entry>Error reply. If the first argument exists and is a
221                 string, it is an error message.</entry>
222               </row>
223               <row>
224                 <entry>SIGNAL</entry>
225                 <entry>4</entry>
226                 <entry>Signal emission.</entry>
227               </row>
228             </tbody>
229           </tgroup>
230         </informaltable>
231       </para>
232       <para>
233         Flags that can appear in the third byte of the header:
234         <informaltable>
235           <tgroup cols="3">
236             <thead>
237               <row>
238                 <entry>Conventional name</entry>
239                 <entry>Hex value</entry>
240                 <entry>Description</entry>
241               </row>
242             </thead>
243             <tbody>
244               <row>
245                 <entry>NO_REPLY_EXPECTED</entry>
246                 <entry>0x1</entry>
247                 <entry>This message does not expect method return replies or
248                 error replies; the reply can be omitted as an
249                 optimization. However, it is compliant with this specification
250                 to return the reply despite this flag.</entry>
251               </row>
252             </tbody>
253           </tgroup>
254         </informaltable>
255       </para>
256     </sect2>
257
258     <sect2 id="message-protocol-header-fields">
259       <title>Header Fields</title>
260       <para>
261         In addition to the required header information mentioned 
262         in <xref linkend="message-protocol-header-encoding"/>, 
263           the header may contain zero or more named 
264           header fields. Future versions of this protocol
265           specification may add new fields. Implementations must
266           ignore fields they do not understand. Implementations
267           must not invent their own header fields; only changes to 
268           this specification may introduce new header fields.
269       </para>
270
271       <para>
272         Header field names MUST consist of a single byte, possible values
273         of which are defined below. Following the name, the field MUST have
274         a type code represented as a single unsigned byte, and then a
275         properly-aligned value of that type.  See <xref
276         linkend="message-protocol-arguments"/> for a description of how each
277         type is encoded. If an implementation sees a header field name that
278         it does not understand, it MUST ignore that field.
279       </para>
280
281       <para>
282         Here are the currently-defined named header fields:
283         <informaltable>
284           <tgroup cols="3">
285             <thead>
286               <row>
287                 <entry>Conventional Name</entry>
288                 <entry>Decimal Value</entry>
289                 <entry>Type</entry>
290                 <entry>Description</entry>
291               </row>
292             </thead>
293             <tbody>
294               <row>
295                 <entry>INVALID</entry>
296                 <entry>0</entry>
297                 <entry>INVALID</entry>
298                 <entry>Not a valid field name (error if it appears in a message)</entry>
299               </row>
300               <row>
301                 <entry>PATH</entry>
302                 <entry>1</entry>
303                 <entry>STRING</entry>
304                 <entry>The object to send the message to; objects are identified by 
305                 a path, "/foo/bar"</entry>
306               </row>
307               <row>
308                 <entry>INTERFACE</entry>
309                 <entry>2</entry>
310                 <entry>STRING</entry>
311                 <entry>The interface to invoke a method call on, or 
312                 that a signal is emitted from. e.g. "org.freedesktop.Introspectable"</entry>
313               </row>
314               <row>
315                 <entry>MEMBER</entry>
316                 <entry>3</entry>
317                 <entry>STRING</entry>
318                 <entry>The member, either the method name or signal name. 
319                 e.g. "Frobate"</entry>
320               </row>
321               <row>
322                 <entry>ERROR_NAME</entry>
323                 <entry>4</entry>
324                 <entry>STRING</entry>
325                 <entry>The name of the error that occurred, for errors</entry>
326               </row>
327               <row>
328                 <entry>REPLY_SERIAL</entry>
329                 <entry>5</entry>
330                 <entry>UINT32</entry>
331                 <entry>The serial number of the message this message is a reply
332                 to. (The serial number is one of the mandatory header fields,
333                 see <xref linkend="message-protocol-header-encoding"/>.)</entry>
334               </row>
335               <row>
336                 <entry>SERVICE</entry>
337                 <entry>6</entry>
338                 <entry>STRING</entry>
339                 <entry>The name of the service this message should be routed to. 
340                 Only used in combination with the message bus, see 
341                 <xref linkend="message-bus"/>.</entry>
342               </row>
343               <row>
344                 <entry>SENDER_SERVICE</entry>
345                 <entry>7</entry>
346                 <entry>STRING</entry>
347                 <entry>Sender service. The name of the base service that sent
348                 this message.  The message bus fills in this field; the field is
349                 only meaningful in combination with the message bus.</entry>
350               </row>
351             </tbody>
352           </tgroup>
353         </informaltable>
354       </para>
355       
356     </sect2>
357     <sect2 id="message-protocol-header-padding">
358       <title>Header Alignment Padding</title>
359       <para>
360         To allow implementations to keep the header and the body in a single
361         buffer while keeping data types aligned, the total length of the header
362         must be a multiple of 8 bytes.  To achieve this, the header MUST be padded
363         with nul bytes to align its total length on an 8-byte boundary. 
364         The minimum number of padding bytes MUST be used. Because zero is an
365         invalid field name, implementations can distinguish padding (which must be
366         zero initialized) from additional named fields.
367       </para>
368     </sect2>
369
370     <sect2 id="message-protocol-arguments">
371       <title>Message Arguments</title>
372       <para>
373         The message body is made up of arguments. Each argument is a type code,
374         represented by a single unsigned byte, followed by the aligned value of
375         the argument in a type-dependent format. Alignment padding between the 
376         typecode and the value is initialized to zero.
377       </para>
378       <para>
379         <informaltable>
380           <tgroup cols="3">
381             <thead>
382               <row>
383                 <entry>Type name</entry>
384                 <entry>Code</entry>
385                 <entry>Description</entry>
386               </row>
387             </thead>
388             <tbody>
389               <row>
390                 <entry>INVALID</entry>
391                 <entry>0</entry>
392                 <entry>Not a valid type code (error if it appears in a message)</entry>
393               </row><row>
394                 <entry>NIL</entry>
395                 <entry>1</entry>
396                 <entry>Marks an "unset" or "nonexistent" argument</entry>
397               </row><row>
398                 <entry>BYTE</entry>
399                 <entry>2</entry>
400                 <entry>8-bit unsigned integer</entry>
401               </row><row>
402                 <entry>BOOLEAN</entry>
403                 <entry>3</entry>
404                 <entry>Boolean value, 0 is FALSE and 1 is TRUE. Everything else is invalid.</entry>
405               </row><row>
406                 <entry>INT32</entry>
407                 <entry>4</entry>
408                 <entry>32-bit signed integer</entry>
409               </row><row>
410                 <entry>UINT32</entry>
411                 <entry>5</entry>
412                 <entry>32-bit unsigned integer</entry>
413               </row><row>
414                 <entry>INT64</entry>
415                 <entry>6</entry>
416                 <entry>64-bit signed integer</entry>
417               </row><row>
418                 <entry>UINT64</entry>
419                 <entry>7</entry>
420                 <entry>64-bit unsigned integer</entry>
421               </row><row>
422                 <entry>DOUBLE</entry>
423                 <entry>8</entry>
424                 <entry>IEEE 754 double</entry>
425               </row><row>
426                 <entry>STRING</entry>
427                 <entry>9</entry>
428                 <entry>UTF-8 string (<emphasis>must</emphasis> be valid UTF-8). Must be zero terminated. </entry>
429               </row><row>
430                 <entry>NAMED</entry>
431                 <entry>10</entry>
432                 <entry>A named byte array, used for custom types</entry>
433               </row><row>
434                 <entry>ARRAY</entry>
435                 <entry>11</entry>
436                 <entry>Array</entry>
437               </row><row>
438                 <entry>DICT</entry>
439                 <entry>12</entry>
440                 <entry>A dictionary of key/value pairs</entry>
441               </row>
442             </tbody>
443           </tgroup>
444         </informaltable>
445       </para>
446       <para>
447         The types are encoded as follows:
448         <informaltable>
449           <tgroup cols="2">
450             <thead>
451               <row>
452                 <entry>Type name</entry>
453                 <entry>Encoding</entry>
454               </row>
455             </thead>
456             <tbody>
457               <row>
458                 <entry>INVALID</entry>
459                 <entry>Not applicable; cannot be encoded.</entry>
460               </row><row>
461                 <entry>NIL</entry>
462                 <entry>No data is encoded; the type code is followed immediately 
463                 by the type code of the next argument.</entry>
464               </row><row>
465                 <entry>BYTE</entry>
466                 <entry>A byte.</entry>
467               </row><row>
468                 <entry>BOOLEAN</entry>
469                 <entry>A byte, with valid values 0 and 1.</entry>
470               </row><row>
471                 <entry>INT32</entry>
472                 <entry>32-bit signed integer in the message's byte order, aligned to 4-byte boundary.</entry>
473               </row><row>
474                 <entry>UINT32</entry>
475                 <entry>32-bit unsigned integer in the message's byte order, aligned to 4-byte boundary.</entry>
476               </row><row>
477                 <entry>INT64</entry>
478                 <entry>64-bit signed integer in the message's byte order, aligned to 8-byte boundary.</entry>
479               </row><row>
480                 <entry>UINT64</entry>
481                 <entry>64-bit unsigned integer in the message's byte order, aligned to 8-byte boundary.</entry>
482               </row><row>
483                 <entry>DOUBLE</entry>
484                 <entry>64-bit IEEE 754 double in the message's byte order, aligned to 8-byte boundary.</entry>
485               </row><row>
486                 <entry>STRING</entry>
487                 <entry>UINT32 aligned to 4-byte boundary indicating the string's 
488                   length in bytes excluding its terminating nul, followed by 
489                   string data of the given length, followed by a terminating nul 
490                   byte.
491                 </entry>
492               </row><row>
493                 <entry>NAMED</entry>
494                 <entry>A string (encoded as the STRING type above) giving the
495                   name of the type followed by an UINT32 aligned to 4-byte boundary
496                   indicating the data length in bytes, followed by the data.
497                 </entry>
498               </row><row>
499                 <entry>ARRAY</entry>
500                 <entry>A sequence of bytes giving the element type of the array, terminated
501                 by a type different from ARRAY (just one byte for one-dimensional arrays, but
502                 larger for multi-dimensional arrays), followed by an UINT32 (aligned to 4 bytes)
503                 giving the length of the array data in bytes. This is followed by each array entry
504                 encoded the way it would normally be encoded, except arrays, which are encoded
505                 without the type information, since that is already declared above. Arrays containing
506                 NIL are not allowed.
507                 </entry>
508               </row><row>
509                 <entry>DICT</entry>
510                 <entry>UINT32 giving the length of the dictionary data in bytes.
511                 This is followed by a number of keyname/value pairs, where the
512                 keyname is encoded as a STRING above, and the value is encoded
513                 as a byte with typecode and how that type normally would be encoded
514                 alone.
515                 </entry>
516               </row>
517             </tbody>
518           </tgroup>
519         </informaltable>
520       </para>
521     </sect2>
522
523     <sect2 id="message-protocol-names">
524       <title>Valid names</title>
525       <para>
526         The various header fields of type STRING have some restrictions 
527         on the string's format.
528       </para>
529       <sect3 id="message-protocol-names-service">
530         <title>Service names</title>
531         <para>
532           Services have names with type STRING, meaning that 
533           they must be valid UTF-8. However, there are also some 
534           additional restrictions that apply to service names 
535           specifically:
536           <itemizedlist>
537             <listitem><para>They must contain at least one '.' (period) character</para></listitem>
538             <listitem><para>They must not begin with a '.' (period) character</para></listitem>
539             <listitem><para>They must not exceed 256 bytes in length</para></listitem>
540             <listitem><para>They must be at least 1 byte in length</para></listitem>
541           </itemizedlist>
542           
543           As a special exception, base service names (those beginning with a colon
544           (':') character) need not contain a period.
545         </para>
546         <para>
547           FIXME really, shouldn't we ban basically everything non-alphanumeric 
548           so the name will work in all programming languages?
549         </para>
550       </sect3>
551       <sect3 id="message-protocol-names-interface">
552         <title>Interface names</title>
553         <para>
554           Interface names have the same restrictions as service names, 
555           but do not have the special exception for names beginning with 
556           a colon.
557         </para>
558         <para>
559           FIXME really, shouldn't we ban basically everything non-alphanumeric 
560           so the name will work in all programming languages?
561         </para>
562       </sect3>
563       <sect3 id="message-protocol-names-method">
564         <title>Method names</title>
565         <para>
566           Method names:
567           <itemizedlist>
568             <listitem><para>May not contain the '.' (period) character</para></listitem>
569             <listitem><para>Must not exceed 256 bytes in length</para></listitem>
570             <listitem><para>Must be at least 1 byte in length</para></listitem>
571           </itemizedlist>
572         </para>
573         <para>
574           FIXME really, shouldn't we ban basically everything non-alphanumeric 
575           so the name will work in all programming languages?
576         </para>
577       </sect3>
578       <sect3 id="message-protocol-names-path">
579         <title>Path names</title>
580         <para>
581           A path must begin with an ASCII '/' (slash) character. Paths may not
582           end with a slash character unless the path is the one-byte string
583           "/". Two slash characters may not appear adjacent to one another (the
584           empty string is not a valid "subdirectory"). Paths may not exceed
585           256 bytes in length.
586         </para>
587       </sect3>
588       <sect3 id="message-protocol-names-error">
589         <title>Error names</title>
590         <para>
591           Error names have the same restrictions as interface names.
592         </para>
593         <para>
594           FIXME really, shouldn't we ban basically everything non-alphanumeric 
595           so the name will work in all programming languages?
596         </para>
597       </sect3>
598     </sect2>
599
600     <sect2 id="message-protocol-types">
601       <title>Message types</title>
602       <para>
603         Each of the message types (METHOD_CALL, METHOD_RETURN, ERROR, and
604         SIGNAL) has its own expected usage conventions and header fields.
605       </para>
606       <sect3 id="message-protocol-types-method">
607         <title>Method Calls, Returns, and Errors</title>
608         <para>
609           Some messages invoke an operation on a remote object.  These are
610           called method call messages and have the type tag METHOD_CALL. Such
611           messages map naturally to methods on objects in a typical program.
612         </para>
613         <para>
614           A method call message is expected to have a MEMBER header field
615           indicating the name of the method. Optionally, the message has an
616           INTERFACE field giving the interface the method is a part of. In the
617           absence of an INTERFACE field, if two interfaces on the same object have
618           a method with the same name, it is undefined which of the two methods
619           will be invoked. Implementations may also choose to return an error in
620           this ambiguous case. However, if a method name is unique
621           implementations should not require an interface field.
622         </para>
623         <para>
624           Method call messages also include a PATH field indicating the 
625           object to invoke the method on. If the call is passing through 
626           a message bus, the message will also have a SERVICE field giving 
627           the service to receive the message.
628         </para>
629         <para>
630           When an application handles a method call message, it is expected to
631           return a reply. The reply is identified by a REPLY_SERIAL header field
632           indicating the serial number of the METHOD_CALL being replied to. The
633           reply can have one of two types; either METHOD_RETURN or ERROR.
634         </para>
635         <para>
636           If the reply has type METHOD_RETURN, the arguments to the reply message 
637           are the return value(s) or "out parameters" of the method call. 
638           If the reply has type ERROR, then an "exception" has been thrown, 
639           and the call fails; no return value will be provided. It makes 
640           no sense to send multiple replies to the same method call.
641         </para>
642         <para>
643           Even if a method call has no return values, a METHOD_RETURN 
644           reply is expected, so the caller will know the method 
645           was successfully processed.
646         </para>
647         <para>
648           The METHOD_RETURN or ERROR reply message MUST have the REPLY_SERIAL 
649           header field. If this field is missing, it should be treated as 
650           a corrupt message.
651         </para>
652         <para>
653           If a METHOD_CALL message has the flag NO_REPLY_EXPECTED, 
654           then as an optimization the application receiving the method 
655           call may choose to omit the reply message (regardless of 
656           whether the reply would have been METHOD_RETURN or ERROR). 
657           However, it is also acceptable to ignore the NO_REPLY_EXPECTED
658           flag and reply anyway.
659         </para>
660         <sect4 id="message-protocol-types-method-apis">
661           <title>Mapping method calls to native APIs</title>
662           <para>
663             APIs for D-BUS may map method calls to a method call in a specific
664             programming language, such as C++, or may map a method call written
665             in an IDL to a D-BUS message.
666           </para>
667           <para>
668             In APIs of this nature, arguments to a method are often termed "in"
669             (which implies sent in the METHOD_CALL), or "out" (which implies
670             returned in the METHOD_RETURN). Some APIs such as CORBA also have
671             "inout" arguments, which are both sent and received, i.e. the caller
672             passes in a value which is modified. Mapped to D-BUS, an "inout"
673             argument is equivalent to an "in" argument, followed by an "out"
674             argument. You can't pass things "by reference" over the wire, so
675             "inout" is purely an illusion of the in-process API.
676           </para>
677           <para>
678             Given a method with zero or one return values, followed by zero or more
679             arguments, where each argument may be "in", "out", or "inout", the
680             caller constructs a message by appending each "in" or "inout" argument,
681             in order. "out" arguments are not represented in the caller's message.
682           </para>
683           <para>
684             The recipient constructs a reply by appending first the return value 
685             if any, then each "out" or "inout" argument, in order. 
686             "in" arguments are not represented in the reply message.
687           </para>
688         </sect4>
689
690       </sect3>
691
692       <sect3 id="message-protocol-types-signal">
693         <title>Signal Emission</title>
694         <para>
695           Unlike method calls, signal emissions have no replies. 
696           A signal emission is simply a single message of type SIGNAL.
697           It must have three header fields: PATH giving the object 
698           the signal was emitted from, plus INTERFACE and MEMBER giving
699           the fully-qualified name of the signal.
700         </para>
701       </sect3>
702
703       <sect3 id="message-protocol-types-notation">
704         <title>Notation in this document</title>
705         <para>
706           This document uses a simple pseudo-IDL to describe particular method 
707           calls and signals. Here is an example of a method call:
708           <programlisting>
709             org.freedesktop.DBus.ActivateService (in STRING service_name, in UINT32 flags,
710                                                   out UINT32 resultcode)
711           </programlisting>
712           This means INTERFACE = org.freedesktop.DBus, MEMBER = ActivateService, 
713           METHOD_CALL arguments are STRING and UINT32, METHOD_RETURN argument
714           is UINT32. Remember that the MEMBER field can't contain any '.' (period)
715           characters so it's known that the last part of the name in
716           the "IDL" is the member name.
717         </para>
718         <para>
719           In C++ that might end up looking like this:
720           <programlisting>
721             unsigned int org::freedesktop::DBus::ActivateService (const char  *service_name, 
722                                                                   unsigned int flags);
723           </programlisting>
724           or equally valid, the return value could be done as an argument:
725           <programlisting>
726             void org::freedesktop::DBus::ActivateService (const char   *service_name, 
727                                                           unsigned int  flags,
728                                                           unsigned int *resultcode);
729           </programlisting>
730           It's really up to the API designer how they want to make 
731           this look. You could design an API where the namespace wasn't used 
732           in C++, using STL or Qt, using varargs, or whatever you wanted.
733         </para>
734         <para>
735           Signals are written as follows:
736           <programlisting>
737             org.freedesktop.DBus.ServiceLost (STRING service_name)
738           </programlisting>
739           Signals don't specify "in" vs. "out" because only 
740           a single direction is possible.
741         </para>
742         <para>
743           In this ad hoc notation, the special type name ANY means any type
744           other than NIL, and the special type name ANY_OR_NIL means any valid
745           type.
746         </para>
747         <para>
748           It isn't especially encouraged to use this lame pseudo-IDL in actual
749           API implementations; you might use the native notation for the
750           language you're using, or you might use COM or CORBA IDL, for example.
751         </para>
752       </sect3>
753     </sect2>
754
755   </sect1>
756
757   <sect1 id="auth-protocol">
758     <title>Authentication Protocol</title>
759     <para>
760       Before the flow of messages begins, two applications must
761       authenticate. A simple plain-text protocol is used for
762       authentication; this protocol is a SASL profile, and maps fairly
763       directly from the SASL specification. The message encoding is
764       NOT used here, only plain text messages.
765     </para>
766     <para>
767       In examples, "C:" and "S:" indicate lines sent by the client and
768       server respectively.
769     </para>
770     <sect2 id="auth-protocol-overview">
771       <title>Protocol Overview</title>
772       <para>
773         The protocol is a line-based protocol, where each line ends with
774         \r\n. Each line begins with an all-caps ASCII command name containing
775         only the character range [A-Z], a space, then any arguments for the
776         command, then the \r\n ending the line. The protocol is
777         case-sensitive. All bytes must be in the ASCII character set.
778
779         Commands from the client to the server are as follows:
780
781         <itemizedlist>
782           <listitem><para>AUTH [mechanism] [initial-response]</para></listitem>
783           <listitem><para>CANCEL</para></listitem>
784           <listitem><para>BEGIN</para></listitem>
785           <listitem><para>DATA &lt;data in base 64 encoding&gt;</para></listitem>
786           <listitem><para>ERROR [human-readable error explanation]</para></listitem>
787         </itemizedlist>
788
789         From server to client are as follows:
790
791         <itemizedlist>
792           <listitem><para>REJECTED &lt;space-separated list of mechanism names&gt;</para></listitem>
793           <listitem><para>OK</para></listitem>
794           <listitem><para>DATA &lt;data in base 64 encoding&gt;</para></listitem>
795           <listitem><para>ERROR</para></listitem>
796         </itemizedlist>
797       </para>
798     </sect2>
799     <sect2 id="auth-nul-byte">
800       <title>Special credentials-passing nul byte</title>
801       <para>
802         Immediately after connecting to the server, the client must send a
803         single nul byte. This byte may be accompanied by credentials
804         information on some operating systems that use sendmsg() with
805         SCM_CREDS or SCM_CREDENTIALS to pass credentials over UNIX domain
806         sockets. However, the nul byte MUST be sent even on other kinds of
807         socket, and even on operating systems that do not require a byte to be
808         sent in order to transmit credentials. The text protocol described in
809         this document begins after the single nul byte. If the first byte
810         received from the client is not a nul byte, the server may disconnect 
811         that client.
812       </para>
813       <para>
814         A nul byte in any context other than the initial byte is an error; 
815         the protocol is ASCII-only.
816       </para>
817       <para>
818         The credentials sent along with the nul byte may be used with the 
819         SASL mechanism EXTERNAL.
820       </para>
821     </sect2>
822     <sect2 id="auth-command-auth">
823       <title>AUTH command</title>
824       <para>
825         If an AUTH command has no arguments, it is a request to list
826         available mechanisms. The server SHOULD respond with a REJECTED
827         command listing the mechanisms it understands.
828       </para>
829       <para>
830         If an AUTH command specifies a mechanism, and the server supports
831         said mechanism, the server SHOULD begin exchanging SASL
832         challenge-response data with the client using DATA commands.
833       </para>
834       <para>
835         If the server does not support the mechanism given in the AUTH
836         command, it SHOULD send a REJECTED command listing the mechanisms
837         it does support.
838       </para>
839       <para>
840         If the [initial-response] argument is provided, it is intended for
841         use with mechanisms that have no initial challenge (or an empty
842         initial challenge), as if it were the argument to an initial DATA
843         command. If the selected mechanism has an initial challenge, the
844         server should reject authentication by sending REJECTED.
845       </para>
846       <para>
847         If authentication succeeds after exchanging DATA commands, 
848         an OK command should be sent to the client. 
849       </para>
850       <para>
851         The first octet received by the client after the \r\n of the OK
852         command MUST be the first octet of the authenticated/encrypted 
853         stream of D-BUS messages.
854       </para>
855       <para>
856         The first octet received by the server after the \r\n of the BEGIN
857         command from the client MUST be the first octet of the
858         authenticated/encrypted stream of D-BUS messages.
859       </para>
860     </sect2>
861     <sect2 id="auth-command-cancel">
862       <title>CANCEL Command</title>
863       <para>
864         At any time up to sending the BEGIN command, the client may send a
865         CANCEL command. On receiving the CANCEL command, the server MUST
866         send a REJECTED command and abort the current authentication
867         exchange.
868       </para>
869     </sect2>
870     <sect2 id="auth-command-data">
871       <title>DATA Command</title>
872       <para>
873         The DATA command may come from either client or server, and simply 
874         contains a base64-encoded block of data to be interpreted 
875         according to the SASL mechanism in use.
876       </para>
877       <para>
878         Some SASL mechanisms support sending an "empty string"; 
879         FIXME we need some way to do this.
880       </para>
881     </sect2>
882     <sect2 id="auth-command-begin">
883       <title>BEGIN Command</title>
884       <para>
885         The BEGIN command acknowledges that the client has received an 
886         OK command from the server, and that the stream of messages
887         is about to begin. 
888       </para>
889       <para>
890         The first octet received by the server after the \r\n of the BEGIN
891         command from the client MUST be the first octet of the
892         authenticated/encrypted stream of D-BUS messages.
893       </para>
894     </sect2>
895     <sect2 id="auth-command-rejected">
896       <title>REJECTED Command</title>
897       <para>
898         The REJECTED command indicates that the current authentication
899         exchange has failed, and further exchange of DATA is inappropriate.
900         The client would normally try another mechanism, or try providing
901         different responses to challenges.
902       </para><para>
903         Optionally, the REJECTED command has a space-separated list of
904         available auth mechanisms as arguments. If a server ever provides
905         a list of supported mechanisms, it MUST provide the same list 
906         each time it sends a REJECTED message. Clients are free to 
907         ignore all lists received after the first.
908       </para>
909     </sect2>
910     <sect2 id="auth-command-ok">
911       <title>OK Command</title>
912       <para>
913         The OK command indicates that the client has been authenticated,
914         and that further communication will be a stream of D-BUS messages
915         (optionally encrypted, as negotiated) rather than this protocol.
916       </para>
917       <para>
918         The first octet received by the client after the \r\n of the OK
919         command MUST be the first octet of the authenticated/encrypted 
920         stream of D-BUS messages.
921       </para>
922       <para>
923         The client MUST respond to the OK command by sending a BEGIN
924         command, followed by its stream of messages, or by disconnecting.
925         The server MUST NOT accept additional commands using this protocol 
926         after the OK command has been sent.
927       </para>
928     </sect2>
929     <sect2 id="auth-command-error">
930       <title>ERROR Command</title>
931       <para>
932         The ERROR command indicates that either server or client did not
933         know a command, does not accept the given command in the current
934         context, or did not understand the arguments to the command. This
935         allows the protocol to be extended; a client or server can send a
936         command present or permitted only in new protocol versions, and if
937         an ERROR is received instead of an appropriate response, fall back
938         to using some other technique.
939       </para>
940       <para>
941         If an ERROR is sent, the server or client that sent the
942         error MUST continue as if the command causing the ERROR had never been
943         received. However, the the server or client receiving the error 
944         should try something other than whatever caused the error; 
945         if only canceling/rejecting the authentication.
946       </para>
947     </sect2>
948     <sect2 id="auth-examples">
949       <title>Authentication examples</title>
950       
951       <para>
952         <figure>
953           <title>Example of successful magic cookie authentication</title>
954           <programlisting>
955             (MAGIC_COOKIE is a made up mechanism)
956
957             C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
958             S: OK
959             C: BEGIN
960           </programlisting>
961         </figure>
962         <figure>
963           <title>Example of finding out mechanisms then picking one</title>
964           <programlisting>
965             C: AUTH
966             S: REJECTED KERBEROS_V4 SKEY
967             C: AUTH SKEY bW9yZ2Fu
968             S: DATA OTUgUWE1ODMwOA==
969             C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
970             S: OK
971             C: BEGIN
972           </programlisting>
973         </figure>
974         <figure>
975           <title>Example of client sends unknown command then falls back to regular auth</title>
976           <programlisting>
977             C: FOOBAR
978             S: ERROR
979             C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
980             S: OK
981             C: BEGIN
982           </programlisting>
983         </figure>
984         <figure>
985           <title>Example of server doesn't support initial auth mechanism</title>
986           <programlisting>
987             C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
988             S: REJECTED KERBEROS_V4 SKEY
989             C: AUTH SKEY bW9yZ2Fu
990             S: DATA OTUgUWE1ODMwOA==
991             C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
992             S: OK
993             C: BEGIN
994           </programlisting>
995         </figure>
996         <figure>
997           <title>Example of wrong password or the like followed by successful retry</title>
998           <programlisting>
999             C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1000             S: REJECTED KERBEROS_V4 SKEY
1001             C: AUTH SKEY bW9yZ2Fu
1002             S: DATA OTUgUWE1ODMwOA==
1003             C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1004             S: REJECTED
1005             C: AUTH SKEY bW9yZ2Fu
1006             S: DATA OTUgUWE1ODMwOA==
1007             C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1008             S: OK
1009             C: BEGIN
1010           </programlisting>
1011         </figure>
1012         <figure>
1013           <title>Example of skey cancelled and restarted</title>
1014           <programlisting>
1015             C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
1016             S: REJECTED KERBEROS_V4 SKEY
1017             C: AUTH SKEY bW9yZ2Fu
1018             S: DATA OTUgUWE1ODMwOA==
1019             C: CANCEL
1020             S: REJECTED
1021             C: AUTH SKEY bW9yZ2Fu
1022             S: DATA OTUgUWE1ODMwOA==
1023             C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
1024             S: OK
1025             C: BEGIN
1026           </programlisting>
1027         </figure>
1028       </para>
1029     </sect2>
1030     <sect2 id="auth-states">
1031       <title>Authentication state diagrams</title>
1032       
1033       <para>
1034         WRITEME
1035       </para>
1036     </sect2>
1037     <sect2 id="auth-mechanisms">
1038       <title>Authentication mechanisms</title>
1039       <para>
1040         This section describes some new authentication mechanisms.
1041         D-BUS also allows any standard SASL mechanism of course.
1042       </para>
1043       <sect3 id="auth-mechanisms-sha">
1044         <title>DBUS_COOKIE_SHA1</title>
1045         <para>
1046           The DBUS_COOKIE_SHA1 mechanism is designed to establish that a client
1047           has the ability to read a private file owned by the user being
1048           authenticated. If the client can prove that it has access to a secret
1049           cookie stored in this file, then the client is authenticated. 
1050           Thus the security of DBUS_COOKIE_SHA1 depends on a secure home 
1051           directory.
1052         </para>
1053         <para>
1054           Authentication proceeds as follows:
1055           <itemizedlist>
1056             <listitem>
1057               <para>
1058                 The client sends the username it would like to authenticate 
1059                 as.
1060               </para>
1061             </listitem>
1062             <listitem>
1063               <para>
1064                 The server sends the name of its "cookie context" (see below); a
1065                 space character; the integer ID of the secret cookie the client
1066                 must demonstrate knowledge of; a space character; then a
1067                 hex-encoded randomly-generated challenge string.
1068               </para>
1069             </listitem>
1070             <listitem>
1071               <para>
1072                 The client locates the cookie, and generates its own hex-encoded
1073                 randomly-generated challenge string.  The client then
1074                 concatentates the server's hex-encoded challenge, a ":"
1075                 character, its own hex-encoded challenge, another ":" character,
1076                 and the hex-encoded cookie.  It computes the SHA-1 hash of this
1077                 composite string.  It sends back to the server the client's
1078                 hex-encoded challenge string, a space character, and the SHA-1
1079                 hash.
1080               </para>
1081             </listitem>
1082             <listitem>
1083               <para>
1084                 The server generates the same concatenated string used by the
1085                 client and computes its SHA-1 hash. It compares the hash with
1086                 the hash received from the client; if the two hashes match, the
1087                 client is authenticated.
1088               </para>
1089             </listitem>
1090           </itemizedlist>
1091         </para>
1092         <para>
1093           Each server has a "cookie context," which is a name that identifies a
1094           set of cookies that apply to that server. A sample context might be
1095           "org_freedesktop_session_bus". Context names must be valid ASCII,
1096           nonzero length, and may not contain the characters slash ("/"),
1097           backslash ("\"), space (" "), newline ("\n"), carriage return ("\r"),
1098           tab ("\t"), or period ("."). There is a default context,
1099           "org_freedesktop_global" that's used by servers that do not specify
1100           otherwise.
1101         </para>
1102         <para>
1103           Cookies are stored in a user's home directory, in the directory
1104           <filename>~/.dbus-keyrings/</filename>. This directory must 
1105           not be readable or writable by other users. If it is, 
1106           clients and servers must ignore it. The directory 
1107           contains cookie files named after the cookie context.
1108         </para>
1109         <para>
1110           A cookie file contains one cookie per line. Each line 
1111           has three space-separated fields:
1112           <itemizedlist>
1113             <listitem>
1114               <para>
1115                 The cookie ID number, which must be a non-negative integer and
1116                 may not be used twice in the same file.
1117               </para>
1118             </listitem>
1119             <listitem>
1120               <para>
1121                 The cookie's creation time, in UNIX seconds-since-the-epoch
1122                 format.
1123               </para>
1124             </listitem>
1125             <listitem>
1126               <para>
1127                 The cookie itself, a hex-encoded random block of bytes.
1128               </para>
1129             </listitem>
1130           </itemizedlist>
1131         </para>
1132         <para>
1133           Only server processes modify the cookie file. 
1134           They must do so with this procedure:
1135           <itemizedlist>
1136             <listitem>
1137               <para>
1138                 Create a lockfile name by appending ".lock" to the name of the
1139                 cookie file.  The server should attempt to create this file
1140                 using <literal>O_CREAT | O_EXCL</literal>.  If file creation
1141                 fails, the lock fails. Servers should retry for a reasonable
1142                 period of time, then they may choose to delete an existing lock
1143                 to keep users from having to manually delete a stale
1144                 lock. <footnote><para>Lockfiles are used instead of real file
1145                 locking <literal>fcntl()</literal> because real locking
1146                 implementations are still flaky on network
1147                 filesystems.</para></footnote>
1148               </para>
1149             </listitem>
1150             <listitem>
1151               <para>
1152                 Once the lockfile has been created, the server loads the cookie
1153                 file. It should then delete any cookies that are old (the
1154                 timeout can be fairly short), or more than a reasonable
1155                 time in the future (so that cookies never accidentally 
1156                 become permanent, if the clock was set far into the future 
1157                 at some point). If no recent keys remain, the 
1158                 server may generate a new key.
1159               </para>
1160             </listitem>
1161             <listitem>
1162               <para>
1163                 The pruned and possibly added-to cookie file 
1164                 must be resaved atomically (using a temporary 
1165                 file which is rename()'d).
1166               </para>
1167             </listitem>
1168             <listitem>
1169               <para>
1170                 The lock must be dropped by deleting the lockfile.
1171               </para>
1172             </listitem>
1173           </itemizedlist>
1174         </para>
1175         <para>
1176           Clients need not lock the file in order to load it, 
1177           because servers are required to save the file atomically.          
1178         </para>
1179       </sect3>
1180     </sect2>
1181   </sect1>
1182   <sect1 id="addresses">
1183     <title>Server Addresses</title>
1184     <para>
1185       Server addresses consist of a transport name followed by a colon, and
1186       then an optional, comma-separated list of keys and values in the form key=value.
1187       [FIXME how do you escape colon, comma, and semicolon in the values of the key=value pairs?]
1188     </para>
1189     <para>
1190       For example: 
1191       <programlisting>unix:path=/tmp/dbus-test</programlisting>
1192       Which is the address to a unix socket with the path /tmp/dbus-test.
1193     </para>
1194     <para>
1195       [FIXME clarify if attempting to connect to each is a requirement 
1196       or just a suggestion]
1197       When connecting to a server, multiple server addresses can be
1198       separated by a semi-colon. The library will then try to connect
1199       to the first address and if that fails, it'll try to connect to
1200       the next one specified, and so forth. For example
1201       <programlisting>unix:path=/tmp/dbus-test;unix:path=/tmp/dbus-test2</programlisting>
1202     </para>
1203     <para>
1204       [FIXME we need to specify in detail each transport and its possible arguments]
1205       Current transports include: unix domain sockets (including 
1206       abstract namespace on linux), TCP/IP, and a debug/testing transport using 
1207       in-process pipes. Future possible transports include one that 
1208       tunnels over X11 protocol.
1209     </para>
1210   </sect1>
1211
1212   <sect1 id="standard-messages">
1213     <title>Standard Peer-to-Peer Messages</title>
1214     <para>
1215       See <xref linkend="message-protocol-types-notation"/> for details on 
1216        the notation used in this section.
1217     </para>
1218     <sect2 id="standard-messages-ping">
1219       <title><literal>org.freedesktop.Peer.Ping</literal></title>
1220       <para>        
1221         <programlisting>
1222           org.freedesktop.Peer.Ping ()
1223         </programlisting>
1224       </para>
1225       <para>
1226         On receipt of the METHOD_CALL
1227         message <literal>org.freedesktop.Peer.Ping</literal>, an application
1228         should do nothing other than reply with a METHOD_RETURN as usual.
1229       </para>
1230     </sect2>
1231
1232     <sect2 id="standard-messages-get-props">
1233       <title><literal>org.freedesktop.Props.Get</literal></title>
1234       <para>
1235         [FIXME this is just a bogus made-up method that isn't implemented 
1236         or thought through, to save an example of table formatting for the 
1237         argument descriptions]
1238         <programlisting>
1239           org.freedesktop.Props.Get (in STRING property_name,
1240                                      out ANY_OR_NIL property_value)
1241         </programlisting>
1242         Message arguments:
1243         <informaltable>
1244           <tgroup cols="3">
1245             <thead>
1246               <row>
1247                 <entry>Argument</entry>
1248                 <entry>Type</entry>
1249                 <entry>Description</entry>
1250               </row>
1251             </thead>
1252             <tbody>
1253               <row>
1254                 <entry>0</entry>
1255                 <entry>in STRING</entry>
1256                 <entry>Name of the property to get</entry>
1257               </row>
1258               <row>
1259                 <entry>1</entry>
1260                 <entry>out ANY_OR_NIL</entry>
1261                 <entry>The value of the property. The type depends on the property.</entry>
1262               </row>
1263             </tbody>
1264           </tgroup>
1265         </informaltable>
1266       </para>
1267     </sect2>
1268   </sect1>
1269
1270   <sect1 id="message-bus">
1271     <title>Message Bus Specification</title>
1272     <sect2 id="message-bus-overview">
1273       <title>Message Bus Overview</title>
1274       <para>
1275         The message bus accepts connections from one or more applications. 
1276         Once connected, applications can send and receive messages from 
1277         the message bus, as in the peer-to-peer case.
1278       </para>
1279       <para>
1280         The message bus keeps track of a set of
1281         <firstterm>services</firstterm>. A service is simply a name, such as
1282         <literal>com.yoyodyne.Screensaver</literal>, which can be
1283         <firstterm>owned</firstterm> by one or more of the connected
1284         applications.  The message bus itself always owns the special service
1285         <literal>org.freedesktop.DBus</literal>.
1286       </para>
1287       <para>
1288         Services may have <firstterm>secondary owners</firstterm>. Secondary owners
1289         of a service are kept in a queue; if the primary owner of a service 
1290         disconnects, or releases the service, the next secondary owner becomes
1291         the new owner of the service.
1292       </para>
1293       <para>
1294         Messages may have a <literal>SERVICE</literal> field (see <xref
1295                                                                   linkend="message-protocol-header-fields"/>).  When the message bus
1296           receives a message, if the <literal>SERVICE</literal> field is absent, the
1297           message is taken to be a standard peer-to-peer message and interpreted
1298           by the message bus itself. For example, sending
1299           an <literal>org.freedesktop.Peer.Ping</literal> message with no 
1300           <literal>SERVICE</literal> will cause the message bus itself to reply 
1301           to the ping immediately; the message bus would never make 
1302           this message visible to other applications.
1303       </para>
1304       <para>
1305         If the <literal>SERVICE</literal> field is present, then it indicates a
1306         request for the message bus to route the message. In the usual case,
1307         messages are routed to the owner of the named service.
1308         Messages may also be <firstterm>broadcast</firstterm>
1309         by sending them to the special service 
1310         <literal>org.freedesktop.DBus.Broadcast</literal>. Broadcast messages are
1311         sent to all applications with <firstterm>message matching
1312           rules</firstterm> that match the message.
1313       </para>
1314       <para>
1315         Continuing the <literal>org.freedesktop.Peer.Ping</literal> example, if
1316         the ping message were sent with a <literal>SERVICE</literal> name of
1317         <literal>com.yoyodyne.Screensaver</literal>, then the ping would be
1318         forwarded, and the Yoyodyne Corporation screensaver application would be
1319         expected to reply to the ping. If
1320         <literal>org.freedesktop.Peer.Ping</literal> were sent to
1321         <literal>org.freedesktop.DBus.Broadcast</literal>, then multiple applications
1322         might receive the ping, and all would normally reply to it.
1323       </para>
1324     </sect2>
1325
1326     <sect2 id="message-bus-services">
1327       <title>Message Bus Services</title>
1328       <para>
1329         A service is a name that identifies a certain application. Each
1330         application connected to the message bus has at least one service name
1331         assigned at connection time and returned in response to the
1332         <literal>org.freedesktop.DBus.Hello</literal> message.
1333         This automatically-assigned service name is called 
1334         the application's <firstterm>base service</firstterm>. 
1335         Base service names are unique and MUST never be reused for two different 
1336         applications.
1337       </para>
1338       <para>
1339         Ownership of the base service is a prerequisite for interaction with 
1340         the message bus. It logically follows that the base service is always 
1341         the first service that an application comes to own, and the last 
1342         service that it loses ownership of.
1343       </para>
1344       <para>
1345         Base service names must begin with the character ':' (ASCII colon
1346         character); service names that are not base service names must not begin
1347         with this character. (The bus must reject any attempt by an application
1348         to manually create a service name beginning with ':'.) This restriction
1349         categorically prevents "spoofing"; messages sent to a base service name
1350         will always go to a single application instance and that instance only.
1351       </para>
1352       <para>
1353         An application can request additional service names to be associated
1354         with it using the
1355         <literal>org.freedesktop.DBus.AcquireService</literal>
1356         message. [FIXME what service names are allowed; ASCII or unicode; 
1357         length limit; etc.]
1358       </para>
1359       <para>
1360         [FIXME this needs more detail, and should move the service-related message 
1361         descriptions up into this section perhaps]
1362         Service ownership handling can be specified in the flags part
1363         of the <literal>org.freedesktop.DBus.AcquireService</literal>
1364         message. If an application specifies the
1365         DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT flag, then all applications
1366         trying to acquire the service will be put in a queue. When the
1367         primary owner disconnects from the bus or removes ownership
1368         from the service, the next application in the queue will be the
1369         primary owner. If the DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT
1370         flag is not specified, then the primary owner will lose
1371         ownership whenever another application requests ownership of the
1372         service.
1373       </para>
1374       <para>
1375         When a client disconnects from the bus, all the services that
1376         the clients own are deleted, or in the case of a service that
1377         prohibits replacement, ownership is transferred to the next
1378         client in the queue, if any.
1379       </para>
1380     </sect2>
1381     <sect2 id="message-bus-routing">
1382       <title>Message Bus Message Routing</title>
1383       <para>
1384         When a message is received by the message bus, the message's 
1385         <literal>sndr</literal> header field MUST be set to the base service of
1386         the application which sent the message.  If the service already has
1387         a <literal>sndr</literal> field, the pre-existing field is replaced.
1388         This rule means that a replies are always sent to the base service name,
1389         i.e. to the same application that sent the message being replied to.
1390       </para>
1391       <para>
1392         [FIXME go into detail about broadcast, multicast, unicast, etc.]
1393       </para>
1394     </sect2>
1395     <sect2 id="message-bus-activation">
1396       <title>Message Bus Service Activation</title>
1397       <para>
1398         <firstterm>Activation</firstterm> means to locate a service 
1399         owner for a service that is currently unowned. For now, it 
1400         means to launch an executable that will take ownership of 
1401         a particular service.
1402       </para>
1403       <para>
1404         To find an executable corresponding to a particular service, the bus
1405         daemon looks for <firstterm>service description files</firstterm>.
1406         Service description files define a mapping from service names to
1407         executables. Different kinds of message bus will look for these files
1408         in different places, see <xref linkend="message-bus-types"/>.
1409       </para>
1410       <para>
1411         [FIXME the file format should be much better specified than
1412         "similar to .desktop entries" esp. since desktop entries are
1413         already badly-specified. ;-)] Service description files have
1414         the ".service" file extension. The message bus will only load
1415         service description files ending with .service; all other
1416         files will be ignored.  The file format is similar to that of
1417         <ulink
1418         url="http://www.freedesktop.org/standards/desktop-entry-spec/desktop-entry-spec.html">desktop
1419         entries</ulink>. All service description files must be in
1420         UTF-8 encoding. To ensure that there will be no name
1421         collisions, service files must be namespaced using the same
1422         mechanism as messages and service names.
1423
1424         <figure>
1425           <title>Example service description file</title>
1426           <programlisting>
1427             # Sample service description file
1428             [D-BUS Service]
1429             Name=org.gnome.ConfigurationDatabase
1430             Exec=/usr/libexec/gconfd-2
1431           </programlisting>
1432         </figure>
1433       </para>
1434       <para>
1435         When an application requests a service to be activated, the
1436         bus daemon tries to find it in the list of activation
1437         entries. It then tries to spawn the executable associated with
1438         it. If this fails, it will report an error. [FIXME what
1439         happens if two .service files offer the same service; what
1440         kind of error is reported, should we have a way for the client
1441         to choose one?]
1442       </para>
1443       <para>
1444         The executable launched will have the environment variable
1445         <literal>DBUS_ACTIVATION_ADDRESS</literal> set to the address of the
1446         message bus so it can connect and register the appropriate services.
1447       </para>
1448       <para>
1449         The executable being launched may want to know whether the message bus
1450         activating it is one of the well-known message buses (see <xref
1451         linkend="message-bus-types"/>). To facilitate this, the bus MUST also set
1452         the <literal>DBUS_ACTIVATION_BUS_TYPE</literal> environment variable if it is one
1453         of the well-known buses. The currently-defined values for this variable
1454         are <literal>system</literal> for the systemwide message bus,
1455         and <literal>session</literal> for the per-login-session message
1456         bus. The activated executable must still connect to the address given
1457         in <literal>DBUS_ACTIVATION_ADDRESS</literal>, but may assume that the
1458         resulting connection is to the well-known bus.
1459       </para>
1460       <para>
1461         [FIXME there should be a timeout somewhere, either specified
1462         in the .service file, by the client, or just a global value
1463         and if the client being activated fails to connect within that
1464         timeout, an error should be sent back.]
1465       </para>
1466     </sect2>
1467
1468     <sect2 id="message-bus-types">
1469       <title>Well-known Message Bus Instances</title>
1470       <para>
1471         Two standard message bus instances are defined here, along with how 
1472         to locate them and where their service files live.
1473       </para>
1474       <sect3 id="message-bus-types-login">
1475         <title>Login session message bus</title>
1476         <para>
1477           Each time a user logs in, a <firstterm>login session message
1478             bus</firstterm> may be started. All applications in the user's login
1479           session may interact with one another using this message bus.
1480         </para>
1481         <para>
1482           The address of the login session message bus is given 
1483           in the <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment 
1484           variable. If that variable is not set, applications may 
1485           also try to read the address from the X Window System root 
1486           window property <literal>_DBUS_SESSION_BUS_ADDRESS</literal>.
1487           The root window property must have type <literal>STRING</literal>.
1488           The environment variable should have precedence over the 
1489           root window property.
1490         </para>
1491         <para>
1492           [FIXME specify location of .service files, probably using 
1493           DESKTOP_DIRS etc. from basedir specification, though login session 
1494           bus is not really desktop-specific]
1495         </para>
1496       </sect3>
1497       <sect3 id="message-bus-types-system">
1498         <title>System message bus</title>
1499         <para>
1500           A computer may have a <firstterm>system message bus</firstterm>,
1501           accessible to all applications on the system. This message bus may be
1502           used to broadcast system events, such as adding new hardware devices, 
1503           changes in the printer queue, and so forth.
1504         </para>
1505         <para>
1506           The address of the login session message bus is given 
1507           in the <literal>DBUS_SYSTEM_BUS_ADDRESS</literal> environment 
1508           variable. If that variable is not set, applications should try 
1509           to connect to the well-known address
1510           <literal>unix:path=/var/run/dbus/system_bus_socket</literal>.
1511           <footnote>
1512             <para>
1513               The D-BUS reference implementation actually honors the 
1514               <literal>$(localstatedir)</literal> configure option 
1515               for this address, on both client and server side.
1516             </para>
1517           </footnote>
1518         </para>
1519         <para>
1520           [FIXME specify location of system bus .service files]
1521         </para>
1522       </sect3>
1523     </sect2>
1524
1525     <sect2 id="message-bus-messages">
1526       <title>Message Bus Messages</title>
1527       <para>
1528         The special message bus service <literal>org.freedesktop.DBus</literal>
1529         responds to a number of messages, allowing applications to 
1530         interact with the message bus.
1531       </para>
1532
1533       <sect3 id="bus-messages-hello">
1534         <title><literal>org.freedesktop.DBus.Hello</literal></title>
1535         <para>
1536           As a method:
1537           <programlisting>
1538             STRING Hello ()
1539           </programlisting>
1540           Reply arguments:
1541           <informaltable>
1542             <tgroup cols="3">
1543               <thead>
1544                 <row>
1545                   <entry>Argument</entry>
1546                   <entry>Type</entry>
1547                   <entry>Description</entry>
1548                 </row>
1549               </thead>
1550               <tbody>
1551                 <row>
1552                   <entry>0</entry>
1553                   <entry>STRING</entry>
1554                   <entry>Name of the service assigned to the application</entry>
1555                 </row>
1556               </tbody>
1557             </tgroup>
1558           </informaltable>
1559         </para>
1560         <para>
1561           Before an application is able to send messages to other
1562           applications it must send the
1563           <literal>org.freedesktop.DBus.Hello</literal> message to the
1564           message bus service. If an application tries to send a
1565           message to another application, or a message to the message
1566           bus service that isn't the
1567           <literal>org.freedesktop.DBus.Hello</literal> message, it
1568           will be disconnected from the bus. If a client wishes to
1569           disconnect from the bus, it just has to disconnect from the
1570           transport used. No de-registration message is necessary.
1571         </para>
1572         <para>
1573           The reply message contains the name of the application's base service.
1574         </para>
1575       </sect3>
1576       <sect3 id="bus-messages-list-services">
1577         <title><literal>org.freedesktop.DBus.ListServices</literal></title>
1578         <para>
1579           As a method:
1580           <programlisting>
1581             STRING_ARRAY ListServices ()
1582           </programlisting>
1583           Reply arguments:
1584           <informaltable>
1585             <tgroup cols="3">
1586               <thead>
1587                 <row>
1588                   <entry>Argument</entry>
1589                   <entry>Type</entry>
1590                   <entry>Description</entry>
1591                 </row>
1592               </thead>
1593               <tbody>
1594                 <row>
1595                   <entry>0</entry>
1596                   <entry>STRING_ARRAY</entry>
1597                   <entry>Array of strings where each string is the name of a service</entry>
1598                 </row>
1599               </tbody>
1600             </tgroup>
1601           </informaltable>
1602         </para>
1603         <para>
1604           Returns a list of all existing services registered with the message bus. 
1605         </para>
1606       </sect3>
1607       <sect3 id="bus-messages-service-exists">
1608         <title><literal>org.freedesktop.DBus.ServiceExists</literal></title>
1609         <para>
1610           As a method:
1611           <programlisting>
1612             BOOLEAN ServiceExists (in STRING service_name)
1613           </programlisting>
1614           Message arguments:
1615           <informaltable>
1616             <tgroup cols="3">
1617               <thead>
1618                 <row>
1619                   <entry>Argument</entry>
1620                   <entry>Type</entry>
1621                   <entry>Description</entry>
1622                 </row>
1623               </thead>
1624               <tbody>
1625                 <row>
1626                   <entry>0</entry>
1627                   <entry>STRING</entry>
1628                   <entry>Name of the service</entry>
1629                 </row>
1630               </tbody>
1631             </tgroup>
1632           </informaltable>
1633           Reply arguments:
1634           <informaltable>
1635             <tgroup cols="3">
1636               <thead>
1637                 <row>
1638                   <entry>Argument</entry>
1639                   <entry>Type</entry>
1640                   <entry>Description</entry>
1641                 </row>
1642               </thead>
1643               <tbody>
1644                 <row>
1645                   <entry>0</entry>
1646                   <entry>BOOLEAN</entry>
1647                   <entry>Return value, true if the service exists</entry>
1648                 </row>
1649               </tbody>
1650             </tgroup>
1651           </informaltable>
1652         </para>
1653         <para>
1654           Checks if a service with a specified name exists.
1655         </para>
1656       </sect3>
1657
1658       <sect3 id="bus-messages-acquire-service">
1659         <title><literal>org.freedesktop.DBus.AcquireService</literal></title>
1660         <para>
1661           As a method:
1662           <programlisting>
1663             UINT32 AcquireService (in STRING service_name)
1664           </programlisting>
1665           Message arguments:
1666           <informaltable>
1667             <tgroup cols="3">
1668               <thead>
1669                 <row>
1670                   <entry>Argument</entry>
1671                   <entry>Type</entry>
1672                   <entry>Description</entry>
1673                 </row>
1674               </thead>
1675               <tbody>
1676                 <row>
1677                   <entry>0</entry>
1678                   <entry>STRING</entry>
1679                   <entry>Name of the service</entry>
1680                 </row>
1681                 <row>
1682                   <entry>1</entry>
1683                   <entry>UINT32</entry>
1684                   <entry>Flags</entry>
1685                 </row>
1686               </tbody>
1687             </tgroup>
1688           </informaltable>
1689           Reply arguments:
1690           <informaltable>
1691             <tgroup cols="3">
1692               <thead>
1693                 <row>
1694                   <entry>Argument</entry>
1695                   <entry>Type</entry>
1696                   <entry>Description</entry>
1697                 </row>
1698               </thead>
1699               <tbody>
1700                 <row>
1701                   <entry>0</entry>
1702                   <entry>UINT32</entry>
1703                   <entry>Return value</entry>
1704                 </row>
1705               </tbody>
1706             </tgroup>
1707           </informaltable>
1708         </para>
1709         <para>
1710           Tries to become owner of a specific service. The flags
1711           specified can be the following values logically ORed together:
1712
1713           <informaltable>
1714             <tgroup cols="3">
1715               <thead>
1716                 <row>
1717                   <entry>Identifier</entry>
1718                   <entry>Value</entry>
1719                   <entry>Description</entry>
1720                 </row>
1721               </thead>
1722               <tbody>
1723                 <row>
1724                   <entry>DBUS_SERVICE_FLAGS_PROHIBIT_REPLACEMENT</entry>
1725                   <entry>0x1</entry>
1726                   <entry>
1727                     If the application succeeds in being the owner of the specified service,
1728                     then ownership of the service can't be transferred until the service
1729                     disconnects. If this flag is not set, then any application trying to become
1730                     the owner of the service will succeed and the previous owner will be
1731                     sent a <literal>org.freedesktop.DBus.ServiceLost</literal> message.
1732                   </entry>
1733                 </row>
1734                 <row>
1735                   <entry>DBUS_SERVICE_FLAGS_REPLACE_EXISTING</entry>
1736                   <entry>0x2</entry>
1737                   <entry>Try to replace the current owner if there is one. If this flag
1738                   is not set the application will only become the owner of the service if
1739                   there is no current owner.</entry>
1740                 </row>
1741               </tbody>
1742             </tgroup>
1743           </informaltable>
1744
1745           [FIXME if it's one of the following values, why are the values
1746           done as flags instead of just 0, 1, 2, 3, 4]
1747           The return value can be one of the following values:
1748
1749           <informaltable>
1750             <tgroup cols="3">
1751               <thead>
1752                 <row>
1753                   <entry>Identifier</entry>
1754                   <entry>Value</entry>
1755                   <entry>Description</entry>
1756                 </row>
1757               </thead>
1758               <tbody>
1759                 <row>
1760                   <entry>DBUS_SERVICE_REPLY_PRIMARY_OWNER</entry>
1761                   <entry>0x1</entry>
1762                   <entry>The application is now the primary owner of the service.</entry>
1763                 </row>
1764                 <row>
1765                   <entry>DBUS_SERVICE_REPLY_IN_QUEUE</entry>
1766                   <entry>0x2</entry>
1767                   <entry>The service already has an owner which do not want to give up ownership and therefore the application has been put in a queue.</entry>
1768                 </row>
1769                 <row>
1770                   <entry>DBUS_SERVICE_REPLY_SERVICE_EXISTS</entry>
1771                   <entry>0x4</entry>
1772                   <entry>The service does already have a primary owner, and DBUS_SERVICE_FLAG_REPLACE_EXISTING was not specified when trying to acquire the service.</entry>
1773                 </row>
1774                 <row>
1775                   <entry>DBUS_SERVICE_REPLY_ALREADY_OWNER</entry>
1776                   <entry>0x8</entry>
1777                   <entry>The application trying to request ownership of the service is already the owner of it.</entry>
1778                 </row>
1779               </tbody>
1780             </tgroup>
1781           </informaltable>
1782         </para>
1783       </sect3>
1784       <sect3 id="bus-messages-service-acquired">
1785         <title><literal>org.freedesktop.DBus.ServiceAcquired</literal></title>
1786         <para>
1787           As a method:
1788           <programlisting>
1789             ServiceAcquired (in STRING service_name)
1790           </programlisting>
1791           Message arguments:
1792           <informaltable>
1793             <tgroup cols="3">
1794               <thead>
1795                 <row>
1796                   <entry>Argument</entry>
1797                   <entry>Type</entry>
1798                   <entry>Description</entry>
1799                 </row>
1800               </thead>
1801               <tbody>
1802                 <row>
1803                   <entry>0</entry>
1804                   <entry>STRING</entry>
1805                   <entry>Name of the service</entry>
1806                 </row>
1807                 <row>
1808                   <entry>1</entry>
1809                   <entry>UINT32</entry>
1810                   <entry>Flags</entry>
1811                 </row>
1812               </tbody>
1813             </tgroup>
1814           </informaltable>
1815         </para>
1816         <para>
1817           This message is sent to a specific application when it becomes the
1818           primary owner of a service.
1819         </para>
1820       </sect3>
1821       <sect3 id="bus-messages-service-lost">
1822         <title><literal>org.freedesktop.DBus.ServiceLost</literal></title>
1823         <para>
1824           As a method:
1825           <programlisting>
1826             ServiceLost (in STRING service_name)
1827           </programlisting>
1828           Message arguments:
1829           <informaltable>
1830             <tgroup cols="3">
1831               <thead>
1832                 <row>
1833                   <entry>Argument</entry>
1834                   <entry>Type</entry>
1835                   <entry>Description</entry>
1836                 </row>
1837               </thead>
1838               <tbody>
1839                 <row>
1840                   <entry>0</entry>
1841                   <entry>STRING</entry>
1842                   <entry>Name of the service</entry>
1843                 </row>
1844                 <row>
1845                   <entry>1</entry>
1846                   <entry>UINT32</entry>
1847                   <entry>Flags</entry>
1848                 </row>
1849               </tbody>
1850             </tgroup>
1851           </informaltable>
1852         </para>
1853         <para>
1854           This message is sent to a specific application when it loses primary
1855           ownership of a service.
1856
1857           [FIXME instead of ServiceLost/ServiceCreated going only to 
1858           a specific app, why not just OwnerChanged that covers both 
1859           lost and created and changed owner and deleted]
1860         </para>
1861       </sect3>
1862
1863       <sect3 id="bus-messages-service-created">
1864         <title><literal>org.freedesktop.DBus.ServiceCreated</literal></title>
1865         <para>
1866           As a method:
1867           <programlisting>
1868             ServiceCreated (in STRING service_name)
1869           </programlisting>
1870           Message arguments:
1871           <informaltable>
1872             <tgroup cols="3">
1873               <thead>
1874                 <row>
1875                   <entry>Argument</entry>
1876                   <entry>Type</entry>
1877                   <entry>Description</entry>
1878                 </row>
1879               </thead>
1880               <tbody>
1881                 <row>
1882                   <entry>0</entry>
1883                   <entry>STRING</entry>
1884                   <entry>Name of the service</entry>
1885                 </row>
1886                 <row>
1887                   <entry>1</entry>
1888                   <entry>UINT32</entry>
1889                   <entry>Flags</entry>
1890                 </row>
1891               </tbody>
1892             </tgroup>
1893           </informaltable>
1894         </para>
1895         <para>
1896           This message is broadcast to all applications when a service has been
1897           successfully registered on the message bus.
1898         </para>
1899       </sect3>
1900
1901       <sect3 id="bus-messages-service-deleted">
1902         <title><literal>org.freedesktop.DBus.ServiceDeleted</literal></title>
1903         <para>
1904           As a method:
1905           <programlisting>
1906             ServiceDeleted (in STRING service_name)
1907           </programlisting>
1908           Message arguments:
1909           <informaltable>
1910             <tgroup cols="3">
1911               <thead>
1912                 <row>
1913                   <entry>Argument</entry>
1914                   <entry>Type</entry>
1915                   <entry>Description</entry>
1916                 </row>
1917               </thead>
1918               <tbody>
1919                 <row>
1920                   <entry>0</entry>
1921                   <entry>STRING</entry>
1922                   <entry>Name of the service</entry>
1923                 </row>
1924                 <row>
1925                   <entry>1</entry>
1926                   <entry>UINT32</entry>
1927                   <entry>Flags</entry>
1928                 </row>
1929               </tbody>
1930             </tgroup>
1931           </informaltable>
1932         </para>
1933         <para>
1934           This message is broadcast to all applications when a service has been
1935           deleted from the message bus.
1936         </para>
1937       </sect3>
1938
1939       <sect3 id="bus-messages-activate-service">
1940         <title><literal>org.freedesktop.DBus.ActivateService</literal></title>
1941         <para>
1942           As a method:
1943           <programlisting>
1944             UINT32 ActivateService (in STRING service_name, in UINT32 flags)
1945           </programlisting>
1946           Message arguments:
1947           <informaltable>
1948             <tgroup cols="3">
1949               <thead>
1950                 <row>
1951                   <entry>Argument</entry>
1952                   <entry>Type</entry>
1953                   <entry>Description</entry>
1954                 </row>
1955               </thead>
1956               <tbody>
1957                 <row>
1958                   <entry>0</entry>
1959                   <entry>STRING</entry>
1960                   <entry>Name of the service to activate</entry>
1961                 </row>
1962                 <row>
1963                   <entry>1</entry>
1964                   <entry>UINT32</entry>
1965                   <entry>Flags (currently not used)</entry>
1966                 </row>
1967               </tbody>
1968             </tgroup>
1969           </informaltable>
1970         Reply arguments:
1971         <informaltable>
1972           <tgroup cols="3">
1973             <thead>
1974               <row>
1975                 <entry>Argument</entry>
1976                 <entry>Type</entry>
1977                 <entry>Description</entry>
1978               </row>
1979             </thead>
1980             <tbody>
1981               <row>
1982                 <entry>0</entry>
1983                 <entry>UINT32</entry>
1984                 <entry>Return value</entry>
1985               </row>
1986             </tbody>
1987           </tgroup>
1988         </informaltable>
1989           Tries to launch the executable associated with a service. For more information, see <xref linkend="message-bus-activation"/>.
1990
1991             [FIXME need semantics in much more detail here; for example, 
1992             if I activate a service then send it a message, is the message 
1993             queued for the new service or is there a race]
1994         </para>
1995         <para>
1996           The return value can be one of the following values:
1997     <informaltable>
1998             <tgroup cols="3">
1999               <thead>
2000                 <row>
2001                   <entry>Identifier</entry>
2002                   <entry>Value</entry>
2003                   <entry>Description</entry>
2004                 </row>
2005               </thead>
2006               <tbody>
2007                 <row>
2008                   <entry>DBUS_ACTIVATION_REPLY_ACTIVATED</entry>
2009                   <entry>0x0</entry>
2010                   <entry>The service was activated successfully.</entry>
2011                 </row>
2012                 <row>
2013                   <entry>DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE</entry>
2014                   <entry>0x1</entry>
2015                   <entry>The service is already active.</entry>
2016                 </row>
2017               </tbody>
2018              </tgroup>
2019            </informaltable>
2020         </para>
2021
2022       </sect3>
2023
2024       <sect3 id="bus-messages-out-of-memory">
2025         <title><literal>org.freedesktop.DBus.Error.NoMemory</literal></title>
2026         <para>
2027           As a method:
2028           <programlisting>
2029             void NoMemory ()
2030           </programlisting>
2031         </para>
2032         <para>
2033           Sent by the message bus when it can't process a message due to an out of memory failure.
2034         </para>
2035       </sect3>
2036
2037       <sect3 id="bus-messages-service-does-not-exist">
2038         <title><literal>org.freedesktop.DBus.Error.ServiceDoesNotExist</literal></title>
2039         <para>
2040           As a method:
2041           <programlisting>
2042             void ServiceDoesNotExist (in STRING error)
2043           </programlisting>
2044         </para>
2045         <para>
2046           Sent by the message bus as a reply to a client that tried to send a message to a service that doesn't exist.
2047         </para>
2048       </sect3>
2049     </sect2>
2050
2051   </sect1>
2052 <!--
2053   <appendix id="implementation-notes">
2054     <title>Implementation notes</title>
2055     <sect1 id="implementation-notes-subsection">
2056       <title></title>
2057       <para>
2058       </para>
2059     </sect1>
2060   </appendix>
2061 -->
2062
2063   <glossary><title>Glossary</title>
2064     <para>
2065       This glossary defines some of the terms used in this specification.
2066     </para>
2067
2068     <glossentry id="term-activation"><glossterm>Activation</glossterm>
2069       <glossdef>
2070         <para>
2071           The process of creating an owner for a particular service, 
2072           typically by launching an executable.
2073         </para>
2074       </glossdef>
2075     </glossentry>
2076
2077     <glossentry id="term-base-service"><glossterm>Base Service</glossterm>
2078       <glossdef>
2079         <para>
2080           The special service automatically assigned to an application by the 
2081           message bus. This service may never change owner, and the service 
2082           name will be unique (never reused during the lifetime of the 
2083           message bus).
2084         </para>
2085       </glossdef>
2086     </glossentry>
2087
2088     <glossentry id="term-broadcast"><glossterm>Broadcast</glossterm>
2089       <glossdef>
2090         <para>
2091           A message sent to the special <literal>org.freedesktop.DBus.Broadcast</literal>
2092           service; the message bus will forward the broadcast message 
2093           to all applications that have expressed interest in it.
2094         </para>
2095       </glossdef>
2096     </glossentry>
2097       
2098     <glossentry id="term-message"><glossterm>Message</glossterm>
2099       <glossdef>
2100         <para>
2101           A message is the atomic unit of communication via the D-BUS
2102           protocol. It consists of a <firstterm>header</firstterm> and a
2103           <firstterm>body</firstterm>; the body is made up of
2104           <firstterm>arguments</firstterm>.
2105         </para>
2106       </glossdef>
2107     </glossentry>
2108
2109     <glossentry id="term-message-bus"><glossterm>Message Bus</glossterm>
2110       <glossdef>
2111         <para>
2112           The message bus is a special application that forwards 
2113           or broadcasts messages between a group of applications
2114           connected to the message bus. It also manages 
2115           <firstterm>services</firstterm>.
2116         </para>
2117       </glossdef>
2118     </glossentry>
2119
2120     <glossentry id="namespace"><glossterm>Namespace</glossterm>
2121       <glossdef>
2122         <para>
2123           Used to prevent collisions when defining message and service
2124           names. The convention used is the same as Java uses for
2125           defining classes: a reversed domain name.
2126         </para>
2127       </glossdef>
2128     </glossentry>
2129
2130     <glossentry id="term-object"><glossterm>Object</glossterm>
2131       <glossdef>
2132         <para>
2133           Each application contains <firstterm>objects</firstterm>,
2134           which have <firstterm>interfaces</firstterm> and 
2135           <firstterm>methods</firstterm>. Objects are referred to 
2136           by a name, called a <firstterm>path</firstterm> or 
2137           <firstterm>object reference</firstterm>.
2138         </para>
2139       </glossdef>
2140     </glossentry>
2141
2142     <glossentry id="term-path"><glossterm>Path</glossterm>
2143       <glossdef>
2144         <para>
2145           Object references (object names) in D-BUS are 
2146           organized into a filesystem-style hierarchy, so 
2147           each object is named by a path. As in LDAP, 
2148           there's no difference between "files" and "directories";
2149           a path can refer to an object, while still having 
2150           child objects below it.
2151         </para>
2152       </glossdef>
2153     </glossentry>
2154
2155     <glossentry id="peer-to-peer"><glossterm>Peer-to-peer</glossterm>
2156       <glossdef>
2157         <para>
2158           An application talking directly to another application, without going through a message bus. 
2159         </para>
2160       </glossdef>
2161     </glossentry>
2162     <glossentry id="term-secondary-owner"><glossterm>Secondary service owner</glossterm>
2163       <glossdef>
2164         <para>
2165           Each service has a primary owner; messages sent to the service name 
2166           go to the primary owner. However, certain services also maintain 
2167           a queue of secondary owners "waiting in the wings." If 
2168           the primary owner releases the service, then the first secondary 
2169           owner in the queue automatically becomes the primary owner.
2170         </para>
2171       </glossdef>
2172     </glossentry>
2173     <glossentry id="term-service"><glossterm>Service</glossterm>
2174       <glossdef>
2175         <para>
2176           A service is simply a named list of applications. For example, the
2177           hypothetical <literal>com.yoyodyne.Screensaver</literal> service might
2178           accept messages that affect a screensaver from Yoyodyne Corporation.
2179           An application is said to <firstterm>own</firstterm> a service if the
2180           message bus has associated the application with the service name.
2181           Services may also have <firstterm>secondary owners</firstterm> (see
2182           <xref linkend="term-secondary-owner"/>).
2183         </para>
2184       </glossdef>
2185     </glossentry>
2186     <glossentry id="term-service-name"><glossterm>Service name</glossterm>
2187       <glossdef>
2188         <para>
2189           The name used when referring to a service. If the service is
2190           a base service it has a unique service name, for example
2191           ":1-20", and otherwise it should be namespaced.
2192         </para>
2193       </glossdef>
2194     </glossentry>
2195     <glossentry id="term-service-description-files"><glossterm>Service Description Files</glossterm>
2196       <glossdef>
2197         <para>
2198           ".service files" tell the bus how to activate a particular service.
2199           See <xref linkend="term-activation"/>
2200         </para>
2201       </glossdef>
2202     </glossentry>
2203
2204   </glossary>
2205 </article>
2206