dbus-client-0.4: Monadic and object-oriented interfaces to DBusSource codeContentsIndex
DBus.Client
Contents
Clients
Handling signals
Name reservation
Exporting local objects
Responding to method calls
Synopsis
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
= AllowReplacement
| ReplaceExisting
| DoNotQueue
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
= MemberMethod Method
| MemberSignal Signature
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 {
methodCtxObject :: Object
methodCtxMethod :: Method
methodCtxSerial :: Serial
methodCtxSender :: Maybe BusName
methodCtxFlags :: Set Flag
methodCtxBody :: [Variant]
}
replyReturn :: MethodCtx -> [Variant] -> DBus ()
replyError :: MethodCtx -> ErrorName -> [Variant] -> DBus ()
data Proxy = Proxy {
proxyName :: BusName
proxyObjectPath :: ObjectPath
proxyInterface :: InterfaceName
}
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 Client Source
Clients are opaque handles to an open connection and other internal state.
data Connection Source
show/hide Instances
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 DBus a Source
show/hide Instances
data DBusException Source
show/hide Instances
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.

getClient :: DBus ClientSource
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.
receive :: DBus ReceivedMessageSource
A wrapper around receive.
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
data RequestNameFlag Source
Constructors
AllowReplacement
ReplaceExisting
DoNotQueue
show/hide Instances
data RequestNameReply Source
Constructors
PrimaryOwner
InQueue
Exists
AlreadyOwner
show/hide Instances
data ReleaseNameReply Source
Constructors
Released
NonExistent
NotOwner
show/hide Instances
requestName :: BusName -> [RequestNameFlag] -> (Error -> DBus ()) -> (RequestNameReply -> DBus ()) -> DBus ()Source
releaseName :: BusName -> (Error -> DBus ()) -> (ReleaseNameReply -> DBus ()) -> DBus ()Source
requestName_ :: BusName -> [RequestNameFlag] -> DBus RequestNameReplySource
releaseName_ :: BusName -> DBus ReleaseNameReplySource
Exporting local objects
newtype Object Source
Constructors
Object (Map InterfaceName Interface)
newtype Interface Source
Constructors
Interface (Map MemberName Member)
data Member Source
Constructors
MemberMethod Method
MemberSignal Signature
data Method Source
Constructors
Method Signature Signature (MethodCtx -> DBus ())
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
methodSource
:: SignatureInput signature
-> SignatureOutput signature
-> MethodCtx -> DBus ()Implementation
-> Member
Responding to method calls
data MethodCtx Source
Constructors
MethodCtx
methodCtxObject :: Object
methodCtxMethod :: Method
methodCtxSerial :: Serial
methodCtxSender :: Maybe BusName
methodCtxFlags :: Set Flag
methodCtxBody :: [Variant]
replyReturn :: MethodCtx -> [Variant] -> DBus ()Source
Send a successful return reply for a method call.
replyError :: MethodCtx -> ErrorName -> [Variant] -> DBus ()Source
data Proxy Source
Constructors
Proxy
proxyName :: BusName
proxyObjectPath :: ObjectPath
proxyInterface :: InterfaceName
show/hide Instances
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.
Produced by Haddock version 2.6.1