aboutsummaryrefslogtreecommitdiff
path: root/Utility/DBus.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-21 19:58:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-21 19:58:53 -0400
commit5a68acb521bae0277b2c8a8ca023dc57a5ff4b33 (patch)
tree75dd571ae83a88f9e29da125faee474c0dc42293 /Utility/DBus.hs
parente3e8d3292478d8cca0206db8b99dcd4d2f9ac5aa (diff)
add NetWatcher thread
This deals with interruptions in network connectevity, by listening for a new network interface coming up (using dbus to see when network-manager or wicd do it), and forcing a rescan of
Diffstat (limited to 'Utility/DBus.hs')
-rw-r--r--Utility/DBus.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Utility/DBus.hs b/Utility/DBus.hs
new file mode 100644
index 000000000..cfd06f762
--- /dev/null
+++ b/Utility/DBus.hs
@@ -0,0 +1,28 @@
+{- DBus utilities
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE OverloadedStrings #-}
+
+module Utility.DBus where
+
+import DBus.Client
+import DBus
+import Data.Maybe
+
+type ServiceName = String
+
+listServiceNames :: Client -> IO [ServiceName]
+listServiceNames client = do
+ reply <- callDBus client "ListNames" []
+ return $ fromMaybe [] $ fromVariant (methodReturnBody reply !! 0)
+
+callDBus :: Client -> MemberName -> [Variant] -> IO MethodReturn
+callDBus client name params = call_ client $
+ (methodCall "/org/freedesktop/DBus" "org.freedesktop.DBus" name)
+ { methodCallDestination = Just "org.freedesktop.DBus"
+ , methodCallBody = params
+ }