recovered
[rrq/lsp-utils.git] / lsp-dbus-test.lsp
1 ;; This is a test program for the lsp-dbus provided dbus API.
2
3 (load "lsp-dbus.lsp")
4 ;; Loading that module sets up core framework API and connects to
5 ;; dbus' system bus registering this application. This includes
6 ;; Dbus:ROOT for the "/org/freedektop/DBus" path, and Dbus:DBus for
7 ;; the interrface "org.freedektop.DBus".
8
9 ;; Register a handler for the NameAcquired signal, to replace the one
10 ;; installed by lsp-dbus.lsp
11
12 ;; Request a bus name "au.rrq" for this client
13 (println "RequestName: "
14          (if (:invoke Dbus:ROOT (:m ObjectManager "RequestName(su)")
15                       '("au.rrq" 0))
16              (!= ($it -1 -1 -1)) ; returns BOOLEAN
17            ))
18
19 ;; Set up a Match rule to see stuff
20 (setf MATCH-RULE
21       (join (list "type='signal'"
22                   ;;"sender='org.example.App2'"
23                   ;;"path_namespace='/au/rrq'"
24                   ;;"eavesdrop='true'"
25                   )
26             ","))
27 (println "AddMatch:\n" MATCH-RULE "\n"
28          (if (:invoke Dbus:ROOT (:m Dbus:DBus "AddMatch(s)")
29                       (list MATCH-RULE))
30              ($it -1 -1 -1) ; returns OOM on error
31            ))
32
33 (reset)
34
35
36 (println (if (:invoke Dbus:ROOT
37                       (print "GetNameOwner(s)")
38                       (println (list "org.bluez")))
39              ($it -1 -1 -1) ; Return value
40            ))
41 (Dbus:process-all-pending)
42
43 (println (setf org.bluez (Dbus "/" "org.bluez")))
44 (println (if (:invoke org.bluez (:m ObjectManager "GetManagedObjects()"))
45              ($it -1 -1 -1) ; Return value
46            ))
47
48
49 (reset) ; 
50
51 "lsp-dbus-test.lsp"