Safe Haskell | None |
---|---|
Language | Haskell98 |
- data ConnectionType
- connectBus :: ConnectionType -> MethodCallHandler -> SignalHandler -> IO DBusConnection
- type MethodCallHandler = DBusConnection -> MessageHeader -> [SomeDBusValue] -> IO ()
- type SignalHandler = DBusConnection -> MessageHeader -> [SomeDBusValue] -> IO ()
- checkAlive :: DBusConnection -> IO Bool
- waitFor :: DBusConnection -> IO ()
- objectRoot :: Object -> Handler
- data MatchRule = MatchRule {
- mrType :: Maybe MessageType
- mrSender :: Maybe Text
- mrInterface :: Maybe Text
- mrMember :: Maybe Text
- mrPath :: Maybe (Bool, ObjectPath)
- mrDestination :: Maybe Text
- mrArgs :: [(Int, Text)]
- mrArgPaths :: [(Int, Text)]
- mrArg0namespace :: Maybe Text
- mrEavesdrop :: Maybe Bool
- matchAll :: MatchRule
- matchSignal :: MessageHeader -> MatchRule -> Bool
- addMatch :: (MonadIO m, MonadThrow m) => MatchRule -> DBusConnection -> m ()
- removeMatch :: (MonadIO m, MonadThrow m) => MatchRule -> DBusConnection -> m ()
- class Representable a where
- makeRepresentable :: Name -> Q [Dec]
- makeRepresentableTuple :: Int -> Q Dec
- data DBusValue :: DBusType -> * where
- DBVByte :: Word8 -> DBusValue (DBusSimpleType TypeByte)
- DBVBool :: Bool -> DBusValue (DBusSimpleType TypeBoolean)
- DBVInt16 :: Int16 -> DBusValue (DBusSimpleType TypeInt16)
- DBVUInt16 :: Word16 -> DBusValue (DBusSimpleType TypeUInt16)
- DBVInt32 :: Int32 -> DBusValue (DBusSimpleType TypeInt32)
- DBVUInt32 :: Word32 -> DBusValue (DBusSimpleType TypeUInt32)
- DBVInt64 :: Int64 -> DBusValue (DBusSimpleType TypeInt64)
- DBVUInt64 :: Word64 -> DBusValue (DBusSimpleType TypeUInt64)
- DBVDouble :: Double -> DBusValue (DBusSimpleType TypeDouble)
- DBVUnixFD :: Word32 -> DBusValue (DBusSimpleType TypeUnixFD)
- DBVString :: Text -> DBusValue (DBusSimpleType TypeString)
- DBVObjectPath :: ObjectPath -> DBusValue (DBusSimpleType TypeObjectPath)
- DBVSignature :: [DBusType] -> DBusValue (DBusSimpleType TypeSignature)
- DBVVariant :: SingI t => DBusValue t -> DBusValue TypeVariant
- DBVArray :: [DBusValue a] -> DBusValue (TypeArray a)
- DBVByteArray :: ByteString -> DBusValue (TypeArray (DBusSimpleType TypeByte))
- DBVStruct :: DBusStruct ts -> DBusValue (TypeStruct ts)
- DBVDict :: [(DBusValue (DBusSimpleType k), DBusValue v)] -> DBusValue (TypeDict k v)
- DBVUnit :: DBusValue TypeUnit
- castDBV :: (SingI s, SingI t) => DBusValue s -> Maybe (DBusValue t)
- data DBusStruct :: [DBusType] -> * where
- StructSingleton :: DBusValue a -> DBusStruct `[a]`
- StructCons :: DBusValue a -> DBusStruct as -> DBusStruct (a : as)
- data SomeDBusValue where
- DBV :: SingI t => DBusValue t -> SomeDBusValue
- dbusValue :: SingI t => SomeDBusValue -> Maybe (DBusValue t)
- fromVariant :: SingI t => DBusValue TypeVariant -> Maybe (DBusValue t)
- data DBusSimpleType
- data DBusType
- newtype Signature = Signature {
- fromSignature :: [DBusType]
- typeOf :: SingI t => DBusValue t -> DBusType
- data Object = Object {}
- data Interface = Interface {}
- data ObjectPath
- objectPath :: Text -> ObjectPath
- objectPathToText :: ObjectPath -> Text
- stripObjectPrefix :: ObjectPath -> ObjectPath -> Maybe ObjectPath
- isPathPrefix :: ObjectPath -> ObjectPath -> Bool
- isRoot :: ObjectPath -> Bool
- isEmpty :: ObjectPath -> Bool
- data Method where
- Method :: (SingI avs, SingI t) => MethodWrapper avs t -> Text -> MethodDescription (ArgParity avs) -> Method
- data MethodWrapper av rv where
- MReturn :: SingI t => IO (DBusValue t) -> MethodWrapper [] t
- MAsk :: SingI t => (DBusValue t -> MethodWrapper avs rv) -> MethodWrapper (t : avs) rv
- data MethodDescription parity where
- (:->) :: Text -> MethodDescription n -> MethodDescription (Arg n)
- Result :: Text -> MethodDescription Null
- repMethod :: RepMethod f => f -> MethodWrapper (RepMethodArgs f) (RepMethodValue f)
- callMethod :: Text -> ObjectPath -> Text -> Text -> [SomeDBusValue] -> [Flag] -> DBusConnection -> IO (STM (Either [SomeDBusValue] SomeDBusValue))
- callMethod' :: (SingI (RepType a), Representable a, MonadThrow m, MonadIO m) => Text -> ObjectPath -> Text -> Text -> [SomeDBusValue] -> [Flag] -> DBusConnection -> m a
- data MsgError = MsgError {}
- addIntrospectable :: Object -> Object
- requestName :: (MonadIO m, MonadThrow m) => Text -> RequestNameFlag -> DBusConnection -> m RequestNameReply
- data RequestNameFlag = RequestNameFlag {}
- data RequestNameReply
- releaseName :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m ReleaseNameReply
- data ReleaseNameReply
- listQueuedOwners :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m [Text]
- listNames :: (MonadIO m, MonadThrow m) => DBusConnection -> m [Text]
- listActivatableNames :: (MonadIO m, MonadThrow m) => DBusConnection -> m [Text]
- nameHasOwner :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Bool
- startServiceByName :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m StartServiceResult
- getNameOwner :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Text
- getConnectionUnixUser :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Word32
- getConnectionProcessID :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Word32
- getID :: (MonadIO m, MonadThrow m) => DBusConnection -> m Text
Connection management
data ConnectionType Source
Which Bus to connect to
System | The well-known system bus. First the environmental variable DBUS_SYSTEM_BUS_ADDRESS is checked and if it doesn't exist the address unix:path=/var/run/dbus/system_bus_socket is used |
Session | The well-known session bus. Refers to the address stored in the environmental variable DBUS_SESSION_BUS_ADDRESS |
Address String | The bus at the give addresss |
:: ConnectionType | Bus to connect to |
-> MethodCallHandler | Handler for incoming method calls |
-> SignalHandler | Handler for incoming signals |
-> IO DBusConnection |
Create a new connection to a message bus
type MethodCallHandler = DBusConnection -> MessageHeader -> [SomeDBusValue] -> IO () Source
type SignalHandler = DBusConnection -> MessageHeader -> [SomeDBusValue] -> IO () Source
checkAlive :: DBusConnection -> IO Bool Source
Check whether connection is alive
waitFor :: DBusConnection -> IO () Source
Wait until connection is closed
Message handling
objectRoot :: Object -> Handler Source
Create a message handler that dispatches matches to the methods in a root object
Signals
MatchRule | |
|
matchSignal :: MessageHeader -> MatchRule -> Bool Source
Match a Signal against a rule. The argN, argNPath and arg0namespace parameter are ignored at the moment
addMatch :: (MonadIO m, MonadThrow m) => MatchRule -> DBusConnection -> m () Source
removeMatch :: (MonadIO m, MonadThrow m) => MatchRule -> DBusConnection -> m () Source
Representable Types
class Representable a where Source
makeRepresentable :: Name -> Q [Dec] Source
makeRepresentableTuple :: Int -> Q Dec Source
DBus specific types
DBus Values
data DBusValue :: DBusType -> * where Source
Eq (DBusValue t) | |
SingI DBusType t => Show (DBusValue t) | |
SingI DBusType t => IsMethod (IO (DBusValue t)) | |
(IsMethod f, SingI DBusType t) => IsMethod (DBusValue t -> f) | |
type ArgTypes (IO (DBusValue t)) = [] DBusType | |
type ResultType (IO (DBusValue t)) = t | |
type ArgTypes (DBusValue t -> f) = (:) DBusType t (ArgTypes f) | |
type ResultType (DBusValue t -> f) = ResultType f |
data DBusStruct :: [DBusType] -> * where Source
StructSingleton :: DBusValue a -> DBusStruct `[a]` | |
StructCons :: DBusValue a -> DBusStruct as -> DBusStruct (a : as) |
Eq (DBusStruct t) | |
SingI [DBusType] a => Show (DBusStruct a) |
fromVariant :: SingI t => DBusValue TypeVariant -> Maybe (DBusValue t) Source
Extract a DBusValue from a Variant iff the type matches or return nothing
Signature
data DBusSimpleType Source
TypeByte | |
TypeBoolean | |
TypeInt16 | |
TypeUInt16 | |
TypeInt32 | |
TypeUInt32 | |
TypeInt64 | |
TypeUInt64 | |
TypeDouble | |
TypeUnixFD | |
TypeString | |
TypeObjectPath | |
TypeSignature |
DBusSimpleType DBusSimpleType | |
TypeArray DBusType | |
TypeStruct [DBusType] | |
TypeDict DBusSimpleType DBusType | |
TypeVariant | |
TypeDictEntry DBusSimpleType DBusType | |
TypeUnit |
Objects
data ObjectPath Source
objectPath :: Text -> ObjectPath Source
Parse an object path. Contrary to the standard, empty path parts are ignored
objectPathToText :: ObjectPath -> Text Source
isPathPrefix :: ObjectPath -> ObjectPath -> Bool Source
isRoot :: ObjectPath -> Bool Source
isEmpty :: ObjectPath -> Bool Source
Methods
Method :: (SingI avs, SingI t) => MethodWrapper avs t -> Text -> MethodDescription (ArgParity avs) -> Method |
data MethodWrapper av rv where Source
MReturn :: SingI t => IO (DBusValue t) -> MethodWrapper [] t | |
MAsk :: SingI t => (DBusValue t -> MethodWrapper avs rv) -> MethodWrapper (t : avs) rv |
data MethodDescription parity where Source
(:->) :: Text -> MethodDescription n -> MethodDescription (Arg n) infixr 0 | |
Result :: Text -> MethodDescription Null |
repMethod :: RepMethod f => f -> MethodWrapper (RepMethodArgs f) (RepMethodValue f) Source
:: Text | Entity to send the message to |
-> ObjectPath | Object |
-> Text | Interface |
-> Text | Member (method) name |
-> [SomeDBusValue] | Arguments |
-> [Flag] | Method call flags |
-> DBusConnection | Connection to send the call over |
-> IO (STM (Either [SomeDBusValue] SomeDBusValue)) |
Asychronously call a method. Returns an STM action that waits for the returned value.
:: (SingI (RepType a), Representable a, MonadThrow m, MonadIO m) | |
=> Text | Entity to send the message to |
-> ObjectPath | Object |
-> Text | Interface |
-> Text | Member (method) to call |
-> [SomeDBusValue] | Arguments |
-> [Flag] | Method call flags |
-> DBusConnection | Connection to send the call over |
-> m a |
Synchronously call a method. Returned errors are thrown as MethodError
s.
If the returned value's type doesn't match the expected type a
MethodSignatureMissmatch
is thrown.
Introspection
addIntrospectable :: Object -> Object Source
Message Bus
requestName :: (MonadIO m, MonadThrow m) => Text -> RequestNameFlag -> DBusConnection -> m RequestNameReply Source
data RequestNameFlag Source
releaseName :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m ReleaseNameReply Source
listQueuedOwners :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m [Text] Source
listNames :: (MonadIO m, MonadThrow m) => DBusConnection -> m [Text] Source
listActivatableNames :: (MonadIO m, MonadThrow m) => DBusConnection -> m [Text] Source
nameHasOwner :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Bool Source
startServiceByName :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m StartServiceResult Source
getNameOwner :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Text Source
getConnectionUnixUser :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Word32 Source
getConnectionProcessID :: (MonadIO m, MonadThrow m) => Text -> DBusConnection -> m Word32 Source
getID :: (MonadIO m, MonadThrow m) => DBusConnection -> m Text Source