Update email-address for David Zeuthen.
[platform/upstream/dbus.git] / doc / dbus-specification.xml
1 <?xml version="1.0" standalone="no" ?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
4 [
5 ]>
6 <article id="index">
7   <articleinfo>
8     <title>D-Bus Specification</title>
9     <releaseinfo>Version 0.23</releaseinfo>
10     <date>2014-01-06</date>
11     <authorgroup>
12       <author>
13         <firstname>Havoc</firstname>
14         <surname>Pennington</surname>
15         <affiliation>
16           <orgname>Red Hat, Inc.</orgname>
17           <address>
18             <email>hp@pobox.com</email>
19           </address>
20         </affiliation>
21       </author>
22       <author>
23         <firstname>Anders</firstname>
24         <surname>Carlsson</surname>
25         <affiliation>
26           <orgname>CodeFactory AB</orgname>
27           <address>
28             <email>andersca@codefactory.se</email>
29           </address>
30         </affiliation>
31       </author>
32       <author>
33         <firstname>Alexander</firstname>
34         <surname>Larsson</surname>
35         <affiliation>
36           <orgname>Red Hat, Inc.</orgname>
37           <address>
38             <email>alexl@redhat.com</email>
39           </address>
40         </affiliation>
41       </author>
42       <author>
43         <firstname>Sven</firstname>
44         <surname>Herzberg</surname>
45         <affiliation>
46           <orgname>Imendio AB</orgname>
47           <address>
48             <email>sven@imendio.com</email>
49           </address>
50         </affiliation>
51       </author>
52       <author>
53         <firstname>Simon</firstname>
54         <surname>McVittie</surname>
55         <affiliation>
56           <orgname>Collabora Ltd.</orgname>
57           <address>
58             <email>simon.mcvittie@collabora.co.uk</email>
59           </address>
60         </affiliation>
61       </author>
62       <author>
63         <firstname>David</firstname>
64         <surname>Zeuthen</surname>
65         <affiliation>
66           <address>
67             <email>zeuthen@gmail.com</email>
68           </address>
69         </affiliation>
70       </author>
71     </authorgroup>
72    <revhistory>
73      <revision>
74        <revnumber>0.23</revnumber>
75        <date>2014-01-06</date>
76        <authorinitials>SMcV, CY</authorinitials>
77        <revremark>
78          method call messages with no INTERFACE may be considered an error;
79          document tcp:bind=... and nonce-tcp:bind=...; define listenable
80          and connectable addresses
81        </revremark>
82      </revision>
83      <revision>
84        <revnumber>0.22</revnumber>
85        <date>2013-10-09</date>
86        <authorinitials></authorinitials>
87        <revremark>add GetConnectionCredentials, document
88         GetAtdAuditSessionData, document GetConnectionSELinuxSecurityContext,
89         document and correct .service file syntax and naming
90       </revremark>
91      </revision>
92      <revision>
93        <revnumber>0.21</revnumber>
94        <date>2013-04-25</date>
95        <authorinitials>smcv</authorinitials>
96        <revremark>allow Unicode noncharacters in UTF-8 (Unicode
97          Corrigendum #9)</revremark>
98      </revision>
99      <revision>
100        <revnumber>0.20</revnumber>
101        <date>22 February 2013</date>
102        <authorinitials>smcv, walters</authorinitials>
103        <revremark>reorganise for clarity, remove false claims about
104          basic types, mention /o/fd/DBus</revremark>
105      </revision>
106      <revision>
107        <revnumber>0.19</revnumber>
108        <date>20 February 2012</date>
109        <authorinitials>smcv/lp</authorinitials>
110        <revremark>formally define unique connection names and well-known
111         bus names; document best practices for interface, bus, member and
112         error names, and object paths; document the search path for session
113         and system services on Unix; document the systemd transport</revremark>
114      </revision>
115      <revision>
116        <revnumber>0.18</revnumber>
117        <date>29 July 2011</date>
118        <authorinitials>smcv</authorinitials>
119        <revremark>define eavesdropping, unicast, broadcast; add eavesdrop
120          match keyword; promote type system to a top-level section</revremark>
121      </revision>
122      <revision>
123        <revnumber>0.17</revnumber>
124        <date>1 June 2011</date>
125        <authorinitials>smcv/davidz</authorinitials>
126        <revremark>define ObjectManager; reserve extra pseudo-type-codes used
127          by GVariant</revremark>
128      </revision>
129      <revision>
130        <revnumber>0.16</revnumber>
131        <date>11 April 2011</date>
132        <authorinitials></authorinitials>
133        <revremark>add path_namespace, arg0namespace; argNpath matches object
134         paths</revremark>
135      </revision>
136      <revision>
137        <revnumber>0.15</revnumber>
138        <date>3 November 2010</date>
139        <authorinitials></authorinitials>
140        <revremark></revremark>
141      </revision>
142      <revision>
143        <revnumber>0.14</revnumber>
144        <date>12 May 2010</date>
145        <authorinitials></authorinitials>
146        <revremark></revremark>
147      </revision>
148      <revision>
149        <revnumber>0.13</revnumber>
150        <date>23 Dezember 2009</date>
151        <authorinitials></authorinitials>
152        <revremark></revremark>
153      </revision>
154      <revision>
155        <revnumber>0.12</revnumber>
156        <date>7 November, 2006</date>
157        <authorinitials></authorinitials>
158        <revremark></revremark>
159      </revision>
160      <revision>
161        <revnumber>0.11</revnumber>
162        <date>6 February 2005</date>
163        <authorinitials></authorinitials>
164        <revremark></revremark>
165      </revision>
166      <revision>
167        <revnumber>0.10</revnumber>
168        <date>28 January 2005</date>
169        <authorinitials></authorinitials>
170        <revremark></revremark>
171      </revision>
172      <revision>
173        <revnumber>0.9</revnumber>
174        <date>7 Januar 2005</date>
175        <authorinitials></authorinitials>
176        <revremark></revremark>
177      </revision>
178      <revision>
179        <revnumber>0.8</revnumber>
180        <date>06 September 2003</date>
181        <authorinitials></authorinitials>
182        <revremark>First released document.</revremark>
183      </revision>
184    </revhistory>
185   </articleinfo>
186
187   <sect1 id="introduction">
188     <title>Introduction</title>
189     <para>
190       D-Bus is a system for low-overhead, easy to use
191       interprocess communication (IPC). In more detail:
192       <itemizedlist>
193         <listitem>
194           <para>
195             D-Bus is <emphasis>low-overhead</emphasis> because it uses a
196             binary protocol, and does not have to convert to and from a text
197             format such as XML. Because D-Bus is intended for potentially
198             high-resolution same-machine IPC, not primarily for Internet IPC,
199             this is an interesting optimization. D-Bus is also designed to
200             avoid round trips and allow asynchronous operation, much like
201             the X protocol.
202           </para>
203         </listitem>
204         <listitem>
205           <para>
206             D-Bus is <emphasis>easy to use</emphasis> because it works in terms
207             of <firstterm>messages</firstterm> rather than byte streams, and
208             automatically handles a lot of the hard IPC issues. Also, the D-Bus
209             library is designed to be wrapped in a way that lets developers use
210             their framework's existing object/type system, rather than learning
211             a new one specifically for IPC.
212           </para>
213         </listitem>
214       </itemizedlist>
215     </para>
216
217     <para>
218       The base D-Bus protocol is a one-to-one (peer-to-peer or client-server)
219       protocol, specified in <xref linkend="message-protocol"/>. That is, it is
220       a system for one application to talk to a single other
221       application. However, the primary intended application of the protocol is the
222       D-Bus <firstterm>message bus</firstterm>, specified in <xref
223       linkend="message-bus"/>. The message bus is a special application that
224       accepts connections from multiple other applications, and forwards
225       messages among them.
226     </para>
227
228     <para>
229       Uses of D-Bus include notification of system changes (notification of when
230       a camera is plugged in to a computer, or a new version of some software
231       has been installed), or desktop interoperability, for example a file
232       monitoring service or a configuration service.
233     </para>
234
235     <para>
236       D-Bus is designed for two specific use cases:
237       <itemizedlist>
238         <listitem>
239           <para>
240             A "system bus" for notifications from the system to user sessions,
241             and to allow the system to request input from user sessions.
242           </para>
243         </listitem>
244         <listitem>
245           <para>
246             A "session bus" used to implement desktop environments such as 
247             GNOME and KDE.
248           </para>
249         </listitem>
250       </itemizedlist>
251       D-Bus is not intended to be a generic IPC system for any possible 
252       application, and intentionally omits many features found in other 
253       IPC systems for this reason.
254     </para>
255
256     <para>
257       At the same time, the bus daemons offer a number of features not found in
258       other IPC systems, such as single-owner "bus names" (similar to X
259       selections), on-demand startup of services, and security policies.
260       In many ways, these features are the primary motivation for developing 
261       D-Bus; other systems would have sufficed if IPC were the only goal.
262     </para>
263
264     <para>
265       D-Bus may turn out to be useful in unanticipated applications, but future
266       versions of this spec and the reference implementation probably will not
267       incorporate features that interfere with the core use cases.
268     </para>
269
270     <para>
271       The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
272       "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
273       document are to be interpreted as described in RFC 2119. However, the
274       document could use a serious audit to be sure it makes sense to do
275       so. Also, they are not capitalized.
276     </para>
277
278     <sect2 id="stability">
279       <title>Protocol and Specification Stability</title>
280       <para>
281         The D-Bus protocol is frozen (only compatible extensions are allowed) as
282         of November 8, 2006.  However, this specification could still use a fair
283         bit of work to make interoperable reimplementation possible without
284         reference to the D-Bus reference implementation. Thus, this
285         specification is not marked 1.0. To mark it 1.0, we'd like to see
286         someone invest significant effort in clarifying the specification
287         language, and growing the specification to cover more aspects of the
288         reference implementation's behavior.
289       </para>
290       <para>
291         Until this work is complete, any attempt to reimplement D-Bus will 
292         probably require looking at the reference implementation and/or asking
293         questions on the D-Bus mailing list about intended behavior. 
294         Questions on the list are very welcome.
295       </para>
296       <para>
297         Nonetheless, this document should be a useful starting point and is 
298         to our knowledge accurate, though incomplete.
299       </para>
300     </sect2>
301     
302   </sect1>
303
304   <sect1 id="type-system">
305     <title>Type System</title>
306
307     <para>
308       D-Bus has a type system, in which values of various types can be
309       serialized into a sequence of bytes referred to as the
310       <firstterm>wire format</firstterm> in a standard way.
311       Converting a value from some other representation into the wire
312       format is called <firstterm>marshaling</firstterm> and converting
313       it back from the wire format is <firstterm>unmarshaling</firstterm>.
314     </para>
315
316     <para>
317       The D-Bus protocol does not include type tags in the marshaled data; a
318       block of marshaled values must have a known <firstterm>type
319         signature</firstterm>. The type signature is made up of zero or more
320       <firstterm id="term-single-complete-type">single complete
321         types</firstterm>, each made up of one or more
322       <firstterm>type codes</firstterm>.
323     </para>
324
325     <para>
326       A type code is an ASCII character representing the
327       type of a value. Because ASCII characters are used, the type signature
328       will always form a valid ASCII string. A simple string compare
329       determines whether two type signatures are equivalent.
330     </para>
331
332     <para>
333       A single complete type is a sequence of type codes that fully describes
334       one type: either a basic type, or a single fully-described container type.
335       A single complete type is a basic type code, a variant type code,
336       an array with its element type, or a struct with its fields (all of which
337       are defined below). So the following signatures are not single complete
338       types:
339       <programlisting>
340         "aa"
341       </programlisting>
342       <programlisting>
343         "(ii"
344       </programlisting>
345       <programlisting>
346         "ii)"
347       </programlisting>
348       And the following signatures contain multiple complete types:
349       <programlisting>
350         "ii"
351       </programlisting>
352       <programlisting>
353         "aiai"
354       </programlisting>
355       <programlisting>
356         "(ii)(ii)"
357       </programlisting>
358       Note however that a single complete type may <emphasis>contain</emphasis>
359       multiple other single complete types, by containing a struct or dict
360       entry.
361     </para>
362
363     <sect2 id="basic-types">
364       <title>Basic types</title>
365
366       <para>
367         The simplest type codes are the <firstterm id="term-basic-type">basic
368           types</firstterm>, which are the types whose structure is entirely
369         defined by their 1-character type code. Basic types consist of
370         fixed types and string-like types.
371       </para>
372
373       <para>
374         The <firstterm id="term-fixed-type">fixed types</firstterm>
375         are basic types whose values have a fixed length, namely BYTE,
376         BOOLEAN, DOUBLE, UNIX_FD, and signed or unsigned integers of length
377         16, 32 or 64 bits.
378       </para>
379
380       <para>
381         As a simple example, the type code for 32-bit integer (<literal>INT32</literal>) is
382         the ASCII character 'i'. So the signature for a block of values 
383         containing a single <literal>INT32</literal> would be:
384         <programlisting>
385           "i"
386         </programlisting>
387         A block of values containing two <literal>INT32</literal> would have this signature:
388         <programlisting>
389           "ii"
390         </programlisting>        
391       </para>
392
393       <para>
394         The characteristics of the fixed types are listed in this table.
395
396         <informaltable>
397           <tgroup cols="3">
398             <thead>
399               <row>
400                 <entry>Conventional name</entry>
401                 <entry>ASCII type-code</entry>
402                 <entry>Encoding</entry>
403               </row>
404             </thead>
405             <tbody>
406               <row>
407                 <entry><literal>BYTE</literal></entry>
408                 <entry><literal>y</literal> (121)</entry>
409                 <entry>Unsigned 8-bit integer</entry>
410               </row>
411               <row>
412                 <entry><literal>BOOLEAN</literal></entry>
413                 <entry><literal>b</literal> (98)</entry>
414                 <entry>Boolean value: 0 is false, 1 is true, any other value
415                   allowed by the marshalling format is invalid</entry>
416               </row>
417               <row>
418                 <entry><literal>INT16</literal></entry>
419                 <entry><literal>n</literal> (110)</entry>
420                 <entry>Signed (two's complement) 16-bit integer</entry>
421               </row>
422               <row>
423                 <entry><literal>UINT16</literal></entry>
424                 <entry><literal>q</literal> (113)</entry>
425                 <entry>Unsigned 16-bit integer</entry>
426               </row>
427               <row>
428                 <entry><literal>INT32</literal></entry>
429                 <entry><literal>i</literal> (105)</entry>
430                 <entry>Signed (two's complement) 32-bit integer</entry>
431               </row>
432               <row>
433                 <entry><literal>UINT32</literal></entry>
434                 <entry><literal>u</literal> (117)</entry>
435                 <entry>Unsigned 32-bit integer</entry>
436               </row>
437               <row>
438                 <entry><literal>INT64</literal></entry>
439                 <entry><literal>x</literal> (120)</entry>
440                 <entry>Signed (two's complement) 64-bit integer
441                   (mnemonic: x and t are the first characters in "sixty" not
442                   already used for something more common)</entry>
443               </row>
444               <row>
445                 <entry><literal>UINT64</literal></entry>
446                 <entry><literal>t</literal> (116)</entry>
447                 <entry>Unsigned 64-bit integer</entry>
448               </row>
449               <row>
450                 <entry><literal>DOUBLE</literal></entry>
451                 <entry><literal>d</literal> (100)</entry>
452                 <entry>IEEE 754 double-precision floating point</entry>
453               </row>
454               <row>
455                 <entry><literal>UNIX_FD</literal></entry>
456                 <entry><literal>h</literal> (104)</entry>
457                 <entry>Unsigned 32-bit integer representing an index into an
458                   out-of-band array of file descriptors, transferred via some
459                   platform-specific mechanism (mnemonic: h for handle)</entry>
460               </row>
461             </tbody>
462           </tgroup>
463         </informaltable>
464       </para>
465
466       <para>
467         The <firstterm id="term-string-like-type">string-like types</firstterm>
468         are basic types with a variable length. The value of any string-like
469         type is conceptually 0 or more Unicode codepoints encoded in UTF-8,
470         none of which may be U+0000. The UTF-8 text must be validated
471         strictly: in particular, it must not contain overlong sequences
472         or codepoints above U+10FFFF.
473       </para>
474
475       <para>
476         Since D-Bus Specification version 0.21, in accordance with Unicode
477         Corrigendum #9, the "noncharacters" U+FDD0..U+FDEF, U+nFFFE and
478         U+nFFFF are allowed in UTF-8 strings (but note that older versions of
479         D-Bus rejected these noncharacters).
480       </para>
481
482       <para>
483         The marshalling formats for the string-like types all end with a
484         single zero (NUL) byte, but that byte is not considered to be part of
485         the text.
486       </para>
487
488       <para>
489         The characteristics of the string-like types are listed in this table.
490
491         <informaltable>
492           <tgroup cols="3">
493             <thead>
494               <row>
495                 <entry>Conventional name</entry>
496                 <entry>ASCII type-code</entry>
497                 <entry>Validity constraints</entry>
498               </row>
499             </thead>
500             <tbody>
501               <row>
502                 <entry><literal>STRING</literal></entry>
503                 <entry><literal>s</literal> (115)</entry>
504                 <entry>No extra constraints</entry>
505               </row>
506               <row>
507                 <entry><literal>OBJECT_PATH</literal></entry>
508                 <entry><literal>o</literal> (111)</entry>
509                 <entry>Must be
510                   <link linkend="message-protocol-marshaling-object-path">a
511                     syntactically valid object path</link></entry>
512               </row>
513               <row>
514                 <entry><literal>SIGNATURE</literal></entry>
515                 <entry><literal>g</literal> (103)</entry>
516                 <entry>Zero or more
517                   <firstterm linkend="term-single-complete-type">single
518                     complete types</firstterm></entry>
519               </row>
520             </tbody>
521           </tgroup>
522         </informaltable>
523       </para>
524
525       <sect3 id="message-protocol-marshaling-object-path">
526         <title>Valid Object Paths</title>
527
528         <para>
529           An object path is a name used to refer to an object instance.
530           Conceptually, each participant in a D-Bus message exchange may have
531           any number of object instances (think of C++ or Java objects) and each
532           such instance will have a path. Like a filesystem, the object
533           instances in an application form a hierarchical tree.
534         </para>
535
536         <para>
537           Object paths are often namespaced by starting with a reversed
538           domain name and containing an interface version number, in the
539           same way as
540           <link linkend="message-protocol-names-interface">interface
541             names</link> and
542           <link linkend="message-protocol-names-bus">well-known
543             bus names</link>.
544           This makes it possible to implement more than one service, or
545           more than one version of a service, in the same process,
546           even if the services share a connection but cannot otherwise
547           co-operate (for instance, if they are implemented by different
548           plugins).
549         </para>
550
551         <para>
552           For instance, if the owner of <literal>example.com</literal> is
553           developing a D-Bus API for a music player, they might use the
554           hierarchy of object paths that start with
555           <literal>/com/example/MusicPlayer1</literal> for its objects.
556         </para>
557
558         <para>
559           The following rules define a valid object path. Implementations must
560           not send or accept messages with invalid object paths.
561           <itemizedlist>
562             <listitem>
563               <para>
564                 The path may be of any length.
565               </para>
566             </listitem>
567             <listitem>
568               <para>
569                 The path must begin with an ASCII '/' (integer 47) character,
570                 and must consist of elements separated by slash characters.
571               </para>
572             </listitem>
573             <listitem>
574               <para>
575                 Each element must only contain the ASCII characters
576                 "[A-Z][a-z][0-9]_"
577               </para>
578             </listitem>
579             <listitem>
580               <para>
581                 No element may be the empty string.
582               </para>
583             </listitem>
584             <listitem>
585               <para>
586                 Multiple '/' characters cannot occur in sequence.
587               </para>
588             </listitem>
589             <listitem>
590               <para>
591                 A trailing '/' character is not allowed unless the
592                 path is the root path (a single '/' character).
593               </para>
594             </listitem>
595           </itemizedlist>
596         </para>
597
598       </sect3>
599
600       <sect3 id="message-protocol-marshaling-signature">
601         <title>Valid Signatures</title>
602         <para>
603           An implementation must not send or accept invalid signatures.
604           Valid signatures will conform to the following rules:
605           <itemizedlist>
606             <listitem>
607               <para>
608                 The signature is a list of single complete types.
609                 Arrays must have element types, and structs must
610                 have both open and close parentheses.
611               </para>
612             </listitem>
613             <listitem>
614               <para>
615                 Only type codes, open and close parentheses, and open and
616                 close curly brackets are allowed in the signature. The
617                 <literal>STRUCT</literal> type code
618                 is not allowed in signatures, because parentheses
619                 are used instead. Similarly, the
620                 <literal>DICT_ENTRY</literal> type code is not allowed in
621                 signatures, because curly brackets are used instead.
622               </para>
623             </listitem>
624             <listitem>
625               <para>
626                 The maximum depth of container type nesting is 32 array type
627                 codes and 32 open parentheses. This implies that the maximum
628                 total depth of recursion is 64, for an "array of array of array
629                 of ... struct of struct of struct of ..."  where there are 32
630                 array and 32 struct.
631               </para>
632             </listitem>
633             <listitem>
634               <para>
635                 The maximum length of a signature is 255.
636               </para>
637             </listitem>
638           </itemizedlist>
639         </para>
640
641         <para>
642           When signatures appear in messages, the marshalling format
643           guarantees that they will be followed by a nul byte (which can
644           be interpreted as either C-style string termination or the INVALID
645           type-code), but this is not conceptually part of the signature.
646         </para>
647       </sect3>
648
649     </sect2>
650
651     <sect2 id="container-types">
652       <title>Container types</title>
653
654       <para>
655         In addition to basic types, there are four <firstterm>container</firstterm> 
656         types: <literal>STRUCT</literal>, <literal>ARRAY</literal>, <literal>VARIANT</literal>, 
657         and <literal>DICT_ENTRY</literal>.
658       </para>
659
660       <para>
661         <literal>STRUCT</literal> has a type code, ASCII character 'r', but this type 
662         code does not appear in signatures. Instead, ASCII characters
663         '(' and ')' are used to mark the beginning and end of the struct.
664         So for example, a struct containing two integers would have this 
665         signature:
666         <programlisting>
667           "(ii)"
668         </programlisting>
669         Structs can be nested, so for example a struct containing 
670         an integer and another struct:
671         <programlisting>
672           "(i(ii))"
673         </programlisting>
674         The value block storing that struct would contain three integers; the
675         type signature allows you to distinguish "(i(ii))" from "((ii)i)" or
676         "(iii)" or "iii".
677       </para>
678
679       <para>
680         The <literal>STRUCT</literal> type code 'r' is not currently used in the D-Bus protocol,
681         but is useful in code that implements the protocol. This type code 
682         is specified to allow such code to interoperate in non-protocol contexts.
683       </para>
684
685       <para>
686         Empty structures are not allowed; there must be at least one
687         type code between the parentheses.
688       </para>
689
690       <para>
691         <literal>ARRAY</literal> has ASCII character 'a' as type code. The array type code must be
692         followed by a <firstterm>single complete type</firstterm>. The single
693         complete type following the array is the type of each array element. So
694         the simple example is:
695         <programlisting>
696           "ai"
697         </programlisting>
698         which is an array of 32-bit integers. But an array can be of any type, 
699         such as this array-of-struct-with-two-int32-fields:
700         <programlisting>
701           "a(ii)"
702         </programlisting>
703         Or this array of array of integer:
704         <programlisting>
705           "aai"
706         </programlisting>
707       </para>
708
709       <para>
710         <literal>VARIANT</literal> has ASCII character 'v' as its type code. A marshaled value of
711         type <literal>VARIANT</literal> will have the signature of a single complete type as part
712         of the <emphasis>value</emphasis>.  This signature will be followed by a
713         marshaled value of that type.
714       </para>
715
716       <para>
717         Unlike a message signature, the variant signature can
718         contain only a single complete type.  So "i", "ai"
719         or "(ii)" is OK, but "ii" is not.  Use of variants may not
720         cause a total message depth to be larger than 64, including
721         other container types such as structures.
722       </para>
723
724       <para>
725         A <literal>DICT_ENTRY</literal> works exactly like a struct, but rather
726         than parentheses it uses curly braces, and it has more restrictions.
727         The restrictions are: it occurs only as an array element type; it has
728         exactly two single complete types inside the curly braces; the first
729         single complete type (the "key") must be a basic type rather than a
730         container type. Implementations must not accept dict entries outside of
731         arrays, must not accept dict entries with zero, one, or more than two
732         fields, and must not accept dict entries with non-basic-typed keys. A
733         dict entry is always a key-value pair.
734       </para>
735       
736       <para>
737         The first field in the <literal>DICT_ENTRY</literal> is always the key.
738         A message is considered corrupt if the same key occurs twice in the same
739         array of <literal>DICT_ENTRY</literal>. However, for performance reasons
740         implementations are not required to reject dicts with duplicate keys.
741       </para>
742
743       <para>
744         In most languages, an array of dict entry would be represented as a 
745         map, hash table, or dict object.
746       </para>
747     </sect2>
748
749     <sect2>
750       <title>Summary of types</title>
751
752       <para>
753         The following table summarizes the D-Bus types.
754         <informaltable>
755           <tgroup cols="3">
756             <thead>
757               <row>
758                 <entry>Conventional Name</entry>
759                 <entry>Code</entry>
760                 <entry>Description</entry>
761               </row>
762             </thead>
763             <tbody>
764               <row>
765                 <entry><literal>INVALID</literal></entry>
766                 <entry>0 (ASCII NUL)</entry>
767                 <entry>Not a valid type code, used to terminate signatures</entry>
768               </row><row>
769                 <entry><literal>BYTE</literal></entry>
770                 <entry>121 (ASCII 'y')</entry>
771                 <entry>8-bit unsigned integer</entry>
772               </row><row>
773                 <entry><literal>BOOLEAN</literal></entry>
774                 <entry>98 (ASCII 'b')</entry>
775                 <entry>Boolean value, 0 is <literal>FALSE</literal> and 1 is <literal>TRUE</literal>. Everything else is invalid.</entry>
776               </row><row>
777                 <entry><literal>INT16</literal></entry>
778                 <entry>110 (ASCII 'n')</entry>
779                 <entry>16-bit signed integer</entry>
780               </row><row>
781                 <entry><literal>UINT16</literal></entry>
782                 <entry>113 (ASCII 'q')</entry>
783                 <entry>16-bit unsigned integer</entry>
784               </row><row>
785                 <entry><literal>INT32</literal></entry>
786                 <entry>105 (ASCII 'i')</entry>
787                 <entry>32-bit signed integer</entry>
788               </row><row>
789                 <entry><literal>UINT32</literal></entry>
790                 <entry>117 (ASCII 'u')</entry>
791                 <entry>32-bit unsigned integer</entry>
792               </row><row>
793                 <entry><literal>INT64</literal></entry>
794                 <entry>120 (ASCII 'x')</entry>
795                 <entry>64-bit signed integer</entry>
796               </row><row>
797                 <entry><literal>UINT64</literal></entry>
798                 <entry>116 (ASCII 't')</entry>
799                 <entry>64-bit unsigned integer</entry>
800               </row><row>
801                 <entry><literal>DOUBLE</literal></entry>
802                 <entry>100 (ASCII 'd')</entry>
803                 <entry>IEEE 754 double</entry>
804               </row><row>
805                 <entry><literal>STRING</literal></entry>
806                 <entry>115 (ASCII 's')</entry>
807                 <entry>UTF-8 string (<emphasis>must</emphasis> be valid UTF-8). Must be nul terminated and contain no other nul bytes.</entry>
808               </row><row>
809                 <entry><literal>OBJECT_PATH</literal></entry>
810                 <entry>111 (ASCII 'o')</entry>
811                 <entry>Name of an object instance</entry>
812               </row><row>
813                 <entry><literal>SIGNATURE</literal></entry>
814                 <entry>103 (ASCII 'g')</entry>
815                 <entry>A type signature</entry>
816               </row><row>
817                 <entry><literal>ARRAY</literal></entry>
818                 <entry>97 (ASCII 'a')</entry>
819                 <entry>Array</entry>
820               </row><row>
821                 <entry><literal>STRUCT</literal></entry>
822                 <entry>114 (ASCII 'r'), 40 (ASCII '('), 41 (ASCII ')')</entry>
823                 <entry>Struct; type code 114 'r' is reserved for use in
824                   bindings and implementations to represent the general
825                   concept of a struct, and must not appear in signatures
826                   used on D-Bus.</entry>
827               </row><row>
828                 <entry><literal>VARIANT</literal></entry>
829                 <entry>118 (ASCII 'v') </entry>
830                 <entry>Variant type (the type of the value is part of the value itself)</entry>
831               </row><row>
832                 <entry><literal>DICT_ENTRY</literal></entry>
833                 <entry>101 (ASCII 'e'), 123 (ASCII '{'), 125 (ASCII '}') </entry>
834                 <entry>Entry in a dict or map (array of key-value pairs).
835                   Type code 101 'e' is reserved for use in bindings and
836                   implementations to represent the general concept of a
837                   dict or dict-entry, and must not appear in signatures
838                   used on D-Bus.</entry>
839               </row><row>
840                 <entry><literal>UNIX_FD</literal></entry>
841                 <entry>104 (ASCII 'h')</entry>
842                 <entry>Unix file descriptor</entry>
843               </row>
844               <row>
845                 <entry>(reserved)</entry>
846                 <entry>109 (ASCII 'm')</entry>
847                 <entry>Reserved for <ulink
848                     url="https://bugs.freedesktop.org/show_bug.cgi?id=27857">a
849                   'maybe' type compatible with the one in GVariant</ulink>,
850                   and must not appear in signatures used on D-Bus until
851                   specified here</entry>
852               </row>
853               <row>
854                 <entry>(reserved)</entry>
855                 <entry>42 (ASCII '*')</entry>
856                 <entry>Reserved for use in bindings/implementations to
857                   represent any <firstterm>single complete type</firstterm>,
858                   and must not appear in signatures used on D-Bus.</entry>
859               </row>
860               <row>
861                 <entry>(reserved)</entry>
862                 <entry>63 (ASCII '?')</entry>
863                 <entry>Reserved for use in bindings/implementations to
864                   represent any <firstterm>basic type</firstterm>, and must
865                   not appear in signatures used on D-Bus.</entry>
866               </row>
867               <row>
868                 <entry>(reserved)</entry>
869                 <entry>64 (ASCII '@'), 38 (ASCII '&amp;'),
870                   94 (ASCII '^')</entry>
871                 <entry>Reserved for internal use by bindings/implementations,
872                   and must not appear in signatures used on D-Bus.
873                   GVariant uses these type-codes to encode calling
874                   conventions.</entry>
875               </row>
876             </tbody>
877           </tgroup>
878         </informaltable>
879       </para>
880
881     </sect2>
882   </sect1>
883
884   <sect1 id="message-protocol-marshaling">
885     <title>Marshaling (Wire Format)</title>
886
887     <para>
888       D-Bus defines a marshalling format for its type system, which is
889       used in D-Bus messages. This is not the only possible marshalling
890       format for the type system: for instance, GVariant (part of GLib)
891       re-uses the D-Bus type system but implements an alternative marshalling
892       format.
893     </para>
894
895     <sect2>
896       <title>Byte order and alignment</title>
897
898       <para>
899         Given a type signature, a block of bytes can be converted into typed
900         values. This section describes the format of the block of bytes.  Byte
901         order and alignment issues are handled uniformly for all D-Bus types.
902       </para>
903
904       <para>
905         A block of bytes has an associated byte order. The byte order
906         has to be discovered in some way; for D-Bus messages, the
907         byte order is part of the message header as described in
908         <xref linkend="message-protocol-messages"/>. For now, assume
909         that the byte order is known to be either little endian or big
910           endian.
911       </para>
912
913       <para>
914         Each value in a block of bytes is aligned "naturally," for example
915         4-byte values are aligned to a 4-byte boundary, and 8-byte values to an
916         8-byte boundary. To properly align a value, <firstterm>alignment
917         padding</firstterm> may be necessary. The alignment padding must always
918         be the minimum required padding to properly align the following value;
919         and it must always be made up of nul bytes. The alignment padding must
920         not be left uninitialized (it can't contain garbage), and more padding
921         than required must not be used.
922       </para>
923
924       <para>
925         As an exception to natural alignment, <literal>STRUCT</literal> and
926         <literal>DICT_ENTRY</literal> values are always aligned to an 8-byte
927         boundary, regardless of the alignments of their contents.
928       </para>
929     </sect2>
930
931     <sect2>
932       <title>Marshalling basic types</title>
933
934       <para>
935         To marshal and unmarshal fixed types, you simply read one value
936         from the data block corresponding to each type code in the signature.
937         All signed integer values are encoded in two's complement, DOUBLE
938         values are IEEE 754 double-precision floating-point, and BOOLEAN
939         values are encoded in 32 bits (of which only the least significant
940         bit is used).
941       </para>
942
943       <para>
944         The string-like types are all marshalled as a
945         fixed-length unsigned integer <varname>n</varname> giving the
946         length of the variable part, followed by <varname>n</varname>
947         nonzero bytes of UTF-8 text, followed by a single zero (nul) byte
948         which is not considered to be part of the text. The alignment
949         of the string-like type is the same as the alignment of
950         <varname>n</varname>.
951       </para>
952
953       <para>
954         For the STRING and OBJECT_PATH types, <varname>n</varname> is
955         encoded in 4 bytes, leading to 4-byte alignment.
956         For the SIGNATURE type, <varname>n</varname> is encoded as a single
957         byte. As a result, alignment padding is never required before a
958         SIGNATURE.
959       </para>
960     </sect2>
961
962     <sect2>
963       <title>Marshalling containers</title>
964
965       <para>
966         Arrays are marshalled as a <literal>UINT32</literal>
967         <varname>n</varname> giving the length of the array data in bytes,
968         followed by alignment padding to the alignment boundary of the array
969         element type, followed by the <varname>n</varname> bytes of the
970         array elements marshalled in sequence. <varname>n</varname> does not
971         include the padding after the length, or any padding after the
972         last element.
973       </para>
974
975       <para>
976         For instance, if the current position in the message is a multiple
977         of 8 bytes and the byte-order is big-endian, an array containing only
978         the 64-bit integer 5 would be marshalled as:
979
980         <screen>
981 00 00 00 08               <lineannotation>8 bytes of data</lineannotation>
982 00 00 00 00               <lineannotation>padding to 8-byte boundary</lineannotation>
983 00 00 00 00  00 00 00 05  <lineannotation>first element = 5</lineannotation>
984         </screen>
985       </para>
986
987       <para>
988         Arrays have a maximum length defined to be 2 to the 26th power or
989         67108864. Implementations must not send or accept arrays exceeding this
990         length.
991       </para>
992
993       <para>
994         Structs and dict entries are marshalled in the same way as their
995         contents, but their alignment is always to an 8-byte boundary,
996         even if their contents would normally be less strictly aligned.
997       </para>
998
999       <para>
1000         Variants are marshalled as the <literal>SIGNATURE</literal> of
1001         the contents (which must be a single complete type), followed by a
1002         marshalled value with the type given by that signature. The
1003         variant has the same 1-byte alignment as the signature, which means
1004         that alignment padding before a variant is never needed.
1005         Use of variants may not cause a total message depth to be larger
1006         than 64, including other container types such as structures.
1007       </para>
1008     </sect2>
1009
1010     <sect2>
1011       <title>Summary of D-Bus marshalling</title>
1012
1013       <para>
1014         Given all this, the types are marshaled on the wire as follows:
1015         <informaltable>
1016           <tgroup cols="3">
1017             <thead>
1018               <row>
1019                 <entry>Conventional Name</entry>
1020                 <entry>Encoding</entry>
1021                 <entry>Alignment</entry>
1022               </row>
1023             </thead>
1024             <tbody>
1025               <row>
1026                 <entry><literal>INVALID</literal></entry>
1027                 <entry>Not applicable; cannot be marshaled.</entry>
1028                 <entry>N/A</entry>
1029               </row><row>
1030                 <entry><literal>BYTE</literal></entry>
1031                 <entry>A single 8-bit byte.</entry>
1032                 <entry>1</entry>
1033               </row><row>
1034                 <entry><literal>BOOLEAN</literal></entry>
1035                 <entry>As for <literal>UINT32</literal>, but only 0 and 1 are valid values.</entry>
1036                 <entry>4</entry>
1037               </row><row>
1038                 <entry><literal>INT16</literal></entry>
1039                 <entry>16-bit signed integer in the message's byte order.</entry>
1040                 <entry>2</entry>
1041               </row><row>
1042                 <entry><literal>UINT16</literal></entry>
1043                 <entry>16-bit unsigned integer in the message's byte order.</entry>
1044                 <entry>2</entry>
1045               </row><row>
1046                 <entry><literal>INT32</literal></entry>
1047                 <entry>32-bit signed integer in the message's byte order.</entry>
1048                 <entry>4</entry>
1049               </row><row>
1050                 <entry><literal>UINT32</literal></entry>
1051                 <entry>32-bit unsigned integer in the message's byte order.</entry>
1052                 <entry>4</entry>
1053               </row><row>
1054                 <entry><literal>INT64</literal></entry>
1055                 <entry>64-bit signed integer in the message's byte order.</entry>
1056                 <entry>8</entry>
1057               </row><row>
1058                 <entry><literal>UINT64</literal></entry>
1059                 <entry>64-bit unsigned integer in the message's byte order.</entry>
1060                 <entry>8</entry>
1061               </row><row>
1062                 <entry><literal>DOUBLE</literal></entry>
1063                 <entry>64-bit IEEE 754 double in the message's byte order.</entry>
1064                 <entry>8</entry>
1065               </row><row>
1066                 <entry><literal>STRING</literal></entry>
1067                 <entry>A <literal>UINT32</literal> indicating the string's 
1068                   length in bytes excluding its terminating nul, followed by 
1069                   non-nul string data of the given length, followed by a terminating nul 
1070                   byte.
1071                 </entry>
1072                 <entry>
1073                   4 (for the length)
1074                 </entry>
1075               </row><row>
1076                 <entry><literal>OBJECT_PATH</literal></entry>
1077                 <entry>Exactly the same as <literal>STRING</literal> except the 
1078                   content must be a valid object path (see above).
1079                 </entry>
1080                 <entry>
1081                   4 (for the length)
1082                 </entry>
1083               </row><row>
1084                 <entry><literal>SIGNATURE</literal></entry>
1085                 <entry>The same as <literal>STRING</literal> except the length is a single 
1086                   byte (thus signatures have a maximum length of 255)
1087                   and the content must be a valid signature (see above).
1088                 </entry>
1089                 <entry>
1090                   1
1091                 </entry>
1092               </row><row>
1093                 <entry><literal>ARRAY</literal></entry>
1094                 <entry>
1095                   A <literal>UINT32</literal> giving the length of the array data in bytes, followed by 
1096                   alignment padding to the alignment boundary of the array element type,
1097                   followed by each array element.
1098                 </entry>
1099                 <entry>
1100                   4 (for the length)
1101                 </entry>
1102               </row><row>
1103                 <entry><literal>STRUCT</literal></entry>
1104                 <entry>
1105                   A struct must start on an 8-byte boundary regardless of the
1106                   type of the struct fields. The struct value consists of each
1107                   field marshaled in sequence starting from that 8-byte
1108                   alignment boundary.
1109                 </entry>
1110                 <entry>
1111                   8
1112                 </entry>
1113               </row><row>
1114                 <entry><literal>VARIANT</literal></entry>
1115                 <entry>
1116                   The marshaled <literal>SIGNATURE</literal> of a single
1117                   complete type, followed by a marshaled value with the type
1118                   given in the signature.
1119                 </entry>
1120                 <entry>
1121                   1 (alignment of the signature)
1122                 </entry>
1123               </row><row>
1124                 <entry><literal>DICT_ENTRY</literal></entry>
1125                 <entry>
1126                   Identical to STRUCT.
1127                 </entry>
1128                 <entry>
1129                   8
1130                 </entry>
1131               </row><row>
1132                 <entry><literal>UNIX_FD</literal></entry>
1133                 <entry>32-bit unsigned integer in the message's byte
1134                 order. The actual file descriptors need to be
1135                 transferred out-of-band via some platform specific
1136                 mechanism. On the wire, values of this type store the index to the
1137                 file descriptor in the array of file descriptors that
1138                 accompany the message.</entry>
1139                 <entry>4</entry>
1140               </row>
1141             </tbody>
1142           </tgroup>
1143         </informaltable>
1144       </para>
1145
1146     </sect2>
1147
1148   </sect1>
1149
1150   <sect1 id="message-protocol">
1151     <title>Message Protocol</title>
1152
1153     <para>
1154       A <firstterm>message</firstterm> consists of a
1155       <firstterm>header</firstterm> and a <firstterm>body</firstterm>. If you
1156       think of a message as a package, the header is the address, and the body
1157       contains the package contents. The message delivery system uses the header
1158       information to figure out where to send the message and how to interpret
1159       it; the recipient interprets the body of the message.
1160     </para>
1161     
1162     <para>
1163       The body of the message is made up of zero or more
1164       <firstterm>arguments</firstterm>, which are typed values, such as an
1165       integer or a byte array.
1166     </para>
1167
1168     <para>
1169       Both header and body use the D-Bus <link linkend="type-system">type
1170         system</link> and format for serializing data.
1171     </para>
1172
1173     <sect2 id="message-protocol-messages">
1174       <title>Message Format</title>
1175
1176       <para>
1177         A message consists of a header and a body. The header is a block of
1178         values with a fixed signature and meaning.  The body is a separate block
1179         of values, with a signature specified in the header.
1180       </para>
1181
1182       <para>
1183         The length of the header must be a multiple of 8, allowing the body to
1184         begin on an 8-byte boundary when storing the entire message in a single
1185         buffer. If the header does not naturally end on an 8-byte boundary 
1186         up to 7 bytes of nul-initialized alignment padding must be added.
1187       </para>
1188
1189       <para>
1190         The message body need not end on an 8-byte boundary.
1191       </para>
1192
1193       <para>
1194         The maximum length of a message, including header, header alignment padding, 
1195         and body is 2 to the 27th power or 134217728. Implementations must not 
1196         send or accept messages exceeding this size.
1197       </para>
1198       
1199       <para>
1200         The signature of the header is:
1201         <programlisting>
1202           "yyyyuua(yv)"
1203         </programlisting>
1204         Written out more readably, this is:
1205         <programlisting>
1206           BYTE, BYTE, BYTE, BYTE, UINT32, UINT32, ARRAY of STRUCT of (BYTE,VARIANT)
1207         </programlisting>
1208       </para>
1209
1210       <para>
1211         These values have the following meanings:
1212         <informaltable>
1213           <tgroup cols="2">
1214             <thead>
1215               <row>
1216                 <entry>Value</entry>
1217                 <entry>Description</entry>
1218               </row>
1219             </thead>
1220             <tbody>
1221               <row>
1222                 <entry>1st <literal>BYTE</literal></entry>
1223                 <entry>Endianness flag; ASCII 'l' for little-endian 
1224                   or ASCII 'B' for big-endian. Both header and body are 
1225                 in this endianness.</entry>
1226               </row>
1227               <row>
1228                 <entry>2nd <literal>BYTE</literal></entry>
1229                 <entry><firstterm>Message type</firstterm>. Unknown types must be ignored. 
1230                   Currently-defined types are described below.
1231                 </entry>
1232               </row>
1233               <row>
1234                 <entry>3rd <literal>BYTE</literal></entry>
1235                 <entry>Bitwise OR of flags. Unknown flags
1236                   must be ignored. Currently-defined flags are described below.
1237                 </entry>
1238               </row>
1239               <row>
1240                 <entry>4th <literal>BYTE</literal></entry>
1241                 <entry>Major protocol version of the sending application.  If
1242                 the major protocol version of the receiving application does not
1243                 match, the applications will not be able to communicate and the
1244                 D-Bus connection must be disconnected. The major protocol
1245                 version for this version of the specification is 1.
1246                 </entry>
1247               </row>
1248               <row>
1249                 <entry>1st <literal>UINT32</literal></entry>
1250                 <entry>Length in bytes of the message body, starting 
1251                   from the end of the header. The header ends after 
1252                   its alignment padding to an 8-boundary.
1253                 </entry>
1254               </row>
1255               <row>
1256                 <entry>2nd <literal>UINT32</literal></entry>
1257                 <entry>The serial of this message, used as a cookie 
1258                   by the sender to identify the reply corresponding
1259                   to this request. This must not be zero.
1260                 </entry>
1261               </row>      
1262               <row>
1263                 <entry><literal>ARRAY</literal> of <literal>STRUCT</literal> of (<literal>BYTE</literal>,<literal>VARIANT</literal>)</entry>
1264                 <entry>An array of zero or more <firstterm>header
1265                   fields</firstterm> where the byte is the field code, and the
1266                   variant is the field value. The message type determines 
1267                   which fields are required.
1268                 </entry>
1269               </row>
1270             </tbody>
1271           </tgroup>
1272         </informaltable>
1273       </para>
1274       <para>
1275         <firstterm>Message types</firstterm> that can appear in the second byte
1276         of the header are:
1277         <informaltable>
1278           <tgroup cols="3">
1279             <thead>
1280               <row>
1281                 <entry>Conventional name</entry>
1282                 <entry>Decimal value</entry>
1283                 <entry>Description</entry>
1284               </row>
1285             </thead>
1286             <tbody>
1287               <row>
1288                 <entry><literal>INVALID</literal></entry>
1289                 <entry>0</entry>
1290                 <entry>This is an invalid type.</entry>
1291               </row>
1292               <row>
1293                 <entry><literal>METHOD_CALL</literal></entry>
1294                 <entry>1</entry>
1295                 <entry>Method call.</entry>
1296               </row>
1297               <row>
1298                 <entry><literal>METHOD_RETURN</literal></entry>
1299                 <entry>2</entry>
1300                 <entry>Method reply with returned data.</entry>
1301               </row>
1302               <row>
1303                 <entry><literal>ERROR</literal></entry>
1304                 <entry>3</entry>
1305                 <entry>Error reply. If the first argument exists and is a
1306                 string, it is an error message.</entry>
1307               </row>
1308               <row>
1309                 <entry><literal>SIGNAL</literal></entry>
1310                 <entry>4</entry>
1311                 <entry>Signal emission.</entry>
1312               </row>
1313             </tbody>
1314           </tgroup>
1315         </informaltable>
1316       </para>
1317       <para>
1318         Flags that can appear in the third byte of the header:
1319         <informaltable>
1320           <tgroup cols="3">
1321             <thead>
1322               <row>
1323                 <entry>Conventional name</entry>
1324                 <entry>Hex value</entry>
1325                 <entry>Description</entry>
1326               </row>
1327             </thead>
1328             <tbody>
1329               <row>
1330                 <entry><literal>NO_REPLY_EXPECTED</literal></entry>
1331                 <entry>0x1</entry>
1332                 <entry>This message does not expect method return replies or
1333                 error replies; the reply can be omitted as an
1334                 optimization. However, it is compliant with this specification
1335                 to return the reply despite this flag and the only harm 
1336                   from doing so is extra network traffic.
1337                 </entry>
1338               </row>
1339               <row>
1340                 <entry><literal>NO_AUTO_START</literal></entry>
1341                 <entry>0x2</entry>
1342                 <entry>The bus must not launch an owner
1343                   for the destination name in response to this message.
1344                 </entry>
1345               </row>
1346             </tbody>
1347           </tgroup>
1348         </informaltable>
1349       </para>
1350
1351       <sect3 id="message-protocol-header-fields">
1352         <title>Header Fields</title>
1353
1354         <para>
1355           The array at the end of the header contains <firstterm>header
1356           fields</firstterm>, where each field is a 1-byte field code followed
1357           by a field value. A header must contain the required header fields for
1358           its message type, and zero or more of any optional header
1359           fields. Future versions of this protocol specification may add new
1360           fields. Implementations must ignore fields they do not
1361           understand. Implementations must not invent their own header fields;
1362           only changes to this specification may introduce new header fields.
1363         </para>
1364
1365         <para>
1366           Again, if an implementation sees a header field code that it does not
1367           expect, it must ignore that field, as it will be part of a new
1368           (but compatible) version of this specification. This also applies 
1369           to known header fields appearing in unexpected messages, for 
1370           example: if a signal has a reply serial it must be ignored
1371           even though it has no meaning as of this version of the spec.
1372         </para>
1373
1374         <para>
1375           However, implementations must not send or accept known header fields
1376           with the wrong type stored in the field value. So for example a
1377           message with an <literal>INTERFACE</literal> field of type
1378           <literal>UINT32</literal> would be considered corrupt.
1379         </para>
1380
1381         <para>
1382           Here are the currently-defined header fields:
1383           <informaltable>
1384             <tgroup cols="5">
1385               <thead>
1386                 <row>
1387                   <entry>Conventional Name</entry>
1388                   <entry>Decimal Code</entry>
1389                   <entry>Type</entry>
1390                   <entry>Required In</entry>
1391                   <entry>Description</entry>
1392                 </row>
1393               </thead>
1394               <tbody>
1395                 <row>
1396                   <entry><literal>INVALID</literal></entry>
1397                   <entry>0</entry>
1398                   <entry>N/A</entry>
1399                   <entry>not allowed</entry>
1400                   <entry>Not a valid field name (error if it appears in a message)</entry>
1401                 </row>
1402                 <row>
1403                   <entry><literal>PATH</literal></entry>
1404                   <entry>1</entry>
1405                   <entry><literal>OBJECT_PATH</literal></entry>
1406                   <entry><literal>METHOD_CALL</literal>, <literal>SIGNAL</literal></entry>
1407                   <entry>The object to send a call to,
1408                     or the object a signal is emitted from.
1409                     The special path
1410                     <literal>/org/freedesktop/DBus/Local</literal> is reserved;
1411                     implementations should not send messages with this path,
1412                     and the reference implementation of the bus daemon will
1413                     disconnect any application that attempts to do so.
1414                   </entry>
1415                 </row>
1416                 <row>
1417                   <entry><literal>INTERFACE</literal></entry>
1418                   <entry>2</entry>
1419                   <entry><literal>STRING</literal></entry>
1420                   <entry><literal>SIGNAL</literal></entry>
1421                   <entry>
1422                     The interface to invoke a method call on, or 
1423                     that a signal is emitted from. Optional for 
1424                     method calls, required for signals.
1425                     The special interface
1426                     <literal>org.freedesktop.DBus.Local</literal> is reserved;
1427                     implementations should not send messages with this
1428                     interface, and the reference implementation of the bus
1429                     daemon will disconnect any application that attempts to
1430                     do so.
1431                   </entry>
1432                 </row>
1433                 <row>
1434                   <entry><literal>MEMBER</literal></entry>
1435                   <entry>3</entry>
1436                   <entry><literal>STRING</literal></entry>
1437                   <entry><literal>METHOD_CALL</literal>, <literal>SIGNAL</literal></entry>
1438                   <entry>The member, either the method name or signal name.</entry>
1439                 </row>
1440                 <row>
1441                   <entry><literal>ERROR_NAME</literal></entry>
1442                   <entry>4</entry>
1443                   <entry><literal>STRING</literal></entry>
1444                   <entry><literal>ERROR</literal></entry>
1445                   <entry>The name of the error that occurred, for errors</entry>
1446                 </row>
1447                 <row>
1448                   <entry><literal>REPLY_SERIAL</literal></entry>
1449                   <entry>5</entry>
1450                   <entry><literal>UINT32</literal></entry>
1451                   <entry><literal>ERROR</literal>, <literal>METHOD_RETURN</literal></entry>
1452                   <entry>The serial number of the message this message is a reply
1453                     to. (The serial number is the second <literal>UINT32</literal> in the header.)</entry>
1454                 </row>
1455                 <row>
1456                   <entry><literal>DESTINATION</literal></entry>
1457                   <entry>6</entry>
1458                   <entry><literal>STRING</literal></entry>
1459                   <entry>optional</entry>
1460                   <entry>The name of the connection this message is intended for.
1461                     Only used in combination with the message bus, see 
1462                     <xref linkend="message-bus"/>.</entry>
1463                 </row>
1464                 <row>
1465                   <entry><literal>SENDER</literal></entry>
1466                   <entry>7</entry>
1467                   <entry><literal>STRING</literal></entry>
1468                   <entry>optional</entry>
1469                   <entry>Unique name of the sending connection.
1470                     The message bus fills in this field so it is reliable; the field is
1471                     only meaningful in combination with the message bus.</entry>
1472                 </row>
1473                 <row>
1474                   <entry><literal>SIGNATURE</literal></entry>
1475                   <entry>8</entry>
1476                   <entry><literal>SIGNATURE</literal></entry>
1477                   <entry>optional</entry>
1478                   <entry>The signature of the message body.
1479                   If omitted, it is assumed to be the 
1480                   empty signature "" (i.e. the body must be 0-length).</entry>
1481                 </row>
1482                 <row>
1483                   <entry><literal>UNIX_FDS</literal></entry>
1484                   <entry>9</entry>
1485                   <entry><literal>UINT32</literal></entry>
1486                   <entry>optional</entry>
1487                   <entry>The number of Unix file descriptors that
1488                   accompany the message.  If omitted, it is assumed
1489                   that no Unix file descriptors accompany the
1490                   message. The actual file descriptors need to be
1491                   transferred via platform specific mechanism
1492                   out-of-band. They must be sent at the same time as
1493                   part of the message itself. They may not be sent
1494                   before the first byte of the message itself is
1495                   transferred or after the last byte of the message
1496                   itself.</entry>
1497                 </row>
1498               </tbody>
1499             </tgroup>
1500           </informaltable>
1501         </para>
1502       </sect3>
1503     </sect2>
1504
1505     <sect2 id="message-protocol-names">
1506       <title>Valid Names</title>
1507       <para>
1508         The various names in D-Bus messages have some restrictions.
1509       </para>
1510       <para>
1511         There is a <firstterm>maximum name length</firstterm> 
1512         of 255 which applies to bus names, interfaces, and members. 
1513       </para>
1514       <sect3 id="message-protocol-names-interface">
1515         <title>Interface names</title>
1516         <para>
1517           Interfaces have names with type <literal>STRING</literal>, meaning that 
1518           they must be valid UTF-8. However, there are also some 
1519           additional restrictions that apply to interface names 
1520           specifically:
1521           <itemizedlist>
1522             <listitem><para>Interface names are composed of 1 or more elements separated by
1523                 a period ('.') character. All elements must contain at least 
1524                 one character.
1525                 </para>
1526             </listitem>
1527             <listitem><para>Each element must only contain the ASCII characters 
1528                 "[A-Z][a-z][0-9]_" and must not begin with a digit.
1529                 </para>
1530             </listitem>
1531
1532             <listitem><para>Interface names must contain at least one '.' (period)
1533               character (and thus at least two elements).
1534               </para></listitem>
1535
1536             <listitem><para>Interface names must not begin with a '.' (period) character.</para></listitem>
1537             <listitem><para>Interface names must not exceed the maximum name length.</para></listitem>
1538           </itemizedlist>
1539         </para>
1540
1541         <para>
1542           Interface names should start with the reversed DNS domain name of
1543           the author of the interface (in lower-case), like interface names
1544           in Java. It is conventional for the rest of the interface name
1545           to consist of words run together, with initial capital letters
1546           on all words ("CamelCase"). Several levels of hierarchy can be used.
1547           It is also a good idea to include the major version of the interface
1548           in the name, and increment it if incompatible changes are made;
1549           this way, a single object can implement several versions of an
1550           interface in parallel, if necessary.
1551         </para>
1552
1553         <para>
1554           For instance, if the owner of <literal>example.com</literal> is
1555           developing a D-Bus API for a music player, they might define
1556           interfaces called <literal>com.example.MusicPlayer1</literal>,
1557           <literal>com.example.MusicPlayer1.Track</literal> and
1558           <literal>com.example.MusicPlayer1.Seekable</literal>.
1559         </para>
1560
1561         <para>
1562           D-Bus does not distinguish between the concepts that would be
1563           called classes and interfaces in Java: either can be identified on
1564           D-Bus by an interface name.
1565         </para>
1566       </sect3>
1567       <sect3 id="message-protocol-names-bus">
1568         <title>Bus names</title>
1569         <para>
1570           Connections have one or more bus names associated with them.
1571           A connection has exactly one bus name that is a <firstterm>unique
1572             connection name</firstterm>. The unique connection name remains
1573           with the connection for its entire lifetime.
1574           A bus name is of type <literal>STRING</literal>,
1575           meaning that it must be valid UTF-8. However, there are also
1576           some additional restrictions that apply to bus names 
1577           specifically:
1578           <itemizedlist>
1579             <listitem><para>Bus names that start with a colon (':')
1580                 character are unique connection names. Other bus names
1581                 are called <firstterm>well-known bus names</firstterm>.
1582                 </para>
1583             </listitem>
1584             <listitem><para>Bus names are composed of 1 or more elements separated by
1585                 a period ('.') character. All elements must contain at least 
1586                 one character.
1587                 </para>
1588             </listitem>
1589             <listitem><para>Each element must only contain the ASCII characters 
1590                 "[A-Z][a-z][0-9]_-". Only elements that are part of a unique
1591                 connection name may begin with a digit, elements in
1592                 other bus names must not begin with a digit.
1593                 </para>
1594             </listitem>
1595
1596             <listitem><para>Bus names must contain at least one '.' (period)
1597               character (and thus at least two elements).
1598               </para></listitem>
1599
1600             <listitem><para>Bus names must not begin with a '.' (period) character.</para></listitem>
1601             <listitem><para>Bus names must not exceed the maximum name length.</para></listitem>
1602           </itemizedlist>
1603         </para>
1604         <para>
1605           Note that the hyphen ('-') character is allowed in bus names but
1606           not in interface names.
1607         </para>
1608
1609         <para>
1610           Like <link linkend="message-protocol-names-interface">interface
1611             names</link>, well-known bus names should start with the
1612           reversed DNS domain name of the author of the interface (in
1613           lower-case), and it is conventional for the rest of the well-known
1614           bus name to consist of words run together, with initial
1615           capital letters. As with interface names, including a version
1616           number in well-known bus names is a good idea; it's possible to
1617           have the well-known bus name for more than one version
1618           simultaneously if backwards compatibility is required.
1619         </para>
1620
1621         <para>
1622           If a well-known bus name implies the presence of a "main" interface,
1623           that "main" interface is often given the same name as
1624           the well-known bus name, and situated at the corresponding object
1625           path. For instance, if the owner of <literal>example.com</literal>
1626           is developing a D-Bus API for a music player, they might define
1627           that any application that takes the well-known name
1628           <literal>com.example.MusicPlayer1</literal> should have an object
1629           at the object path <literal>/com/example/MusicPlayer1</literal>
1630           which implements the interface
1631           <literal>com.example.MusicPlayer1</literal>.
1632         </para>
1633       </sect3>
1634       <sect3 id="message-protocol-names-member">
1635         <title>Member names</title>
1636         <para>
1637           Member (i.e. method or signal) names:
1638           <itemizedlist>
1639             <listitem><para>Must only contain the ASCII characters
1640                 "[A-Z][a-z][0-9]_" and may not begin with a
1641                 digit.</para></listitem>
1642             <listitem><para>Must not contain the '.' (period) character.</para></listitem>
1643             <listitem><para>Must not exceed the maximum name length.</para></listitem>
1644             <listitem><para>Must be at least 1 byte in length.</para></listitem>
1645           </itemizedlist>
1646         </para>
1647
1648         <para>
1649           It is conventional for member names on D-Bus to consist of
1650           capitalized words with no punctuation ("camel-case").
1651           Method names should usually be verbs, such as
1652           <literal>GetItems</literal>, and signal names should usually be
1653           a description of an event, such as <literal>ItemsChanged</literal>.
1654         </para>
1655       </sect3>
1656       <sect3 id="message-protocol-names-error">
1657         <title>Error names</title>
1658         <para>
1659           Error names have the same restrictions as interface names.
1660         </para>
1661
1662         <para>
1663           Error names have the same naming conventions as interface
1664           names, and often contain <literal>.Error.</literal>; for instance,
1665           the owner of <literal>example.com</literal> might define the
1666           errors <literal>com.example.MusicPlayer.Error.FileNotFound</literal>
1667           and <literal>com.example.MusicPlayer.Error.OutOfMemory</literal>.
1668           The errors defined by D-Bus itself, such as
1669           <literal>org.freedesktop.DBus.Error.Failed</literal>, follow a
1670           similar pattern.
1671         </para>
1672       </sect3>
1673     </sect2>
1674
1675     <sect2 id="message-protocol-types">
1676       <title>Message Types</title>
1677       <para>
1678         Each of the message types (<literal>METHOD_CALL</literal>, <literal>METHOD_RETURN</literal>, <literal>ERROR</literal>, and
1679         <literal>SIGNAL</literal>) has its own expected usage conventions and header fields.
1680         This section describes these conventions.
1681       </para>
1682       <sect3 id="message-protocol-types-method">
1683         <title>Method Calls</title>
1684         <para>
1685           Some messages invoke an operation on a remote object.  These are
1686           called method call messages and have the type tag <literal>METHOD_CALL</literal>. Such
1687           messages map naturally to methods on objects in a typical program.
1688         </para>
1689         <para>
1690           A method call message is required to have a <literal>MEMBER</literal> header field
1691           indicating the name of the method. Optionally, the message has an
1692           <literal>INTERFACE</literal> field giving the interface the method is a part of.
1693           Including the <literal>INTERFACE</literal> in all method call
1694           messages is strongly recommended.
1695         </para>
1696         <para>
1697           In the absence of an <literal>INTERFACE</literal> field, if two
1698           or more interfaces on the same object have a method with the same
1699           name, it is undefined which of those methods will be invoked.
1700           Implementations may choose to either return an error, or deliver the
1701           message as though it had an arbitrary one of those interfaces.
1702         </para>
1703         <para>
1704           In some situations (such as the well-known system bus), messages
1705           are filtered through an access-control list external to the
1706           remote object implementation. If that filter rejects certain
1707           messages by matching their interface, or accepts only messages
1708           to specific interfaces, it must also reject messages that have no
1709           <literal>INTERFACE</literal>: otherwise, malicious
1710           applications could use this to bypass the filter.
1711         </para>
1712         <para>
1713           Method call messages also include a <literal>PATH</literal> field
1714           indicating the object to invoke the method on. If the call is passing
1715           through a message bus, the message will also have a
1716           <literal>DESTINATION</literal> field giving the name of the connection
1717           to receive the message.
1718         </para>
1719         <para>
1720           When an application handles a method call message, it is required to
1721           return a reply. The reply is identified by a <literal>REPLY_SERIAL</literal> header field
1722           indicating the serial number of the <literal>METHOD_CALL</literal> being replied to. The
1723           reply can have one of two types; either <literal>METHOD_RETURN</literal> or <literal>ERROR</literal>.
1724         </para>
1725         <para>
1726           If the reply has type <literal>METHOD_RETURN</literal>, the arguments to the reply message 
1727           are the return value(s) or "out parameters" of the method call. 
1728           If the reply has type <literal>ERROR</literal>, then an "exception" has been thrown, 
1729           and the call fails; no return value will be provided. It makes 
1730           no sense to send multiple replies to the same method call.
1731         </para>
1732         <para>
1733           Even if a method call has no return values, a <literal>METHOD_RETURN</literal> 
1734           reply is required, so the caller will know the method 
1735           was successfully processed.
1736         </para>
1737         <para>
1738           The <literal>METHOD_RETURN</literal> or <literal>ERROR</literal> reply message must have the <literal>REPLY_SERIAL</literal> 
1739           header field.
1740         </para>
1741         <para>
1742           If a <literal>METHOD_CALL</literal> message has the flag <literal>NO_REPLY_EXPECTED</literal>, 
1743           then as an optimization the application receiving the method 
1744           call may choose to omit the reply message (regardless of 
1745           whether the reply would have been <literal>METHOD_RETURN</literal> or <literal>ERROR</literal>). 
1746           However, it is also acceptable to ignore the <literal>NO_REPLY_EXPECTED</literal>
1747           flag and reply anyway.
1748         </para>
1749         <para>
1750           Unless a message has the flag <literal>NO_AUTO_START</literal>, if the
1751           destination name does not exist then a program to own the destination
1752           name will be started before the message is delivered.  The message
1753           will be held until the new program is successfully started or has
1754           failed to start; in case of failure, an error will be returned. This
1755           flag is only relevant in the context of a message bus, it is ignored
1756           during one-to-one communication with no intermediate bus.
1757         </para>
1758         <sect4 id="message-protocol-types-method-apis">
1759           <title>Mapping method calls to native APIs</title>
1760           <para>
1761             APIs for D-Bus may map method calls to a method call in a specific
1762             programming language, such as C++, or may map a method call written
1763             in an IDL to a D-Bus message.
1764           </para>
1765           <para>
1766             In APIs of this nature, arguments to a method are often termed "in"
1767             (which implies sent in the <literal>METHOD_CALL</literal>), or "out" (which implies
1768             returned in the <literal>METHOD_RETURN</literal>). Some APIs such as CORBA also have
1769             "inout" arguments, which are both sent and received, i.e. the caller
1770             passes in a value which is modified. Mapped to D-Bus, an "inout"
1771             argument is equivalent to an "in" argument, followed by an "out"
1772             argument. You can't pass things "by reference" over the wire, so
1773             "inout" is purely an illusion of the in-process API.
1774           </para>
1775           <para>
1776             Given a method with zero or one return values, followed by zero or more
1777             arguments, where each argument may be "in", "out", or "inout", the
1778             caller constructs a message by appending each "in" or "inout" argument,
1779             in order. "out" arguments are not represented in the caller's message.
1780           </para>
1781           <para>
1782             The recipient constructs a reply by appending first the return value 
1783             if any, then each "out" or "inout" argument, in order. 
1784             "in" arguments are not represented in the reply message.
1785           </para>
1786           <para>
1787             Error replies are normally mapped to exceptions in languages that have
1788             exceptions.
1789           </para>
1790           <para>
1791             In converting from native APIs to D-Bus, it is perhaps nice to 
1792             map D-Bus naming conventions ("FooBar") to native conventions 
1793             such as "fooBar" or "foo_bar" automatically. This is OK 
1794             as long as you can say that the native API is one that 
1795             was specifically written for D-Bus. It makes the most sense
1796             when writing object implementations that will be exported 
1797             over the bus. Object proxies used to invoke remote D-Bus 
1798             objects probably need the ability to call any D-Bus method,
1799             and thus a magic name mapping like this could be a problem.
1800           </para>
1801           <para>
1802             This specification doesn't require anything of native API bindings;
1803             the preceding is only a suggested convention for consistency 
1804             among bindings.
1805           </para>
1806         </sect4>
1807       </sect3>
1808
1809       <sect3 id="message-protocol-types-signal">
1810         <title>Signal Emission</title>
1811         <para>
1812           Unlike method calls, signal emissions have no replies. 
1813           A signal emission is simply a single message of type <literal>SIGNAL</literal>.
1814           It must have three header fields: <literal>PATH</literal> giving the object 
1815           the signal was emitted from, plus <literal>INTERFACE</literal> and <literal>MEMBER</literal> giving
1816           the fully-qualified name of the signal. The <literal>INTERFACE</literal> header is required
1817           for signals, though it is optional for method calls.
1818         </para>
1819       </sect3>
1820
1821       <sect3 id="message-protocol-types-errors">
1822         <title>Errors</title>
1823         <para>
1824           Messages of type <literal>ERROR</literal> are most commonly replies 
1825           to a <literal>METHOD_CALL</literal>, but may be returned in reply 
1826           to any kind of message. The message bus for example
1827           will return an <literal>ERROR</literal> in reply to a signal emission if 
1828           the bus does not have enough memory to send the signal.
1829         </para>
1830         <para>
1831           An <literal>ERROR</literal> may have any arguments, but if the first 
1832           argument is a <literal>STRING</literal>, it must be an error message.
1833           The error message may be logged or shown to the user
1834           in some way.
1835         </para>
1836       </sect3>
1837
1838       <sect3 id="message-protocol-types-notation">
1839         <title>Notation in this document</title>
1840         <para>
1841           This document uses a simple pseudo-IDL to describe particular method 
1842           calls and signals. Here is an example of a method call:
1843           <programlisting>
1844             org.freedesktop.DBus.StartServiceByName (in STRING name, in UINT32 flags,
1845                                                      out UINT32 resultcode)
1846           </programlisting>
1847           This means <literal>INTERFACE</literal> = org.freedesktop.DBus, <literal>MEMBER</literal> = StartServiceByName, 
1848           <literal>METHOD_CALL</literal> arguments are <literal>STRING</literal> and <literal>UINT32</literal>, <literal>METHOD_RETURN</literal> argument
1849           is <literal>UINT32</literal>. Remember that the <literal>MEMBER</literal> field can't contain any '.' (period)
1850           characters so it's known that the last part of the name in
1851           the "IDL" is the member name.
1852         </para>
1853         <para>
1854           In C++ that might end up looking like this:
1855           <programlisting>
1856             unsigned int org::freedesktop::DBus::StartServiceByName (const char  *name,
1857                                                                      unsigned int flags);
1858           </programlisting>
1859           or equally valid, the return value could be done as an argument:
1860           <programlisting>
1861             void org::freedesktop::DBus::StartServiceByName (const char   *name, 
1862                                                              unsigned int  flags,
1863                                                              unsigned int *resultcode);
1864           </programlisting>
1865           It's really up to the API designer how they want to make 
1866           this look. You could design an API where the namespace wasn't used 
1867           in C++, using STL or Qt, using varargs, or whatever you wanted.
1868         </para>
1869         <para>
1870           Signals are written as follows:
1871           <programlisting>
1872             org.freedesktop.DBus.NameLost (STRING name)
1873           </programlisting>
1874           Signals don't specify "in" vs. "out" because only 
1875           a single direction is possible.
1876         </para>
1877         <para>
1878           It isn't especially encouraged to use this lame pseudo-IDL in actual
1879           API implementations; you might use the native notation for the
1880           language you're using, or you might use COM or CORBA IDL, for example.
1881         </para>
1882       </sect3>
1883     </sect2>
1884
1885     <sect2 id="message-protocol-handling-invalid">
1886       <title>Invalid Protocol and Spec Extensions</title>
1887       
1888       <para>
1889         For security reasons, the D-Bus protocol should be strictly parsed and
1890         validated, with the exception of defined extension points. Any invalid
1891         protocol or spec violations should result in immediately dropping the
1892         connection without notice to the other end. Exceptions should be
1893         carefully considered, e.g. an exception may be warranted for a
1894         well-understood idiosyncrasy of a widely-deployed implementation.  In
1895         cases where the other end of a connection is 100% trusted and known to
1896         be friendly, skipping validation for performance reasons could also make
1897         sense in certain cases.
1898       </para>
1899
1900       <para>
1901         Generally speaking violations of the "must" requirements in this spec 
1902         should be considered possible attempts to exploit security, and violations 
1903         of the "should" suggestions should be considered legitimate (though perhaps
1904         they should generate an error in some cases).
1905       </para>
1906
1907       <para>
1908         The following extension points are built in to D-Bus on purpose and must
1909         not be treated as invalid protocol. The extension points are intended
1910         for use by future versions of this spec, they are not intended for third
1911         parties.  At the moment, the only way a third party could extend D-Bus
1912         without breaking interoperability would be to introduce a way to negotiate new
1913         feature support as part of the auth protocol, using EXTENSION_-prefixed
1914         commands. There is not yet a standard way to negotiate features.
1915         <itemizedlist>
1916           <listitem>
1917             <para>
1918               In the authentication protocol (see <xref linkend="auth-protocol"/>) unknown 
1919                 commands result in an ERROR rather than a disconnect. This enables 
1920                 future extensions to the protocol. Commands starting with EXTENSION_ are 
1921                 reserved for third parties.
1922             </para>
1923           </listitem>
1924           <listitem>
1925             <para>
1926               The authentication protocol supports pluggable auth mechanisms.
1927             </para>
1928           </listitem>
1929           <listitem>
1930             <para>
1931               The address format (see <xref linkend="addresses"/>) supports new
1932               kinds of transport.
1933             </para>
1934           </listitem>
1935           <listitem>
1936             <para>
1937               Messages with an unknown type (something other than
1938               <literal>METHOD_CALL</literal>, <literal>METHOD_RETURN</literal>,
1939               <literal>ERROR</literal>, <literal>SIGNAL</literal>) are ignored. 
1940               Unknown-type messages must still be well-formed in the same way 
1941               as the known messages, however. They still have the normal 
1942               header and body.
1943             </para>
1944           </listitem>
1945           <listitem>
1946             <para>
1947               Header fields with an unknown or unexpected field code must be ignored, 
1948               though again they must still be well-formed.
1949             </para>
1950           </listitem>
1951           <listitem>
1952             <para>
1953               New standard interfaces (with new methods and signals) can of course be added.
1954             </para>
1955           </listitem>
1956         </itemizedlist>
1957       </para>
1958
1959     </sect2>
1960
1961   </sect1>
1962
1963   <sect1 id="auth-protocol">
1964     <title>Authentication Protocol</title>
1965     <para>
1966       Before the flow of messages begins, two applications must
1967       authenticate. A simple plain-text protocol is used for
1968       authentication; this protocol is a SASL profile, and maps fairly
1969       directly from the SASL specification. The message encoding is
1970       NOT used here, only plain text messages.
1971     </para>
1972     <para>
1973       In examples, "C:" and "S:" indicate lines sent by the client and
1974       server respectively.
1975     </para>
1976     <sect2 id="auth-protocol-overview">
1977       <title>Protocol Overview</title>
1978       <para>
1979         The protocol is a line-based protocol, where each line ends with
1980         \r\n. Each line begins with an all-caps ASCII command name containing
1981         only the character range [A-Z_], a space, then any arguments for the
1982         command, then the \r\n ending the line. The protocol is
1983         case-sensitive. All bytes must be in the ASCII character set.
1984
1985         Commands from the client to the server are as follows:
1986
1987         <itemizedlist>
1988           <listitem><para>AUTH [mechanism] [initial-response]</para></listitem>
1989           <listitem><para>CANCEL</para></listitem>
1990           <listitem><para>BEGIN</para></listitem>
1991           <listitem><para>DATA &lt;data in hex encoding&gt;</para></listitem>
1992           <listitem><para>ERROR [human-readable error explanation]</para></listitem>
1993           <listitem><para>NEGOTIATE_UNIX_FD</para></listitem>
1994         </itemizedlist>
1995
1996         From server to client are as follows:
1997
1998         <itemizedlist>
1999           <listitem><para>REJECTED &lt;space-separated list of mechanism names&gt;</para></listitem>
2000           <listitem><para>OK &lt;GUID in hex&gt;</para></listitem>
2001           <listitem><para>DATA &lt;data in hex encoding&gt;</para></listitem>
2002           <listitem><para>ERROR</para></listitem>
2003           <listitem><para>AGREE_UNIX_FD</para></listitem>
2004         </itemizedlist>
2005       </para>
2006       <para>
2007         Unofficial extensions to the command set must begin with the letters 
2008         "EXTENSION_", to avoid conflicts with future official commands.
2009         For example, "EXTENSION_COM_MYDOMAIN_DO_STUFF".
2010       </para>
2011     </sect2>
2012     <sect2 id="auth-nul-byte">
2013       <title>Special credentials-passing nul byte</title>
2014       <para>
2015         Immediately after connecting to the server, the client must send a
2016         single nul byte. This byte may be accompanied by credentials
2017         information on some operating systems that use sendmsg() with
2018         SCM_CREDS or SCM_CREDENTIALS to pass credentials over UNIX domain
2019         sockets. However, the nul byte must be sent even on other kinds of
2020         socket, and even on operating systems that do not require a byte to be
2021         sent in order to transmit credentials. The text protocol described in
2022         this document begins after the single nul byte. If the first byte
2023         received from the client is not a nul byte, the server may disconnect 
2024         that client.
2025       </para>
2026       <para>
2027         A nul byte in any context other than the initial byte is an error; 
2028         the protocol is ASCII-only.
2029       </para>
2030       <para>
2031         The credentials sent along with the nul byte may be used with the 
2032         SASL mechanism EXTERNAL.
2033       </para>
2034     </sect2>
2035     <sect2 id="auth-command-auth">
2036       <title>AUTH command</title>
2037       <para>
2038         If an AUTH command has no arguments, it is a request to list
2039         available mechanisms. The server must respond with a REJECTED
2040         command listing the mechanisms it understands, or with an error.
2041       </para>
2042       <para>
2043         If an AUTH command specifies a mechanism, and the server supports
2044         said mechanism, the server should begin exchanging SASL
2045         challenge-response data with the client using DATA commands.
2046       </para>
2047       <para>
2048         If the server does not support the mechanism given in the AUTH
2049         command, it must send either a REJECTED command listing the mechanisms
2050         it does support, or an error.
2051       </para>
2052       <para>
2053         If the [initial-response] argument is provided, it is intended for use
2054         with mechanisms that have no initial challenge (or an empty initial
2055         challenge), as if it were the argument to an initial DATA command. If
2056         the selected mechanism has an initial challenge and [initial-response]
2057         was provided, the server should reject authentication by sending
2058         REJECTED.
2059       </para>
2060       <para>
2061         If authentication succeeds after exchanging DATA commands, 
2062         an OK command must be sent to the client.
2063       </para>
2064       <para>
2065         The first octet received by the server after the \r\n of the BEGIN
2066         command from the client must be the first octet of the
2067         authenticated/encrypted stream of D-Bus messages.
2068       </para>
2069       <para>
2070         If BEGIN is received by the server, the first octet received
2071         by the client after the \r\n of the OK command must be the
2072         first octet of the authenticated/encrypted stream of D-Bus
2073         messages.
2074       </para>
2075     </sect2>
2076     <sect2 id="auth-command-cancel">
2077       <title>CANCEL Command</title>
2078       <para>
2079         At any time up to sending the BEGIN command, the client may send a
2080         CANCEL command. On receiving the CANCEL command, the server must
2081         send a REJECTED command and abort the current authentication
2082         exchange.
2083       </para>
2084     </sect2>
2085     <sect2 id="auth-command-data">
2086       <title>DATA Command</title>
2087       <para>
2088         The DATA command may come from either client or server, and simply 
2089         contains a hex-encoded block of data to be interpreted 
2090         according to the SASL mechanism in use.
2091       </para>
2092       <para>
2093         Some SASL mechanisms support sending an "empty string"; 
2094         FIXME we need some way to do this.
2095       </para>
2096     </sect2>
2097     <sect2 id="auth-command-begin">
2098       <title>BEGIN Command</title>
2099       <para>
2100         The BEGIN command acknowledges that the client has received an 
2101         OK command from the server, and that the stream of messages
2102         is about to begin. 
2103       </para>
2104       <para>
2105         The first octet received by the server after the \r\n of the BEGIN
2106         command from the client must be the first octet of the
2107         authenticated/encrypted stream of D-Bus messages.
2108       </para>
2109     </sect2>
2110     <sect2 id="auth-command-rejected">
2111       <title>REJECTED Command</title>
2112       <para>
2113         The REJECTED command indicates that the current authentication
2114         exchange has failed, and further exchange of DATA is inappropriate.
2115         The client would normally try another mechanism, or try providing
2116         different responses to challenges.
2117       </para><para>
2118         Optionally, the REJECTED command has a space-separated list of
2119         available auth mechanisms as arguments. If a server ever provides
2120         a list of supported mechanisms, it must provide the same list 
2121         each time it sends a REJECTED message. Clients are free to 
2122         ignore all lists received after the first.
2123       </para>
2124     </sect2>
2125     <sect2 id="auth-command-ok">
2126       <title>OK Command</title>
2127       <para>
2128         The OK command indicates that the client has been
2129         authenticated. The client may now proceed with negotiating
2130         Unix file descriptor passing. To do that it shall send
2131         NEGOTIATE_UNIX_FD to the server.
2132       </para>
2133       <para>
2134         Otherwise, the client must respond to the OK command by
2135         sending a BEGIN command, followed by its stream of messages,
2136         or by disconnecting.  The server must not accept additional
2137         commands using this protocol after the BEGIN command has been
2138         received. Further communication will be a stream of D-Bus
2139         messages (optionally encrypted, as negotiated) rather than
2140         this protocol.
2141       </para>
2142       <para>
2143         If a client sends BEGIN the first octet received by the client
2144         after the \r\n of the OK command must be the first octet of
2145         the authenticated/encrypted stream of D-Bus messages.
2146       </para>
2147       <para>
2148         The OK command has one argument, which is the GUID of the server.
2149         See <xref linkend="addresses"/> for more on server GUIDs.
2150       </para>
2151     </sect2>
2152     <sect2 id="auth-command-error">
2153       <title>ERROR Command</title>
2154       <para>
2155         The ERROR command indicates that either server or client did not
2156         know a command, does not accept the given command in the current
2157         context, or did not understand the arguments to the command. This
2158         allows the protocol to be extended; a client or server can send a
2159         command present or permitted only in new protocol versions, and if
2160         an ERROR is received instead of an appropriate response, fall back
2161         to using some other technique.
2162       </para>
2163       <para>
2164         If an ERROR is sent, the server or client that sent the
2165         error must continue as if the command causing the ERROR had never been
2166         received. However, the the server or client receiving the error 
2167         should try something other than whatever caused the error; 
2168         if only canceling/rejecting the authentication.
2169       </para>
2170       <para>
2171         If the D-Bus protocol changes incompatibly at some future time,
2172         applications implementing the new protocol would probably be able to
2173         check for support of the new protocol by sending a new command and
2174         receiving an ERROR from applications that don't understand it. Thus the
2175         ERROR feature of the auth protocol is an escape hatch that lets us
2176         negotiate extensions or changes to the D-Bus protocol in the future.
2177       </para>
2178     </sect2>
2179     <sect2 id="auth-command-negotiate-unix-fd">
2180       <title>NEGOTIATE_UNIX_FD Command</title>
2181       <para>
2182         The NEGOTIATE_UNIX_FD command indicates that the client
2183         supports Unix file descriptor passing. This command may only
2184         be sent after the connection is authenticated, i.e. after OK
2185         was received by the client. This command may only be sent on
2186         transports that support Unix file descriptor passing.
2187       </para>
2188       <para>
2189         On receiving NEGOTIATE_UNIX_FD the server must respond with
2190         either AGREE_UNIX_FD or ERROR. It shall respond the former if
2191         the transport chosen supports Unix file descriptor passing and
2192         the server supports this feature. It shall respond the latter
2193         if the transport does not support Unix file descriptor
2194         passing, the server does not support this feature, or the
2195         server decides not to enable file descriptor passing due to
2196         security or other reasons.
2197       </para>
2198     </sect2>
2199     <sect2 id="auth-command-agree-unix-fd">
2200       <title>AGREE_UNIX_FD Command</title>
2201       <para>
2202         The AGREE_UNIX_FD command indicates that the server supports
2203         Unix file descriptor passing. This command may only be sent
2204         after the connection is authenticated, and the client sent
2205         NEGOTIATE_UNIX_FD to enable Unix file descriptor passing. This
2206         command may only be sent on transports that support Unix file
2207         descriptor passing.
2208       </para>
2209       <para>
2210         On receiving AGREE_UNIX_FD the client must respond with BEGIN,
2211         followed by its stream of messages, or by disconnecting.  The
2212         server must not accept additional commands using this protocol
2213         after the BEGIN command has been received. Further
2214         communication will be a stream of D-Bus messages (optionally
2215         encrypted, as negotiated) rather than this protocol.
2216       </para>
2217     </sect2>
2218     <sect2 id="auth-command-future">
2219       <title>Future Extensions</title>
2220       <para>
2221         Future extensions to the authentication and negotiation
2222         protocol are possible. For that new commands may be
2223         introduced. If a client or server receives an unknown command
2224         it shall respond with ERROR and not consider this fatal. New
2225         commands may be introduced both before, and after
2226         authentication, i.e. both before and after the OK command.
2227       </para>
2228     </sect2>
2229     <sect2 id="auth-examples">
2230       <title>Authentication examples</title>
2231       
2232       <para>
2233         <figure>
2234           <title>Example of successful magic cookie authentication</title>
2235           <programlisting>
2236             (MAGIC_COOKIE is a made up mechanism)
2237
2238             C: AUTH MAGIC_COOKIE 3138363935333137393635383634
2239             S: OK 1234deadbeef
2240             C: BEGIN
2241           </programlisting>
2242         </figure>
2243         <figure>
2244           <title>Example of finding out mechanisms then picking one</title>
2245           <programlisting>
2246             C: AUTH
2247             S: REJECTED KERBEROS_V4 SKEY
2248             C: AUTH SKEY 7ab83f32ee
2249             S: DATA 8799cabb2ea93e
2250             C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
2251             S: OK 1234deadbeef
2252             C: BEGIN
2253           </programlisting>
2254         </figure>
2255         <figure>
2256           <title>Example of client sends unknown command then falls back to regular auth</title>
2257           <programlisting>
2258             C: FOOBAR
2259             S: ERROR
2260             C: AUTH MAGIC_COOKIE 3736343435313230333039
2261             S: OK 1234deadbeef
2262             C: BEGIN
2263           </programlisting>
2264         </figure>
2265         <figure>
2266           <title>Example of server doesn't support initial auth mechanism</title>
2267           <programlisting>
2268             C: AUTH MAGIC_COOKIE 3736343435313230333039
2269             S: REJECTED KERBEROS_V4 SKEY
2270             C: AUTH SKEY 7ab83f32ee
2271             S: DATA 8799cabb2ea93e
2272             C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
2273             S: OK 1234deadbeef
2274             C: BEGIN
2275           </programlisting>
2276         </figure>
2277         <figure>
2278           <title>Example of wrong password or the like followed by successful retry</title>
2279           <programlisting>
2280             C: AUTH MAGIC_COOKIE 3736343435313230333039
2281             S: REJECTED KERBEROS_V4 SKEY
2282             C: AUTH SKEY 7ab83f32ee
2283             S: DATA 8799cabb2ea93e
2284             C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
2285             S: REJECTED
2286             C: AUTH SKEY 7ab83f32ee
2287             S: DATA 8799cabb2ea93e
2288             C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
2289             S: OK 1234deadbeef
2290             C: BEGIN
2291           </programlisting>
2292         </figure>
2293         <figure>
2294           <title>Example of skey cancelled and restarted</title>
2295           <programlisting>
2296             C: AUTH MAGIC_COOKIE 3736343435313230333039
2297             S: REJECTED KERBEROS_V4 SKEY
2298             C: AUTH SKEY 7ab83f32ee
2299             S: DATA 8799cabb2ea93e
2300             C: CANCEL
2301             S: REJECTED
2302             C: AUTH SKEY 7ab83f32ee
2303             S: DATA 8799cabb2ea93e
2304             C: DATA 8ac876e8f68ee9809bfa876e6f9876g8fa8e76e98f
2305             S: OK 1234deadbeef
2306             C: BEGIN
2307           </programlisting>
2308         </figure>
2309         <figure>
2310           <title>Example of successful magic cookie authentication with successful negotiation of Unix FD passing</title>
2311           <programlisting>
2312             (MAGIC_COOKIE is a made up mechanism)
2313
2314             C: AUTH MAGIC_COOKIE 3138363935333137393635383634
2315             S: OK 1234deadbeef
2316             C: NEGOTIATE_UNIX_FD
2317             S: AGREE_UNIX_FD
2318             C: BEGIN
2319           </programlisting>
2320         </figure>
2321         <figure>
2322           <title>Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing</title>
2323           <programlisting>
2324             (MAGIC_COOKIE is a made up mechanism)
2325
2326             C: AUTH MAGIC_COOKIE 3138363935333137393635383634
2327             S: OK 1234deadbeef
2328             C: NEGOTIATE_UNIX_FD
2329             S: ERROR
2330             C: BEGIN
2331           </programlisting>
2332         </figure>
2333       </para>
2334     </sect2>
2335     <sect2 id="auth-states">
2336       <title>Authentication state diagrams</title>
2337       
2338       <para>
2339         This section documents the auth protocol in terms of 
2340         a state machine for the client and the server. This is 
2341         probably the most robust way to implement the protocol.
2342       </para>
2343
2344       <sect3 id="auth-states-client">
2345         <title>Client states</title>
2346         
2347         <para>
2348           To more precisely describe the interaction between the
2349           protocol state machine and the authentication mechanisms the
2350           following notation is used: MECH(CHALL) means that the
2351           server challenge CHALL was fed to the mechanism MECH, which
2352           returns one of
2353
2354           <itemizedlist>
2355             <listitem>
2356               <para>
2357                 CONTINUE(RESP) means continue the auth conversation
2358                 and send RESP as the response to the server;
2359               </para>
2360             </listitem>
2361
2362             <listitem>
2363               <para>
2364                 OK(RESP) means that after sending RESP to the server
2365                 the client side of the auth conversation is finished
2366                 and the server should return "OK";
2367               </para>
2368             </listitem>
2369
2370             <listitem>
2371               <para>
2372                 ERROR means that CHALL was invalid and could not be
2373                 processed.
2374               </para>
2375             </listitem>
2376           </itemizedlist>
2377           
2378           Both RESP and CHALL may be empty.
2379         </para>
2380         
2381         <para>
2382           The Client starts by getting an initial response from the
2383           default mechanism and sends AUTH MECH RESP, or AUTH MECH if
2384           the mechanism did not provide an initial response.  If the
2385           mechanism returns CONTINUE, the client starts in state
2386           <emphasis>WaitingForData</emphasis>, if the mechanism
2387           returns OK the client starts in state
2388           <emphasis>WaitingForOK</emphasis>.
2389         </para>
2390         
2391         <para>
2392           The client should keep track of available mechanisms and
2393           which it mechanisms it has already attempted. This list is
2394           used to decide which AUTH command to send. When the list is
2395           exhausted, the client should give up and close the
2396           connection.
2397         </para>
2398
2399         <formalpara>
2400           <title><emphasis>WaitingForData</emphasis></title>
2401           <para>
2402             <itemizedlist>
2403               <listitem>
2404                 <para>
2405                   Receive DATA CHALL
2406                   <simplelist>
2407                     <member>
2408                       MECH(CHALL) returns CONTINUE(RESP) &rarr; send
2409                       DATA RESP, goto
2410                       <emphasis>WaitingForData</emphasis>
2411                     </member>
2412
2413                     <member>
2414                       MECH(CHALL) returns OK(RESP) &rarr; send DATA
2415                       RESP, goto <emphasis>WaitingForOK</emphasis>
2416                     </member>
2417
2418                     <member>
2419                       MECH(CHALL) returns ERROR &rarr; send ERROR
2420                       [msg], goto <emphasis>WaitingForData</emphasis>
2421                     </member>
2422                   </simplelist>
2423                 </para>
2424               </listitem>
2425
2426               <listitem>
2427                 <para>
2428                   Receive REJECTED [mechs] &rarr;
2429                   send AUTH [next mech], goto
2430                   WaitingForData or <emphasis>WaitingForOK</emphasis>
2431                 </para>
2432               </listitem>
2433               <listitem>
2434                 <para>
2435                   Receive ERROR &rarr; send
2436                   CANCEL, goto
2437                   <emphasis>WaitingForReject</emphasis>
2438                 </para>
2439               </listitem>
2440               <listitem>
2441                 <para>
2442                   Receive OK &rarr; send
2443                   BEGIN, terminate auth
2444                   conversation, authenticated
2445                 </para>
2446               </listitem>
2447               <listitem>
2448                 <para>
2449                   Receive anything else &rarr; send
2450                   ERROR, goto
2451                   <emphasis>WaitingForData</emphasis>
2452                 </para>
2453               </listitem>
2454             </itemizedlist>
2455           </para>
2456         </formalpara>
2457
2458         <formalpara>
2459           <title><emphasis>WaitingForOK</emphasis></title>
2460           <para>
2461             <itemizedlist>
2462               <listitem>
2463                 <para>
2464                   Receive OK &rarr; send BEGIN, terminate auth
2465                   conversation, <emphasis>authenticated</emphasis>
2466                 </para>
2467               </listitem>
2468               <listitem>
2469                 <para>
2470                   Receive REJECTED [mechs] &rarr; send AUTH [next mech],
2471                   goto <emphasis>WaitingForData</emphasis> or
2472                   <emphasis>WaitingForOK</emphasis>
2473                 </para>
2474               </listitem>
2475
2476               <listitem>
2477                 <para>
2478                   Receive DATA &rarr; send CANCEL, goto
2479                   <emphasis>WaitingForReject</emphasis>
2480                 </para>
2481               </listitem>
2482
2483               <listitem>
2484                 <para>
2485                   Receive ERROR &rarr; send CANCEL, goto
2486                   <emphasis>WaitingForReject</emphasis>
2487                 </para>
2488               </listitem>
2489
2490               <listitem>
2491                 <para>
2492                   Receive anything else &rarr; send ERROR, goto
2493                   <emphasis>WaitingForOK</emphasis>
2494                 </para>
2495               </listitem>
2496             </itemizedlist>
2497           </para>
2498         </formalpara>
2499
2500         <formalpara>
2501           <title><emphasis>WaitingForReject</emphasis></title>
2502           <para>
2503             <itemizedlist>
2504               <listitem>
2505                 <para>
2506                   Receive REJECTED [mechs] &rarr; send AUTH [next mech],
2507                   goto <emphasis>WaitingForData</emphasis> or
2508                   <emphasis>WaitingForOK</emphasis>
2509                 </para>
2510               </listitem>
2511
2512               <listitem>
2513                 <para>
2514                   Receive anything else &rarr; terminate auth
2515                   conversation, disconnect
2516                 </para>
2517               </listitem>
2518             </itemizedlist>
2519           </para>
2520         </formalpara>
2521
2522       </sect3>
2523
2524       <sect3 id="auth-states-server">
2525         <title>Server states</title>
2526  
2527         <para>
2528           For the server MECH(RESP) means that the client response
2529           RESP was fed to the the mechanism MECH, which returns one of
2530
2531           <itemizedlist>
2532             <listitem>
2533               <para>
2534                 CONTINUE(CHALL) means continue the auth conversation and
2535                 send CHALL as the challenge to the client;
2536               </para>
2537             </listitem>
2538
2539             <listitem>
2540               <para>
2541                 OK means that the client has been successfully
2542                 authenticated;
2543               </para>
2544             </listitem>
2545
2546             <listitem>
2547               <para>
2548                 REJECTED means that the client failed to authenticate or
2549                 there was an error in RESP.
2550               </para>
2551             </listitem>
2552           </itemizedlist>
2553
2554           The server starts out in state
2555           <emphasis>WaitingForAuth</emphasis>.  If the client is
2556           rejected too many times the server must disconnect the
2557           client.
2558         </para>
2559
2560         <formalpara>
2561           <title><emphasis>WaitingForAuth</emphasis></title>
2562           <para>
2563             <itemizedlist>
2564
2565               <listitem>
2566                 <para>
2567                   Receive AUTH &rarr; send REJECTED [mechs], goto
2568                   <emphasis>WaitingForAuth</emphasis>
2569                 </para>
2570               </listitem>
2571
2572               <listitem>
2573                 <para>
2574                   Receive AUTH MECH RESP
2575
2576                   <simplelist>
2577                     <member>
2578                       MECH not valid mechanism &rarr; send REJECTED
2579                       [mechs], goto
2580                       <emphasis>WaitingForAuth</emphasis>
2581                     </member>
2582
2583                     <member>
2584                       MECH(RESP) returns CONTINUE(CHALL) &rarr; send
2585                       DATA CHALL, goto
2586                       <emphasis>WaitingForData</emphasis>
2587                     </member>
2588
2589                     <member>
2590                       MECH(RESP) returns OK &rarr; send OK, goto
2591                       <emphasis>WaitingForBegin</emphasis>
2592                     </member>
2593
2594                     <member>
2595                       MECH(RESP) returns REJECTED &rarr; send REJECTED
2596                       [mechs], goto
2597                       <emphasis>WaitingForAuth</emphasis>
2598                     </member>
2599                   </simplelist>
2600                 </para>
2601               </listitem>
2602
2603               <listitem>
2604                 <para>
2605                   Receive BEGIN &rarr; terminate
2606                   auth conversation, disconnect
2607                 </para>
2608               </listitem>
2609
2610               <listitem>
2611                 <para>
2612                   Receive ERROR &rarr; send REJECTED [mechs], goto
2613                   <emphasis>WaitingForAuth</emphasis>
2614                 </para>
2615               </listitem>
2616
2617               <listitem>
2618                 <para>
2619                   Receive anything else &rarr; send
2620                   ERROR, goto
2621                   <emphasis>WaitingForAuth</emphasis>
2622                 </para>
2623               </listitem>
2624             </itemizedlist>
2625           </para>
2626         </formalpara>
2627
2628        
2629         <formalpara>
2630           <title><emphasis>WaitingForData</emphasis></title>
2631           <para>
2632             <itemizedlist>
2633               <listitem>
2634                 <para>
2635                   Receive DATA RESP
2636                   <simplelist>
2637                     <member>
2638                       MECH(RESP) returns CONTINUE(CHALL) &rarr; send
2639                       DATA CHALL, goto
2640                       <emphasis>WaitingForData</emphasis>
2641                     </member>
2642
2643                     <member>
2644                       MECH(RESP) returns OK &rarr; send OK, goto
2645                       <emphasis>WaitingForBegin</emphasis>
2646                     </member>
2647
2648                     <member>
2649                       MECH(RESP) returns REJECTED &rarr; send REJECTED
2650                       [mechs], goto
2651                       <emphasis>WaitingForAuth</emphasis>
2652                     </member>
2653                   </simplelist>
2654                 </para>
2655               </listitem>
2656
2657               <listitem>
2658                 <para>
2659                   Receive BEGIN &rarr; terminate auth conversation,
2660                   disconnect
2661                 </para>
2662               </listitem>
2663
2664               <listitem>
2665                 <para>
2666                   Receive CANCEL &rarr; send REJECTED [mechs], goto
2667                   <emphasis>WaitingForAuth</emphasis>
2668                 </para>
2669               </listitem>
2670
2671               <listitem>
2672                 <para>
2673                   Receive ERROR &rarr; send REJECTED [mechs], goto
2674                   <emphasis>WaitingForAuth</emphasis>
2675                 </para>
2676               </listitem>
2677
2678               <listitem>
2679                 <para>
2680                   Receive anything else &rarr; send ERROR, goto
2681                   <emphasis>WaitingForData</emphasis>
2682                 </para>
2683               </listitem>
2684             </itemizedlist>
2685           </para>
2686         </formalpara>
2687
2688         <formalpara>
2689           <title><emphasis>WaitingForBegin</emphasis></title>
2690           <para>
2691             <itemizedlist>
2692               <listitem>
2693                 <para>
2694                   Receive BEGIN &rarr; terminate auth conversation,
2695                   client authenticated
2696                 </para>
2697               </listitem>
2698
2699               <listitem>
2700                 <para>
2701                   Receive CANCEL &rarr; send REJECTED [mechs], goto
2702                   <emphasis>WaitingForAuth</emphasis>
2703                 </para>
2704               </listitem>
2705
2706               <listitem>
2707                 <para>
2708                   Receive ERROR &rarr; send REJECTED [mechs], goto
2709                   <emphasis>WaitingForAuth</emphasis>
2710                 </para>
2711               </listitem>
2712
2713               <listitem>
2714                 <para>
2715                   Receive anything else &rarr; send ERROR, goto
2716                   <emphasis>WaitingForBegin</emphasis>
2717                 </para>
2718               </listitem>
2719             </itemizedlist>
2720           </para>
2721         </formalpara>
2722
2723       </sect3>
2724       
2725     </sect2>
2726     <sect2 id="auth-mechanisms">
2727       <title>Authentication mechanisms</title>
2728       <para>
2729         This section describes some new authentication mechanisms.
2730         D-Bus also allows any standard SASL mechanism of course.
2731       </para>
2732       <sect3 id="auth-mechanisms-sha">
2733         <title>DBUS_COOKIE_SHA1</title>
2734         <para>
2735           The DBUS_COOKIE_SHA1 mechanism is designed to establish that a client
2736           has the ability to read a private file owned by the user being
2737           authenticated. If the client can prove that it has access to a secret
2738           cookie stored in this file, then the client is authenticated. 
2739           Thus the security of DBUS_COOKIE_SHA1 depends on a secure home 
2740           directory.
2741         </para>
2742         <para>
2743           Throughout this description, "hex encoding" must output the digits
2744           from a to f in lower-case; the digits A to F must not be used
2745           in the DBUS_COOKIE_SHA1 mechanism.
2746         </para>
2747         <para>
2748           Authentication proceeds as follows:
2749           <itemizedlist>
2750             <listitem>
2751               <para>
2752                 The client sends the username it would like to authenticate 
2753                 as, hex-encoded.
2754               </para>
2755             </listitem>
2756             <listitem>
2757               <para>
2758                 The server sends the name of its "cookie context" (see below); a
2759                 space character; the integer ID of the secret cookie the client
2760                 must demonstrate knowledge of; a space character; then a
2761                 randomly-generated challenge string, all of this hex-encoded into
2762                 one, single string.
2763               </para>
2764             </listitem>
2765             <listitem>
2766               <para>
2767                 The client locates the cookie and generates its own
2768                 randomly-generated challenge string. The client then concatenates
2769                 the server's decoded challenge, a ":" character, its own challenge,
2770                 another ":" character, and the cookie. It computes the SHA-1 hash
2771                 of this composite string as a hex digest. It concatenates the
2772                 client's challenge string, a space character, and the SHA-1 hex
2773                 digest, hex-encodes the result and sends it back to the server.
2774               </para>
2775             </listitem>
2776             <listitem>
2777               <para>
2778                 The server generates the same concatenated string used by the
2779                 client and computes its SHA-1 hash. It compares the hash with
2780                 the hash received from the client; if the two hashes match, the
2781                 client is authenticated.
2782               </para>
2783             </listitem>
2784           </itemizedlist>
2785         </para>
2786         <para>
2787           Each server has a "cookie context," which is a name that identifies a
2788           set of cookies that apply to that server. A sample context might be
2789           "org_freedesktop_session_bus". Context names must be valid ASCII,
2790           nonzero length, and may not contain the characters slash ("/"),
2791           backslash ("\"), space (" "), newline ("\n"), carriage return ("\r"),
2792           tab ("\t"), or period ("."). There is a default context,
2793           "org_freedesktop_general" that's used by servers that do not specify
2794           otherwise.
2795         </para>
2796         <para>
2797           Cookies are stored in a user's home directory, in the directory
2798           <filename>~/.dbus-keyrings/</filename>. This directory must 
2799           not be readable or writable by other users. If it is, 
2800           clients and servers must ignore it. The directory 
2801           contains cookie files named after the cookie context.
2802         </para>
2803         <para>
2804           A cookie file contains one cookie per line. Each line 
2805           has three space-separated fields:
2806           <itemizedlist>
2807             <listitem>
2808               <para>
2809                 The cookie ID number, which must be a non-negative integer and
2810                 may not be used twice in the same file.
2811               </para>
2812             </listitem>
2813             <listitem>
2814               <para>
2815                 The cookie's creation time, in UNIX seconds-since-the-epoch
2816                 format.
2817               </para>
2818             </listitem>
2819             <listitem>
2820               <para>
2821                 The cookie itself, a hex-encoded random block of bytes. The cookie
2822                 may be of any length, though obviously security increases 
2823                 as the length increases.
2824               </para>
2825             </listitem>
2826           </itemizedlist>
2827         </para>
2828         <para>
2829           Only server processes modify the cookie file.
2830           They must do so with this procedure:
2831           <itemizedlist>
2832             <listitem>
2833               <para>
2834                 Create a lockfile name by appending ".lock" to the name of the
2835                 cookie file.  The server should attempt to create this file
2836                 using <literal>O_CREAT | O_EXCL</literal>.  If file creation
2837                 fails, the lock fails. Servers should retry for a reasonable
2838                 period of time, then they may choose to delete an existing lock
2839                 to keep users from having to manually delete a stale
2840                 lock. <footnote><para>Lockfiles are used instead of real file
2841                 locking <literal>fcntl()</literal> because real locking
2842                 implementations are still flaky on network
2843                 filesystems.</para></footnote>
2844               </para>
2845             </listitem>
2846             <listitem>
2847               <para>
2848                 Once the lockfile has been created, the server loads the cookie
2849                 file. It should then delete any cookies that are old (the
2850                 timeout can be fairly short), or more than a reasonable
2851                 time in the future (so that cookies never accidentally 
2852                 become permanent, if the clock was set far into the future 
2853                 at some point). If no recent keys remain, the 
2854                 server may generate a new key.
2855               </para>
2856             </listitem>
2857             <listitem>
2858               <para>
2859                 The pruned and possibly added-to cookie file 
2860                 must be resaved atomically (using a temporary 
2861                 file which is rename()'d).
2862               </para>
2863             </listitem>
2864             <listitem>
2865               <para>
2866                 The lock must be dropped by deleting the lockfile.
2867               </para>
2868             </listitem>
2869           </itemizedlist>
2870         </para>
2871         <para>
2872           Clients need not lock the file in order to load it, 
2873           because servers are required to save the file atomically.          
2874         </para>
2875       </sect3>
2876     </sect2>
2877   </sect1>
2878   <sect1 id="addresses">
2879     <title>Server Addresses</title>
2880     <para>
2881       Server addresses consist of a transport name followed by a colon, and
2882       then an optional, comma-separated list of keys and values in the form key=value.
2883       Each value is escaped.
2884     </para>
2885     <para>
2886       For example: 
2887       <programlisting>unix:path=/tmp/dbus-test</programlisting>
2888       Which is the address to a unix socket with the path /tmp/dbus-test.
2889     </para>
2890     <para>
2891       Value escaping is similar to URI escaping but simpler.
2892       <itemizedlist>
2893         <listitem>
2894           <para>
2895             The set of optionally-escaped bytes is:
2896             <literal>[0-9A-Za-z_-/.\]</literal>. To escape, each
2897             <emphasis>byte</emphasis> (note, not character) which is not in the
2898             set of optionally-escaped bytes must be replaced with an ASCII
2899             percent (<literal>%</literal>) and the value of the byte in hex.
2900             The hex value must always be two digits, even if the first digit is
2901             zero. The optionally-escaped bytes may be escaped if desired.
2902           </para>
2903         </listitem>
2904         <listitem>
2905           <para>
2906             To unescape, append each byte in the value; if a byte is an ASCII
2907             percent (<literal>%</literal>) character then append the following
2908             hex value instead. It is an error if a <literal>%</literal> byte
2909             does not have two hex digits following. It is an error if a
2910             non-optionally-escaped byte is seen unescaped.
2911           </para>
2912         </listitem>
2913       </itemizedlist>
2914       The set of optionally-escaped bytes is intended to preserve address 
2915       readability and convenience.
2916     </para>
2917
2918     <para>
2919       A server may specify a key-value pair with the key <literal>guid</literal>
2920       and the value a hex-encoded 16-byte sequence. <xref linkend="uuids"/>
2921       describes the format of the <literal>guid</literal> field.  If present,
2922       this UUID may be used to distinguish one server address from another. A
2923       server should use a different UUID for each address it listens on. For
2924       example, if a message bus daemon offers both UNIX domain socket and TCP
2925       connections, but treats clients the same regardless of how they connect,
2926       those two connections are equivalent post-connection but should have
2927       distinct UUIDs to distinguish the kinds of connection.
2928     </para>
2929     
2930     <para>
2931       The intent of the address UUID feature is to allow a client to avoid
2932       opening multiple identical connections to the same server, by allowing the
2933       client to check whether an address corresponds to an already-existing
2934       connection.  Comparing two addresses is insufficient, because addresses
2935       can be recycled by distinct servers, and equivalent addresses may look
2936       different if simply compared as strings (for example, the host in a TCP
2937       address can be given as an IP address or as a hostname).
2938     </para>
2939
2940     <para>
2941       Note that the address key is <literal>guid</literal> even though the 
2942       rest of the API and documentation says "UUID," for historical reasons.
2943     </para>
2944
2945     <para>
2946       [FIXME clarify if attempting to connect to each is a requirement 
2947       or just a suggestion]
2948       When connecting to a server, multiple server addresses can be
2949       separated by a semi-colon. The library will then try to connect
2950       to the first address and if that fails, it'll try to connect to
2951       the next one specified, and so forth. For example
2952       <programlisting>unix:path=/tmp/dbus-test;unix:path=/tmp/dbus-test2</programlisting>
2953     </para>
2954
2955     <para>
2956       Some addresses are <firstterm>connectable</firstterm>. A connectable
2957       address is one containing enough information for a client to connect
2958       to it. For instance, <literal>tcp:host=127.0.0.1,port=4242</literal>
2959       is a connectable address. It is not necessarily possible to listen
2960       on every connectable address: for instance, it is not possible to
2961       listen on a <literal>unixexec:</literal> address.
2962     </para>
2963
2964     <para>
2965       Some addresses are <firstterm>listenable</firstterm>. A listenable
2966       address is one containing enough information for a server to listen on
2967       it, producing a connectable address (which may differ from the
2968       original address). Many listenable addresses are not connectable:
2969       for instance, <literal>tcp:host=127.0.0.1</literal>
2970       is listenable, but not connectable (because it does not specify
2971       a port number).
2972     </para>
2973
2974     <para>
2975       Listening on an address that is not connectable will result in a
2976       connectable address that is not the same as the listenable address.
2977       For instance, listening on <literal>tcp:host=127.0.0.1</literal>
2978       might result in the connectable address
2979       <literal>tcp:host=127.0.0.1,port=30958</literal>,
2980       or listening on <literal>unix:tmpdir=/tmp</literal>
2981       might result in the connectable address
2982       <literal>unix:abstract=/tmp/dbus-U8OSdmf7</literal>.
2983     </para>
2984   </sect1>
2985   
2986   <sect1 id="transports">
2987     <title>Transports</title>
2988     <para>
2989       [FIXME we need to specify in detail each transport and its possible arguments]
2990     
2991       Current transports include: unix domain sockets (including 
2992       abstract namespace on linux), launchd, systemd, TCP/IP, an executed subprocess and a debug/testing transport
2993       using in-process pipes. Future possible transports include one that
2994       tunnels over X11 protocol.
2995     </para>
2996   
2997     <sect2 id="transports-unix-domain-sockets">
2998       <title>Unix Domain Sockets</title>
2999       <para>
3000         Unix domain sockets can be either paths in the file system or on Linux 
3001         kernels, they can be abstract which are similar to paths but
3002         do not show up in the file system.
3003       </para>
3004
3005       <para>
3006         When a socket is opened by the D-Bus library it truncates the path 
3007         name right before the first trailing Nul byte.  This is true for both
3008         normal paths and abstract paths.  Note that this is a departure from
3009         previous versions of D-Bus that would create sockets with a fixed
3010         length path name.  Names which were shorter than the fixed length
3011         would be padded by Nul bytes.
3012       </para>
3013       <para>
3014         Unix domain sockets are not available on Windows.
3015       </para>
3016       <para>
3017         Unix addresses that specify <literal>path</literal> or
3018         <literal>abstract</literal> are both listenable and connectable.
3019         Unix addresses that specify <literal>tmpdir</literal> are only
3020         listenable: the corresponding connectable address will specify
3021         either <literal>path</literal> or <literal>abstract</literal>.
3022       </para>
3023       <sect3 id="transports-unix-domain-sockets-addresses">
3024         <title>Server Address Format</title>
3025         <para> 
3026           Unix domain socket addresses are identified by the "unix:" prefix 
3027           and support the following key/value pairs:
3028         </para>
3029         <informaltable>
3030          <tgroup cols="3">
3031           <thead>
3032            <row>
3033             <entry>Name</entry>
3034             <entry>Values</entry>
3035             <entry>Description</entry>
3036            </row>
3037           </thead>
3038           <tbody>
3039            <row>
3040             <entry>path</entry>
3041             <entry>(path)</entry>
3042             <entry>path of the unix domain socket. If set, the "tmpdir" and "abstract" key must not be set.</entry>
3043           </row>
3044           <row>
3045             <entry>tmpdir</entry>
3046             <entry>(path)</entry>
3047             <entry>temporary directory in which a socket file with a random file name starting with 'dbus-' will be created by the server. This key can only be used in server addresses, not in client addresses. If set, the "path" and "abstract" key must not be set.</entry>
3048           </row>
3049           <row>
3050             <entry>abstract</entry>
3051             <entry>(string)</entry>
3052             <entry>unique string (path) in the abstract namespace. If set, the "path" or "tmpdir" key must not be set. This key is only supported on platforms with "abstract Unix sockets", of which Linux is the only known example.</entry>
3053           </row>
3054         </tbody>
3055         </tgroup>
3056        </informaltable>
3057        <para>
3058          Exactly one of the keys <literal>path</literal>,
3059          <literal>abstract</literal> or
3060          <literal>tmpdir</literal> must be provided.
3061        </para>
3062       </sect3>
3063     </sect2>
3064     <sect2 id="transports-launchd">
3065       <title>launchd</title>
3066       <para>
3067         launchd is an open-source server management system that replaces init, inetd
3068         and cron on Apple Mac OS X versions 10.4 and above. It provides a common session
3069         bus address for each user and deprecates the X11-enabled D-Bus launcher on OSX.
3070       </para>
3071
3072       <para>
3073         launchd allocates a socket and provides it with the unix path through the
3074         DBUS_LAUNCHD_SESSION_BUS_SOCKET variable in launchd's environment. Every process
3075         spawned by launchd (or dbus-daemon, if it was started by launchd) can access
3076         it through its environment.
3077         Other processes can query for the launchd socket by executing:
3078         $ launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
3079         This is normally done by the D-Bus client library so doesn't have to be done
3080         manually.
3081       </para>
3082       <para>
3083         launchd is not available on Microsoft Windows.
3084       </para>
3085       <para>
3086         launchd addresses are listenable and connectable.
3087       </para>
3088       <sect3 id="transports-launchd-addresses">
3089         <title>Server Address Format</title>
3090         <para>
3091           launchd addresses are identified by the "launchd:" prefix
3092           and support the following key/value pairs:
3093         </para>
3094         <informaltable>
3095          <tgroup cols="3">
3096           <thead>
3097            <row>
3098             <entry>Name</entry>
3099             <entry>Values</entry>
3100             <entry>Description</entry>
3101            </row>
3102           </thead>
3103           <tbody>
3104            <row>
3105             <entry>env</entry>
3106             <entry>(environment variable)</entry>
3107             <entry>path of the unix domain socket for the launchd created dbus-daemon.</entry>
3108           </row>
3109         </tbody>
3110         </tgroup>
3111        </informaltable>
3112        <para>
3113          The <literal>env</literal> key is required.
3114        </para>
3115       </sect3>
3116     </sect2>
3117     <sect2 id="transports-systemd">
3118       <title>systemd</title>
3119       <para>
3120         systemd is an open-source server management system that
3121         replaces init and inetd on newer Linux systems. It supports
3122         socket activation. The D-Bus systemd transport is used to acquire
3123         socket activation file descriptors from systemd and use them
3124         as D-Bus transport when the current process is spawned by
3125         socket activation from it.
3126       </para>
3127       <para>
3128         The systemd transport accepts only one or more Unix domain or
3129         TCP streams sockets passed in via socket activation.
3130       </para>
3131       <para>
3132         The systemd transport is not available on non-Linux operating systems.
3133       </para>
3134       <para>
3135         The systemd transport defines no parameter keys.
3136       </para>
3137       <para>
3138         systemd addresses are listenable, but not connectable. The
3139         corresponding connectable address is the <literal>unix</literal>
3140         or <literal>tcp</literal> address of the socket.
3141       </para>
3142     </sect2>
3143     <sect2 id="transports-tcp-sockets">
3144       <title>TCP Sockets</title>
3145       <para>
3146         The tcp transport provides TCP/IP based connections between clients
3147         located on the same or different hosts. 
3148       </para>
3149       <para>
3150         Using tcp transport without any additional secure authentification mechanismus 
3151         over a network is unsecure. 
3152       </para>
3153       <para>  
3154         On Windows and most Unix platforms, the TCP stack is unable to transfer
3155         credentials over a TCP connection, so the EXTERNAL authentication
3156         mechanism does not work for this transport.
3157       </para>
3158       <para>
3159         All <literal>tcp</literal> addresses are listenable.
3160         <literal>tcp</literal> addresses in which both
3161         <literal>host</literal> and <literal>port</literal> are
3162         specified, and <literal>port</literal> is non-zero,
3163         are also connectable.
3164       </para>
3165       <sect3 id="transports-tcp-sockets-addresses">
3166         <title>Server Address Format</title>
3167         <para> 
3168          TCP/IP socket addresses are identified by the "tcp:" prefix 
3169          and support the following key/value pairs:
3170         </para>
3171         <informaltable>
3172          <tgroup cols="3">
3173           <thead>
3174            <row>
3175             <entry>Name</entry>
3176             <entry>Values</entry>
3177             <entry>Description</entry>
3178            </row>
3179           </thead>
3180           <tbody>
3181            <row>
3182             <entry>host</entry>
3183             <entry>(string)</entry>
3184             <entry>DNS name or IP address</entry>
3185           </row>
3186           <row>
3187            <entry>bind</entry>
3188            <entry>(string)</entry>
3189            <entry>Used in a listenable address to configure the interface
3190             on which the server will listen: either the IP address of one of
3191             the local machine's interfaces (most commonly <literal>127.0.0.1
3192             </literal>), or a DNS name that resolves to one of those IP
3193             addresses, or '*' to listen on all interfaces simultaneously.
3194             If not specified, the default is the same value as "host".
3195            </entry>
3196           </row>
3197           <row>
3198            <entry>port</entry>
3199            <entry>(number)</entry>
3200            <entry>The tcp port the server will open. A zero value let the server 
3201             choose a free port provided from the underlaying operating system. 
3202             libdbus is able to retrieve the real used port from the server.  
3203            </entry>
3204           </row>
3205           <row>
3206            <entry>family</entry>
3207            <entry>(string)</entry>
3208            <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry>
3209           </row>
3210          </tbody>
3211         </tgroup>
3212        </informaltable>
3213       </sect3>
3214     </sect2>
3215     <sect2 id="transports-nonce-tcp-sockets">
3216       <title>Nonce-secured TCP Sockets</title>
3217       <para>
3218         The nonce-tcp transport provides a secured TCP transport, using a
3219         simple authentication mechanism to ensure that only clients with read
3220         access to a certain location in the filesystem can connect to the server.
3221         The server writes a secret, the nonce, to a file and an incoming client
3222         connection is only accepted if the client sends the nonce right after
3223         the connect. The nonce mechanism requires no setup and is orthogonal to
3224         the higher-level authentication mechanisms described in the
3225         Authentication section.
3226       </para>
3227
3228       <para>
3229         On start, the server generates a random 16 byte nonce and writes it
3230         to a file in the user's temporary directory. The nonce file location
3231         is published as part of the server's D-Bus address using the
3232         "noncefile" key-value pair.
3233
3234         After an accept, the server reads 16 bytes from the socket. If the
3235         read bytes do not match the nonce stored in the nonce file, the
3236         server MUST immediately drop the connection.
3237         If the nonce match the received byte sequence, the client is accepted
3238         and the transport behaves like an unsecured tcp transport.
3239       </para>
3240       <para>
3241         After a successful connect to the server socket, the client MUST read
3242         the nonce from the file published by the server via the noncefile=
3243         key-value pair and send it over the socket. After that, the
3244         transport behaves like an unsecured tcp transport.
3245       </para>
3246       <para>
3247         All nonce-tcp addresses are listenable. nonce-tcp addresses in which
3248         <literal>host</literal>, <literal>port</literal> and
3249         <literal>noncefile</literal> are all specified,
3250         and <literal>port</literal> is nonzero, are also connectable.
3251       </para>
3252       <sect3 id="transports-nonce-tcp-sockets-addresses">
3253         <title>Server Address Format</title>
3254         <para> 
3255          Nonce TCP/IP socket addresses uses the "nonce-tcp:" prefix 
3256          and support the following key/value pairs:
3257         </para>
3258         <informaltable>
3259          <tgroup cols="3">
3260           <thead>
3261            <row>
3262             <entry>Name</entry>
3263             <entry>Values</entry>
3264             <entry>Description</entry>
3265            </row>
3266           </thead>
3267           <tbody>
3268            <row>
3269             <entry>host</entry>
3270             <entry>(string)</entry>
3271             <entry>DNS name or IP address</entry>
3272           </row>
3273           <row>
3274            <entry>bind</entry>
3275            <entry>(string)</entry>
3276            <entry>The same as for tcp: addresses
3277            </entry>
3278           </row>
3279           <row>
3280            <entry>port</entry>
3281            <entry>(number)</entry>
3282            <entry>The tcp port the server will open. A zero value let the server 
3283             choose a free port provided from the underlaying operating system. 
3284             libdbus is able to retrieve the real used port from the server.  
3285            </entry>
3286           </row>
3287           <row>
3288            <entry>family</entry>
3289            <entry>(string)</entry>
3290            <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry>
3291           </row>
3292           <row>
3293            <entry>noncefile</entry>
3294            <entry>(path)</entry>
3295            <entry>File location containing the secret.
3296              This is only meaningful in connectable addresses:
3297              a listening D-Bus server that offers this transport
3298              will always create a new nonce file.</entry>
3299           </row>
3300          </tbody>
3301         </tgroup>
3302        </informaltable>
3303       </sect3>
3304     </sect2>
3305     <sect2 id="transports-exec">
3306       <title>Executed Subprocesses on Unix</title>
3307       <para>
3308         This transport forks off a process and connects its standard
3309         input and standard output with an anonymous Unix domain
3310         socket. This socket is then used for communication by the
3311         transport. This transport may be used to use out-of-process
3312         forwarder programs as basis for the D-Bus protocol.
3313       </para>
3314       <para>
3315         The forked process will inherit the standard error output and
3316         process group from the parent process.
3317       </para>
3318       <para>
3319         Executed subprocesses are not available on Windows.
3320       </para>
3321       <para>
3322         <literal>unixexec</literal> addresses are connectable, but are not
3323         listenable.
3324       </para>
3325       <sect3 id="transports-exec-addresses">
3326         <title>Server Address Format</title>
3327         <para>
3328           Executed subprocess addresses are identified by the "unixexec:" prefix
3329           and support the following key/value pairs:
3330         </para>
3331         <informaltable>
3332          <tgroup cols="3">
3333           <thead>
3334            <row>
3335             <entry>Name</entry>
3336             <entry>Values</entry>
3337             <entry>Description</entry>
3338            </row>
3339           </thead>
3340           <tbody>
3341            <row>
3342             <entry>path</entry>
3343             <entry>(path)</entry>
3344             <entry>Path of the binary to execute, either an absolute
3345             path or a binary name that is searched for in the default
3346             search path of the OS. This corresponds to the first
3347             argument of execlp(). This key is mandatory.</entry>
3348           </row>
3349           <row>
3350             <entry>argv0</entry>
3351             <entry>(string)</entry>
3352             <entry>The program name to use when executing the
3353             binary. If omitted the same value as specified for path=
3354             will be used. This corresponds to the second argument of
3355             execlp().</entry>
3356           </row>
3357           <row>
3358             <entry>argv1, argv2, ...</entry>
3359             <entry>(string)</entry>
3360             <entry>Arguments to pass to the binary. This corresponds
3361             to the third and later arguments of execlp(). If a
3362             specific argvX is not specified no further argvY for Y > X
3363             are taken into account.</entry>
3364           </row>
3365         </tbody>
3366         </tgroup>
3367        </informaltable>
3368       </sect3>
3369     </sect2>
3370    </sect1>
3371    <sect1 id="meta-transports">
3372     <title>Meta Transports</title>
3373     <para>
3374       Meta transports are a kind of transport with special enhancements or
3375       behavior. Currently available meta transports include: autolaunch
3376     </para>
3377
3378     <sect2 id="meta-transports-autolaunch">
3379      <title>Autolaunch</title>
3380      <para>The autolaunch transport provides a way for dbus clients to autodetect
3381        a running dbus session bus and to autolaunch a session bus if not present.
3382      </para>
3383       <para>
3384         On Unix, <literal>autolaunch</literal> addresses are connectable,
3385         but not listenable.
3386       </para>
3387       <para>
3388         On Windows, <literal>autolaunch</literal> addresses are both
3389         connectable and listenable.
3390       </para>
3391
3392      <sect3 id="meta-transports-autolaunch-addresses">
3393        <title>Server Address Format</title>
3394        <para>
3395          Autolaunch addresses uses the "autolaunch:" prefix and support the
3396          following key/value pairs:
3397        </para>
3398        <informaltable>
3399         <tgroup cols="3">
3400          <thead>
3401           <row>
3402            <entry>Name</entry>
3403            <entry>Values</entry>
3404            <entry>Description</entry>
3405           </row>
3406          </thead>
3407          <tbody>
3408           <row>
3409            <entry>scope</entry>
3410            <entry>(string)</entry>
3411            <entry>scope of autolaunch (Windows only)
3412             <itemizedlist>
3413              <listitem>
3414               <para>
3415                "*install-path" - limit session bus to dbus installation path.
3416                The dbus installation path is determined from the location of
3417                the shared dbus library. If the library is located in a 'bin'
3418                subdirectory the installation root is the directory above,
3419                otherwise the directory where the library lives is taken as
3420                installation root.
3421                <programlisting>
3422                    &lt;install-root&gt;/bin/[lib]dbus-1.dll
3423                    &lt;install-root&gt;/[lib]dbus-1.dll
3424                </programlisting>
3425               </para>
3426              </listitem>
3427              <listitem>
3428               <para>
3429                "*user" - limit session bus to the recent user.
3430               </para>
3431              </listitem>
3432              <listitem>
3433               <para>
3434                other values - specify dedicated session bus like "release",
3435                "debug" or other
3436               </para>
3437              </listitem>
3438             </itemizedlist>
3439            </entry>
3440          </row>
3441         </tbody>
3442        </tgroup>
3443       </informaltable>
3444      </sect3>
3445
3446      <sect3 id="meta-transports-autolaunch-windows-implementation">
3447       <title>Windows implementation</title>
3448       <para>
3449         On start, the server opens a platform specific transport, creates a mutex
3450         and a shared memory section containing the related session bus address.
3451         This mutex will be inspected by the dbus client library to detect a
3452         running dbus session bus. The access to the mutex and the shared memory
3453         section are protected by global locks.
3454       </para>
3455       <para>
3456        In the recent implementation the autolaunch transport uses a tcp transport
3457        on localhost with a port choosen from the operating system. This detail may
3458        change in the future.
3459       </para>
3460       <para>
3461         Disclaimer: The recent implementation is in an early state and may not
3462         work in all cirumstances and/or may have security issues. Because of this
3463         the implementation is not documentated yet.
3464       </para>
3465      </sect3>
3466     </sect2>
3467    </sect1>
3468
3469   <sect1 id="uuids">
3470     <title>UUIDs</title>
3471     <para>
3472       A working D-Bus implementation uses universally-unique IDs in two places.
3473       First, each server address has a UUID identifying the address, 
3474       as described in <xref linkend="addresses"/>. Second, each operating
3475       system kernel instance running a D-Bus client or server has a UUID
3476       identifying that kernel, retrieved by invoking the method
3477       org.freedesktop.DBus.Peer.GetMachineId() (see <xref
3478       linkend="standard-interfaces-peer"/>).
3479     </para>
3480     <para>
3481       The term "UUID" in this document is intended literally, i.e. an
3482       identifier that is universally unique. It is not intended to refer to
3483       RFC4122, and in fact the D-Bus UUID is not compatible with that RFC.
3484     </para>
3485     <para>
3486       The UUID must contain 128 bits of data and be hex-encoded.  The
3487       hex-encoded string may not contain hyphens or other non-hex-digit
3488       characters, and it must be exactly 32 characters long.  To generate a
3489       UUID, the current reference implementation concatenates 96 bits of random
3490       data followed by the 32-bit time in seconds since the UNIX epoch (in big
3491       endian byte order).
3492     </para>
3493     <para>
3494       It would also be acceptable and probably better to simply generate 128
3495       bits of random data, as long as the random number generator is of high
3496       quality. The timestamp could conceivably help if the random bits are not
3497       very random. With a quality random number generator, collisions are
3498       extremely unlikely even with only 96 bits, so it's somewhat academic.
3499     </para>
3500     <para>
3501       Implementations should, however, stick to random data for the first 96 bits
3502       of the UUID.
3503     </para>
3504   </sect1>
3505     
3506   <sect1 id="standard-interfaces">
3507     <title>Standard Interfaces</title>
3508     <para>
3509       See <xref linkend="message-protocol-types-notation"/> for details on 
3510        the notation used in this section. There are some standard interfaces
3511       that may be useful across various D-Bus applications.
3512     </para>
3513     <sect2 id="standard-interfaces-peer">
3514       <title><literal>org.freedesktop.DBus.Peer</literal></title>
3515       <para>
3516         The <literal>org.freedesktop.DBus.Peer</literal> interface 
3517         has two methods:
3518         <programlisting>
3519           org.freedesktop.DBus.Peer.Ping ()
3520           org.freedesktop.DBus.Peer.GetMachineId (out STRING machine_uuid)
3521         </programlisting>
3522       </para>
3523       <para>
3524         On receipt of the <literal>METHOD_CALL</literal> message
3525         <literal>org.freedesktop.DBus.Peer.Ping</literal>, an application should do
3526         nothing other than reply with a <literal>METHOD_RETURN</literal> as
3527         usual.  It does not matter which object path a ping is sent to.  The
3528         reference implementation handles this method automatically.
3529       </para>
3530       <para>
3531         On receipt of the <literal>METHOD_CALL</literal> message
3532         <literal>org.freedesktop.DBus.Peer.GetMachineId</literal>, an application should 
3533         reply with a <literal>METHOD_RETURN</literal> containing a hex-encoded 
3534         UUID representing the identity of the machine the process is running on.
3535         This UUID must be the same for all processes on a single system at least
3536         until that system next reboots. It should be the same across reboots 
3537         if possible, but this is not always possible to implement and is not 
3538         guaranteed.
3539         It does not matter which object path a GetMachineId is sent to.  The
3540         reference implementation handles this method automatically.
3541       </para>
3542       <para>
3543         The UUID is intended to be per-instance-of-the-operating-system, so may represent
3544         a virtual machine running on a hypervisor, rather than a physical machine.
3545         Basically if two processes see the same UUID, they should also see the same
3546         shared memory, UNIX domain sockets, process IDs, and other features that require 
3547         a running OS kernel in common between the processes.
3548       </para>
3549       <para>
3550         The UUID is often used where other programs might use a hostname. Hostnames 
3551         can change without rebooting, however, or just be "localhost" - so the UUID
3552         is more robust.
3553       </para>
3554       <para>
3555         <xref linkend="uuids"/> explains the format of the UUID.
3556       </para>
3557     </sect2>
3558
3559     <sect2 id="standard-interfaces-introspectable">
3560       <title><literal>org.freedesktop.DBus.Introspectable</literal></title>
3561       <para>
3562         This interface has one method:
3563         <programlisting>
3564           org.freedesktop.DBus.Introspectable.Introspect (out STRING xml_data)
3565         </programlisting>
3566       </para>
3567       <para>
3568         Objects instances may implement
3569         <literal>Introspect</literal> which returns an XML description of
3570         the object, including its interfaces (with signals and methods), objects
3571         below it in the object path tree, and its properties.
3572       </para>
3573       <para>
3574         <xref linkend="introspection-format"/> describes the format of this XML string.
3575       </para>
3576     </sect2>
3577     <sect2 id="standard-interfaces-properties">
3578       <title><literal>org.freedesktop.DBus.Properties</literal></title>
3579       <para>
3580         Many native APIs will have a concept of object <firstterm>properties</firstterm> 
3581         or <firstterm>attributes</firstterm>. These can be exposed via the 
3582         <literal>org.freedesktop.DBus.Properties</literal> interface.
3583       </para>
3584       <para>
3585         <programlisting>
3586               org.freedesktop.DBus.Properties.Get (in STRING interface_name,
3587                                                    in STRING property_name,
3588                                                    out VARIANT value);
3589               org.freedesktop.DBus.Properties.Set (in STRING interface_name,
3590                                                    in STRING property_name,
3591                                                    in VARIANT value);
3592               org.freedesktop.DBus.Properties.GetAll (in STRING interface_name,
3593                                                       out DICT&lt;STRING,VARIANT&gt; props);
3594         </programlisting>
3595       </para>
3596       <para>
3597         It is conventional to give D-Bus properties names consisting of
3598         capitalized words without punctuation ("CamelCase"), like
3599         <link linkend="message-protocol-names-member">member names</link>.
3600         For instance, the GObject property
3601         <literal>connection-status</literal> or the Qt property
3602         <literal>connectionStatus</literal> could be represented on D-Bus
3603         as <literal>ConnectionStatus</literal>.
3604       </para>
3605       <para>
3606         Strictly speaking, D-Bus property names are not required to follow
3607         the same naming restrictions as member names, but D-Bus property
3608         names that would not be valid member names (in particular,
3609         GObject-style dash-separated property names) can cause interoperability
3610         problems and should be avoided.
3611       </para>
3612       <para>
3613         The available properties and whether they are writable can be determined
3614         by calling <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>,
3615         see <xref linkend="standard-interfaces-introspectable"/>.
3616       </para>
3617       <para>
3618         An empty string may be provided for the interface name; in this case, 
3619         if there are multiple properties on an object with the same name, 
3620         the results are undefined (picking one by according to an arbitrary 
3621         deterministic rule, or returning an error, are the reasonable 
3622         possibilities).
3623       </para>
3624       <para>
3625         If one or more properties change on an object, the
3626         <literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
3627         signal may be emitted (this signal was added in 0.14):
3628       </para>
3629       <para>
3630         <programlisting>
3631               org.freedesktop.DBus.Properties.PropertiesChanged (STRING interface_name,
3632                                                                  DICT&lt;STRING,VARIANT&gt; changed_properties,
3633                                                                  ARRAY&lt;STRING&gt; invalidated_properties);
3634         </programlisting>
3635       </para>
3636       <para>
3637         where <literal>changed_properties</literal> is a dictionary
3638         containing the changed properties with the new values and
3639         <literal>invalidated_properties</literal> is an array of
3640         properties that changed but the value is not conveyed.
3641       </para>
3642       <para>
3643         Whether the <literal>PropertiesChanged</literal> signal is
3644         supported can be determined by calling
3645         <literal>org.freedesktop.DBus.Introspectable.Introspect</literal>. Note
3646         that the signal may be supported for an object but it may
3647         differ how whether and how it is used on a per-property basis
3648         (for e.g. performance or security reasons). Each property (or
3649         the parent interface) must be annotated with the
3650         <literal>org.freedesktop.DBus.Property.EmitsChangedSignal</literal>
3651         annotation to convey this (usually the default value
3652         <literal>true</literal> is sufficient meaning that the
3653         annotation does not need to be used). See <xref
3654         linkend="introspection-format"/> for details on this
3655         annotation.
3656       </para>
3657     </sect2>
3658
3659     <sect2 id="standard-interfaces-objectmanager">
3660       <title><literal>org.freedesktop.DBus.ObjectManager</literal></title>
3661       <para>
3662         An API can optionally make use of this interface for one or
3663         more sub-trees of objects. The root of each sub-tree implements
3664         this interface so other applications can get all objects,
3665         interfaces and properties in a single method call.  It is
3666         appropriate to use this interface if users of the tree of
3667         objects are expected to be interested in all interfaces of all
3668         objects in the tree; a more granular API should be used if
3669         users of the objects are expected to be interested in a small
3670         subset of the objects, a small subset of their interfaces, or
3671         both.
3672       </para>
3673       <para>
3674         The method that applications can use to get all objects and
3675         properties is <literal>GetManagedObjects</literal>:
3676       </para>
3677       <para>
3678         <programlisting>
3679           org.freedesktop.DBus.ObjectManager.GetManagedObjects (out DICT&lt;OBJPATH,DICT&lt;STRING,DICT&lt;STRING,VARIANT&gt;&gt;&gt; objpath_interfaces_and_properties);
3680         </programlisting>
3681       </para>
3682       <para>
3683         The return value of this method is a dict whose keys are
3684         object paths. All returned object paths are children of the
3685         object path implementing this interface, i.e. their object
3686         paths start with the ObjectManager's object path plus '/'.
3687       </para>
3688       <para>
3689         Each value is a dict whose keys are interfaces names.  Each
3690         value in this inner dict is the same dict that would be
3691         returned by the <link
3692         linkend="standard-interfaces-properties">org.freedesktop.DBus.Properties.GetAll()</link>
3693         method for that combination of object path and interface. If
3694         an interface has no properties, the empty dict is returned.
3695       </para>
3696       <para>
3697         Changes are emitted using the following two signals:
3698       </para>
3699       <para>
3700         <programlisting>
3701           org.freedesktop.DBus.ObjectManager.InterfacesAdded (OBJPATH object_path,
3702                                                               DICT&lt;STRING,DICT&lt;STRING,VARIANT&gt;&gt; interfaces_and_properties);
3703           org.freedesktop.DBus.ObjectManager.InterfacesRemoved (OBJPATH object_path,
3704                                                                 ARRAY&lt;STRING&gt; interfaces);
3705         </programlisting>
3706       </para>
3707       <para>
3708         The <literal>InterfacesAdded</literal> signal is emitted when
3709         either a new object is added or when an existing object gains
3710         one or more interfaces. The
3711         <literal>InterfacesRemoved</literal> signal is emitted
3712         whenever an object is removed or it loses one or more
3713         interfaces. The second parameter of the
3714         <literal>InterfacesAdded</literal> signal contains a dict with
3715         the interfaces and properties (if any) that have been added to
3716         the given object path. Similarly, the second parameter of the
3717         <literal>InterfacesRemoved</literal> signal contains an array
3718         of the interfaces that were removed. Note that changes on
3719         properties on existing interfaces are not reported using this
3720         interface - an application should also monitor the existing <link
3721         linkend="standard-interfaces-properties">PropertiesChanged</link>
3722         signal on each object.
3723       </para>
3724       <para>
3725         Applications SHOULD NOT export objects that are children of an
3726         object (directly or otherwise) implementing this interface but
3727         which are not returned in the reply from the
3728         <literal>GetManagedObjects()</literal> method of this
3729         interface on the given object.
3730       </para>
3731       <para>
3732         The intent of the <literal>ObjectManager</literal> interface
3733         is to make it easy to write a robust client
3734         implementation. The trivial client implementation only needs
3735         to make two method calls:
3736       </para>
3737       <para>
3738         <programlisting>
3739           org.freedesktop.DBus.AddMatch (bus_proxy,
3740                                          "type='signal',name='org.example.App',path_namespace='/org/example/App'");
3741           objects = org.freedesktop.DBus.ObjectManager.GetManagedObjects (app_proxy);
3742         </programlisting>
3743       </para>
3744       <para>
3745         on the message bus and the remote application's
3746         <literal>ObjectManager</literal>, respectively. Whenever a new
3747         remote object is created (or an existing object gains a new
3748         interface), the <literal>InterfacesAdded</literal> signal is
3749         emitted, and since this signal contains all properties for the
3750         interfaces, no calls to the
3751         <literal>org.freedesktop.Properties</literal> interface on the
3752         remote object are needed. Additionally, since the initial
3753         <literal>AddMatch()</literal> rule already includes signal
3754         messages from the newly created child object, no new
3755         <literal>AddMatch()</literal> call is needed.
3756       </para>
3757
3758       <para>
3759         <emphasis>
3760           The <literal>org.freedesktop.DBus.ObjectManager</literal>
3761           interface was added in version 0.17 of the D-Bus
3762           specification.
3763         </emphasis>
3764       </para>
3765     </sect2>
3766   </sect1>
3767
3768   <sect1 id="introspection-format">
3769     <title>Introspection Data Format</title>
3770     <para>
3771       As described in <xref linkend="standard-interfaces-introspectable"/>, 
3772       objects may be introspected at runtime, returning an XML string 
3773       that describes the object. The same XML format may be used in 
3774       other contexts as well, for example as an "IDL" for generating 
3775       static language bindings.
3776     </para>
3777     <para>
3778       Here is an example of introspection data:
3779       <programlisting>
3780         &lt;!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
3781          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"&gt;
3782         &lt;node name="/com/example/sample_object"&gt;
3783           &lt;interface name="com.example.SampleInterface"&gt;
3784             &lt;method name="Frobate"&gt;
3785               &lt;arg name="foo" type="i" direction="in"/&gt;
3786               &lt;arg name="bar" type="s" direction="out"/&gt;
3787               &lt;arg name="baz" type="a{us}" direction="out"/&gt;
3788               &lt;annotation name="org.freedesktop.DBus.Deprecated" value="true"/&gt;
3789             &lt;/method&gt;
3790             &lt;method name="Bazify"&gt;
3791               &lt;arg name="bar" type="(iiu)" direction="in"/&gt;
3792               &lt;arg name="bar" type="v" direction="out"/&gt;
3793             &lt;/method&gt;
3794             &lt;method name="Mogrify"&gt;
3795               &lt;arg name="bar" type="(iiav)" direction="in"/&gt;
3796             &lt;/method&gt;
3797             &lt;signal name="Changed"&gt;
3798               &lt;arg name="new_value" type="b"/&gt;
3799             &lt;/signal&gt;
3800             &lt;property name="Bar" type="y" access="readwrite"/&gt;
3801           &lt;/interface&gt;
3802           &lt;node name="child_of_sample_object"/&gt;
3803           &lt;node name="another_child_of_sample_object"/&gt;
3804        &lt;/node&gt;
3805       </programlisting>
3806     </para>
3807     <para>
3808       A more formal DTD and spec needs writing, but here are some quick notes.
3809       <itemizedlist>
3810         <listitem>
3811           <para>
3812             Only the root &lt;node&gt; element can omit the node name, as it's
3813             known to be the object that was introspected.  If the root
3814             &lt;node&gt; does have a name attribute, it must be an absolute
3815             object path. If child &lt;node&gt; have object paths, they must be
3816             relative.
3817           </para>
3818         </listitem>
3819         <listitem>
3820           <para>
3821             If a child &lt;node&gt; has any sub-elements, then they 
3822             must represent a complete introspection of the child.
3823             If a child &lt;node&gt; is empty, then it may or may 
3824             not have sub-elements; the child must be introspected
3825             in order to find out. The intent is that if an object 
3826             knows that its children are "fast" to introspect
3827             it can go ahead and return their information, but 
3828             otherwise it can omit it.
3829           </para>
3830         </listitem>
3831         <listitem>
3832           <para>
3833             The direction element on &lt;arg&gt; may be omitted, 
3834             in which case it defaults to "in" for method calls 
3835             and "out" for signals. Signals only allow "out" 
3836             so while direction may be specified, it's pointless.
3837           </para>
3838         </listitem>
3839         <listitem>
3840           <para>
3841             The possible directions are "in" and "out", 
3842             unlike CORBA there is no "inout"
3843           </para>
3844         </listitem>
3845         <listitem>
3846           <para>
3847             The possible property access flags are 
3848             "readwrite", "read", and "write"
3849           </para>
3850         </listitem>
3851         <listitem>
3852           <para>
3853             Multiple interfaces can of course be listed for 
3854             one &lt;node&gt;.
3855           </para>
3856         </listitem>
3857         <listitem>
3858           <para>
3859             The "name" attribute on arguments is optional.
3860           </para>
3861         </listitem>
3862       </itemizedlist>
3863     </para>
3864     <para>
3865         Method, interface, property, and signal elements may have
3866         "annotations", which are generic key/value pairs of metadata.
3867         They are similar conceptually to Java's annotations and C# attributes.
3868         Well-known annotations:
3869      </para>
3870      <informaltable>
3871        <tgroup cols="3">
3872          <thead>
3873            <row>
3874              <entry>Name</entry>
3875              <entry>Values (separated by ,)</entry>
3876              <entry>Description</entry>
3877            </row>
3878          </thead>
3879          <tbody>
3880            <row>
3881              <entry>org.freedesktop.DBus.Deprecated</entry>
3882              <entry>true,false</entry>
3883              <entry>Whether or not the entity is deprecated; defaults to false</entry>
3884            </row>
3885            <row>
3886              <entry>org.freedesktop.DBus.GLib.CSymbol</entry>
3887              <entry>(string)</entry>
3888              <entry>The C symbol; may be used for methods and interfaces</entry>
3889            </row>
3890            <row>
3891              <entry>org.freedesktop.DBus.Method.NoReply</entry>
3892              <entry>true,false</entry>
3893              <entry>If set, don't expect a reply to the method call; defaults to false.</entry>
3894            </row>
3895            <row>
3896              <entry>org.freedesktop.DBus.Property.EmitsChangedSignal</entry>
3897              <entry>true,invalidates,false</entry>
3898              <entry>
3899                <para>
3900                  If set to <literal>false</literal>, the
3901                  <literal>org.freedesktop.DBus.Properties.PropertiesChanged</literal>
3902                  signal, see <xref
3903                  linkend="standard-interfaces-properties"/> is not
3904                  guaranteed to be emitted if the property changes.
3905                </para>
3906                <para>
3907                  If set to <literal>invalidates</literal> the signal
3908                  is emitted but the value is not included in the
3909                  signal.
3910                </para>
3911                <para>
3912                  If set to <literal>true</literal> the signal is
3913                  emitted with the value included.
3914                </para>
3915                <para>
3916                  The value for the annotation defaults to
3917                  <literal>true</literal> if the enclosing interface
3918                  element does not specify the annotation. Otherwise it
3919                  defaults to the value specified in the enclosing
3920                  interface element.
3921                </para>
3922              </entry>
3923            </row>
3924          </tbody>
3925        </tgroup>
3926      </informaltable>
3927   </sect1>
3928   <sect1 id="message-bus">
3929     <title>Message Bus Specification</title>
3930     <sect2 id="message-bus-overview">
3931       <title>Message Bus Overview</title>
3932       <para>
3933         The message bus accepts connections from one or more applications. 
3934         Once connected, applications can exchange messages with other 
3935         applications that are also connected to the bus.
3936       </para>
3937       <para>
3938         In order to route messages among connections, the message bus keeps a
3939         mapping from names to connections. Each connection has one
3940         unique-for-the-lifetime-of-the-bus name automatically assigned.
3941         Applications may request additional names for a connection. Additional
3942         names are usually "well-known names" such as
3943         "com.example.TextEditor". When a name is bound to a connection,
3944         that connection is said to <firstterm>own</firstterm> the name.
3945       </para>
3946       <para>
3947         The bus itself owns a special name,
3948         <literal>org.freedesktop.DBus</literal>, with an object
3949         located at <literal>/org/freedesktop/DBus</literal> that
3950         implements the <literal>org.freedesktop.DBus</literal>
3951         interface. This service allows applications to make
3952         administrative requests of the bus itself. For example,
3953         applications can ask the bus to assign a name to a connection.
3954       </para>
3955       <para>
3956         Each name may have <firstterm>queued owners</firstterm>.  When an
3957         application requests a name for a connection and the name is already in
3958         use, the bus will optionally add the connection to a queue waiting for 
3959         the name. If the current owner of the name disconnects or releases
3960         the name, the next connection in the queue will become the new owner.
3961       </para>
3962
3963       <para>
3964         This feature causes the right thing to happen if you start two text
3965         editors for example; the first one may request "com.example.TextEditor",
3966         and the second will be queued as a possible owner of that name. When 
3967         the first exits, the second will take over.
3968       </para>
3969
3970       <para>
3971         Applications may send <firstterm>unicast messages</firstterm> to
3972         a specific recipient or to the message bus itself, or
3973         <firstterm>broadcast messages</firstterm> to all interested recipients.
3974         See <xref linkend="message-bus-routing"/> for details.
3975       </para>
3976     </sect2>
3977
3978     <sect2 id="message-bus-names">
3979       <title>Message Bus Names</title>
3980       <para>
3981         Each connection has at least one name, assigned at connection time and
3982         returned in response to the
3983         <literal>org.freedesktop.DBus.Hello</literal> method call.  This
3984         automatically-assigned name is called the connection's <firstterm>unique
3985         name</firstterm>.  Unique names are never reused for two different
3986         connections to the same bus.
3987       </para>
3988       <para>
3989         Ownership of a unique name is a prerequisite for interaction with 
3990         the message bus. It logically follows that the unique name is always 
3991         the first name that an application comes to own, and the last 
3992         one that it loses ownership of.
3993       </para>
3994       <para>
3995         Unique connection names must begin with the character ':' (ASCII colon
3996         character); bus names that are not unique names must not begin
3997         with this character. (The bus must reject any attempt by an application
3998         to manually request a name beginning with ':'.) This restriction
3999         categorically prevents "spoofing"; messages sent to a unique name
4000         will always go to the expected connection.
4001       </para>
4002       <para>
4003         When a connection is closed, all the names that it owns are deleted (or
4004         transferred to the next connection in the queue if any).
4005       </para>
4006       <para>
4007         A connection can request additional names to be associated with it using
4008         the <literal>org.freedesktop.DBus.RequestName</literal> message. <xref
4009         linkend="message-protocol-names-bus"/> describes the format of a valid
4010         name. These names can be released again using the
4011         <literal>org.freedesktop.DBus.ReleaseName</literal> message.
4012       </para>
4013
4014       <sect3 id="bus-messages-request-name">
4015         <title><literal>org.freedesktop.DBus.RequestName</literal></title>
4016         <para>
4017           As a method:
4018           <programlisting>
4019             UINT32 RequestName (in STRING name, in UINT32 flags)
4020           </programlisting>
4021           Message arguments:
4022           <informaltable>
4023             <tgroup cols="3">
4024               <thead>
4025                 <row>
4026                   <entry>Argument</entry>
4027                   <entry>Type</entry>
4028                   <entry>Description</entry>
4029                 </row>
4030               </thead>
4031               <tbody>
4032                 <row>
4033                   <entry>0</entry>
4034                   <entry>STRING</entry>
4035                   <entry>Name to request</entry>
4036                 </row>
4037                 <row>
4038                   <entry>1</entry>
4039                   <entry>UINT32</entry>
4040                   <entry>Flags</entry>
4041                 </row>
4042               </tbody>
4043             </tgroup>
4044           </informaltable>
4045           Reply arguments:
4046           <informaltable>
4047             <tgroup cols="3">
4048               <thead>
4049                 <row>
4050                   <entry>Argument</entry>
4051                   <entry>Type</entry>
4052                   <entry>Description</entry>
4053                 </row>
4054               </thead>
4055               <tbody>
4056                 <row>
4057                   <entry>0</entry>
4058                   <entry>UINT32</entry>
4059                   <entry>Return value</entry>
4060                 </row>
4061               </tbody>
4062             </tgroup>
4063           </informaltable>
4064         </para>
4065         <para>
4066           This method call should be sent to
4067           <literal>org.freedesktop.DBus</literal> and asks the message bus to
4068           assign the given name to the method caller. Each name maintains a
4069           queue of possible owners, where the head of the queue is the primary
4070           or current owner of the name. Each potential owner in the queue
4071           maintains the DBUS_NAME_FLAG_ALLOW_REPLACEMENT and
4072           DBUS_NAME_FLAG_DO_NOT_QUEUE settings from its latest RequestName
4073           call.  When RequestName is invoked the following occurs:
4074           <itemizedlist>
4075             <listitem>
4076               <para>
4077                 If the method caller is currently the primary owner of the name,
4078                 the DBUS_NAME_FLAG_ALLOW_REPLACEMENT and DBUS_NAME_FLAG_DO_NOT_QUEUE
4079                 values are updated with the values from the new RequestName call, 
4080                 and nothing further happens.
4081               </para>
4082             </listitem>
4083
4084             <listitem>
4085               <para>
4086                 If the current primary owner (head of the queue) has
4087                 DBUS_NAME_FLAG_ALLOW_REPLACEMENT set, and the RequestName
4088                 invocation has the DBUS_NAME_FLAG_REPLACE_EXISTING flag, then
4089                 the caller of RequestName replaces the current primary owner at
4090                 the head of the queue and the current primary owner moves to the
4091                 second position in the queue. If the caller of RequestName was 
4092                 in the queue previously its flags are updated with the values from 
4093                 the new RequestName in addition to moving it to the head of the queue.
4094               </para>
4095             </listitem>
4096
4097             <listitem>
4098               <para>
4099                 If replacement is not possible, and the method caller is
4100                 currently in the queue but not the primary owner, its flags are
4101                 updated with the values from the new RequestName call.
4102               </para>
4103             </listitem>
4104
4105             <listitem>
4106               <para>
4107                 If replacement is not possible, and the method caller is
4108                 currently not in the queue, the method caller is appended to the
4109                 queue.
4110               </para>
4111             </listitem>
4112
4113             <listitem>
4114               <para>
4115                 If any connection in the queue has DBUS_NAME_FLAG_DO_NOT_QUEUE
4116                 set and is not the primary owner, it is removed from the
4117                 queue. This can apply to the previous primary owner (if it
4118                 was replaced) or the method caller (if it updated the
4119                 DBUS_NAME_FLAG_DO_NOT_QUEUE flag while still stuck in the
4120                 queue, or if it was just added to the queue with that flag set).
4121               </para>
4122             </listitem>
4123           </itemizedlist>
4124         </para>
4125         <para>
4126           Note that DBUS_NAME_FLAG_REPLACE_EXISTING results in "jumping the
4127           queue," even if another application already in the queue had specified
4128           DBUS_NAME_FLAG_REPLACE_EXISTING.  This comes up if a primary owner
4129           that does not allow replacement goes away, and the next primary owner
4130           does allow replacement. In this case, queued items that specified
4131           DBUS_NAME_FLAG_REPLACE_EXISTING <emphasis>do not</emphasis>
4132           automatically replace the new primary owner. In other words,
4133           DBUS_NAME_FLAG_REPLACE_EXISTING is not saved, it is only used at the
4134           time RequestName is called. This is deliberate to avoid an infinite loop
4135           anytime two applications are both DBUS_NAME_FLAG_ALLOW_REPLACEMENT 
4136           and DBUS_NAME_FLAG_REPLACE_EXISTING.
4137         </para>
4138         <para>
4139           The flags argument contains any of the following values logically ORed
4140           together:
4141
4142           <informaltable>
4143             <tgroup cols="3">
4144               <thead>
4145                 <row>
4146                   <entry>Conventional Name</entry>
4147                   <entry>Value</entry>
4148                   <entry>Description</entry>
4149                 </row>
4150               </thead>
4151               <tbody>
4152                 <row>
4153                   <entry>DBUS_NAME_FLAG_ALLOW_REPLACEMENT</entry>
4154                   <entry>0x1</entry>
4155                   <entry>
4156
4157                     If an application A specifies this flag and succeeds in
4158                     becoming the owner of the name, and another application B
4159                     later calls RequestName with the
4160                     DBUS_NAME_FLAG_REPLACE_EXISTING flag, then application A
4161                     will lose ownership and receive a
4162                     <literal>org.freedesktop.DBus.NameLost</literal> signal, and
4163                     application B will become the new owner. If DBUS_NAME_FLAG_ALLOW_REPLACEMENT
4164                     is not specified by application A, or DBUS_NAME_FLAG_REPLACE_EXISTING
4165                     is not specified by application B, then application B will not replace
4166                     application A as the owner.
4167
4168                   </entry>
4169                 </row>
4170                 <row>
4171                   <entry>DBUS_NAME_FLAG_REPLACE_EXISTING</entry>
4172                   <entry>0x2</entry>
4173                   <entry>
4174
4175                     Try to replace the current owner if there is one. If this
4176                     flag is not set the application will only become the owner of
4177                     the name if there is no current owner. If this flag is set,
4178                     the application will replace the current owner if
4179                     the current owner specified DBUS_NAME_FLAG_ALLOW_REPLACEMENT.
4180
4181                   </entry>
4182                 </row>
4183                 <row>
4184                   <entry>DBUS_NAME_FLAG_DO_NOT_QUEUE</entry>
4185                   <entry>0x4</entry>
4186                   <entry>
4187
4188                     Without this flag, if an application requests a name that is
4189                     already owned, the application will be placed in a queue to
4190                     own the name when the current owner gives it up. If this
4191                     flag is given, the application will not be placed in the
4192                     queue, the request for the name will simply fail.  This flag
4193                     also affects behavior when an application is replaced as
4194                     name owner; by default the application moves back into the
4195                     waiting queue, unless this flag was provided when the application
4196                     became the name owner.
4197
4198                   </entry>
4199                 </row>
4200               </tbody>
4201             </tgroup>
4202           </informaltable>
4203
4204           The return code can be one of the following values:
4205
4206           <informaltable>
4207             <tgroup cols="3">
4208               <thead>
4209                 <row>
4210                   <entry>Conventional Name</entry>
4211                   <entry>Value</entry>
4212                   <entry>Description</entry>
4213                 </row>
4214               </thead>
4215               <tbody>
4216                 <row>
4217                   <entry>DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER</entry>
4218                   <entry>1</entry> <entry>The caller is now the primary owner of
4219                   the name, replacing any previous owner. Either the name had no
4220                   owner before, or the caller specified
4221                   DBUS_NAME_FLAG_REPLACE_EXISTING and the current owner specified
4222                   DBUS_NAME_FLAG_ALLOW_REPLACEMENT.</entry>
4223                 </row>
4224                 <row>
4225                   <entry>DBUS_REQUEST_NAME_REPLY_IN_QUEUE</entry>
4226                   <entry>2</entry>
4227
4228                   <entry>The name already had an owner,
4229                     DBUS_NAME_FLAG_DO_NOT_QUEUE was not specified, and either
4230                     the current owner did not specify
4231                     DBUS_NAME_FLAG_ALLOW_REPLACEMENT or the requesting
4232                     application did not specify DBUS_NAME_FLAG_REPLACE_EXISTING.
4233                     </entry>
4234                 </row>
4235                 <row>
4236                   <entry>DBUS_REQUEST_NAME_REPLY_EXISTS</entry> <entry>3</entry>
4237                   <entry>The name already has an owner,
4238                   DBUS_NAME_FLAG_DO_NOT_QUEUE was specified, and either
4239                   DBUS_NAME_FLAG_ALLOW_REPLACEMENT was not specified by the
4240                   current owner, or DBUS_NAME_FLAG_REPLACE_EXISTING was not
4241                   specified by the requesting application.</entry>
4242                 </row>
4243                 <row>
4244                   <entry>DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER</entry>
4245                   <entry>4</entry>
4246                   <entry>The application trying to request ownership of a name is already the owner of it.</entry>
4247                 </row>
4248               </tbody>
4249             </tgroup>
4250           </informaltable>
4251         </para>
4252        </sect3>
4253
4254        <sect3 id="bus-messages-release-name">
4255         <title><literal>org.freedesktop.DBus.ReleaseName</literal></title>
4256         <para>
4257           As a method:
4258           <programlisting>
4259             UINT32 ReleaseName (in STRING name)
4260           </programlisting>
4261           Message arguments:
4262           <informaltable>
4263             <tgroup cols="3">
4264               <thead>
4265                 <row>
4266                   <entry>Argument</entry>
4267                   <entry>Type</entry>
4268                   <entry>Description</entry>
4269                 </row>
4270               </thead>
4271               <tbody>
4272                 <row>
4273                   <entry>0</entry>
4274                   <entry>STRING</entry>
4275                   <entry>Name to release</entry>
4276                 </row>
4277               </tbody>
4278             </tgroup>
4279           </informaltable>
4280           Reply arguments:
4281           <informaltable>
4282             <tgroup cols="3">
4283               <thead>
4284                 <row>
4285                   <entry>Argument</entry>
4286                   <entry>Type</entry>
4287                   <entry>Description</entry>
4288                 </row>
4289               </thead>
4290               <tbody>
4291                 <row>
4292                   <entry>0</entry>
4293                   <entry>UINT32</entry>
4294                   <entry>Return value</entry>
4295                 </row>
4296               </tbody>
4297             </tgroup>
4298           </informaltable>
4299         </para>
4300         <para>
4301           This method call should be sent to
4302           <literal>org.freedesktop.DBus</literal> and asks the message bus to
4303           release the method caller's claim to the given name. If the caller is
4304           the primary owner, a new primary owner will be selected from the
4305           queue if any other owners are waiting. If the caller is waiting in
4306           the queue for the name, the caller will removed from the queue and
4307           will not be made an owner of the name if it later becomes available.
4308           If there are no other owners in the queue for the name, it will be
4309           removed from the bus entirely.
4310
4311           The return code can be one of the following values:
4312
4313           <informaltable>
4314             <tgroup cols="3">
4315               <thead>
4316                 <row>
4317                   <entry>Conventional Name</entry>
4318                   <entry>Value</entry>
4319                   <entry>Description</entry>
4320                 </row>
4321               </thead>
4322               <tbody>
4323                 <row>
4324                   <entry>DBUS_RELEASE_NAME_REPLY_RELEASED</entry>
4325                   <entry>1</entry> <entry>The caller has released his claim on
4326                   the given name. Either the caller was the primary owner of
4327                   the name, and the name is now unused or taken by somebody
4328                   waiting in the queue for the name, or the caller was waiting
4329                   in the queue for the name and has now been removed from the
4330                   queue.</entry>
4331                 </row>
4332                 <row>
4333                   <entry>DBUS_RELEASE_NAME_REPLY_NON_EXISTENT</entry>
4334                   <entry>2</entry>
4335                   <entry>The given name does not exist on this bus.</entry>
4336                 </row>
4337                 <row>
4338                   <entry>DBUS_RELEASE_NAME_REPLY_NOT_OWNER</entry>
4339                   <entry>3</entry>
4340                   <entry>The caller was not the primary owner of this name,
4341                   and was also not waiting in the queue to own this name.</entry>
4342                 </row>
4343               </tbody>
4344             </tgroup>
4345           </informaltable>
4346         </para>
4347        </sect3>
4348
4349        <sect3 id="bus-messages-list-queued-owners">
4350         <title><literal>org.freedesktop.DBus.ListQueuedOwners</literal></title>
4351         <para>
4352           As a method:
4353           <programlisting>
4354             ARRAY of STRING ListQueuedOwners (in STRING name)
4355           </programlisting>
4356           Message arguments:
4357           <informaltable>
4358             <tgroup cols="3">
4359               <thead>
4360                 <row>
4361                   <entry>Argument</entry>
4362                   <entry>Type</entry>
4363                   <entry>Description</entry>
4364                 </row>
4365               </thead>
4366               <tbody>
4367                 <row>
4368                   <entry>0</entry>
4369                   <entry>STRING</entry>
4370                   <entry>The well-known bus name to query, such as
4371                     <literal>com.example.cappuccino</literal></entry>
4372                 </row>
4373               </tbody>
4374             </tgroup>
4375           </informaltable>
4376           Reply arguments:
4377           <informaltable>
4378             <tgroup cols="3">
4379               <thead>
4380                 <row>
4381                   <entry>Argument</entry>
4382                   <entry>Type</entry>
4383                   <entry>Description</entry>
4384                 </row>
4385               </thead>
4386               <tbody>
4387                 <row>
4388                   <entry>0</entry>
4389                   <entry>ARRAY of STRING</entry>
4390                   <entry>The unique bus names of connections currently queued
4391                     for the name</entry>
4392                 </row>
4393               </tbody>
4394             </tgroup>
4395           </informaltable>
4396         </para>
4397         <para>
4398           This method call should be sent to
4399           <literal>org.freedesktop.DBus</literal> and lists the connections
4400           currently queued for a bus name (see
4401           <xref linkend="term-queued-owner"/>).
4402         </para>
4403        </sect3>
4404     </sect2>
4405
4406     <sect2 id="message-bus-routing">
4407       <title>Message Bus Message Routing</title>
4408
4409       <para>
4410         Messages may have a <literal>DESTINATION</literal> field (see <xref
4411           linkend="message-protocol-header-fields"/>), resulting in a
4412         <firstterm>unicast message</firstterm>.  If the
4413         <literal>DESTINATION</literal> field is present, it specifies a message
4414         recipient by name. Method calls and replies normally specify this field.
4415         The message bus must send messages (of any type) with the
4416         <literal>DESTINATION</literal> field set to the specified recipient,
4417         regardless of whether the recipient has set up a match rule matching
4418         the message.
4419       </para>
4420
4421       <para>
4422         When the message bus receives a signal, if the
4423         <literal>DESTINATION</literal> field is absent, it is considered to
4424         be a <firstterm>broadcast signal</firstterm>, and is sent to all
4425         applications with <firstterm>message matching rules</firstterm> that
4426         match the message. Most signal messages are broadcasts.
4427       </para>
4428
4429       <para>
4430         Unicast signal messages (those with a <literal>DESTINATION</literal>
4431         field) are not commonly used, but they are treated like any unicast
4432         message: they are delivered to the specified receipient,
4433         regardless of its match rules.  One use for unicast signals is to
4434         avoid a race condition in which a signal is emitted before the intended
4435         recipient can call <xref linkend="bus-messages-add-match"/> to
4436         receive that signal: if the signal is sent directly to that recipient
4437         using a unicast message, it does not need to add a match rule at all,
4438         and there is no race condition.  Another use for unicast signals,
4439         on message buses whose security policy prevents eavesdropping, is to
4440         send sensitive information which should only be visible to one
4441         recipient.
4442       </para>
4443
4444       <para>
4445         When the message bus receives a method call, if the
4446         <literal>DESTINATION</literal> field is absent, the call is taken to be
4447         a standard one-to-one message and interpreted by the message bus
4448         itself. For example, sending an
4449         <literal>org.freedesktop.DBus.Peer.Ping</literal> message with no
4450         <literal>DESTINATION</literal> will cause the message bus itself to
4451         reply to the ping immediately; the message bus will not make this
4452         message visible to other applications.
4453       </para>
4454
4455       <para>
4456         Continuing the <literal>org.freedesktop.DBus.Peer.Ping</literal> example, if
4457         the ping message were sent with a <literal>DESTINATION</literal> name of
4458         <literal>com.yoyodyne.Screensaver</literal>, then the ping would be
4459         forwarded, and the Yoyodyne Corporation screensaver application would be
4460         expected to reply to the ping.
4461       </para>
4462
4463       <para>
4464         Message bus implementations may impose a security policy which
4465         prevents certain messages from being sent or received.
4466         When a message cannot be sent or received due to a security
4467         policy, the message bus should send an error reply, unless the
4468         original message had the <literal>NO_REPLY</literal> flag.
4469       </para>
4470
4471       <sect3 id="message-bus-routing-eavesdropping">
4472         <title>Eavesdropping</title>
4473         <para>
4474           Receiving a unicast message whose <literal>DESTINATION</literal>
4475           indicates a different recipient is called
4476           <firstterm>eavesdropping</firstterm>. On a message bus which acts as
4477           a security boundary (like the standard system bus), the security
4478           policy should usually prevent eavesdropping, since unicast messages
4479           are normally kept private and may contain security-sensitive
4480           information.
4481         </para>
4482
4483         <para>
4484           Eavesdropping is mainly useful for debugging tools, such as
4485           the <literal>dbus-monitor</literal> tool in the reference
4486           implementation of D-Bus. Tools which eavesdrop on the message bus
4487           should be careful to avoid sending a reply or error in response to
4488           messages intended for a different client.
4489         </para>
4490
4491         <para>
4492           Clients may attempt to eavesdrop by adding match rules
4493           (see <xref linkend="message-bus-routing-match-rules"/>) containing
4494           the <literal>eavesdrop='true'</literal> match. If the message bus'
4495           security policy does not allow eavesdropping, the match rule can
4496           still be added, but will not have any practical effect. For
4497           compatibility with older message bus implementations, if adding such
4498           a match rule results in an error reply, the client may fall back to
4499           adding the same rule with the <literal>eavesdrop</literal> match
4500           omitted.
4501         </para>
4502       </sect3>
4503
4504       <sect3 id="message-bus-routing-match-rules">
4505         <title>Match Rules</title>
4506         <para>
4507           An important part of the message bus routing protocol is match
4508           rules. Match rules describe the messages that should be sent to a
4509           client, based on the contents of the message.  Broadcast signals
4510           are only sent to clients which have a suitable match rule: this
4511           avoids waking up client processes to deal with signals that are
4512           not relevant to that client.
4513         </para>
4514         <para>
4515           Messages that list a client as their <literal>DESTINATION</literal>
4516           do not need to match the client's match rules, and are sent to that
4517           client regardless. As a result, match rules are mainly used to
4518           receive a subset of broadcast signals.
4519         </para>
4520         <para>
4521           Match rules can also be used for eavesdropping
4522           (see <xref linkend="message-bus-routing-eavesdropping"/>),
4523           if the security policy of the message bus allows it.
4524         </para>
4525         <para>
4526           Match rules are added using the AddMatch bus method 
4527           (see <xref linkend="bus-messages-add-match"/>).  Rules are
4528           specified as a string of comma separated key/value pairs. 
4529           Excluding a key from the rule indicates a wildcard match.  
4530           For instance excluding the the member from a match rule but 
4531           adding a sender would let all messages from that sender through.
4532           An example of a complete rule would be 
4533           "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='Foo',path='/bar/foo',destination=':452345.34',arg2='bar'"
4534         </para>
4535         <para>
4536           The following table describes the keys that can be used to create 
4537           a match rule.
4538           <informaltable>
4539             <tgroup cols="3">
4540               <thead>
4541                 <row>
4542                   <entry>Key</entry>
4543                   <entry>Possible Values</entry>
4544                   <entry>Description</entry>
4545                 </row>
4546               </thead>
4547               <tbody>
4548                 <row>
4549                   <entry><literal>type</literal></entry>
4550                   <entry>'signal', 'method_call', 'method_return', 'error'</entry>
4551                   <entry>Match on the message type.  An example of a type match is type='signal'</entry>
4552                 </row>
4553                 <row>
4554                   <entry><literal>sender</literal></entry>
4555                   <entry>A bus or unique name (see <xref linkend="term-bus-name"/>
4556                   and <xref linkend="term-unique-name"/> respectively)
4557                   </entry>
4558                   <entry>Match messages sent by a particular sender.  An example of a sender match
4559                   is sender='org.freedesktop.Hal'</entry>
4560                 </row>
4561                 <row>
4562                   <entry><literal>interface</literal></entry>
4563                   <entry>An interface name (see <xref linkend="message-protocol-names-interface"/>)</entry>
4564                   <entry>Match messages sent over or to a particular interface.  An example of an
4565                   interface match is interface='org.freedesktop.Hal.Manager'.
4566                   If a message omits the interface header, it must not match any rule 
4567                   that specifies this key.</entry>
4568                 </row>
4569                 <row>
4570                   <entry><literal>member</literal></entry>
4571                   <entry>Any valid method or signal name</entry>
4572                   <entry>Matches messages which have the give method or signal name. An example of
4573                   a member match is member='NameOwnerChanged'</entry>
4574                 </row>
4575                 <row>
4576                   <entry><literal>path</literal></entry>
4577                   <entry>An object path (see <xref linkend="message-protocol-marshaling-object-path"/>)</entry>
4578                   <entry>Matches messages which are sent from or to the given object. An example of a
4579                   path match is path='/org/freedesktop/Hal/Manager'</entry>
4580                 </row>
4581                 <row>
4582                   <entry><literal>path_namespace</literal></entry>
4583                   <entry>An object path</entry>
4584                   <entry>
4585                     <para>
4586                       Matches messages which are sent from or to an
4587                       object for which the object path is either the
4588                       given value, or that value followed by one or
4589                       more path components.
4590                     </para>
4591
4592                     <para>
4593                       For example,
4594                       <literal>path_namespace='/com/example/foo'</literal>
4595                       would match signals sent by
4596                       <literal>/com/example/foo</literal>
4597                       or by
4598                       <literal>/com/example/foo/bar</literal>,
4599                       but not by
4600                       <literal>/com/example/foobar</literal>.
4601                     </para>
4602
4603                     <para>
4604                       Using both <literal>path</literal> and
4605                       <literal>path_namespace</literal> in the same match
4606                       rule is not allowed.
4607                     </para>
4608
4609                     <para>
4610                       <emphasis>
4611                         This match key was added in version 0.16 of the
4612                         D-Bus specification and implemented by the bus
4613                         daemon in dbus 1.5.0 and later.
4614                       </emphasis>
4615                     </para>
4616                 </entry>
4617                 </row>
4618                 <row>
4619                   <entry><literal>destination</literal></entry>
4620                   <entry>A unique name (see <xref linkend="term-unique-name"/>)</entry>
4621                   <entry>Matches messages which are being sent to the given unique name. An
4622                   example of a destination match is destination=':1.0'</entry>
4623                 </row>
4624                 <row>
4625                   <entry><literal>arg[0, 1, 2, 3, ...]</literal></entry>
4626                   <entry>Any string</entry>
4627                   <entry>Arg matches are special and are used for further restricting the 
4628                   match based on the arguments in the body of a message. Only arguments of type
4629                   STRING can be matched in this way. An example of an argument match 
4630                   would be arg3='Foo'. Only argument indexes from 0 to 63 should be 
4631                   accepted.</entry>
4632                 </row>
4633                 <row>
4634                   <entry><literal>arg[0, 1, 2, 3, ...]path</literal></entry>
4635                   <entry>Any string</entry>
4636                   <entry>
4637                     <para>Argument path matches provide a specialised form of wildcard matching for
4638                       path-like namespaces. They can match arguments whose type is either STRING or
4639                       OBJECT_PATH. As with normal argument matches,
4640                       if the argument is exactly equal to the string given in the match
4641                       rule then the rule is satisfied. Additionally, there is also a
4642                       match when either the string given in the match rule or the
4643                       appropriate message argument ends with '/' and is a prefix of the
4644                       other. An example argument path match is arg0path='/aa/bb/'. This
4645                       would match messages with first arguments of '/', '/aa/',
4646                       '/aa/bb/', '/aa/bb/cc/' and '/aa/bb/cc'. It would not match
4647                       messages with first arguments of '/aa/b', '/aa' or even '/aa/bb'.</para>
4648
4649                     <para>This is intended for monitoring “directories” in file system-like
4650                       hierarchies, as used in the <citetitle>dconf</citetitle> configuration
4651                       system. An application interested in all nodes in a particular hierarchy would
4652                       monitor <literal>arg0path='/ca/example/foo/'</literal>. Then the service could
4653                       emit a signal with zeroth argument <literal>"/ca/example/foo/bar"</literal> to
4654                       represent a modification to the “bar” property, or a signal with zeroth
4655                       argument <literal>"/ca/example/"</literal> to represent atomic modification of
4656                       many properties within that directory, and the interested application would be
4657                       notified in both cases.</para>
4658                     <para>
4659                       <emphasis>
4660                         This match key was added in version 0.12 of the
4661                         D-Bus specification, implemented for STRING
4662                         arguments by the bus daemon in dbus 1.2.0 and later,
4663                         and implemented for OBJECT_PATH arguments in dbus 1.5.0
4664                         and later.
4665                       </emphasis>
4666                     </para>
4667                   </entry>
4668                 </row>
4669                 <row>
4670                   <entry><literal>arg0namespace</literal></entry>
4671                   <entry>Like a bus name, except that the string is not
4672                     required to contain a '.' (period)</entry>
4673                   <entry>
4674                     <para>Match messages whose first argument is of type STRING, and is a bus name
4675                       or interface name within the specified namespace. This is primarily intended
4676                       for watching name owner changes for a group of related bus names, rather than
4677                       for a single name or all name changes.</para>
4678
4679                     <para>Because every valid interface name is also a valid
4680                       bus name, this can also be used for messages whose
4681                       first argument is an interface name.</para>
4682
4683                     <para>For example, the match rule
4684                       <literal>member='NameOwnerChanged',arg0namespace='com.example.backend'</literal>
4685                       matches name owner changes for bus names such as
4686                       <literal>com.example.backend.foo</literal>,
4687                       <literal>com.example.backend.foo.bar</literal>, and
4688                       <literal>com.example.backend</literal> itself.</para>
4689
4690                     <para>See also <xref linkend='bus-messages-name-owner-changed'/>.</para>
4691                     <para>
4692                       <emphasis>
4693                         This match key was added in version 0.16 of the
4694                         D-Bus specification and implemented by the bus
4695                         daemon in dbus 1.5.0 and later.
4696                       </emphasis>
4697                     </para>
4698                   </entry>
4699                 </row>
4700                 <row>
4701                   <entry><literal>eavesdrop</literal></entry>
4702                   <entry><literal>'true'</literal>, <literal>'false'</literal></entry>
4703                   <entry>Since D-Bus 1.5.6, match rules do not
4704                     match messages which have a <literal>DESTINATION</literal>
4705                     field unless the match rule specifically
4706                     requests this
4707                     (see <xref linkend="message-bus-routing-eavesdropping"/>)
4708                     by specifying <literal>eavesdrop='true'</literal>
4709                     in the match rule.  <literal>eavesdrop='false'</literal>
4710                     restores the default behaviour. Messages are
4711                     delivered to their <literal>DESTINATION</literal>
4712                     regardless of match rules, so this match does not
4713                     affect normal delivery of unicast messages.
4714                     If the message bus has a security policy which forbids
4715                     eavesdropping, this match may still be used without error,
4716                     but will not have any practical effect.
4717                     In older versions of D-Bus, this match was not allowed
4718                     in match rules, and all match rules behaved as if
4719                     <literal>eavesdrop='true'</literal> had been used.
4720                   </entry>
4721                 </row>
4722               </tbody>
4723             </tgroup>
4724           </informaltable>
4725         </para>
4726       </sect3>
4727     </sect2>
4728     <sect2 id="message-bus-starting-services">
4729       <title>Message Bus Starting Services</title>
4730       <para>
4731         The message bus can start applications on behalf of other applications.
4732         In CORBA terms, this would be called <firstterm>activation</firstterm>.
4733         An application that can be started in this way is called a
4734         <firstterm>service</firstterm>.
4735       </para>
4736       <para>
4737         With D-Bus, starting a service is normally done by name. That is,
4738         applications ask the message bus to start some program that will own a
4739         well-known name, such as <literal>com.example.TextEditor</literal>.
4740         This implies a contract documented along with the name
4741         <literal>com.example.TextEditor</literal> for which object
4742         the owner of that name will provide, and what interfaces those 
4743         objects will have.
4744       </para>
4745       <para>
4746         To find an executable corresponding to a particular name, the bus daemon
4747         looks for <firstterm>service description files</firstterm>.  Service
4748         description files define a mapping from names to executables. Different
4749         kinds of message bus will look for these files in different places, see
4750         <xref linkend="message-bus-types"/>.
4751       </para>
4752       <para>
4753         Service description files have the ".service" file
4754         extension. The message bus will only load service description files
4755         ending with .service; all other files will be ignored.  The file format
4756         is similar to that of <ulink
4757         url="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html">desktop
4758         entries</ulink>. All service description files must be in UTF-8
4759         encoding. To ensure that there will be no name collisions, service files
4760         must be namespaced using the same mechanism as messages and service
4761         names.
4762       </para>
4763
4764       <para>
4765         On the well-known system bus, the name of a service description file
4766         must be its well-known name plus <literal>.service</literal>,
4767         for instance
4768         <literal>com.example.ConfigurationDatabase.service</literal>.
4769       </para>
4770
4771       <para>
4772         On the well-known session bus, services should follow the same
4773         service description file naming convention as on the system bus,
4774         but for backwards compatibility they are not required to do so.
4775       </para>
4776
4777       <para>
4778         [FIXME the file format should be much better specified than "similar to
4779         .desktop entries" esp. since desktop entries are already
4780         badly-specified. ;-)]
4781         These sections from the specification apply to service files as well:
4782
4783         <itemizedlist>
4784           <listitem><para>General syntax</para></listitem>
4785           <listitem><para>Comment format</para></listitem>
4786         </itemizedlist>
4787
4788         Service description files must contain a
4789         <literal>D-BUS Service</literal> group with at least the keys
4790         <literal>Name</literal> (the well-known name of the service)
4791         and <literal>Exec</literal> (the command to be executed).
4792
4793         <figure>
4794           <title>Example service description file</title>
4795           <programlisting>
4796             # Sample service description file
4797             [D-BUS Service]
4798             Name=com.example.ConfigurationDatabase
4799             Exec=/usr/bin/sample-configd
4800           </programlisting>
4801         </figure>
4802       </para>
4803
4804       <para>
4805         Additionally, service description files for the well-known system
4806         bus on Unix must contain a <literal>User</literal> key, whose value
4807         is the name of a user account (e.g. <literal>root</literal>).
4808         The system service will be run as that user.
4809       </para>
4810
4811       <para>
4812         When an application asks to start a service by name, the bus daemon tries to
4813         find a service that will own that name. It then tries to spawn the
4814         executable associated with it. If this fails, it will report an
4815         error.
4816       </para>
4817
4818       <para>
4819         On the well-known system bus, it is not possible for two .service files
4820         in the same directory to offer the same service, because they are
4821         constrained to have names that match the service name.
4822       </para>
4823
4824       <para>
4825         On the well-known session bus, if two .service files in the same
4826         directory offer the same service name, the result is undefined.
4827         Distributors should avoid this situation, for instance by naming
4828         session services' .service files according to their service name.
4829       </para>
4830
4831       <para>
4832         If two .service files in different directories offer the same
4833         service name, the one in the higher-priority directory is used:
4834         for instance, on the system bus, .service files in
4835         /usr/local/share/dbus-1/system-services take precedence over those
4836         in /usr/share/dbus-1/system-services.
4837       </para>
4838       <para>
4839         The executable launched will have the environment variable
4840         <literal>DBUS_STARTER_ADDRESS</literal> set to the address of the
4841         message bus so it can connect and request the appropriate names.
4842       </para>
4843       <para>
4844         The executable being launched may want to know whether the message bus
4845         starting it is one of the well-known message buses (see <xref
4846         linkend="message-bus-types"/>). To facilitate this, the bus must also set
4847         the <literal>DBUS_STARTER_BUS_TYPE</literal> environment variable if it is one
4848         of the well-known buses. The currently-defined values for this variable
4849         are <literal>system</literal> for the systemwide message bus,
4850         and <literal>session</literal> for the per-login-session message
4851         bus. The new executable must still connect to the address given
4852         in <literal>DBUS_STARTER_ADDRESS</literal>, but may assume that the
4853         resulting connection is to the well-known bus.
4854       </para>
4855       <para>
4856         [FIXME there should be a timeout somewhere, either specified
4857         in the .service file, by the client, or just a global value
4858         and if the client being activated fails to connect within that
4859         timeout, an error should be sent back.]
4860       </para>
4861
4862       <sect3 id="message-bus-starting-services-scope">
4863         <title>Message Bus Service Scope</title>
4864         <para>
4865           The "scope" of a service is its "per-", such as per-session,
4866           per-machine, per-home-directory, or per-display. The reference
4867           implementation doesn't yet support starting services in a different
4868           scope from the message bus itself. So e.g. if you start a service
4869           on the session bus its scope is per-session.
4870         </para>
4871         <para>
4872           We could add an optional scope to a bus name. For example, for
4873           per-(display,session pair), we could have a unique ID for each display
4874           generated automatically at login and set on screen 0 by executing a
4875           special "set display ID" binary. The ID would be stored in a
4876           <literal>_DBUS_DISPLAY_ID</literal> property and would be a string of
4877           random bytes. This ID would then be used to scope names.
4878           Starting/locating a service could be done by ID-name pair rather than
4879           only by name.
4880         </para>
4881         <para>
4882           Contrast this with a per-display scope. To achieve that, we would 
4883           want a single bus spanning all sessions using a given display.
4884           So we might set a <literal>_DBUS_DISPLAY_BUS_ADDRESS</literal> 
4885           property on screen 0 of the display, pointing to this bus.
4886         </para>
4887       </sect3>
4888     </sect2>
4889
4890     <sect2 id="message-bus-types">
4891       <title>Well-known Message Bus Instances</title>
4892       <para>
4893         Two standard message bus instances are defined here, along with how 
4894         to locate them and where their service files live.
4895       </para>
4896       <sect3 id="message-bus-types-login">
4897         <title>Login session message bus</title>
4898         <para>
4899           Each time a user logs in, a <firstterm>login session message
4900             bus</firstterm> may be started. All applications in the user's login
4901           session may interact with one another using this message bus.
4902         </para>
4903         <para>
4904           The address of the login session message bus is given 
4905           in the <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment 
4906           variable. If that variable is not set, applications may 
4907           also try to read the address from the X Window System root 
4908           window property <literal>_DBUS_SESSION_BUS_ADDRESS</literal>.
4909           The root window property must have type <literal>STRING</literal>.
4910           The environment variable should have precedence over the 
4911           root window property.
4912         </para>
4913         <para>The address of the login session message bus is given in the
4914         <literal>DBUS_SESSION_BUS_ADDRESS</literal> environment variable. If
4915         DBUS_SESSION_BUS_ADDRESS is not set, or if it's set to the string
4916         "autolaunch:", the system should use platform-specific methods of
4917         locating a running D-Bus session server, or starting one if a running
4918         instance cannot be found. Note that this mechanism is not recommended
4919         for attempting to determine if a daemon is running. It is inherently
4920         racy to attempt to make this determination, since the bus daemon may
4921         be started just before or just after the determination is made.
4922         Therefore, it is recommended that applications do not try to make this
4923         determination for their functionality purposes, and instead they
4924         should attempt to start the server.</para>
4925
4926         <sect4 id="message-bus-types-login-x-windows">
4927           <title>X Windowing System</title>
4928           <para>
4929             For the X Windowing System, the application must locate the
4930             window owner of the selection represented by the atom formed by
4931             concatenating:
4932             <itemizedlist>
4933               <listitem>
4934                 <para>the literal string "_DBUS_SESSION_BUS_SELECTION_"</para>
4935               </listitem>
4936
4937               <listitem>
4938                 <para>the current user's username</para>
4939               </listitem>
4940
4941               <listitem>
4942                 <para>the literal character '_' (underscore)</para>
4943               </listitem>
4944
4945               <listitem>
4946                 <para>the machine's ID</para>
4947               </listitem>
4948             </itemizedlist>
4949           </para>
4950
4951           <para>
4952             The following properties are defined for the window that owns
4953             this X selection:
4954             <informaltable frame="all">
4955               <tgroup cols="2">
4956                 <tbody>
4957                   <row>
4958                     <entry>
4959                       <para>Atom</para>
4960                     </entry>
4961
4962                     <entry>
4963                       <para>meaning</para>
4964                     </entry>
4965                   </row>
4966
4967                   <row>
4968                     <entry>
4969                       <para>_DBUS_SESSION_BUS_ADDRESS</para>
4970                     </entry>
4971
4972                     <entry>
4973                       <para>the actual address of the server socket</para>
4974                     </entry>
4975                   </row>
4976
4977                   <row>
4978                     <entry>
4979                       <para>_DBUS_SESSION_BUS_PID</para>
4980                     </entry>
4981
4982                     <entry>
4983                       <para>the PID of the server process</para>
4984                     </entry>
4985                   </row>
4986                 </tbody>
4987               </tgroup>
4988             </informaltable>
4989           </para>
4990
4991           <para>
4992             At least the _DBUS_SESSION_BUS_ADDRESS property MUST be
4993             present in this window.
4994           </para>
4995
4996           <para>
4997             If the X selection cannot be located or if reading the
4998             properties from the window fails, the implementation MUST conclude
4999             that there is no D-Bus server running and proceed to start a new
5000             server. (See below on concurrency issues)
5001           </para>
5002
5003           <para>
5004             Failure to connect to the D-Bus server address thus obtained
5005             MUST be treated as a fatal connection error and should be reported
5006             to the application.
5007           </para>
5008
5009           <para>
5010             As an alternative, an implementation MAY find the information
5011             in the following file located in the current user's home directory,
5012             in subdirectory .dbus/session-bus/:
5013             <itemizedlist>
5014               <listitem>
5015                 <para>the machine's ID</para>
5016               </listitem>
5017
5018               <listitem>
5019                 <para>the literal character '-' (dash)</para>
5020               </listitem>
5021
5022               <listitem>
5023                 <para>the X display without the screen number, with the
5024                 following prefixes removed, if present: ":", "localhost:"
5025                 ."localhost.localdomain:". That is, a display of
5026                 "localhost:10.0" produces just the number "10"</para>
5027               </listitem>
5028             </itemizedlist>
5029           </para>
5030
5031           <para>
5032             The contents of this file NAME=value assignment pairs and
5033             lines starting with # are comments (no comments are allowed
5034             otherwise). The following variable names are defined:
5035             <informaltable
5036               frame="all">
5037               <tgroup cols="2">
5038                 <tbody>
5039                   <row>
5040                     <entry>
5041                       <para>Variable</para>
5042                     </entry>
5043
5044                     <entry>
5045                       <para>meaning</para>
5046                     </entry>
5047                   </row>
5048
5049                   <row>
5050                     <entry>
5051                       <para>DBUS_SESSION_BUS_ADDRESS</para>
5052                     </entry>
5053
5054                     <entry>
5055                       <para>the actual address of the server socket</para>
5056                     </entry>
5057                   </row>
5058
5059                   <row>
5060                     <entry>
5061                       <para>DBUS_SESSION_BUS_PID</para>
5062                     </entry>
5063
5064                     <entry>
5065                       <para>the PID of the server process</para>
5066                     </entry>
5067                   </row>
5068
5069                   <row>
5070                     <entry>
5071                       <para>DBUS_SESSION_BUS_WINDOWID</para>
5072                     </entry>
5073
5074                     <entry>
5075                       <para>the window ID</para>
5076                     </entry>
5077                   </row>
5078                 </tbody>
5079               </tgroup>
5080             </informaltable>
5081           </para>
5082
5083           <para>
5084             At least the DBUS_SESSION_BUS_ADDRESS variable MUST be present
5085             in this file.
5086           </para>
5087
5088           <para>
5089             Failure to open this file MUST be interpreted as absence of a
5090             running server. Therefore, the implementation MUST proceed to
5091             attempting to launch a new bus server if the file cannot be
5092             opened.
5093           </para>
5094
5095           <para>
5096             However, success in opening this file MUST NOT lead to the
5097             conclusion that the server is running. Thus, a failure to connect to
5098             the bus address obtained by the alternative method MUST NOT be
5099             considered a fatal error. If the connection cannot be established,
5100             the implementation MUST proceed to check the X selection settings or
5101             to start the server on its own.
5102           </para>
5103
5104           <para>
5105             If the implementation concludes that the D-Bus server is not
5106             running it MUST attempt to start a new server and it MUST also
5107             ensure that the daemon started as an effect of the "autolaunch"
5108             mechanism provides the lookup mechanisms described above, so
5109             subsequent calls can locate the newly started server. The
5110             implementation MUST also ensure that if two or more concurrent
5111             initiations happen, only one server remains running and all other
5112             initiations are able to obtain the address of this server and
5113             connect to it. In other words, the implementation MUST ensure that
5114             the X selection is not present when it attempts to set it, without
5115             allowing another process to set the selection between the
5116             verification and the setting (e.g., by using XGrabServer /
5117             XungrabServer).
5118           </para>
5119         </sect4>
5120         <sect4>
5121           <title></title>
5122           <para>
5123             On Unix systems, the session bus should search for .service files
5124             in <literal>$XDG_DATA_DIRS/dbus-1/services</literal> as defined
5125             by the
5126             <ulink url="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory Specification</ulink>.
5127             Implementations may also search additional locations, which
5128             should be searched with lower priority than anything in
5129             XDG_DATA_HOME, XDG_DATA_DIRS or their respective defaults;
5130             for example, the reference implementation also
5131             looks in <literal>${datadir}/dbus-1/services</literal> as
5132             set at compile time.
5133           </para>
5134           <para>
5135             As described in the XDG Base Directory Specification, software
5136             packages should install their session .service files to their
5137             configured <literal>${datadir}/dbus-1/services</literal>,
5138             where <literal>${datadir}</literal> is as defined by the GNU
5139             coding standards. System administrators or users can arrange
5140             for these service files to be read by setting XDG_DATA_DIRS or by
5141             symlinking them into the default locations.
5142           </para>
5143         </sect4>
5144       </sect3>
5145       <sect3 id="message-bus-types-system">
5146         <title>System message bus</title>
5147         <para>
5148           A computer may have a <firstterm>system message bus</firstterm>,
5149           accessible to all applications on the system. This message bus may be
5150           used to broadcast system events, such as adding new hardware devices, 
5151           changes in the printer queue, and so forth.
5152         </para>
5153         <para>
5154           The address of the system message bus is given 
5155           in the <literal>DBUS_SYSTEM_BUS_ADDRESS</literal> environment 
5156           variable. If that variable is not set, applications should try 
5157           to connect to the well-known address
5158           <literal>unix:path=/var/run/dbus/system_bus_socket</literal>.
5159           <footnote>
5160             <para>
5161               The D-Bus reference implementation actually honors the 
5162               <literal>$(localstatedir)</literal> configure option 
5163               for this address, on both client and server side.
5164             </para>
5165           </footnote>
5166         </para>
5167         <para>
5168           On Unix systems, the system bus should default to searching
5169           for .service files in
5170           <literal>/usr/local/share/dbus-1/system-services</literal>,
5171           <literal>/usr/share/dbus-1/system-services</literal> and
5172           <literal>/lib/dbus-1/system-services</literal>, with that order
5173           of precedence. It may also search other implementation-specific
5174           locations, but should not vary these locations based on environment
5175           variables.
5176           <footnote>
5177             <para>
5178               The system bus is security-sensitive and is typically executed
5179               by an init system with a clean environment. Its launch helper
5180               process is particularly security-sensitive, and specifically
5181               clears its own environment.
5182             </para>
5183           </footnote>
5184         </para>
5185         <para>
5186           Software packages should install their system .service
5187           files to their configured
5188           <literal>${datadir}/dbus-1/system-services</literal>,
5189           where <literal>${datadir}</literal> is as defined by the GNU
5190           coding standards. System administrators can arrange
5191           for these service files to be read by editing the system bus'
5192           configuration file or by symlinking them into the default
5193           locations.
5194         </para>
5195       </sect3>
5196     </sect2>
5197
5198     <sect2 id="message-bus-messages">
5199       <title>Message Bus Messages</title>
5200       <para>
5201         The special message bus name <literal>org.freedesktop.DBus</literal>
5202         responds to a number of additional messages.
5203       </para>
5204
5205       <sect3 id="bus-messages-hello">
5206         <title><literal>org.freedesktop.DBus.Hello</literal></title>
5207         <para>
5208           As a method:
5209           <programlisting>
5210             STRING Hello ()
5211           </programlisting>
5212           Reply arguments:
5213           <informaltable>
5214             <tgroup cols="3">
5215               <thead>
5216                 <row>
5217                   <entry>Argument</entry>
5218                   <entry>Type</entry>
5219                   <entry>Description</entry>
5220                 </row>
5221               </thead>
5222               <tbody>
5223                 <row>
5224                   <entry>0</entry>
5225                   <entry>STRING</entry>
5226                   <entry>Unique name assigned to the connection</entry>
5227                 </row>
5228               </tbody>
5229             </tgroup>
5230           </informaltable>
5231         </para>
5232         <para>
5233           Before an application is able to send messages to other applications
5234           it must send the <literal>org.freedesktop.DBus.Hello</literal> message
5235           to the message bus to obtain a unique name. If an application without
5236           a unique name tries to send a message to another application, or a
5237           message to the message bus itself that isn't the
5238           <literal>org.freedesktop.DBus.Hello</literal> message, it will be
5239           disconnected from the bus.
5240         </para>
5241         <para>
5242           There is no corresponding "disconnect" request; if a client wishes to
5243           disconnect from the bus, it simply closes the socket (or other 
5244           communication channel).
5245         </para>
5246       </sect3>
5247       <sect3 id="bus-messages-list-names">
5248         <title><literal>org.freedesktop.DBus.ListNames</literal></title>
5249         <para>
5250           As a method:
5251           <programlisting>
5252             ARRAY of STRING ListNames ()
5253           </programlisting>
5254           Reply arguments:
5255           <informaltable>
5256             <tgroup cols="3">
5257               <thead>
5258                 <row>
5259                   <entry>Argument</entry>
5260                   <entry>Type</entry>
5261                   <entry>Description</entry>
5262                 </row>
5263               </thead>
5264               <tbody>
5265                 <row>
5266                   <entry>0</entry>
5267                   <entry>ARRAY of STRING</entry>
5268                   <entry>Array of strings where each string is a bus name</entry>
5269                 </row>
5270               </tbody>
5271             </tgroup>
5272           </informaltable>
5273         </para>
5274         <para>
5275           Returns a list of all currently-owned names on the bus.
5276         </para>
5277       </sect3>
5278       <sect3 id="bus-messages-list-activatable-names">
5279         <title><literal>org.freedesktop.DBus.ListActivatableNames</literal></title>
5280         <para>
5281           As a method:
5282           <programlisting>
5283             ARRAY of STRING ListActivatableNames ()
5284           </programlisting>
5285           Reply arguments:
5286           <informaltable>
5287             <tgroup cols="3">
5288               <thead>
5289                 <row>
5290                   <entry>Argument</entry>
5291                   <entry>Type</entry>
5292                   <entry>Description</entry>
5293                 </row>
5294               </thead>
5295               <tbody>
5296                 <row>
5297                   <entry>0</entry>
5298                   <entry>ARRAY of STRING</entry>
5299                   <entry>Array of strings where each string is a bus name</entry>
5300                 </row>
5301               </tbody>
5302             </tgroup>
5303           </informaltable>
5304         </para>
5305         <para>
5306           Returns a list of all names that can be activated on the bus.
5307         </para>
5308       </sect3>
5309       <sect3 id="bus-messages-name-exists">
5310         <title><literal>org.freedesktop.DBus.NameHasOwner</literal></title>
5311         <para>
5312           As a method:
5313           <programlisting>
5314             BOOLEAN NameHasOwner (in STRING name)
5315           </programlisting>
5316           Message arguments:
5317           <informaltable>
5318             <tgroup cols="3">
5319               <thead>
5320                 <row>
5321                   <entry>Argument</entry>
5322                   <entry>Type</entry>
5323                   <entry>Description</entry>
5324                 </row>
5325               </thead>
5326               <tbody>
5327                 <row>
5328                   <entry>0</entry>
5329                   <entry>STRING</entry>
5330                   <entry>Name to check</entry>
5331                 </row>
5332               </tbody>
5333             </tgroup>
5334           </informaltable>
5335           Reply arguments:
5336           <informaltable>
5337             <tgroup cols="3">
5338               <thead>
5339                 <row>
5340                   <entry>Argument</entry>
5341                   <entry>Type</entry>
5342                   <entry>Description</entry>
5343                 </row>
5344               </thead>
5345               <tbody>
5346                 <row>
5347                   <entry>0</entry>
5348                   <entry>BOOLEAN</entry>
5349                   <entry>Return value, true if the name exists</entry>
5350                 </row>
5351               </tbody>
5352             </tgroup>
5353           </informaltable>
5354         </para>
5355         <para>
5356           Checks if the specified name exists (currently has an owner).
5357         </para>
5358       </sect3>
5359
5360       <sect3 id="bus-messages-name-owner-changed">
5361         <title><literal>org.freedesktop.DBus.NameOwnerChanged</literal></title>
5362         <para>
5363           This is a signal:
5364           <programlisting>
5365             NameOwnerChanged (STRING name, STRING old_owner, STRING new_owner)
5366           </programlisting>
5367           Message arguments:
5368           <informaltable>
5369             <tgroup cols="3">
5370               <thead>
5371                 <row>
5372                   <entry>Argument</entry>
5373                   <entry>Type</entry>
5374                   <entry>Description</entry>
5375                 </row>
5376               </thead>
5377               <tbody>
5378                 <row>
5379                   <entry>0</entry>
5380                   <entry>STRING</entry>
5381                   <entry>Name with a new owner</entry>
5382                 </row>
5383                 <row>
5384                   <entry>1</entry>
5385                   <entry>STRING</entry>
5386                   <entry>Old owner or empty string if none</entry>
5387                 </row>
5388                 <row>
5389                   <entry>2</entry>
5390                   <entry>STRING</entry>
5391                   <entry>New owner or empty string if none</entry>
5392                 </row>
5393               </tbody>
5394             </tgroup>
5395           </informaltable>
5396         </para>
5397         <para>
5398           This signal indicates that the owner of a name has changed.
5399           It's also the signal to use to detect the appearance of 
5400           new names on the bus.
5401         </para>
5402       </sect3>
5403       <sect3 id="bus-messages-name-lost">
5404         <title><literal>org.freedesktop.DBus.NameLost</literal></title>
5405         <para>
5406           This is a signal:
5407           <programlisting>
5408             NameLost (STRING name)
5409           </programlisting>
5410           Message arguments:
5411           <informaltable>
5412             <tgroup cols="3">
5413               <thead>
5414                 <row>
5415                   <entry>Argument</entry>
5416                   <entry>Type</entry>
5417                   <entry>Description</entry>
5418                 </row>
5419               </thead>
5420               <tbody>
5421                 <row>
5422                   <entry>0</entry>
5423                   <entry>STRING</entry>
5424                   <entry>Name which was lost</entry>
5425                 </row>
5426               </tbody>
5427             </tgroup>
5428           </informaltable>
5429         </para>
5430         <para>
5431           This signal is sent to a specific application when it loses
5432           ownership of a name.
5433         </para>
5434       </sect3>
5435
5436       <sect3 id="bus-messages-name-acquired">
5437         <title><literal>org.freedesktop.DBus.NameAcquired</literal></title>
5438         <para>
5439           This is a signal:
5440           <programlisting>
5441             NameAcquired (STRING name)
5442           </programlisting>
5443           Message arguments:
5444           <informaltable>
5445             <tgroup cols="3">
5446               <thead>
5447                 <row>
5448                   <entry>Argument</entry>
5449                   <entry>Type</entry>
5450                   <entry>Description</entry>
5451                 </row>
5452               </thead>
5453               <tbody>
5454                 <row>
5455                   <entry>0</entry>
5456                   <entry>STRING</entry>
5457                   <entry>Name which was acquired</entry>
5458                 </row>
5459               </tbody>
5460             </tgroup>
5461           </informaltable>
5462         </para>
5463         <para>
5464           This signal is sent to a specific application when it gains
5465           ownership of a name.
5466         </para>
5467       </sect3>
5468
5469       <sect3 id="bus-messages-start-service-by-name">
5470         <title><literal>org.freedesktop.DBus.StartServiceByName</literal></title>
5471         <para>
5472           As a method:
5473           <programlisting>
5474             UINT32 StartServiceByName (in STRING name, in UINT32 flags)
5475           </programlisting>
5476           Message arguments:
5477           <informaltable>
5478             <tgroup cols="3">
5479               <thead>
5480                 <row>
5481                   <entry>Argument</entry>
5482                   <entry>Type</entry>
5483                   <entry>Description</entry>
5484                 </row>
5485               </thead>
5486               <tbody>
5487                 <row>
5488                   <entry>0</entry>
5489                   <entry>STRING</entry>
5490                   <entry>Name of the service to start</entry>
5491                 </row>
5492                 <row>
5493                   <entry>1</entry>
5494                   <entry>UINT32</entry>
5495                   <entry>Flags (currently not used)</entry>
5496                 </row>
5497               </tbody>
5498             </tgroup>
5499           </informaltable>
5500         Reply arguments:
5501         <informaltable>
5502           <tgroup cols="3">
5503             <thead>
5504               <row>
5505                 <entry>Argument</entry>
5506                 <entry>Type</entry>
5507                 <entry>Description</entry>
5508               </row>
5509             </thead>
5510             <tbody>
5511               <row>
5512                 <entry>0</entry>
5513                 <entry>UINT32</entry>
5514                 <entry>Return value</entry>
5515               </row>
5516             </tbody>
5517           </tgroup>
5518         </informaltable>
5519           Tries to launch the executable associated with a name. For more information, see <xref linkend="message-bus-starting-services"/>.
5520
5521         </para>
5522         <para>
5523           The return value can be one of the following values:
5524           <informaltable>
5525             <tgroup cols="3">
5526               <thead>
5527                 <row>
5528                   <entry>Identifier</entry>
5529                   <entry>Value</entry>
5530                   <entry>Description</entry>
5531                 </row>
5532               </thead>
5533               <tbody>
5534                 <row>
5535                   <entry>DBUS_START_REPLY_SUCCESS</entry>
5536                   <entry>1</entry>
5537                   <entry>The service was successfully started.</entry>
5538                 </row>
5539                 <row>
5540                   <entry>DBUS_START_REPLY_ALREADY_RUNNING</entry>
5541                   <entry>2</entry>
5542                   <entry>A connection already owns the given name.</entry>
5543                 </row>
5544               </tbody>
5545              </tgroup>
5546            </informaltable>
5547         </para>
5548
5549       </sect3>
5550
5551       <sect3 id="bus-messages-update-activation-environment">
5552         <title><literal>org.freedesktop.DBus.UpdateActivationEnvironment</literal></title>
5553         <para>
5554           As a method:
5555           <programlisting>
5556             UpdateActivationEnvironment (in ARRAY of DICT&lt;STRING,STRING&gt; environment)
5557           </programlisting>
5558           Message arguments:
5559           <informaltable>
5560             <tgroup cols="3">
5561               <thead>
5562                 <row>
5563                   <entry>Argument</entry>
5564                   <entry>Type</entry>
5565                   <entry>Description</entry>
5566                 </row>
5567               </thead>
5568               <tbody>
5569                 <row>
5570                   <entry>0</entry>
5571                   <entry>ARRAY of DICT&lt;STRING,STRING&gt;</entry>
5572                   <entry>Environment to add or update</entry>
5573                 </row>
5574               </tbody>
5575             </tgroup>
5576             </informaltable>
5577             Normally, session bus activated services inherit the environment of the bus daemon.  This method adds to or modifies that environment when activating services.
5578         </para>
5579         <para>
5580           Some bus instances, such as the standard system bus, may disable access to this method for some or all callers.
5581         </para>
5582         <para>
5583           Note, both the environment variable names and values must be valid UTF-8.  There's no way to update the activation environment with data that is invalid UTF-8.
5584         </para>
5585
5586       </sect3>
5587
5588       <sect3 id="bus-messages-get-name-owner">
5589         <title><literal>org.freedesktop.DBus.GetNameOwner</literal></title>
5590         <para>
5591           As a method:
5592           <programlisting>
5593             STRING GetNameOwner (in STRING name)
5594           </programlisting>
5595           Message arguments:
5596           <informaltable>
5597             <tgroup cols="3">
5598               <thead>
5599                 <row>
5600                   <entry>Argument</entry>
5601                   <entry>Type</entry>
5602                   <entry>Description</entry>
5603                 </row>
5604               </thead>
5605               <tbody>
5606                 <row>
5607                   <entry>0</entry>
5608                   <entry>STRING</entry>
5609                   <entry>Name to get the owner of</entry>
5610                 </row>
5611               </tbody>
5612             </tgroup>
5613           </informaltable>
5614         Reply arguments:
5615         <informaltable>
5616           <tgroup cols="3">
5617             <thead>
5618               <row>
5619                 <entry>Argument</entry>
5620                 <entry>Type</entry>
5621                 <entry>Description</entry>
5622               </row>
5623             </thead>
5624             <tbody>
5625               <row>
5626                 <entry>0</entry>
5627                 <entry>STRING</entry>
5628                 <entry>Return value, a unique connection name</entry>
5629               </row>
5630             </tbody>
5631           </tgroup>
5632         </informaltable>
5633         Returns the unique connection name of the primary owner of the name
5634         given. If the requested name doesn't have an owner, returns a
5635         <literal>org.freedesktop.DBus.Error.NameHasNoOwner</literal> error.
5636        </para>
5637       </sect3>
5638
5639       <sect3 id="bus-messages-get-connection-unix-user">
5640         <title><literal>org.freedesktop.DBus.GetConnectionUnixUser</literal></title>
5641         <para>
5642           As a method:
5643           <programlisting>
5644             UINT32 GetConnectionUnixUser (in STRING bus_name)
5645           </programlisting>
5646           Message arguments:
5647           <informaltable>
5648             <tgroup cols="3">
5649               <thead>
5650                 <row>
5651                   <entry>Argument</entry>
5652                   <entry>Type</entry>
5653                   <entry>Description</entry>
5654                 </row>
5655               </thead>
5656               <tbody>
5657                 <row>
5658                   <entry>0</entry>
5659                   <entry>STRING</entry>
5660                   <entry>Unique or well-known bus name of the connection to
5661                     query, such as <literal>:12.34</literal> or
5662                     <literal>com.example.tea</literal></entry>
5663                 </row>
5664               </tbody>
5665             </tgroup>
5666           </informaltable>
5667         Reply arguments:
5668         <informaltable>
5669           <tgroup cols="3">
5670             <thead>
5671               <row>
5672                 <entry>Argument</entry>
5673                 <entry>Type</entry>
5674                 <entry>Description</entry>
5675               </row>
5676             </thead>
5677             <tbody>
5678               <row>
5679                 <entry>0</entry>
5680                 <entry>UINT32</entry>
5681                 <entry>Unix user ID</entry>
5682               </row>
5683             </tbody>
5684           </tgroup>
5685         </informaltable>
5686         Returns the Unix user ID of the process connected to the server. If
5687         unable to determine it (for instance, because the process is not on the
5688         same machine as the bus daemon), an error is returned.
5689        </para>
5690       </sect3>
5691
5692       <sect3 id="bus-messages-get-connection-unix-process-id">
5693         <title><literal>org.freedesktop.DBus.GetConnectionUnixProcessID</literal></title>
5694         <para>
5695           As a method:
5696           <programlisting>
5697             UINT32 GetConnectionUnixProcessID (in STRING bus_name)
5698           </programlisting>
5699           Message arguments:
5700           <informaltable>
5701             <tgroup cols="3">
5702               <thead>
5703                 <row>
5704                   <entry>Argument</entry>
5705                   <entry>Type</entry>
5706                   <entry>Description</entry>
5707                 </row>
5708               </thead>
5709               <tbody>
5710                 <row>
5711                   <entry>0</entry>
5712                   <entry>STRING</entry>
5713                   <entry>Unique or well-known bus name of the connection to
5714                     query, such as <literal>:12.34</literal> or
5715                     <literal>com.example.tea</literal></entry>
5716                 </row>
5717               </tbody>
5718             </tgroup>
5719           </informaltable>
5720         Reply arguments:
5721         <informaltable>
5722           <tgroup cols="3">
5723             <thead>
5724               <row>
5725                 <entry>Argument</entry>
5726                 <entry>Type</entry>
5727                 <entry>Description</entry>
5728               </row>
5729             </thead>
5730             <tbody>
5731               <row>
5732                 <entry>0</entry>
5733                 <entry>UINT32</entry>
5734                 <entry>Unix process id</entry>
5735               </row>
5736             </tbody>
5737           </tgroup>
5738         </informaltable>
5739         Returns the Unix process ID of the process connected to the server. If
5740         unable to determine it (for instance, because the process is not on the
5741         same machine as the bus daemon), an error is returned.
5742        </para>
5743       </sect3>
5744
5745       <sect3 id="bus-messages-get-connection-credentials">
5746         <title><literal>org.freedesktop.DBus.GetConnectionCredentials</literal></title>
5747         <para>
5748           As a method:
5749           <programlisting>
5750             DICT&lt;STRING,VARIANT&gt; GetConnectionCredentials (in STRING bus_name)
5751           </programlisting>
5752           Message arguments:
5753           <informaltable>
5754             <tgroup cols="3">
5755               <thead>
5756                 <row>
5757                   <entry>Argument</entry>
5758                   <entry>Type</entry>
5759                   <entry>Description</entry>
5760                 </row>
5761               </thead>
5762               <tbody>
5763                 <row>
5764                   <entry>0</entry>
5765                   <entry>STRING</entry>
5766                   <entry>Unique or well-known bus name of the connection to
5767                     query, such as <literal>:12.34</literal> or
5768                     <literal>com.example.tea</literal></entry>
5769                 </row>
5770               </tbody>
5771             </tgroup>
5772           </informaltable>
5773         Reply arguments:
5774         <informaltable>
5775           <tgroup cols="3">
5776             <thead>
5777               <row>
5778                 <entry>Argument</entry>
5779                 <entry>Type</entry>
5780                 <entry>Description</entry>
5781               </row>
5782             </thead>
5783             <tbody>
5784               <row>
5785                 <entry>0</entry>
5786                 <entry>DICT&lt;STRING,VARIANT&gt;</entry>
5787                 <entry>Credentials</entry>
5788               </row>
5789             </tbody>
5790           </tgroup>
5791         </informaltable>
5792       </para>
5793
5794       <para>
5795         Returns as many credentials as possible for the process connected to
5796         the server. If unable to determine certain credentials (for instance,
5797         because the process is not on the same machine as the bus daemon,
5798         or because this version of the bus daemon does not support a
5799         particular security framework), or if the values of those credentials
5800         cannot be represented as documented here, then those credentials
5801         are omitted.
5802       </para>
5803
5804       <para>
5805         Keys in the returned dictionary not containing "." are defined
5806         by this specification. Bus daemon implementors supporting
5807         credentials frameworks not mentioned in this document should either
5808         contribute patches to this specification, or use keys containing
5809         "." and starting with a reversed domain name.
5810         <informaltable>
5811           <tgroup cols="3">
5812             <thead>
5813               <row>
5814                 <entry>Key</entry>
5815                 <entry>Value type</entry>
5816                 <entry>Value</entry>
5817               </row>
5818             </thead>
5819             <tbody>
5820               <row>
5821                 <entry>UnixUserID</entry>
5822                 <entry>UINT32</entry>
5823                 <entry>The numeric Unix user ID, as defined by POSIX</entry>
5824               </row>
5825               <row>
5826                 <entry>ProcessID</entry>
5827                 <entry>UINT32</entry>
5828                 <entry>The numeric process ID, on platforms that have
5829                   this concept. On Unix, this is the process ID defined by
5830                   POSIX.</entry>
5831               </row>
5832             </tbody>
5833           </tgroup>
5834         </informaltable>
5835        </para>
5836
5837         <para>
5838           This method was added in D-Bus 1.7 to reduce the round-trips
5839           required to list a process's credentials. In older versions, calling
5840           this method will fail: applications should recover by using the
5841           separate methods such as
5842           <xref linkend="bus-messages-get-connection-unix-user"/>
5843           instead.
5844         </para>
5845       </sect3>
5846
5847       <sect3 id="bus-messages-get-adt-audit-session-data">
5848         <title><literal>org.freedesktop.DBus.GetAdtAuditSessionData</literal></title>
5849         <para>
5850           As a method:
5851           <programlisting>
5852             ARRAY of BYTE GetAdtAuditSessionData (in STRING bus_name)
5853           </programlisting>
5854           Message arguments:
5855           <informaltable>
5856             <tgroup cols="3">
5857               <thead>
5858                 <row>
5859                   <entry>Argument</entry>
5860                   <entry>Type</entry>
5861                   <entry>Description</entry>
5862                 </row>
5863               </thead>
5864               <tbody>
5865                 <row>
5866                   <entry>0</entry>
5867                   <entry>STRING</entry>
5868                   <entry>Unique or well-known bus name of the connection to
5869                     query, such as <literal>:12.34</literal> or
5870                     <literal>com.example.tea</literal></entry>
5871                 </row>
5872               </tbody>
5873             </tgroup>
5874           </informaltable>
5875           Reply arguments:
5876           <informaltable>
5877             <tgroup cols="3">
5878               <thead>
5879                 <row>
5880                   <entry>Argument</entry>
5881                   <entry>Type</entry>
5882                   <entry>Description</entry>
5883                 </row>
5884               </thead>
5885               <tbody>
5886                 <row>
5887                   <entry>0</entry>
5888                   <entry>ARRAY of BYTE</entry>
5889                   <entry>auditing data as returned by
5890                     adt_export_session_data()</entry>
5891                 </row>
5892               </tbody>
5893             </tgroup>
5894           </informaltable>
5895           Returns auditing data used by Solaris ADT, in an unspecified
5896           binary format. If you know what this means, please contribute
5897           documentation via the D-Bus bug tracking system.
5898           This method is on the core DBus interface for historical reasons;
5899           the same information should be made available via
5900           <xref linkend="bus-messages-get-connection-credentials"/>
5901           in future.
5902         </para>
5903       </sect3>
5904
5905       <sect3 id="bus-messages-get-connection-selinux-security-context">
5906         <title><literal>org.freedesktop.DBus.GetConnectionSELinuxSecurityContext</literal></title>
5907         <para>
5908           As a method:
5909           <programlisting>
5910             ARRAY of BYTE GetConnectionSELinuxSecurityContext (in STRING bus_name)
5911           </programlisting>
5912           Message arguments:
5913           <informaltable>
5914             <tgroup cols="3">
5915               <thead>
5916                 <row>
5917                   <entry>Argument</entry>
5918                   <entry>Type</entry>
5919                   <entry>Description</entry>
5920                 </row>
5921               </thead>
5922               <tbody>
5923                 <row>
5924                   <entry>0</entry>
5925                   <entry>STRING</entry>
5926                   <entry>Unique or well-known bus name of the connection to
5927                     query, such as <literal>:12.34</literal> or
5928                     <literal>com.example.tea</literal></entry>
5929                 </row>
5930               </tbody>
5931             </tgroup>
5932           </informaltable>
5933           Reply arguments:
5934           <informaltable>
5935             <tgroup cols="3">
5936               <thead>
5937                 <row>
5938                   <entry>Argument</entry>
5939                   <entry>Type</entry>
5940                   <entry>Description</entry>
5941                 </row>
5942               </thead>
5943               <tbody>
5944                 <row>
5945                   <entry>0</entry>
5946                   <entry>ARRAY of BYTE</entry>
5947                   <entry>some sort of string of bytes, not necessarily UTF-8,
5948                     not including '\0'</entry>
5949                 </row>
5950               </tbody>
5951             </tgroup>
5952           </informaltable>
5953           Returns the security context used by SELinux, in an unspecified
5954           format. If you know what this means, please contribute
5955           documentation via the D-Bus bug tracking system.
5956           This method is on the core DBus interface for historical reasons;
5957           the same information should be made available via
5958           <xref linkend="bus-messages-get-connection-credentials"/>
5959           in future.
5960         </para>
5961       </sect3>
5962
5963
5964       <sect3 id="bus-messages-add-match">
5965         <title><literal>org.freedesktop.DBus.AddMatch</literal></title>
5966         <para>
5967           As a method:
5968           <programlisting>
5969             AddMatch (in STRING rule)
5970           </programlisting>
5971           Message arguments:
5972           <informaltable>
5973             <tgroup cols="3">
5974               <thead>
5975                 <row>
5976                   <entry>Argument</entry>
5977                   <entry>Type</entry>
5978                   <entry>Description</entry>
5979                 </row>
5980               </thead>
5981               <tbody>
5982                 <row>
5983                   <entry>0</entry>
5984                   <entry>STRING</entry>
5985                   <entry>Match rule to add to the connection</entry>
5986                 </row>
5987               </tbody>
5988             </tgroup>
5989           </informaltable>
5990         Adds a match rule to match messages going through the message bus (see <xref linkend='message-bus-routing-match-rules'/>). 
5991         If the bus does not have enough resources the <literal>org.freedesktop.DBus.Error.OOM</literal>
5992         error is returned.
5993        </para>
5994       </sect3>
5995       <sect3 id="bus-messages-remove-match">
5996         <title><literal>org.freedesktop.DBus.RemoveMatch</literal></title>
5997         <para>
5998           As a method:
5999           <programlisting>
6000             RemoveMatch (in STRING rule)
6001           </programlisting>
6002           Message arguments:
6003           <informaltable>
6004             <tgroup cols="3">
6005               <thead>
6006                 <row>
6007                   <entry>Argument</entry>
6008                   <entry>Type</entry>
6009                   <entry>Description</entry>
6010                 </row>
6011               </thead>
6012               <tbody>
6013                 <row>
6014                   <entry>0</entry>
6015                   <entry>STRING</entry>
6016                   <entry>Match rule to remove from the connection</entry>
6017                 </row>
6018               </tbody>
6019             </tgroup>
6020           </informaltable>
6021         Removes the first rule that matches (see <xref linkend='message-bus-routing-match-rules'/>). 
6022         If the rule is not found the <literal>org.freedesktop.DBus.Error.MatchRuleNotFound</literal>
6023         error is returned.
6024        </para>
6025       </sect3>
6026
6027       <sect3 id="bus-messages-get-id">
6028         <title><literal>org.freedesktop.DBus.GetId</literal></title>
6029         <para>
6030           As a method:
6031           <programlisting>
6032             GetId (out STRING id)
6033           </programlisting>
6034         Reply arguments:
6035         <informaltable>
6036           <tgroup cols="3">
6037             <thead>
6038               <row>
6039                 <entry>Argument</entry>
6040                 <entry>Type</entry>
6041                 <entry>Description</entry>
6042               </row>
6043             </thead>
6044             <tbody>
6045               <row>
6046                 <entry>0</entry>
6047                 <entry>STRING</entry>
6048                 <entry>Unique ID identifying the bus daemon</entry>
6049               </row>
6050             </tbody>
6051           </tgroup>
6052         </informaltable>
6053         Gets the unique ID of the bus. The unique ID here is shared among all addresses the 
6054         bus daemon is listening on (TCP, UNIX domain socket, etc.) and its format is described in 
6055         <xref linkend="uuids"/>. Each address the bus is listening on also has its own unique 
6056         ID, as described in <xref linkend="addresses"/>. The per-bus and per-address IDs are not related.
6057         There is also a per-machine ID, described in <xref linkend="standard-interfaces-peer"/> and returned
6058         by org.freedesktop.DBus.Peer.GetMachineId().
6059         For a desktop session bus, the bus ID can be used as a way to uniquely identify a user's session.
6060         </para>
6061       </sect3>
6062
6063     </sect2>
6064
6065   </sect1>
6066 <!--
6067   <appendix id="implementation-notes">
6068     <title>Implementation notes</title>
6069     <sect1 id="implementation-notes-subsection">
6070       <title></title>
6071       <para>
6072       </para>
6073     </sect1>
6074   </appendix>
6075 -->
6076
6077   <glossary><title>Glossary</title>
6078     <para>
6079       This glossary defines some of the terms used in this specification.
6080     </para>
6081
6082     <glossentry id="term-bus-name"><glossterm>Bus Name</glossterm>
6083       <glossdef>
6084         <para>
6085           The message bus maintains an association between names and
6086           connections. (Normally, there's one connection per application.)  A
6087           bus name is simply an identifier used to locate connections. For
6088           example, the hypothetical <literal>com.yoyodyne.Screensaver</literal>
6089           name might be used to send a message to a screensaver from Yoyodyne
6090           Corporation.  An application is said to <firstterm>own</firstterm> a
6091           name if the message bus has associated the application's connection
6092           with the name.  Names may also have <firstterm>queued
6093           owners</firstterm> (see <xref linkend="term-queued-owner"/>).
6094             The bus assigns a unique name to each connection, 
6095             see <xref linkend="term-unique-name"/>. Other names 
6096               can be thought of as "well-known names" and are 
6097               used to find applications that offer specific functionality.
6098         </para>
6099
6100         <para>
6101           See <xref linkend="message-protocol-names-bus"/> for details of
6102           the syntax and naming conventions for bus names.
6103         </para>
6104       </glossdef>
6105     </glossentry>
6106       
6107     <glossentry id="term-message"><glossterm>Message</glossterm>
6108       <glossdef>
6109         <para>
6110           A message is the atomic unit of communication via the D-Bus
6111           protocol. It consists of a <firstterm>header</firstterm> and a
6112           <firstterm>body</firstterm>; the body is made up of
6113           <firstterm>arguments</firstterm>.
6114         </para>
6115       </glossdef>
6116     </glossentry>
6117
6118     <glossentry id="term-message-bus"><glossterm>Message Bus</glossterm>
6119       <glossdef>
6120         <para>
6121           The message bus is a special application that forwards 
6122           or routes messages between a group of applications
6123           connected to the message bus. It also manages 
6124           <firstterm>names</firstterm> used for routing
6125           messages.
6126         </para>
6127       </glossdef>
6128     </glossentry>
6129
6130     <glossentry id="term-name"><glossterm>Name</glossterm>
6131       <glossdef>
6132         <para>
6133           See <xref linkend="term-bus-name"/>. "Name" may 
6134             also be used to refer to some of the other names
6135             in D-Bus, such as interface names.
6136         </para>
6137       </glossdef>
6138     </glossentry>
6139
6140     <glossentry id="namespace"><glossterm>Namespace</glossterm>
6141       <glossdef>
6142         <para>
6143           Used to prevent collisions when defining new interfaces, bus names
6144           etc. The convention used is the same one Java uses for defining
6145           classes: a reversed domain name.
6146           See <xref linkend="message-protocol-names-bus"/>,
6147           <xref linkend="message-protocol-names-interface"/>,
6148           <xref linkend="message-protocol-names-error"/>,
6149           <xref linkend="message-protocol-marshaling-object-path"/>.
6150         </para>
6151       </glossdef>
6152     </glossentry>
6153
6154     <glossentry id="term-object"><glossterm>Object</glossterm>
6155       <glossdef>
6156         <para>
6157           Each application contains <firstterm>objects</firstterm>, which have
6158           <firstterm>interfaces</firstterm> and
6159           <firstterm>methods</firstterm>. Objects are referred to by a name,
6160           called a <firstterm>path</firstterm>.
6161         </para>
6162       </glossdef>
6163     </glossentry>
6164
6165     <glossentry id="one-to-one"><glossterm>One-to-One</glossterm>
6166       <glossdef>
6167         <para>
6168           An application talking directly to another application, without going
6169           through a message bus. One-to-one connections may be "peer to peer" or
6170           "client to server." The D-Bus protocol has no concept of client
6171           vs. server after a connection has authenticated; the flow of messages
6172           is symmetrical (full duplex).
6173         </para>
6174       </glossdef>
6175     </glossentry>
6176
6177     <glossentry id="term-path"><glossterm>Path</glossterm>
6178       <glossdef>
6179         <para>
6180           Object references (object names) in D-Bus are organized into a
6181           filesystem-style hierarchy, so each object is named by a path. As in
6182           LDAP, there's no difference between "files" and "directories"; a path
6183           can refer to an object, while still having child objects below it.
6184         </para>
6185       </glossdef>
6186     </glossentry>
6187
6188     <glossentry id="term-queued-owner"><glossterm>Queued Name Owner</glossterm>
6189       <glossdef>
6190         <para>
6191           Each bus name has a primary owner; messages sent to the name go to the
6192           primary owner. However, certain names also maintain a queue of
6193           secondary owners "waiting in the wings." If the primary owner releases
6194           the name, then the first secondary owner in the queue automatically
6195           becomes the new owner of the name.
6196         </para>
6197       </glossdef>
6198     </glossentry>
6199
6200     <glossentry id="term-service"><glossterm>Service</glossterm>
6201       <glossdef>
6202         <para>
6203           A service is an executable that can be launched by the bus daemon.
6204           Services normally guarantee some particular features, for example they
6205           may guarantee that they will request a specific name such as
6206           "com.example.Screensaver", have a singleton object
6207           "/com/example/Application", and that object will implement the
6208           interface "com.example.Screensaver.Control".
6209         </para>
6210       </glossdef>
6211     </glossentry>
6212
6213     <glossentry id="term-service-description-files"><glossterm>Service Description Files</glossterm>
6214       <glossdef>
6215         <para>
6216           ".service files" tell the bus about service applications that can be
6217           launched (see <xref linkend="term-service"/>). Most importantly they
6218           provide a mapping from bus names to services that will request those
6219             names when they start up.
6220         </para>
6221       </glossdef>
6222     </glossentry>
6223
6224     <glossentry id="term-unique-name"><glossterm>Unique Connection Name</glossterm>
6225       <glossdef>
6226         <para>
6227           The special name automatically assigned to each connection by the
6228           message bus. This name will never change owner, and will be unique
6229           (never reused during the lifetime of the message bus).
6230           It will begin with a ':' character.
6231         </para>
6232       </glossdef>
6233     </glossentry>
6234
6235   </glossary>
6236 </article>