- module DBus.Bus
- module DBus.Types
- module DBus.Message
- data Client
- data Connection
- clientName :: Client -> BusName
- newClient :: (Connection, BusName) -> IO Client
- data DBus a
- data DBusException
- runDBus :: Client -> DBus a -> IO a
- getClient :: DBus Client
- processMessage :: ReceivedMessage -> DBus ()
- send :: Message msg => (Serial -> DBus a) -> msg -> DBus a
- send_ :: Message msg => msg -> DBus ()
- receive :: DBus ReceivedMessage
- mainLoop :: DBus ()
- call :: MethodCall -> (Error -> DBus ()) -> (MethodReturn -> DBus ()) -> DBus ()
- callBlocking :: MethodCall -> DBus (Either Error MethodReturn)
- callBlocking_ :: MethodCall -> DBus MethodReturn
- onSignal :: MatchRule -> (BusName -> Signal -> DBus ()) -> DBus ()
- data RequestNameFlag
- data RequestNameReply
- = PrimaryOwner
- | InQueue
- | Exists
- | AlreadyOwner
- data ReleaseNameReply
- = Released
- | NonExistent
- | NotOwner
- requestName :: BusName -> [RequestNameFlag] -> (Error -> DBus ()) -> (RequestNameReply -> DBus ()) -> DBus ()
- releaseName :: BusName -> (Error -> DBus ()) -> (ReleaseNameReply -> DBus ()) -> DBus ()
- requestName_ :: BusName -> [RequestNameFlag] -> DBus RequestNameReply
- releaseName_ :: BusName -> DBus ReleaseNameReply
- newtype Object = Object (Map InterfaceName Interface)
- newtype Interface = Interface (Map MemberName Member)
- data Member
- data Method = Method Signature Signature (MethodCtx -> DBus ())
- export :: ObjectPath -> Object -> DBus ()
- object :: [(InterfaceName, Interface)] -> Object
- interface :: [(MemberName, Member)] -> Interface
- method :: Signature -> Signature -> (MethodCtx -> DBus ()) -> Member
- data MethodCtx = MethodCtx {}
- replyReturn :: MethodCtx -> [Variant] -> DBus ()
- replyError :: MethodCtx -> ErrorName -> [Variant] -> DBus ()
- data Proxy = Proxy {}
- callProxy :: Proxy -> MemberName -> [Flag] -> [Variant] -> (Error -> DBus ()) -> (MethodReturn -> DBus ()) -> DBus ()
- callProxyBlocking :: Proxy -> MemberName -> [Flag] -> [Variant] -> DBus (Either Error MethodReturn)
- callProxyBlocking_ :: Proxy -> MemberName -> [Flag] -> [Variant] -> DBus MethodReturn
- onProxySignal :: Proxy -> MemberName -> (Signal -> DBus ()) -> DBus ()
Documentation
module DBus.Bus
module DBus.Types
module DBus.Message
Clients
data Connection
clientName :: Client -> BusNameSource
newClient :: (Connection, BusName) -> IO ClientSource
Create a new Client
from an open connection and bus name. The weird
signature allows newClient
to use the computations in DBus.Bus
directly, without unpacking:
client <- newClient =<< getSessionBus
Only one client should be created for any given connection. Otherwise, they will compete to receive messages.
data DBusException Source
runDBus :: Client -> DBus a -> IO aSource
Run a DBus computation with the given client callbacks. Errors
encountered while running will be thrown as exceptions, using the
DBusException
type.
Use the MonadError
instance for DBus
to handle errors inside
the computation.
processMessage :: ReceivedMessage -> DBus ()Source
Run message handlers with the received message. If any method reply callbacks or signal handlers are found, they will be run in the current thread.
send_ :: Message msg => msg -> DBus ()Source
A wrapper around send
, which does not allow the message serial
to be recorded. This is a useful shortcut when sending messages which
are not expected to receive a reply.
receive :: DBus ReceivedMessageSource
A wrapper around receive
.
Run in a loop forever, processing messages.
This is commonly run in a separate thread, ie
client <- newClient =<< getSessionBus forkIO $ runDBus client mainLoop
call :: MethodCall -> (Error -> DBus ()) -> (MethodReturn -> DBus ()) -> DBus ()Source
Perform an asynchronous method call. One of the provided computations will be performed depending on what message type the destination sends back.
callBlocking :: MethodCall -> DBus (Either Error MethodReturn)Source
Sends a method call, and then blocks until a reply is received. Use this when the receive/process loop is running in a separate thread.
callBlocking_ :: MethodCall -> DBus MethodReturnSource
A variant of callBlocking
, which throws an exception if the
remote client returns Error
.
Handling signals
onSignal :: MatchRule -> (BusName -> Signal -> DBus ()) -> DBus ()Source
Perform some computation every time this client receives a matching signal.
Name reservation
requestName :: BusName -> [RequestNameFlag] -> (Error -> DBus ()) -> (RequestNameReply -> DBus ()) -> DBus ()Source
requestName_ :: BusName -> [RequestNameFlag] -> DBus RequestNameReplySource
Exporting local objects
export :: ObjectPath -> Object -> DBus ()Source
Export a set of interfaces on the bus. Whenever a method call is received which matches the object's path, interface, and member name, one of its members will be called.
Exported objects automatically implement the
org.freedesktop.DBus.Introspectable
interface.
object :: [(InterfaceName, Interface)] -> ObjectSource
interface :: [(MemberName, Member)] -> InterfaceSource
Responding to method calls
replyReturn :: MethodCtx -> [Variant] -> DBus ()Source
Send a successful return reply for a method call.
callProxy :: Proxy -> MemberName -> [Flag] -> [Variant] -> (Error -> DBus ()) -> (MethodReturn -> DBus ()) -> DBus ()Source
As call
, except that the proxy's information is used to
build the message.
callProxyBlocking :: Proxy -> MemberName -> [Flag] -> [Variant] -> DBus (Either Error MethodReturn)Source
As callBlocking
, except that the proxy's information is used
to build the message.
callProxyBlocking_ :: Proxy -> MemberName -> [Flag] -> [Variant] -> DBus MethodReturnSource
As callBlocking_
, except that the proxy's information is used
to build the message.
onProxySignal :: Proxy -> MemberName -> (Signal -> DBus ()) -> DBus ()Source
As onSIgnal
, except that the proxy's information is used
to build the match rule.