dbus-th-introspection: Generate bindings for DBus calls by using DBus introspection and dbus-th

[ bsd3, development, library, program ] [ Propose Tags ] [ Report a vulnerability ]

This package is aimed to simplify writing bindings for DBus interfaces by using DBus introspection and dbus-th package.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.2, 0.1.2.0
Dependencies base (>=4.7 && <5), cmdargs, containers (>=0.5), dbus (>=0.10), dbus-th (>=0.1.2.0), template-haskell (>=2.9) [details]
License BSD-3-Clause
Author Ilya Portnov
Maintainer portnov84@rambler.ru
Category Development
Source repo head: git clone https://github.com/portnov/dbus-th-introspection.git
Uploaded by IlyaPortnov at 2018-03-31T06:53:55Z
Distributions NixOS:0.1.2.0
Reverse Dependencies 1 direct, 0 indirect [details]
Executables dbus-introspect-hs
Downloads 2277 total (8 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-04-14 [all 1 reports]

Readme for dbus-th-introspection-0.1.2.0

[back to package description]
This package is aimed to simplify writing bindings for DBus interfaces by using
DBus introspection and dbus-th package.

The synopsis is:

dbus-introspect-hs [OPTIONS] [SERVICE.NAME] [/PATH/TO/OBJECT] [INTERFACE.NAME]
  Introspect specified DBus object/interface and generate TemplateHaskell
  source for calling all functions from Haskell

Common flags:
  -m --module=NAME --modulename  Haskell module name
  -o --output=FILE --outputfile  Output file
  -s --system                    Use system bus instead of sesion bus
  -d --dynamic --dynamicobject   If specified - generated functions will get
                                 object path as 2nd argument

If service name is not provided, the program will generate bindings for all
services available (Warning: you can receive a very large file). If object 
path is not provided, the program will generate bindings for all objects
provided by specified service. Similarly, if interface name is not proviced,
the program will generate bindings for all interfaces provided by speciifed
object.

If -d option is specified, the program will generate bindings by using
"interface'" instead of "interface"; so, all generated functions will get
object path as their second argument.

For example, one may run

    $ dbus-introspect-hs --dynamic --session -m Session \
      org.freedesktop.login1 /org/freedesktop/login1/session/self \
      org.freedesktop.login1.Session

and receive:

    {-# LANGUAGE TemplateHaskell #-}
    module Session where

    import DBus.TH
    import DBus.TH.Introspection

    -- Service BusName "org.freedesktop.login1"
    -- Interface org.freedesktop.login1.Session
    interface' "org.freedesktop.login1" Nothing "org.freedesktop.login1.Session" Nothing [
        "Terminate" =:: Return ''(),
        "Activate" =:: Return ''(),
        "Lock" =:: Return ''(),
        "Unlock" =:: Return ''(),
        "SetIdleHint" =:: ''Bool :-> Return ''(),
        "Kill" =:: ''String :-> ''Int32 :-> Return ''(),
        "TakeControl" =:: ''Bool :-> Return ''(),
        "ReleaseControl" =:: Return ''(),
        -- Error: method TakeDevice: Method TakeDevice has more than one out parameter,
        "ReleaseDevice" =:: ''Word32 :-> ''Word32 :-> Return ''(),
        "PauseDeviceComplete" =:: ''Word32 :-> ''Word32 :-> Return ''()
      ]

After "import Session", the functions like activate :: Client -> String -> IO ()
will be available.

Note that many DBus services provide one interface for many objects; and 
in one interface, there could be several functions with the same name (but
with different signatures). In this case, the source generated by this
program would not compile due to duplicated declaration names.

So, the sources generated by this program are primarily intended for 
hand inspection and editing (change declaration names, remove unneded or
duplicated declarations); not for automatic compilation during some
package build process.