The dbus-th-introspection package

[Tags:bsd3, library, program]

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


[Skip to Readme]

Properties

Versions 0.1.0.0
Dependencies base (==4.7.*), cmdargs, containers (==0.5.*), dbus (==0.10.*), dbus-th (>=0.1.2.0), template-haskell (==2.9.*) [details]
License BSD3
Author Ilya Portnov
Maintainer portnov84@rambler.ru
Category Development
Source repository head: git clone https://github.com/portnov/dbus-th-introspection.git
Uploaded Sat Mar 5 12:52:40 UTC 2016 by IlyaPortnov
Distributions NixOS:0.1.0.0
Downloads 79 total (9 in the last 30 days)
Votes
0 []
Status Docs not available [build log]
All reported builds failed as of 2016-11-11 [all 4 reports]
Hackage Matrix CI

Modules

  • DBus
    • TH
      • DBus.TH.Introspection
        • DBus.TH.Introspection.Output
        • DBus.TH.Introspection.Types

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for dbus-th-introspection

Readme for dbus-th-introspection-0.1.0.0

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.