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