D-Bus integration in Emacs
**************************

This manual documents an API for usage of D-Bus in Emacs.  D-Bus is a message bus system, a simple way for applications to talk to one another.  An overview of D-Bus can be found at http://dbus.freedesktop.org/.

Copyright © 2007, 2008, 2009, 2010 Free Software Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the license is included in the section entitled ``GNU Free Documentation License''.

     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and modify this GNU manual.  Buying copies from the FSF supports it in developing GNU and promoting software freedom.''

An overview of D-Bus
********************

D-Bus is an inter-process communication mechanism for applications residing on the same host.  The communication is based on messages.  Data in the messages is carried in a structured way, it is not just a byte stream.

The communication is connection oriented to two kinds of message buses: a so called system bus, and a session bus.  On a given machine, there is always one single system bus for miscellaneous system-wide communication, like changing of hardware configuration. On the other hand, the session bus is always related to a single user's session.

Every client application, which is connected to a bus, registers under a unique name at the bus.  This name is used for identifying the client application.  Such a unique name starts always with a colon, and looks like :1.42.

Additionally, a client application can register itself to a so called known name, which is a series of identifiers separated by dots, as in org.gnu.Emacs.  If several applications register to the same known name, these registrations are queued, and only the first application which has registered for the known name is reachable via this name.  If this application disconnects from the bus, the next queued unique name becomes the owner of this known name.

An application can install one or several objects under its name. Such objects are identified by an object path, which looks similar to paths in a filesystem.  An example of such an object path could be /org/gnu/Emacs/.

Applications might send a request to an object, that means sending a message with some data as input parameters, and receiving a message from that object with the result of this message, the output parameters.  Such a request is called method in D-Bus.

The other form of communication are signals.  The underlying message is emitted from an object and will be received by all other applications which have registered for such a signal.

All methods and signals an object supports are called interface of the object.  Interfaces are specified under a hierarchical name in D-Bus; an object can support several interfaces.  Such an interface name could be org.gnu.Emacs.TextEditor or org.gnu.Emacs.FileManager.

Inspection of D-Bus services.
*****************************

Bus names.
==========

There are several basic functions which inspect the buses for registered names.  Internally they use the basic interface org.freedesktop.DBus, which is supported by all objects of a bus.

 -- Function: dbus-list-activatable-names
     This function returns the D-Bus service names, which can be activated. An activatable service is described in a service registration file. Under GNU/Linux, such files are located at /usr/share/dbus-1/services/.

     The result is a list of strings, which is nil when there are no activatable service names at all.

 -- Function: dbus-list-names bus
     All service names, which are registered at D-Bus BUS, are returned.  The result is a list of strings, which is nil when there are no registered service names at all.  Well known names are strings like org.freedesktop.DBus.  Names starting with : are unique names for services.

     BUS must be either the symbol :system or the symbol :session.

 -- Function: dbus-list-known-names bus
     Retrieves all services which correspond to a known name in BUS. A service has a known name if it doesn't start with :.  The result is a list of strings, which is nil when there are no known names at all.

     BUS must be either the symbol :system or the symbol :session.

 -- Function: dbus-list-queued-owners bus service
     For a given service, registered at D-Bus BUS under the name SERVICE, all queued unique names are returned.  The result is a list of strings, or nil when there are no queued names for SERVICE at all.

     BUS must be either the symbol :system or the symbol :session.  SERVICE must be a known service name as string.

 -- Function: dbus-get-name-owner bus service
     For a given service, registered at D-Bus BUS under the name SERVICE, the unique name of the name owner is returned.  The result is a string, or nil when there exist no name owner of SERVICE.

     BUS must be either the symbol :system or the symbol :session.  SERVICE must be a known service name as string.

 -- Function: dbus-ping bus service &optional timeout
     Check whether the service name SERVICE is registered at D-Bus BUS.  SERVICE might not have been started yet, it is autostarted if possible.  The result is either t or nil.

     BUS must be either the symbol :system or the symbol :session.  SERVICE must be a string.  TIMEOUT, a nonnegative integer, specifies the maximum number of milliseconds dbus-ping must return.  The default value is 25,000.  Example:

          (message
             "%s screensaver on board."
             (cond
               ((dbus-ping :session "org.gnome.ScreenSaver" 100) "Gnome")
               ((dbus-ping :session "org.freedesktop.ScreenSaver" 100) "KDE")
               (t "No")))

     If it shall be checked whether SERVICE is already running without autostarting it, one shall apply

          (member service (dbus-list-known-names bus))

 -- Function: dbus-get-unique-name bus
     The unique name, under which Emacs is registered at D-Bus BUS, is returned as string.

     BUS must be either the symbol :system or the symbol :session.

Knowing the details of D-Bus services.
======================================

D-Bus services publish their interfaces.  This can be retrieved and analyzed during runtime, in order to understand the used implementation.

The resulting introspection data are in XML format.  The root introspection element is always a node element.  It might have a name attribute, which denotes the (absolute) object path an interface is introspected.

The root node element may have node and interface children.  A child node element must have a name attribute, this case it is the relative object path to the root node element.

An interface element has just one attribute, name, which is the full name of that interface.  The default interface org.freedesktop.DBus.Introspectable is always present.  Example:

     <node name="/org/bluez">
       <interface name="org.freedesktop.DBus.Introspectable">
         ...
       </interface>
       <interface name="org.bluez.Manager">
         ...
       </interface>
       <interface name="org.bluez.Database">
         ...
       </interface>
       <interface name="org.bluez.Security">
         ...
       </interface>
       <node name="service_audio"/>
       <node name="service_input"/>
       <node name="service_network"/>
       <node name="service_serial"/>
     </node>

Children of an interface element can be method, signal and property elements.  A method element stands for a D-Bus method of the surrounding interface.  The element itself has a name attribute, showing the method name.  Children elements arg stand for the arguments of a method.  Example:

     <method name="ResolveHostName">
       <arg name="interface" type="i" direction="in"/>
       <arg name="protocol" type="i" direction="in"/>
       <arg name="name" type="s" direction="in"/>
       <arg name="aprotocol" type="i" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
       <arg name="interface" type="i" direction="out"/>
       <arg name="protocol" type="i" direction="out"/>
       <arg name="name" type="s" direction="out"/>
       <arg name="aprotocol" type="i" direction="out"/>
       <arg name="address" type="s" direction="out"/>
       <arg name="flags" type="u" direction="out"/>
     </method>

arg elements can have the attributes name, type and direction.  The name attribute is optional.  The type attribute stands for the signature of the argument in D-Bus.  For a discussion of D-Bus types and their Lisp representation see Type Conversion. (D-Bus signatures are explained in the D-Bus specification http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures.) The direction attribute of an arg element can be only in or out; in case it is omitted, it defaults to in.

A signal element of an interface has a similar structure.  The direction attribute of an arg child element can be only out here; which is also the default value. Example:

     <signal name="StateChanged">
       <arg name="state" type="i"/>
       <arg name="error" type="s"/>
     </signal>

A property element has no arg child element.  It just has the attributes name, type and access, which are all mandatory.  The access attribute allows the values readwrite, read, and write. Example:

     <property name="Status" type="u" direction="read"/>

annotation elements can be children of interface, method, signal, and property elements.  Unlike properties, which can change their values during lifetime of a D-Bus object, annotations are static.  Often they are used for code generators of D-Bus langugae bindings.  Example:

     <annotation name="de.berlios.Pinot.GetStatistics" value="pinotDBus"/>

Annotations have just name and value attributes, both must be strings.

 -- Function: dbus-introspect bus service path
     This function returns all interfaces and sub-nodes of SERVICE, registered at object path PATH at bus BUS.

     BUS must be either the symbol :system or the symbol :session.  SERVICE must be a known service name, and PATH must be a valid object path.  The last two parameters are strings.  The result, the introspection data, is a string in XML format.  Example:

          (dbus-introspect
            :system "org.freedesktop.Hal"
            "/org/freedesktop/Hal/devices/computer")

          => "<!DOCTYPE node PUBLIC
              "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
              "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
              <node>
                <interface name="org.freedesktop.Hal.Device">
                  <method name="GetAllProperties">
                    <arg name="properties" direction="out" type="a{sv}"/>
                  </method>
                  ...
                  <signal name="PropertyModified">
                    <arg name="num_updates" type="i"/>
                    <arg name="updates" type="a(sbb)"/>
                  </signal>
                </interface>
                ...
              </node>"

     This example informs us, that the service org.freedesktop.Hal at object path /org/freedesktop/Hal/devices/computer offers the interface org.freedesktop.Hal.Device (and 2 other interfaces not documented here).  This interface contains the method GetAllProperties, which needs no input parameters, but returns as output parameter an array of dictionary entries (key-value pairs). Every dictionary entry has a string as key, and a variant as value.

     The interface offers also a signal, which returns 2 parameters: an integer, and an array consisting of elements which are a struct of a string and 2 boolean values. (The interfaces of the service org.freedesktop.Hal are described at http://people.freedesktop.org/~david/hal-spec/hal-spec.html#interfaces.)

 -- Function: dbus-introspect-xml bus service path
     This function has the same intention as function dbus-introspect.  The returned value is a parsed XML tree, which can be used for further analysis.  Example:

          (dbus-introspect-xml
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main")

          => (node ((name . "/org/freedesktop/xesam/searcher/main"))
               (interface ((name . "org.freedesktop.xesam.Search"))
                 (method ((name . "GetHitData"))
                   (arg ((name . "search") (type . "s") (direction . "in")))
                   (arg ((name . "hit_ids") (type . "au") (direction . "in")))
                   (arg ((name . "fields") (type . "as") (direction . "in")))
                   (arg ((name . "hit_data") (type . "aav") (direction . "out")))
                 )
                 ...
                 (signal ((name . "HitsAdded"))
                   (arg ((name . "search") (type . "s")))
                   (arg ((name . "count") (type . "u")))
                 )
               )
               ...
             )

 -- Function: dbus-introspect-get-attribute object attribute
     It returns the ATTRIBUTE value of a D-Bus introspection OBJECT.  OBJECT can be every subtree of a parsed XML tree as retrieved with dbus-introspect-xml.  ATTRIBUTE must be a string according to the attribute names in the D-Bus specification. Example:

          (dbus-introspect-get-attribute
            (dbus-introspect-xml :system "org.freedesktop.SystemToolsBackends"
              "/org/freedesktop/SystemToolsBackends/UsersConfig")
            "name")

          => "/org/freedesktop/SystemToolsBackends/UsersConfig"

     If OBJECT has no ATTRIBUTE, the function returns nil.

Detecting object paths and interfaces.
======================================

The first elements, to be introspected for a D-Bus object, are further object paths and interfaces.

 -- Function: dbus-introspect-get-node-names bus service path
     All node names of SERVICE in D-Bus BUS at object path PATH are returned as list of strings.  Example:

          (dbus-introspect-get-node-names
            :session "org.gnome.seahorse" "/org/gnome/seahorse")

          => ("crypto" "keys")

     The node names stand for further object paths of the D-Bus SERVICE, relative to PATH.  In the example, /org/gnome/seahorse/crypto and /org/gnome/seahorse/keys are also object paths of the D-Bus service org.gnome.seahorse.

 -- Function: dbus-introspect-get-all-nodes bus service path
     This function returns all node names of SERVICE in D-Bus BUS at object path PATH.  It returns a list of strings with all object paths of SERVICE, starting at PATH. Example:

          (dbus-introspect-get-all-nodes :session "org.gnome.seahorse" "/")

          => ("/" "/org" "/org/gnome" "/org/gnome/seahorse"
              "/org/gnome/seahorse/crypto"
              "/org/gnome/seahorse/keys"
              "/org/gnome/seahorse/keys/openpgp"
              "/org/gnome/seahorse/keys/openpgp/local"
              "/org/gnome/seahorse/keys/openssh"
              "/org/gnome/seahorse/keys/openssh/local")

 -- Function: dbus-introspect-get-interface-names bus service path
     There will be returned a list strings of all interface names of SERVICE in D-Bus BUS at object path PATH.  This list will contain the default interface org.freedesktop.DBus.Introspectable.

     Another default interface is org.freedesktop.DBus.Properties. If present, interface elements can also have property children.  Example:

          (dbus-introspect-get-interface-names
            :system "org.freedesktop.Hal"
            "/org/freedesktop/Hal/devices/computer")

          => ("org.freedesktop.DBus.Introspectable"
              "org.freedesktop.Hal.Device"
              "org.freedesktop.Hal.Device.SystemPowerManagement"
              "org.freedesktop.Hal.Device.CPUFreq")

 -- Function: dbus-introspect-get-interface bus service path interface
     Return INTERFACE of SERVICE in D-Bus BUS at object path PATH.  The return value is an XML element.  INTERFACE must be a string, element of the list returned by dbus-introspect-get-interface-names.  Example:

          (dbus-introspect-get-interface
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search")

          => (interface ((name . "org.freedesktop.xesam.Search"))
               (method ((name . "GetHitData"))
                 (arg ((name . "search") (type . "s") (direction . "in")))
                 (arg ((name . "hit_ids") (type . "au") (direction . "in")))
                 (arg ((name . "fields") (type . "as") (direction . "in")))
                 (arg ((name . "hit_data") (type . "aav") (direction . "out")))
               )
               ...
               (signal ((name . "HitsAdded"))
                 (arg ((name . "search") (type . "s")))
                 (arg ((name . "count") (type . "u")))
               )
             )

With these functions, it is possible to retrieve all introspection data from a running system:

     (with-current-buffer (switch-to-buffer "*introspect*")
       (erase-buffer)
       (dolist (service (dbus-list-known-names :session))
         (dolist (path (dbus-introspect-get-all-nodes :session service "/"))
           ;; We want to introspect only elements, which have more than
           ;; the default interface "org.freedesktop.DBus.Introspectable".
           (when (delete
                  "org.freedesktop.DBus.Introspectable"
                  (dbus-introspect-get-interface-names :session service path))
             (insert (message "\nservice: \"%s\" path: \"%s\"\n" service path)
                     (dbus-introspect :session service path))
             (redisplay t)))))

Applying the functionality.
===========================

Methods and signals are the communicatione means to D-Bus.  The following functions return their specifications.

 -- Function: dbus-introspect-get-method-names bus service path interface
     Return a list of strings of all method names of INTERFACE of SERVICE in D-Bus BUS at object path PATH.  Example:

          (dbus-introspect-get-method-names
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search")

          => ("GetState" "StartSearch" "GetHitCount" "GetHits" "NewSession"
              "CloseSession" "GetHitData" "SetProperty" "NewSearch"
              "GetProperty" "CloseSearch")

 -- Function: dbus-introspect-get-method bus service path interface method
     This function returns METHOD of INTERFACE as XML element. It must be located at SERVICE in D-Bus BUS at object path PATH.  METHOD must be a string, element of the list returned by dbus-introspect-get-method-names.  Example:

          (dbus-introspect-get-method
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "GetHitData")

          => (method ((name . "GetHitData"))
               (arg ((name . "search") (type . "s") (direction . "in")))
               (arg ((name . "hit_ids") (type . "au") (direction . "in")))
               (arg ((name . "fields") (type . "as") (direction . "in")))
               (arg ((name . "hit_data") (type . "aav") (direction . "out")))
             )

 -- Function: dbus-introspect-get-signal-names bus service path interface
     Return a list of strings of all signal names of INTERFACE of SERVICE in D-Bus BUS at object path PATH.  Example:

          (dbus-introspect-get-signal-names
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search")

          => ("StateChanged" "SearchDone" "HitsModified"
              "HitsRemoved" "HitsAdded")

 -- Function: dbus-introspect-get-signal bus service path interface signal
     This function returns SIGNAL of INTERFACE as XML element. It must be located at SERVICE in D-Bus BUS at object path PATH.  SIGNAL must be a string, element of the list returned by dbus-introspect-get-signal-names.  Example:

          (dbus-introspect-get-signal
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "HitsAdded")

          => (signal ((name . "HitsAdded"))
               (arg ((name . "search") (type . "s")))
               (arg ((name . "count") (type . "u")))
             )

What else to know about interfaces.
===================================

Interfaces can have properties.  These can be exposed via the org.freedesktop.DBus.Properties interface (See http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties). That is, properties can be retrieved and changed during lifetime of an element.

Annotations, on the other hand, are static values for an element. Often, they are used to instruct generators, how to generate code from the interface for a given language binding.

 -- Function: dbus-introspect-get-property-names bus service path interface
     Return a list of strings with all property names of INTERFACE of SERVICE in D-Bus BUS at object path PATH.  Example:

          (dbus-introspect-get-property-names
            :session "org.kde.kded" "/modules/networkstatus"
            "org.kde.Solid.Networking.Client")

          => ("Status")

     If an interface declares properties, the corresponding element supports also the org.freedesktop.DBus.Properties interface.

 -- Function: dbus-introspect-get-property bus service path interface property
     This function returns PROPERTY of INTERFACE as XML element. It must be located at SERVICE in D-Bus BUS at object path PATH.  PROPERTY must be a string, element of the list returned by dbus-introspect-get-property-names.

     A PROPERTY value can be retrieved by the function dbus-introspect-get-attribute.  Example:

          (dbus-introspect-get-property
            :session "org.kde.kded" "/modules/networkstatus"
            "org.kde.Solid.Networking.Client" "Status")

          => (property ((access . "read") (type . "u") (name . "Status")))

          (dbus-introspect-get-attribute
            (dbus-introspect-get-property
              :session "org.kde.kded" "/modules/networkstatus"
              "org.kde.Solid.Networking.Client" "Status")
            "access")

          => "read"

 -- Function: dbus-get-property bus service path interface property
     This function returns the value of PROPERTY of INTERFACE. It will be checked at BUS, SERVICE, PATH.  The result can be any valid D-Bus value, or nil if there is no PROPERTY.  Example:

          (dbus-get-property
            :session "org.kde.kded" "/modules/networkstatus"
            "org.kde.Solid.Networking.Client" "Status")

          => 4

 -- Function: dbus-set-property bus service path interface property value
     Set value of PROPERTY of INTERFACE to VALUE.  It will be checked at BUS, SERVICE, PATH.  When the value has been set successful, the result is VALUE.  Otherwise, nil is returned.  Example:

          (dbus-set-property
            :session "org.kde.kaccess" "/MainApplication"
            "com.trolltech.Qt.QApplication" "doubleClickInterval" 500)

          => 500

 -- Function: dbus-get-all-properties bus service path interface
     This function returns all properties of INTERFACE.  It will be checked at BUS, SERVICE, PATH.  The result is a list of cons.  Every cons contains the name of the property, and its value. If there are no properties, nil is returned.  Example:

          (dbus-get-all-properties
            :session "org.kde.kaccess" "/MainApplication"
            "com.trolltech.Qt.QApplication")

          => (("cursorFlashTime" . 1000) ("doubleClickInterval" . 500)
              ("keyboardInputInterval" . 400) ("wheelScrollLines" . 3)
              ("globalStrut" 0 0) ("startDragTime" . 500)
              ("startDragDistance" . 4) ("quitOnLastWindowClosed" . t)
              ("styleSheet" . ""))

 -- Function: dbus-introspect-get-annotation-names bus service path interface &optional name
     Return a list of all annotation names as list of strings.  If NAME is nil, the annotations are children of INTERFACE, otherwise NAME must be a method, signal, or property XML element, where the annotations belong to.  Example:

          (dbus-introspect-get-annotation-names
            :session "de.berlios.Pinot" "/de/berlios/Pinot"
            "de.berlios.Pinot" "GetStatistics")

          => ("de.berlios.Pinot.GetStatistics")

     Default annotation names (See http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format) are

     org.freedesktop.DBus.Deprecated
          Whether or not the entity is deprecated; defaults to nil

     org.freedesktop.DBus.GLib.CSymbol
          The C symbol; may be used for methods and interfaces

     org.freedesktop.DBus.Method.NoReply
          If set, don't expect a reply to the method call; defaults to nil

 -- Function: dbus-introspect-get-annotation bus service path interface name annotation
     Return annotation ANNOTATION as XML object.  If NAME is nil, ANNOTATION is a child of INTERFACE, otherwise NAME must be the name of a method, signal, or property XML element, where the ANNOTATION belongs to.

     An attribute value can be retrieved by dbus-introspect-get-attribute.  Example:

          (dbus-introspect-get-annotation
            :session "de.berlios.Pinot" "/de/berlios/Pinot"
            "de.berlios.Pinot" "GetStatistics"
            "de.berlios.Pinot.GetStatistics")

          => (annotation ((name . "de.berlios.Pinot.GetStatistics")
                          (value . "pinotDBus")))

          (dbus-introspect-get-attribute
            (dbus-introspect-get-annotation
              :session "de.berlios.Pinot" "/de/berlios/Pinot"
              "de.berlios.Pinot" "GetStatistics"
              "de.berlios.Pinot.GetStatistics")
            "value")

          => "pinotDBus"

The final details.
==================

Methods and signals have arguments.  They are described in the arg XML elements.

 -- Function: dbus-introspect-get-argument-names bus service path interface name
     Return a list of all argument names as list of strings.  NAME must be a method or signal XML element.  Example:

          (dbus-introspect-get-argument-names
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "GetHitData")

          => ("search" "hit_ids" "fields" "hit_data")

     Argument names are optional; the function can return nil therefore, even if the method or signal has arguments.

 -- Function: dbus-introspect-get-argument bus service path interface name arg
     Return argument ARG as XML object.  NAME must be a method or signal XML element.  Example:

          (dbus-introspect-get-argument
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "GetHitData" "search")

          => (arg ((name . "search") (type . "s") (direction . "in")))

 -- Function: dbus-introspect-get-signature bus service path interface name &optional direction
     Return signature of a method or signal, represented by NAME, as string.

     If NAME is a method, DIRECTION can be either in or out.  If DIRECTION is nil, in is assumed.

     If NAME is a signal, and DIRECTION is non-nil, DIRECTION must be out.  Example:

          (dbus-introspect-get-signature
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "GetHitData" "in")

          => "sauas"

          (dbus-introspect-get-signature
            :session "org.freedesktop.xesam.searcher"
            "/org/freedesktop/xesam/searcher/main"
            "org.freedesktop.xesam.Search" "HitsAdded")

          => "su"

Mapping Lisp types and D-Bus types.
***********************************

D-Bus method calls and signals accept usually several arguments as parameters, either as input parameter, or as output parameter.  Every argument belongs to a D-Bus type.

Such arguments must be mapped between the value encoded as a D-Bus type, and the corresponding type of Lisp objects.  The mapping is applied Lisp object ==> D-Bus type for input parameters, and D-Bus type ==> Lisp object for output parameters.

Input parameters.
=================

Input parameters for D-Bus methods and signals occur as arguments of a Lisp function call.  The following mapping to D-Bus types is applied, when the corresponding D-Bus message is created:

     Lisp type                                D-Bus type

     t and nil   ==>   DBUS_TYPE_BOOLEAN
     natural number            ==>   DBUS_TYPE_UINT32
     negative integer          ==>   DBUS_TYPE_INT32
     float                     ==>   DBUS_TYPE_DOUBLE
     string                    ==>   DBUS_TYPE_STRING
     list                      ==>   DBUS_TYPE_ARRAY

Other Lisp objects, like symbols or hash tables, are not accepted as input parameter.

If it is necessary to use another D-Bus type, a corresponding type symbol can be preceeded to the corresponding Lisp object. Basic D-Bus types are represented by the type symbols :byte, :boolean, :int16, :uint16, :int32, :uint32, :int64, :uint64, :double, :string, :object-path and :signature.

Example:

     (dbus-call-method ... NAT-NUMBER STRING)

is equivalent to

     (dbus-call-method ... :uint32 NAT-NUMBER :string STRING)

but different to

     (dbus-call-method ... :int32 NAT-NUMBER :signature STRING)

The value for a byte D-Bus type can be any integer in the range 0 through 255.  If a character is used as argument, modifiers represented outside this range are stripped of.  For example, :byte ?x is equal to :byte ?\M-x, but it is not equal to :byte ?\C-x or :byte ?\M-\C-x.

A D-Bus compound type is always represented as a list.  The CAR of this list can be the type symbol :array, :variant, :struct or :dict-entry, which would result in a corresponding D-Bus container.  :array is optional, because this is the default compound D-Bus type for a list.

The objects being elements of the list are checked according to the D-Bus compound type rules.

  * An array must contain only elements of the same D-Bus type.  It can be empty.

  * A variant must contain only one single element.

  * A dictionary entry must be element of an array, and it must contain only a key-value pair of two elements, with a basic D-Bus type key.

  * There is no restriction for structs.

If an empty array needs an element D-Bus type other than string, it can contain exactly one element of D-Bus type :signature.  The value of this element (a string) is used as the signature of the elements of this array.  Example:

     (dbus-call-method
       :session "org.freedesktop.Notifications"
       "/org/freedesktop/Notifications"
       "org.freedesktop.Notifications" "Notify"
       "GNU Emacs"                 ;; Application name.
       0                           ;; No replacement of other notifications.
       ""                          ;; No icon.
       "Notification summary"      ;; Summary.
       (format                     ;; Body.
         "This is a test notification, raised from %s" (emacs-version))
       '(:array)                   ;; No actions (empty array of strings).
       '(:array :signature "{sv}") ;; No hints
                                   ;; (empty array of dictionary entries).
       :int32 -1)                 ;; Default timeout.

     => 3

 -- Function: dbus-string-to-byte-array string
     Sometimes, D-Bus methods require as input parameter an array of bytes, instead of a string.  If it is guaranteed, that STRING is an UTF8 string, this function performs the conversion.  Example:

          (dbus-string-to-byte-array "/etc/hosts")

          => (:array :byte 47 :byte 101 :byte 116 :byte 99 :byte 47
                     :byte 104 :byte 111 :byte 115 :byte 116 :byte 115)

 -- Function: dbus-escape-as-identifier string
     Escape an arbitrary STRING so it follows the rules for a C identifier.  The escaped string can be used as object path component, interface element component, bus name component or member name in D-Bus.

     The escaping consists of replacing all non-alphanumerics, and the first character if it's a digit, with an underscore and two lower-case hex digits.  As a special case, "" is escaped to "_".  Example:

          (dbus-escape-as-identifier "0123abc_xyz\x01\xff")

          => "_30123abc_5fxyz_01_ff"

Output parameters.
==================

Output parameters of D-Bus methods and signals are mapped to Lisp objects.

     D-Bus type                             Lisp type

     DBUS_TYPE_BOOLEAN       ==>   t or nil
     DBUS_TYPE_BYTE          ==>   natural number
     DBUS_TYPE_UINT16        ==>   natural number
     DBUS_TYPE_INT16         ==>   integer
     DBUS_TYPE_UINT32        ==>   natural number or float
     DBUS_TYPE_INT32         ==>   integer or float
     DBUS_TYPE_UINT64        ==>   natural number or float
     DBUS_TYPE_INT64         ==>   integer or float
     DBUS_TYPE_DOUBLE        ==>   float
     DBUS_TYPE_STRING        ==>   string
     DBUS_TYPE_OBJECT_PATH   ==>   string
     DBUS_TYPE_SIGNATURE     ==>   string
     DBUS_TYPE_ARRAY         ==>   list
     DBUS_TYPE_VARIANT       ==>   list
     DBUS_TYPE_STRUCT        ==>   list
     DBUS_TYPE_DICT_ENTRY    ==>   list

A float object in case of DBUS_TYPE_UINT32, DBUS_TYPE_INT32, DBUS_TYPE_UINT64 and DBUS_TYPE_INT6432 is returned, when the C value exceeds the Emacs number size range.

The resulting list of the last 4 D-Bus compound types contains as elements the elements of the D-Bus container, mapped according to the same rules.

The signal PropertyModified, discussed as example in Inspection, would offer as Lisp data the following object (BOOL stands here for either nil or t):

     (INTEGER ((STRING BOOL BOOL) (STRING BOOL BOOL) ...))

 -- Function: dbus-byte-array-to-string byte-array
     If a D-Bus method or signal returns an array of bytes, which are known to represent an UTF8 string, this function converts BYTE-ARRAY to the corresponding string.  Example:

          (dbus-byte-array-to-string '(47 101 116 99 47 104 111 115 116 115))

          => "/etc/hosts"

 -- Function: dbus-unescape-from-identifier string
     Retrieve the original string from the encoded STRING. STRING must have been coded with dbus-escape-as-identifier.  Example:

          (dbus-unescape-from-identifier "_30123abc_5fxyz_01_ff")

          => "0123abc_xyz^Aÿ"

Calling methods in a blocking way.
**********************************

Methods can be called synchronously (blocking) or asynchronously (non-blocking).

At D-Bus level, a method call consist of two messages: one message which carries the input parameters to the object owning the method to be called, and a reply message returning the resulting output parameters from the object.

 -- Function: dbus-call-method bus service path interface method &optional :timeout timeout &rest args
     This function calls METHOD on the D-Bus BUS.  BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name to be used.  PATH is the D-Bus object path, SERVICE is registered at.  INTERFACE is an interface offered by SERVICE.  It must provide METHOD.

     If the parameter :timeout is given, the following integer TIMEOUT specifies the maximum number of milliseconds the method call must return.  The default value is 25,000.  If the method call doesn't return in time, a D-Bus error is raised (see Errors and Events).

     All other arguments args are passed to METHOD as arguments. They are converted into D-Bus types as described in Type Conversion.

     The function returns the resulting values of METHOD as a list of Lisp objects, according to the type conversion rules described in Type Conversion.  Example:

          (dbus-call-method
            :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
            "org.gnome.seahorse.Keys" "GetKeyField"
            "openpgp:657984B8C7A966DD" "simple-name")

          => (t ("Philip R. Zimmermann"))

     If the result of the method call is just one value, the converted Lisp object is returned instead of a list containing this single Lisp object.  Example:

          (dbus-call-method
            :system "org.freedesktop.Hal"
            "/org/freedesktop/Hal/devices/computer"
            "org.freedesktop.Hal.Device" "GetPropertyString"
            "system.kernel.machine")

          => "i686"

     With the dbus-introspect function it is possible to explore the interfaces of org.freedesktop.Hal service. It offers the interfaces org.freedesktop.Hal.Manager for the object at the path /org/freedesktop/Hal/Manager as well as the interface org.freedesktop.Hal.Device for all objects prefixed with the path /org/freedesktop/Hal/devices.  With the methods GetAllDevices and GetAllProperties, it is simple to emulate the lshal command on GNU/Linux systems:

          (dolist (device
                    (dbus-call-method
                      :system "org.freedesktop.Hal"
                      "/org/freedesktop/Hal/Manager"
                      "org.freedesktop.Hal.Manager" "GetAllDevices"))
            (message "\nudi = %s" device)
            (dolist (properties
                      (dbus-call-method
                        :system "org.freedesktop.Hal" device
                        "org.freedesktop.Hal.Device" "GetAllProperties"))
              (message "  %s = %S"
                       (car properties) (or (caar (cdr properties)) ""))))

          -| "udi = /org/freedesktop/Hal/devices/computer
                info.addons = (\"hald-addon-acpi\")
                info.bus = \"unknown\"
                info.product = \"Computer\"
                info.subsystem = \"unknown\"
                info.udi = \"/org/freedesktop/Hal/devices/computer\"
                linux.sysfs_path_device = \"(none)\"
                power_management.acpi.linux.version = \"20051216\"
                power_management.can_suspend_to_disk = t
                power_management.can_suspend_to_ram = \"\"
                power_management.type = \"acpi\"
                smbios.bios.release_date = \"11/07/2001\"
                system.chassis.manufacturer = \"COMPAL\"
                system.chassis.type = \"Notebook\"
                system.firmware.release_date = \"03/19/2005\"
                ..."

 -- Function: dbus-call-method-non-blocking bus service path interface method &optional :timeout timeout &rest args
     Call METHOD on the D-Bus BUS, but don't block the event queue. This is necessary for communicating to registered D-Bus methods, which are running in the same Emacs process.

     The arguments are the same as in dbus-call-method.  Example:

          (dbus-call-method-non-blocking
            :system "org.freedesktop.Hal"
            "/org/freedesktop/Hal/devices/computer"
            "org.freedesktop.Hal.Device" "GetPropertyString"
            "system.kernel.machine")

          => "i686"

Calling methods non-blocking.
*****************************

 -- Function: dbus-call-method-asynchronously bus service path interface method handler &optional :timeout timeout &rest args
     This function calls METHOD on the D-Bus BUS asynchronously.  BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name to be used.  PATH is the D-Bus object path, SERVICE is registered at.  INTERFACE is an interface offered by SERVICE.  It must provide METHOD.

     HANDLER is a Lisp function, which is called when the corresponding return message has arrived.  If HANDLER is nil, no return message will be expected.

     If the parameter :timeout is given, the following integer TIMEOUT specifies the maximum number of milliseconds a reply message must arrive.  The default value is 25,000.  If there is no reply message in time, a D-Bus error is raised (see Errors and Events).

     All other arguments args are passed to METHOD as arguments. They are converted into D-Bus types as described in Type Conversion.

     Unless HANDLER is nil, the function returns a key into the hash table dbus-registered-objects-table.  The corresponding entry in the hash table is removed, when the return message has been arrived, and HANDLER is called.  Example:

          (dbus-call-method-asynchronously
            :system "org.freedesktop.Hal"
            "/org/freedesktop/Hal/devices/computer"
            "org.freedesktop.Hal.Device" "GetPropertyString" 'message
            "system.kernel.machine")

          => (:system 2)

          -| i686

Offering own methods.
*********************

Emacs can also offer own methods, which can be called by other applications.  These methods could be an implementation of an interface of a well known service, like org.freedesktop.TextEditor.

It could be also an implementation of an own interface.  In this case, the service name must be org.gnu.Emacs.  The object path shall begin with /org/gnu/Emacs/Application/, and the interface name shall be org.gnu.Emacs.Application. Application is the name of the application which provides the interface.

 -- Constant: dbus-service-emacs
     The well known service name of Emacs.

 -- Constant: dbus-path-emacs
     The object path head "/org/gnu/Emacs" used by Emacs.  All object paths, used by offered methods or signals, shall start with this string.

 -- Function: dbus-register-method bus service path interface method handler
     With this function, an application registers METHOD on the D-Bus BUS.

     BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name of the D-Bus object METHOD is registered for.  It must be a known name.

     PATH is the D-Bus object path SERVICE is registered.

     INTERFACE is the interface offered by SERVICE.  It must provide METHOD.

     HANDLER is a Lisp function to be called when a METHOD call is received.  It must accept as arguments the input arguments of METHOD.  HANDLER should return a list, whose elements are to be used as arguments for the reply message of METHOD.  This list can be composed like the input parameters in Type Conversion.

     If HANDLER wants to return just one Lisp object and it is not a cons cell, HANDLER can return this object directly, instead of returning a list containing the object.

     In case HANDLER shall return a reply message with an empty argument list, HANDLER must return the symbol :ignore.

     The default D-Bus timeout when waiting for a message reply is 25 seconds.  This value could be even smaller, depending on the calling client.  Therefore, HANDLER shall not last longer than absolutely necessary.

     dbus-register-method returns a Lisp object, which can be used as argument in dbus-unregister-object for removing the registration for METHOD.  Example:

          (defun my-dbus-method-handler (filename)
            (let (result)
              (if (find-file filename)
                  (setq result '(:boolean t))
                (setq result '(:boolean nil)))
              result))

          => my-dbus-method-handler

          (dbus-register-method
            :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
            "org.freedesktop.TextEditor" "OpenFile"
            'my-dbus-method-handler)

          => ((:session "org.freedesktop.TextEditor" "OpenFile")
              ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
               my-dbus-method-handler))

     If you invoke the method org.freedesktop.TextEditor.OpenFile from another D-Bus application with a filename as parameter, the file is opened in Emacs, and the method returns either TRUE or FALSE, indicating the success of the method.  As test tool one could use the command line tool dbus-send in a shell:

          # dbus-send --session --print-reply \
              --dest="org.freedesktop.TextEditor" \
              "/org/freedesktop/TextEditor" \
              "org.freedesktop.TextEditor.OpenFile" string:"/etc/hosts"

          -| method return sender=:1.22 -> dest=:1.23 reply_serial=2
                boolean true

     You can indicate an error by raising the Emacs signal dbus-error.  The handler above could be changed like this:

          (defun my-dbus-method-handler (&rest args)
            (unless (and (= (length args) 1) (stringp (car args)))
              (signal 'dbus-error (list (format "Wrong argument list: %S" args))))
            (condition-case err
                (find-file (car args))
              (error (signal 'dbus-error (cdr err))))
            t)

          => my-dbus-method-handler

     The test runs then

          # dbus-send --session --print-reply \
              --dest="org.freedesktop.TextEditor" \
              "/org/freedesktop/TextEditor" \
              "org.freedesktop.TextEditor.OpenFile" \
              string:"/etc/hosts" string:"/etc/passwd"

          -| Error org.freedesktop.DBus.Error.Failed:
             Wrong argument list: ("/etc/hosts" "/etc/passwd")

 -- Function: dbus-register-property bus service path interface property access value &optional emits-signal
     With this function, an application declares a PROPERTY on the D-Bus BUS.

     BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name of the D-Bus.  It must be a known name.

     PATH is the D-Bus object path SERVICE is registered.

     INTERFACE is the name of the interface used at PATH, PROPERTY is the name of the property of INTERFACE.

     ACCESS indicates, whether the property can be changed by other services via D-Bus.  It must be either the symbol :read or :readwrite.  VALUE is the initial value of the property, it can be of any valid type (see dbus-call-method for details).

     If PROPERTY already exists on PATH, it will be overwritten.  For properties with access type :read this is the only way to change their values.  Properties with access type :readwrite can be changed by dbus-set-property.

     The interface org.freedesktop.DBus.Properties is added to PATH, including a default handler for the Get, GetAll and Set methods of this interface.  When EMITS-SIGNAL is non-nil, the signal PropertiesChanged is sent when the property is changed by dbus-set-property.

     Example:

          (dbus-register-property
            :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
            "org.freedesktop.TextEditor" "name" :read "GNU Emacs")

          => ((:session "org.freedesktop.TextEditor" "name")
              ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"))

          (dbus-register-property
            :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
            "org.freedesktop.TextEditor" "version" :readwrite emacs-version t)

          => ((:session "org.freedesktop.TextEditor" "version")
              ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"))

     Other D-Bus applications can read the property via the default methods org.freedesktop.DBus.Properties.Get and org.freedesktop.DBus.Properties.GetAll.  Testing is also possible via the command line tool dbus-send in a shell:

          # dbus-send --session --print-reply \
              --dest="org.freedesktop.TextEditor" \
              "/org/freedesktop/TextEditor" \
              "org.freedesktop.DBus.Properties.GetAll" \
              string:"org.freedesktop.TextEditor"

          -| method return sender=:1.22 -> dest=:1.23 reply_serial=3
                array [
                   dict entry(
                      string "name"
                      variant             string "GNU Emacs"
                   )
                   dict entry(
                      string "version"
                      variant             string "23.1.50.5"
                   )
                ]

     It is also possible, to apply the dbus-get-property, dbus-get-all-properties and dbus-set-property functions (see Properties and Annotations).

          (dbus-set-property
            :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
            "org.freedesktop.TextEditor" "version" "23.1.50")

          => "23.1.50"

          (dbus-get-property
            :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
            "org.freedesktop.TextEditor" "version")

          => "23.1.50"

 -- Function: dbus-unregister-object object
     Unregister OBJECT from the D-Bus.  OBJECT must be the result of a preceding dbus-register-method, dbus-register-property or dbus-register-signal call (see Signals).  It returns t if OBJECT has been unregistered, nil otherwise.

     When OBJECT identifies the last method or property, which is registered for the respective service, Emacs releases its association to the service from D-Bus.

 -- Function: dbus-unregister-service bus service
     Unregister all objects from D-Bus BUS, registered by Emacs for SERVICE.

     BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name of the D-Bus.  It must be a known name.  Emacs releases its association to SERVICE from D-Bus.

Sending and receiving signals.
******************************

Signals are broadcast messages.  They carry input parameters, which are received by all objects which have registered for such a signal.

 -- Function: dbus-send-signal bus service path interface signal &rest args
     This function is similar to dbus-call-method.  The difference is, that there are no returning output parameters.

     The function emits SIGNAL on the D-Bus BUS.  BUS is either the symbol :system or the symbol :session.  It doesn't matter whether another object has registered for SIGNAL.

     SERVICE is the D-Bus service name of the object the signal is emitted from.  PATH is the corresponding D-Bus object path, SERVICE is registered at.  INTERFACE is an interface offered by SERVICE.  It must provide SIGNAL.

     All other arguments args are passed to SIGNAL as arguments. They are converted into D-Bus types as described in Type Conversion.  Example:

          (dbus-send-signal
            :session dbus-service-emacs dbus-path-emacs
            (concat dbus-service-emacs ".FileManager") "FileModified"
            "/home/albinus/.emacs")

 -- Function: dbus-register-signal bus service path interface signal handler &rest args
     With this function, an application registers for SIGNAL on the D-Bus BUS.

     BUS is either the symbol :system or the symbol :session.

     SERVICE is the D-Bus service name used by the sending D-Bus object.  It can be either a known name or the unique name of the D-Bus object sending the signal.  In case of a unique name, signals won't be received any longer once the object owning this unique name has disappeared, and a new queued object has replaced it.

     When SERVICE is nil, related signals from all D-Bus objects shall be accepted.

     PATH is the corresponding D-Bus object path, SERVICE is registered at.  It can also be nil if the path name of incoming signals shall not be checked.

     INTERFACE is an interface offered by SERVICE.  It must provide SIGNAL.

     HANDLER is a Lisp function to be called when the SIGNAL is received.  It must accept as arguments the output parameters SIGNAL is sending.

     All other arguments ARGS, if specified, must be strings.  They stand for the respective arguments of SIGNAL in their order, and are used for filtering as well.  A nil argument might be used to preserve the order.

     dbus-register-signal returns a Lisp object, which can be used as argument in dbus-unregister-object for removing the registration for SIGNAL.  Example:

          (defun my-dbus-signal-handler (device)
            (message "Device %s added" device))

          => my-dbus-signal-handler

          (dbus-register-signal
            :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
            "org.freedesktop.Hal.Manager" "DeviceAdded"
            'my-dbus-signal-handler)

          => ((:system "org.freedesktop.Hal.Manager" "DeviceAdded")
              ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
               my-signal-handler))

     As we know from the introspection data of interface org.freedesktop.Hal.Manager, the signal DeviceAdded provides one single parameter, which is mapped into a Lisp string. The callback function my-dbus-signal-handler must define one single string argument therefore.  Plugging an USB device to your machine, when registered for signal DeviceAdded, will show you which objects the GNU/Linux hal daemon adds.

Errors and events.
******************

The internal actions can be traced by running in a debug mode.

 -- Variable: dbus-debug
     If this variable is non-nil, D-Bus specific debug messages are raised.

Input parameters of dbus-call-method, dbus-call-method-non-blocking, dbus-call-method-asynchronously, and dbus-register-signal are checked for correct D-Bus types. If there is a type mismatch, the Lisp error wrong-type-argument D-Bus ARG is raised.

All errors raised by D-Bus are signaled with the error symbol dbus-error.  If possible, error messages from D-Bus are appended to the dbus-error.

 -- Special Form: dbus-ignore-errors forms...
     This executes FORMS exactly like a progn, except that dbus-error errors are ignored during the FORMS.  These errors can be made visible when dbus-debug is set to t.

Incoming D-Bus messages are handled as Emacs events, see Misc Events (elisp).  They are retrieved only, when Emacs runs in interactive mode.  The generated event has this form:

     (dbus-event BUS TYPE SERIAL SERVICE PATH INTERFACE MEMBER HANDLER
             &rest ARGS)

BUS identifies the D-Bus the message is coming from.  It is either the symbol :system or the symbol :session.

TYPE is the D-Bus message type which has caused the event.  It can be dbus-message-type-invalid, dbus-message-type-method-call, dbus-message-type-method-return, dbus-message-type-error, or dbus-message-type-signal. SERIAL is the serial number of the received D-Bus message.

SERVICE and PATH are the unique name and the object path of the D-Bus object emitting the message.  INTERFACE and MEMBER denote the message which has been sent.

HANDLER is the callback function which has been registered for this message (see Signals).  When a dbus-event event arrives, HANDLER is called with ARGS as arguments.

In order to inspect the dbus-event data, you could extend the definition of the callback function in Signals:

     (defun my-dbus-signal-handler (&rest args)
       (message "my-dbus-signal-handler: %S" last-input-event))

There exist convenience functions which could be called inside a callback function in order to retrieve the information from the event.

 -- Function: dbus-event-bus-name event
     Returns the bus name EVENT is coming from. The result is either the symbol :system or the symbol :session.

 -- Function: dbus-event-message-type event
     Returns the message type of the corresponding D-Bus message.  The result is a natural number.

 -- Function: dbus-event-serial-number event
     Returns the serial number of the corresponding D-Bus message. The result is a natural number.

 -- Function: dbus-event-service-name event
     Returns the unique name of the D-Bus object EVENT is coming from.

 -- Function: dbus-event-path-name event
     Returns the object path of the D-Bus object EVENT is coming from.

 -- Function: dbus-event-interface-name event
     Returns the interface name of the D-Bus object EVENT is coming from.

 -- Function: dbus-event-member-name event
     Returns the member name of the D-Bus object EVENT is coming from.  It is either a signal name or a method name.

D-Bus errors are not propagated during event handling, because it is usually not desired.  D-Bus errors in events can be made visible by setting the variable dbus-debug to t.  They can also be handled by a hook function.

 -- Variable: dbus-event-error-hooks
     This hook variable keeps a list of functions, which are called when a D-Bus error happens in the event handler.  Every function must accept two arguments, the event and the error variable catched in condition-case by dbus-error.

     Such functions can be used the adapt the error signal to be raised. Example:

          (defun my-dbus-event-error-handler (event error)
            (when (string-equal (concat dbus-service-emacs ".FileManager")
                                (dbus-event-interface-name event))
              (message "my-dbus-event-error-handler: %S %S" event error)
              (signal 'file-error (cdr error))))

          (add-hook 'dbus-event-error-hooks 'my-dbus-event-error-handler)

Hook functions shall take into account, that there might be other D-Bus applications running.  Therefore, they shall check carefully, whether a given D-Bus error is related to them.

GNU Free Documentation License
******************************

     [file doclicense.texi not included]