em-ruby-dbus 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +504 -0
  3. data/NEWS +253 -0
  4. data/README.md +93 -0
  5. data/Rakefile +58 -0
  6. data/VERSION +1 -0
  7. data/doc/Reference.md +207 -0
  8. data/doc/Tutorial.md +480 -0
  9. data/doc/ex-calling-methods.body.rb +8 -0
  10. data/doc/ex-calling-methods.rb +3 -0
  11. data/doc/ex-properties.body.rb +9 -0
  12. data/doc/ex-properties.rb +3 -0
  13. data/doc/ex-setup.rb +7 -0
  14. data/doc/ex-signal.body.rb +20 -0
  15. data/doc/ex-signal.rb +3 -0
  16. data/doc/example-helper.rb +6 -0
  17. data/em-ruby-dbus.gemspec +20 -0
  18. data/examples/gdbus/gdbus +255 -0
  19. data/examples/gdbus/gdbus.glade +184 -0
  20. data/examples/gdbus/launch.sh +4 -0
  21. data/examples/no-introspect/nm-test.rb +21 -0
  22. data/examples/no-introspect/tracker-test.rb +16 -0
  23. data/examples/rhythmbox/playpause.rb +25 -0
  24. data/examples/service/call_service.rb +25 -0
  25. data/examples/service/service_newapi.rb +51 -0
  26. data/examples/simple/call_introspect.rb +34 -0
  27. data/examples/simple/properties.rb +19 -0
  28. data/examples/utils/listnames.rb +11 -0
  29. data/examples/utils/notify.rb +19 -0
  30. data/lib/dbus.rb +82 -0
  31. data/lib/dbus/auth.rb +269 -0
  32. data/lib/dbus/bus.rb +739 -0
  33. data/lib/dbus/core_ext/array/extract_options.rb +31 -0
  34. data/lib/dbus/core_ext/class/attribute.rb +129 -0
  35. data/lib/dbus/core_ext/kernel/singleton_class.rb +8 -0
  36. data/lib/dbus/core_ext/module/remove_method.rb +14 -0
  37. data/lib/dbus/error.rb +46 -0
  38. data/lib/dbus/export.rb +128 -0
  39. data/lib/dbus/introspect.rb +219 -0
  40. data/lib/dbus/logger.rb +31 -0
  41. data/lib/dbus/loop-em.rb +19 -0
  42. data/lib/dbus/marshall.rb +434 -0
  43. data/lib/dbus/matchrule.rb +101 -0
  44. data/lib/dbus/message.rb +276 -0
  45. data/lib/dbus/message_queue.rb +166 -0
  46. data/lib/dbus/proxy_object.rb +149 -0
  47. data/lib/dbus/proxy_object_factory.rb +41 -0
  48. data/lib/dbus/proxy_object_interface.rb +128 -0
  49. data/lib/dbus/type.rb +193 -0
  50. data/lib/dbus/xml.rb +161 -0
  51. data/test/async_spec.rb +47 -0
  52. data/test/binding_spec.rb +74 -0
  53. data/test/bus_and_xml_backend_spec.rb +39 -0
  54. data/test/bus_driver_spec.rb +20 -0
  55. data/test/bus_spec.rb +20 -0
  56. data/test/byte_array_spec.rb +38 -0
  57. data/test/err_msg_spec.rb +42 -0
  58. data/test/introspect_xml_parser_spec.rb +26 -0
  59. data/test/introspection_spec.rb +32 -0
  60. data/test/main_loop_spec.rb +82 -0
  61. data/test/property_spec.rb +53 -0
  62. data/test/server_robustness_spec.rb +66 -0
  63. data/test/server_spec.rb +53 -0
  64. data/test/service_newapi.rb +217 -0
  65. data/test/session_bus_spec_manual.rb +15 -0
  66. data/test/signal_spec.rb +90 -0
  67. data/test/spec_helper.rb +33 -0
  68. data/test/thread_safety_spec.rb +31 -0
  69. data/test/tools/dbus-launch-simple +35 -0
  70. data/test/tools/dbus-limited-session.conf +28 -0
  71. data/test/tools/test_env +13 -0
  72. data/test/tools/test_server +39 -0
  73. data/test/type_spec.rb +19 -0
  74. data/test/value_spec.rb +81 -0
  75. data/test/variant_spec.rb +66 -0
  76. metadata +145 -0
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env rspec
2
+ require_relative "spec_helper"
3
+ require "dbus"
4
+
5
+ describe "IntrospectXMLParserTest" do
6
+ it "tests split interfaces" do
7
+ xml = <<EOS
8
+ <node>
9
+ <interface name="org.example.Foo">
10
+ <method name="Dwim"/>
11
+ </interface>
12
+ <interface name="org.example.Bar">
13
+ <method name="Drink"/>
14
+ </interface>
15
+ <interface name="org.example.Foo">
16
+ <method name="Smurf"/>
17
+ </interface>
18
+ </node>
19
+ EOS
20
+
21
+ interfaces, _ = DBus::IntrospectXMLParser.new(xml).parse
22
+
23
+ foo = interfaces.find {|i| i.name == "org.example.Foo" }
24
+ expect(foo.methods.keys.size).to eq(2)
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rspec
2
+ require_relative "spec_helper"
3
+ require "dbus"
4
+
5
+ describe "IntrospectionTest" do
6
+ before(:each) do
7
+ session_bus = DBus::ASessionBus.new
8
+ svc = session_bus.service("org.ruby.service")
9
+ @obj = svc.object("/org/ruby/MyInstance")
10
+ @obj.introspect
11
+ @obj.default_iface = "org.ruby.SampleInterface"
12
+ end
13
+
14
+ it "tests wrong number of arguments" do
15
+ expect { @obj.test_variant "too","many","args" }.to raise_error(ArgumentError)
16
+ # not enough
17
+ expect { @obj.test_variant }.to raise_error(ArgumentError)
18
+ end
19
+
20
+ it "tests shortcut methods" do
21
+ @obj.default_iface = nil
22
+ expect(@obj.bounce_variant("varargs")).to eq(["varargs"])
23
+ # test for a duplicated method name
24
+ expect { @obj.the_answer }.to raise_error(NoMethodError)
25
+ # ensure istance methods of ProxyObject aren't overwritten by remote
26
+ # methods
27
+ expect { @obj.interfaces }.not_to raise_error
28
+
29
+ @obj.default_iface = "org.ruby.SampleInterface"
30
+ expect(@obj.the_answer).to eq([42])
31
+ end
32
+ end
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env rspec
2
+ # Test the main loop
3
+ require_relative "spec_helper"
4
+ require "dbus"
5
+
6
+ describe "MainLoopTest" do
7
+ before(:each) do
8
+ @session_bus = DBus::ASessionBus.new
9
+ svc = @session_bus.service("org.ruby.service")
10
+ @obj = svc.object("/org/ruby/MyInstance")
11
+ @obj.introspect # necessary
12
+ @obj.default_iface = "org.ruby.Loop"
13
+
14
+ @loop = DBus::Main.new
15
+ @loop << @session_bus
16
+ end
17
+
18
+ # Hack the library internals so that there is a delay between
19
+ # sending a DBus call and listening for its reply, so that
20
+ # the bus has a chance to join the server messages and a race is reproducible
21
+ def call_lazily
22
+ class << @session_bus
23
+ alias :wait_for_message_orig :wait_for_message
24
+ def wait_for_message_lazy
25
+ DBus.logger.debug "I am so lazy"
26
+ sleep 1 # Give the server+bus a chance to join the messages
27
+ wait_for_message_orig
28
+ end
29
+ alias :wait_for_message :wait_for_message_lazy
30
+ end
31
+
32
+ yield
33
+
34
+ # undo
35
+ class << @session_bus
36
+ remove_method :wait_for_message
37
+ remove_method :wait_for_message_lazy
38
+ alias :wait_for_message :wait_for_message_orig
39
+ end
40
+ end
41
+
42
+ def test_loop_quit(delay)
43
+ @obj.on_signal "LongTaskEnd" do
44
+ DBus.logger.debug "Telling loop to quit"
45
+ @loop.quit
46
+ end
47
+
48
+ call_lazily do
49
+ # The method will sleep the requested amount of seconds
50
+ # (in another thread) before signalling LongTaskEnd
51
+ @obj.LongTaskBegin delay
52
+ end
53
+
54
+ # this thread will make the test fail if @loop.run does not return
55
+ dynamite = Thread.new do
56
+ DBus.logger.debug "Dynamite burning"
57
+ sleep 2
58
+ DBus.logger.debug "Dynamite explodes"
59
+ # We need to raise in the main thread.
60
+ # Simply raising here means the exception is ignored
61
+ # (until dynamite.join which we don't call) or
62
+ # (if abort_on_exception is set) it terminates the whole script.
63
+ Thread.main.raise RuntimeError, "The main loop did not quit in time"
64
+ end
65
+
66
+ @loop.run
67
+ DBus.logger.debug "Defusing dynamite"
68
+ # if we get here, defuse the bomb
69
+ dynamite.exit
70
+ # remove signal handler
71
+ @obj.on_signal "LongTaskEnd"
72
+ end
73
+
74
+ it "tests loop quit" do
75
+ test_loop_quit 1
76
+ end
77
+
78
+ # https://bugzilla.novell.com/show_bug.cgi?id=537401
79
+ it "tests loop drained socket" do
80
+ test_loop_quit 0
81
+ end
82
+ end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env rspec
2
+ require_relative "spec_helper"
3
+ require "dbus"
4
+
5
+ describe "PropertyTest" do
6
+ before(:each) do
7
+ session_bus = DBus::ASessionBus.new
8
+ svc = session_bus.service("org.ruby.service")
9
+ @obj = svc.object("/org/ruby/MyInstance")
10
+ @obj.introspect
11
+ @iface = @obj["org.ruby.SampleInterface"]
12
+ end
13
+
14
+ it "tests property reading" do
15
+ expect(@iface["ReadMe"]).to eq("READ ME")
16
+ end
17
+
18
+ it "tests property nonreading" do
19
+ expect { @iface["WriteMe"] }.to raise_error(DBus::Error, /not readable/)
20
+ end
21
+
22
+ it "tests property writing" do
23
+ @iface["ReadOrWriteMe"] = "VALUE"
24
+ expect(@iface["ReadOrWriteMe"]).to eq("VALUE")
25
+ end
26
+
27
+ # https://github.com/mvidner/ruby-dbus/pull/19
28
+ it "tests service select timeout" do
29
+ @iface["ReadOrWriteMe"] = "VALUE"
30
+ expect(@iface["ReadOrWriteMe"]).to eq("VALUE")
31
+ # wait for the service to become idle
32
+ sleep 6
33
+ # fail: "Property value changed; perhaps the service died and got restarted"
34
+ expect(@iface["ReadOrWriteMe"]).to eq("VALUE")
35
+ end
36
+
37
+ it "tests property nonwriting" do
38
+ expect { @iface["ReadMe"] = "WROTE" }.to raise_error(DBus::Error, /not writable/)
39
+ end
40
+
41
+ it "tests get all" do
42
+ all = @iface.all_properties
43
+ expect(all.keys.sort).to eq(["ReadMe", "ReadOrWriteMe"])
44
+ end
45
+
46
+ it "tests unknown property reading" do
47
+ expect { @iface["Spoon"] }.to raise_error(DBus::Error, /not found/)
48
+ end
49
+
50
+ it "tests unknown property writing" do
51
+ expect { @iface["Spoon"] = "FPRK" }.to raise_error(DBus::Error, /not found/)
52
+ end
53
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env rspec
2
+ # Test that a server survives various error cases
3
+ require_relative "spec_helper"
4
+ require "dbus"
5
+
6
+ describe "ServerRobustnessTest" do
7
+ before(:each) do
8
+ @bus = DBus::ASessionBus.new
9
+ @svc = @bus.service("org.ruby.service")
10
+ end
11
+
12
+ # https://trac.luon.net/ruby-dbus/ticket/31
13
+ # the server should not crash
14
+ it "tests no such path with introspection" do
15
+ obj = @svc.object "/org/ruby/NotMyInstance"
16
+ expect { obj.introspect }.to raise_error(DBus::Error) do |e|
17
+ expect(e).to_not match(/timeout/)
18
+ end
19
+ end
20
+
21
+ it "tests no such path without introspection" do
22
+ obj = @svc.object "/org/ruby/NotMyInstance"
23
+ ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
24
+ ifc.define_method("the_answer", "out n:i")
25
+ expect { ifc.the_answer }.to raise_error(DBus::Error) do |e|
26
+ expect(e).to_not match(/timeout/)
27
+ end
28
+ end
29
+
30
+ it "tests a method that raises" do
31
+ obj = @svc.object "/org/ruby/MyInstance"
32
+ obj.introspect
33
+ obj.default_iface = "org.ruby.SampleInterface"
34
+ expect { obj.will_raise }.to raise_error(DBus::Error) do |e|
35
+ expect(e).to_not match(/timeout/)
36
+ end
37
+ end
38
+
39
+ it "tests a method that raises name error" do
40
+ obj = @svc.object "/org/ruby/MyInstance"
41
+ obj.introspect
42
+ obj.default_iface = "org.ruby.SampleInterface"
43
+ expect { obj.will_raise_name_error }.to raise_error(DBus::Error) do |e|
44
+ expect(e).to_not match(/timeout/)
45
+ end
46
+ end
47
+
48
+ # https://trac.luon.net/ruby-dbus/ticket/31#comment:3
49
+ it "tests no such method without introspection" do
50
+ obj = @svc.object "/org/ruby/MyInstance"
51
+ ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
52
+ ifc.define_method("not_the_answer", "out n:i")
53
+ expect { ifc.not_the_answer }.to raise_error(DBus::Error) do |e|
54
+ expect(e).to_not match(/timeout/)
55
+ end
56
+ end
57
+
58
+ it "tests no such interface without introspection" do
59
+ obj = @svc.object "/org/ruby/MyInstance"
60
+ ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.NoSuchInterface")
61
+ ifc.define_method("the_answer", "out n:i")
62
+ expect { ifc.the_answer }.to raise_error(DBus::Error) do |e|
63
+ expect(e).to_not match(/timeout/)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env rspec
2
+ # Test that a server survives various error cases
3
+ require_relative "spec_helper"
4
+ require "dbus"
5
+
6
+ class Foo < DBus::Object
7
+ dbus_interface "org.ruby.ServerTest" do
8
+ dbus_signal :signal_without_arguments
9
+ dbus_signal :signal_with_argument, "epsilon:d"
10
+ end
11
+
12
+ dbus_signal :signal_without_interface
13
+ rescue DBus::Object::UndefinedInterface
14
+ # raised by the preceding signal declaration
15
+ end
16
+
17
+ class Bar < DBus::Object
18
+ dbus_interface "org.ruby.ServerTest" do
19
+ # a valid Ruby symbol but an invalid DBus name; Ticket#38
20
+ dbus_signal :signal_with_a_bang!
21
+ end
22
+ rescue DBus::InvalidMethodName
23
+ # raised by the preceding signal declaration
24
+ end
25
+
26
+ describe "ServerTest" do
27
+ before(:each) do
28
+ @bus = DBus::ASessionBus.new
29
+ @svc = @bus.request_service "org.ruby.server-test"
30
+ end
31
+
32
+ after(:each) do
33
+ @bus.proxy.ReleaseName "org.ruby.server-test"
34
+ end
35
+
36
+ it "tests unexporting an object" do
37
+ obj = Foo.new "/org/ruby/Foo"
38
+ @svc.export obj
39
+ expect(@svc.unexport(obj)).to be_true
40
+ end
41
+
42
+ it "tests unexporting an object not exported" do
43
+ obj = Foo.new "/org/ruby/Foo"
44
+ expect(@svc.unexport(obj)).to be_false
45
+ end
46
+
47
+ it "tests emiting signals" do
48
+ obj = Foo.new "/org/ruby/Foo"
49
+ @svc.export obj
50
+ obj.signal_without_arguments
51
+ obj.signal_with_argument(-0.1)
52
+ end
53
+ end
@@ -0,0 +1,217 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require_relative "spec_helper"
5
+ SimpleCov.command_name "Service Tests" if Object.const_defined? "SimpleCov"
6
+ # find the library without external help
7
+ $:.unshift File.expand_path("../../lib", __FILE__)
8
+
9
+ require 'dbus'
10
+
11
+ PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties"
12
+
13
+ class Test < DBus::Object
14
+ INTERFACE = "org.ruby.SampleInterface"
15
+ def initialize(path)
16
+ super path
17
+ @read_me = "READ ME"
18
+ @read_or_write_me = "READ OR WRITE ME"
19
+ end
20
+
21
+ # Create an interface aggregating all upcoming dbus_method defines.
22
+ dbus_interface INTERFACE do
23
+ dbus_method :hello, "in name:s, in name2:s" do |name, name2|
24
+ puts "hello(#{name}, #{name2})"
25
+ end
26
+
27
+ dbus_method :test_variant, "in stuff:v" do |variant|
28
+ DBus.logger.debug variant.inspect
29
+ end
30
+
31
+ dbus_method :bounce_variant, "in stuff:v, out chaff:v" do |variant|
32
+ [variant]
33
+ end
34
+
35
+ dbus_method :variant_size, "in stuff:v, out size:u" do |variant|
36
+ [variant.size]
37
+ end
38
+
39
+ dbus_method :the_answer, "out answer:i" do
40
+ 42
41
+ end
42
+
43
+ dbus_method :will_raise, "" do
44
+ raise "Handle this"
45
+ end
46
+
47
+ dbus_method :will_raise_error_failed, "" do
48
+ raise DBus.error, "failed as designed"
49
+ end
50
+
51
+ dbus_method :will_raise_name_error, "" do
52
+ "foo".frobnicate
53
+ end
54
+
55
+ dbus_method :Error, "in name:s, in description:s" do |name, description|
56
+ raise DBus.error(name), description
57
+ end
58
+
59
+ dbus_method :mirror_byte_array, "in bytes:ay, out mirrored:ay" do |bytes|
60
+ [bytes]
61
+ end
62
+ end
63
+
64
+ # closing and reopening the same interface
65
+ dbus_interface INTERFACE do
66
+ dbus_method :multibyte_string, "out string:s" do
67
+ "あいうえお"
68
+ end
69
+
70
+ dbus_signal :SomethingJustHappened, "toto:s, tutu:u"
71
+ end
72
+
73
+ dbus_interface "org.ruby.AnotherInterface" do
74
+ dbus_method :ThatsALongMethodNameIThink do
75
+ puts "ThatsALongMethodNameIThink"
76
+ end
77
+ dbus_method :Reverse, "in instr:s, out outstr:s" do |instr|
78
+ outstr = instr.split(//).reverse.join
79
+ [outstr]
80
+ end
81
+ end
82
+
83
+ dbus_interface "org.ruby.Ticket30" do
84
+ dbus_method :Sybilla, 'in choices:av, out advice:s' do |choices|
85
+ ["Do #{choices[0]}"]
86
+ end
87
+ end
88
+
89
+ dbus_interface "org.ruby.Duplicates" do
90
+ dbus_method :the_answer, "out answer:i" do
91
+ [0]
92
+ end
93
+ dbus_method :interfaces, "out answer:i" do
94
+ raise "This DBus method is currently shadowed by ProxyObject#interfaces"
95
+ end
96
+ end
97
+
98
+ dbus_interface "org.ruby.Loop" do
99
+ # starts doing something long, but returns immediately
100
+ # and sends a signal when done
101
+ dbus_method :LongTaskBegin, 'in delay:i' do |delay|
102
+ # FIXME did not complain about mismatch between signature and block args
103
+ self.LongTaskStart
104
+ DBus.logger.debug "Long task began"
105
+ task = Thread.new do
106
+ DBus.logger.debug "Long task thread started (#{delay}s)"
107
+ sleep delay
108
+ DBus.logger.debug "Long task will signal end"
109
+ self.LongTaskEnd
110
+ end
111
+ task.abort_on_exception = true # protect from test case bugs
112
+ end
113
+
114
+ dbus_signal :LongTaskStart
115
+ dbus_signal :LongTaskEnd
116
+ end
117
+
118
+ # Properties:
119
+ # ReadMe:string, returns "READ ME" at first, then what WriteMe received
120
+ # WriteMe:string
121
+ # ReadOrWriteMe:string, returns "READ OR WRITE ME" at first
122
+ dbus_interface PROPERTY_INTERFACE do
123
+ dbus_method :Get, "in interface:s, in propname:s, out value:v" do |interface, propname|
124
+ if interface == INTERFACE
125
+ if propname == "ReadMe"
126
+ [@read_me]
127
+ elsif propname == "ReadOrWriteMe"
128
+ [@read_or_write_me]
129
+ elsif propname == "WriteMe"
130
+ raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"), "Property '#{interface}.#{propname}' (on object '#{@path}') is not readable"
131
+ else
132
+ raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"), "Property '#{interface}.#{propname}' not found on object '#{@path}'"
133
+ end
134
+ else
135
+ raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"), "Interface '#{interface}' not found on object '#{@path}'"
136
+ end
137
+ # what should happen for unknown properties
138
+ # plasma: InvalidArgs (propname), UnknownInterface (interface)
139
+ end
140
+
141
+ dbus_method :Set, "in interface:s, in propname:s, in value:v" do |interface, propname, value|
142
+ if interface == INTERFACE
143
+ if propname == "ReadMe"
144
+ raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"), "Property '#{interface}.#{propname}' (on object '#{@path}') is not writable"
145
+ elsif propname == "ReadOrWriteMe"
146
+ @read_or_write_me = value
147
+ self.PropertiesChanged(interface, {propname => value}, [])
148
+ elsif propname == "WriteMe"
149
+ @read_me = value
150
+ self.PropertiesChanged(interface, {"ReadMe" => value}, [])
151
+ else
152
+ raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"), "Property '#{interface}.#{propname}' not found on object '#{@path}'"
153
+ end
154
+ else
155
+ raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"), "Interface '#{interface}' not found on object '#{@path}'"
156
+ end
157
+ end
158
+
159
+ dbus_method :GetAll, "in interface:s, out value:a{sv}" do |interface|
160
+ if interface == INTERFACE
161
+ [ {
162
+ "ReadMe" => @read_me,
163
+ "ReadOrWriteMe" =>@read_or_write_me,
164
+ } ]
165
+ else
166
+ raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"), "Interface '#{interface}' not found on object '#{@path}'"
167
+ end
168
+ end
169
+
170
+ dbus_signal :PropertiesChanged, "interface:s, changed_properties:a{sv}, invalidated_properties:as"
171
+ end
172
+ end
173
+
174
+ class Derived < Test
175
+ end
176
+
177
+ class Test2 < DBus::Object
178
+ dbus_interface "org.ruby.Test2" do
179
+ dbus_method :hi, "in name:s, out greeting:s" do |name|
180
+ "Hi, #{name}!"
181
+ end
182
+ end
183
+ end
184
+
185
+ bus = DBus::SessionBus.instance
186
+ service = bus.request_service("org.ruby.service")
187
+ myobj = Test.new("/org/ruby/MyInstance")
188
+ service.export(myobj)
189
+ derived = Derived.new "/org/ruby/MyDerivedInstance"
190
+ service.export derived
191
+ test2 = Test2.new "/org/ruby/MyInstance2"
192
+ service.export test2
193
+
194
+ # introspect every other connection, Ticket #34
195
+ # (except the one that activates us - it has already emitted
196
+ # NOC by the time we run this. Therefore the test for #34 will not work
197
+ # by running t2.rb alone, one has to run t1 before it; 'rake' does it)
198
+ mr = DBus::MatchRule.new.from_s "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
199
+ bus.add_match(mr) do |msg|
200
+ new_unique_name = msg.params[2]
201
+ unless new_unique_name.empty?
202
+ DBus.logger.debug "RRRING #{new_unique_name}"
203
+ bus.introspect_data(new_unique_name, "/") do
204
+ # ignore the result
205
+ end
206
+ end
207
+ end
208
+
209
+ puts "listening, with ruby-#{RUBY_VERSION}"
210
+ main = DBus::Main.new
211
+ main << bus
212
+ begin
213
+ main.run
214
+ rescue SystemCallError
215
+ # the test driver will kill the bus, that's OK
216
+ end
217
+