source: project/release/4/dbus/trunk/examples/introspect-connman.scm @ 25883

Last change on this file since 25883 was 25883, checked in by ecloud, 9 years ago

Added "boxed" variant type and unsupported type to distinguish from #f.

You can choose whether to have variants automatically unboxed when reading, or not.
But the enclosing record will be necessary to indicate to e.g. dbus:send that
you wish to send an item in a variant.

File size: 1.2 KB
RevLine 
[25880]1(use dbus)
2
3(define ctxt (dbus:make-context
4        bus: dbus:system-bus
5        service: 'net.connman
6))
7
[25881]8(display (dbus:discover-api-xml ctxt))
[25880]9
[25881]10(define (device-properties device)
11  (let ((c (dbus:make-context bus: dbus:system-bus
12                              service: 'net.connman
13                              interface: 'net.connman.Service
14                              path: device)))
15    (dbus:call c "GetProperties")))
16
[25880]17(define mgr-ctxt (dbus:make-context bus: dbus:system-bus
18        service: 'net.connman interface: 'net.connman.Manager))
19
[25881]20(printf "~%==== Clock Properties:~%")
21(define clock-ctxt (dbus:make-context bus: dbus:system-bus
22        service: 'net.connman interface: 'net.connman.Clock))
23(pretty-print (dbus:call clock-ctxt "GetProperties"))
[25880]24
25(printf "~%==== Manager Services:~%")
26(pretty-print (dbus:call mgr-ctxt "GetServices"))
27
[25881]28(printf "~%==== Manager Properties:~%")
[25883]29(auto-unbox-variants #t)
[25881]30(let ([mgr-props (dbus:call mgr-ctxt "GetProperties")])
31        (pretty-print mgr-props)
32        (let ([ifaces (assoc "Services" (vector->list (car mgr-props)))])
33                (when (pair? ifaces)
34                        (set! ifaces (vector->list (cdr ifaces)))
35(printf "~%==== Network interface Properties:~%")
36                        (for-each (lambda (path)
37                                        (printf "---- ~a~%" path)
38                                        (pp (vector->list (car (device-properties path))))
39                                ) ifaces)
40                )))
[25880]41
42(sleep 1)
43(exit)
Note: See TracBrowser for help on using the repository browser.