@@ -20,13 +20,15 @@ The following code is assumed as a prolog to all following ones
2020
2121#### Calling Methods
2222
23- 1 . Connect to the session bus; get the screensaver service and its
24- screensaver object.
25- 2 . Perform explicit introspection to define the interfaces and methods
26- on the {DBus::ProxyObject object proxy}
27- ({https://github.com/mvidner/ruby-dbus/issues/28 I #28 }).
28- 3 . Get the screensaver interface
29- ({https://github.com/mvidner/ruby-dbus/issues/29 I #29 }).
23+ 1 . {DBus.session_bus Connect to the session bus};
24+ {DBus::Connection#[ ] get the screensaver service}
25+ {DBus::Service#object and its screensaver object}.
26+ 2 . Perform {DBus::ProxyObject#introspect explicit introspection}
27+ to define the interfaces and methods
28+ on the {DBus::ProxyObject object proxy}
29+ [ I #28 ] ( https://github.com/mvidner/ruby-dbus/issues/28 ) .
30+ 3 . Get the screensaver {DBus::ProxyObject#[ ] interface}
31+ [ I #29 ] ( https://github.com/mvidner/ruby-dbus/issues/29 ) .
30324 . Call one of its methods in a loop, solving [ xkcd #196 ] ( http://xkcd.com/196 ) .
3133
3234{include:file: doc /ex-calling-methods.body.rb}
@@ -37,7 +39,7 @@ A method proxy always returns an array of values. This is to
3739accomodate the rare cases of a DBus method specifying more than one
3840* out* parameter. For nearly all methods you should use ` Method[0] ` or
3941` Method.first `
40- ({ https://github.com/mvidner/ruby-dbus/issues/30 I # 30 } ).
42+ [ I # 30 ] ( https://github.com/mvidner/ruby-dbus/issues/30 ) .
4143
4244
4345 # wrong
@@ -52,14 +54,41 @@ accomodate the rare cases of a DBus method specifying more than one
5254
5355#### Accessing Properties
5456
55- {include:file: doc /ex-properties.body.rb}
57+ To access properties, think of the {DBus::ProxyObjectInterface interface} as a
58+ {DBus::ProxyObjectInterface#[ ] hash} keyed by strings,
59+ or use {DBus::ProxyObjectInterface#all_properties} to get
60+ an actual Hash of them.
5661
57- #### Receiving Signals
62+ {include:file : doc /ex-properties.body.rb}
5863
64+ (TODO a writable property example)
5965
6066#### Asynchronous Operation
67+
68+ If a method call has a block attached, it is asynchronous and the block
69+ is invoked on receiving a method_return message or an error message
70+
6171##### Main Loop
6272
73+ For asynchronous operation an event loop is necessary. Use {DBus::Main}:
74+
75+ # [set up signal handlers...]
76+ main = DBus::Main.new
77+ main << mybus
78+ main.run
79+
80+ Alternately, run the GLib main loop and add your DBus connections to it via
81+ {DBus::Connection#glibize}.
82+
83+ #### Receiving Signals
84+
85+ To receive signals for a specific object and interface, use
86+ {DBus::ProxyObjectInterface#on\_ signal}(bus, name, &block) or
87+ {DBus::ProxyObject#on_signal}(name, &block), for the default interface.
88+ [ I #31 ] ( https://github.com/mvidner/ruby-dbus/issues/31 )
89+
90+ {include:file: doc /ex-signal.body.rb}
91+
6392### Intermediate Concepts
6493#### Names
6594#### Types
0 commit comments