dbus-client-0.4.0.4: Monadic and object-oriented interfaces to DBus

DBus.Client

Contents

Synopsis

Documentation

module DBus.Bus

module DBus.Types

Clients

data Client Source

Clients are opaque handles to an open connection and other internal state.

data Connection

Instances

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.

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 => (Serial -> DBus a) -> msg -> DBus aSource

A wrapper around send.

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.

mainLoop :: DBus ()Source

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

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.

methodSource

Arguments

:: Signature

Input signature

-> Signature

Output signature

-> (MethodCtx -> DBus ())

Implementation

-> Member 

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.