ruby-dbus 0.12.0 → 0.13.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.
- checksums.yaml +4 -4
- data/NEWS.md +344 -0
- data/Rakefile +21 -15
- data/VERSION +1 -1
- data/doc/Reference.md +26 -37
- data/examples/doc/_extract_examples +4 -4
- data/examples/gdbus/gdbus +40 -39
- data/examples/no-introspect/nm-test.rb +1 -3
- data/examples/no-introspect/tracker-test.rb +2 -4
- data/examples/rhythmbox/playpause.rb +1 -2
- data/examples/service/call_service.rb +0 -3
- data/examples/service/service_newapi.rb +3 -4
- data/examples/simple/call_introspect.rb +0 -3
- data/examples/simple/get_id.rb +1 -3
- data/examples/simple/properties.rb +3 -4
- data/examples/utils/listnames.rb +6 -7
- data/examples/utils/notify.rb +3 -5
- data/lib/dbus.rb +8 -20
- data/lib/dbus/auth.rb +59 -61
- data/lib/dbus/bus.rb +86 -97
- data/lib/dbus/error.rb +1 -1
- data/lib/dbus/export.rb +20 -18
- data/lib/dbus/introspect.rb +26 -28
- data/lib/dbus/logger.rb +1 -1
- data/lib/dbus/marshall.rb +72 -74
- data/lib/dbus/matchrule.rb +22 -26
- data/lib/dbus/message.rb +24 -33
- data/lib/dbus/message_queue.rb +30 -30
- data/lib/dbus/proxy_object.rb +34 -30
- data/lib/dbus/proxy_object_factory.rb +5 -2
- data/lib/dbus/proxy_object_interface.rb +10 -8
- data/lib/dbus/type.rb +154 -156
- data/lib/dbus/xml.rb +22 -16
- data/ruby-dbus.gemspec +15 -3
- data/spec/async_spec.rb +2 -4
- data/spec/binding_spec.rb +1 -5
- data/spec/bus_and_xml_backend_spec.rb +6 -9
- data/spec/bus_spec.rb +1 -1
- data/spec/byte_array_spec.rb +0 -2
- data/spec/err_msg_spec.rb +13 -10
- data/spec/introspect_xml_parser_spec.rb +2 -2
- data/spec/introspection_spec.rb +1 -1
- data/spec/main_loop_spec.rb +4 -5
- data/spec/property_spec.rb +0 -3
- data/spec/proxy_object_spec.rb +42 -0
- data/spec/server_robustness_spec.rb +0 -2
- data/spec/service_newapi.rb +51 -41
- data/spec/session_bus_spec.rb +6 -7
- data/spec/signal_spec.rb +2 -3
- data/spec/spec_helper.rb +28 -24
- data/spec/thread_safety_spec.rb +1 -2
- data/spec/type_spec.rb +2 -2
- data/spec/value_spec.rb +7 -10
- data/spec/variant_spec.rb +15 -16
- metadata +60 -3
- data/NEWS +0 -279
data/ruby-dbus.gemspec
CHANGED
@@ -12,9 +12,21 @@ GEMSPEC = Gem::Specification.new do |s|
|
|
12
12
|
s.author = "Ruby DBus Team"
|
13
13
|
s.email = "ruby-dbus-devel@lists.luon.net"
|
14
14
|
s.homepage = "https://trac.luon.net/ruby-dbus"
|
15
|
-
s.files = FileList[
|
15
|
+
s.files = FileList[
|
16
|
+
"{doc,examples,lib,spec}/**/*",
|
17
|
+
"COPYING", "NEWS.md", "Rakefile", "README.md",
|
18
|
+
"ruby-dbus.gemspec", "VERSION", ".rspec"].to_a.sort
|
16
19
|
s.require_path = "lib"
|
20
|
+
|
17
21
|
s.required_ruby_version = ">= 2.0.0"
|
18
|
-
|
19
|
-
|
22
|
+
|
23
|
+
# This is optional
|
24
|
+
# s.add_runtime_dependency "nokogiri"
|
25
|
+
|
26
|
+
s.add_development_dependency "coveralls"
|
27
|
+
s.add_development_dependency "packaging_rake_tasks"
|
28
|
+
s.add_development_dependency "rake"
|
29
|
+
s.add_development_dependency "rspec", "~> 3"
|
30
|
+
s.add_development_dependency "rubocop", "= 0.41.2"
|
31
|
+
s.add_development_dependency "simplecov"
|
20
32
|
end
|
data/spec/async_spec.rb
CHANGED
@@ -8,7 +8,6 @@ describe "AsyncTest" do
|
|
8
8
|
@bus = DBus::ASessionBus.new
|
9
9
|
@svc = @bus.service("org.ruby.service")
|
10
10
|
@obj = @svc.object "/org/ruby/MyInstance"
|
11
|
-
@obj.introspect
|
12
11
|
@obj.default_iface = "org.ruby.SampleInterface"
|
13
12
|
end
|
14
13
|
|
@@ -17,7 +16,7 @@ describe "AsyncTest" do
|
|
17
16
|
loop = DBus::Main.new
|
18
17
|
loop << @bus
|
19
18
|
|
20
|
-
immediate_answer = @obj.the_answer do |
|
19
|
+
immediate_answer = @obj.the_answer do |_msg, retval|
|
21
20
|
expect(retval).to eq(42)
|
22
21
|
loop.quit
|
23
22
|
end
|
@@ -33,7 +32,7 @@ describe "AsyncTest" do
|
|
33
32
|
loop << @bus
|
34
33
|
|
35
34
|
ifc = @obj["org.ruby.AnotherInterface"]
|
36
|
-
immediate_answer = ifc.Reverse("abcd") do |
|
35
|
+
immediate_answer = ifc.Reverse("abcd") do |_msg, retval|
|
37
36
|
expect(retval).to eq("dcba")
|
38
37
|
loop.quit
|
39
38
|
end
|
@@ -43,5 +42,4 @@ describe "AsyncTest" do
|
|
43
42
|
# wait for the async reply
|
44
43
|
loop.run
|
45
44
|
end
|
46
|
-
|
47
45
|
end
|
data/spec/binding_spec.rb
CHANGED
@@ -9,14 +9,12 @@ describe "BindingTest" do
|
|
9
9
|
@bus = DBus::ASessionBus.new
|
10
10
|
@svc = @bus.service("org.ruby.service")
|
11
11
|
@base = @svc.object "/org/ruby/MyInstance"
|
12
|
-
@base.introspect
|
13
12
|
@base.default_iface = "org.ruby.SampleInterface"
|
14
13
|
end
|
15
14
|
|
16
15
|
# https://trac.luon.net/ruby-dbus/ticket/36#comment:3
|
17
16
|
it "tests class inheritance" do
|
18
17
|
derived = @svc.object "/org/ruby/MyDerivedInstance"
|
19
|
-
derived.introspect
|
20
18
|
|
21
19
|
# it should inherit from the parent
|
22
20
|
expect(derived["org.ruby.SampleInterface"]).not_to be_nil
|
@@ -26,7 +24,6 @@ describe "BindingTest" do
|
|
26
24
|
# Interfaces and methods/signals appeared on all classes
|
27
25
|
it "tests separation of classes" do
|
28
26
|
test2 = @svc.object "/org/ruby/MyInstance2"
|
29
|
-
test2.introspect
|
30
27
|
|
31
28
|
# it should have its own interface
|
32
29
|
expect(test2["org.ruby.Test2"]).not_to be_nil
|
@@ -57,7 +54,7 @@ describe "BindingTest" do
|
|
57
54
|
# interfaces can be defined dynamicaly
|
58
55
|
derived = DBus::Object.new "/org/ruby/MyDerivedInstance"
|
59
56
|
|
60
|
-
#define a new interface
|
57
|
+
# define a new interface
|
61
58
|
derived.singleton_class.instance_eval do
|
62
59
|
dbus_interface "org.ruby.DynamicInterface" do
|
63
60
|
dbus_method :hello2, "in name:s, in name2:s" do |name, name2|
|
@@ -70,5 +67,4 @@ describe "BindingTest" do
|
|
70
67
|
ifaces = derived.intfs
|
71
68
|
expect(ifaces).to include "org.ruby.DynamicInterface"
|
72
69
|
end
|
73
|
-
|
74
70
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
# Test the bus class
|
3
3
|
require_relative "spec_helper"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "rubygems"
|
6
|
+
require "nokogiri"
|
7
7
|
require "dbus"
|
8
8
|
|
9
9
|
describe "BusAndXmlBackendTest" do
|
@@ -15,12 +15,11 @@ describe "BusAndXmlBackendTest" do
|
|
15
15
|
DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::REXMLParser
|
16
16
|
@svc = @bus.service("org.ruby.service")
|
17
17
|
obj = @svc.object("/org/ruby/MyInstance")
|
18
|
-
obj.default_iface =
|
19
|
-
obj.introspect
|
18
|
+
obj.default_iface = "org.ruby.SampleInterface"
|
20
19
|
# "should respond to :the_answer"
|
21
20
|
expect(obj.the_answer[0]).to eq(42)
|
22
21
|
# "should work with multiple interfaces"
|
23
|
-
expect(obj["org.ruby.AnotherInterface"].Reverse(
|
22
|
+
expect(obj["org.ruby.AnotherInterface"].Reverse("foo")[0]).to eq("oof")
|
24
23
|
end
|
25
24
|
|
26
25
|
it "tests introspection reading nokogiri" do
|
@@ -28,12 +27,10 @@ describe "BusAndXmlBackendTest" do
|
|
28
27
|
DBus::IntrospectXMLParser.backend = DBus::IntrospectXMLParser::NokogiriParser
|
29
28
|
@svc = @bus.service("org.ruby.service")
|
30
29
|
obj = @svc.object("/org/ruby/MyInstance")
|
31
|
-
obj.default_iface =
|
32
|
-
obj.introspect
|
30
|
+
obj.default_iface = "org.ruby.SampleInterface"
|
33
31
|
# "should respond to :the_answer"
|
34
32
|
expect(obj.the_answer[0]).to eq(42)
|
35
33
|
# "should work with multiple interfaces"
|
36
|
-
expect(obj["org.ruby.AnotherInterface"].Reverse(
|
34
|
+
expect(obj["org.ruby.AnotherInterface"].Reverse("foo")[0]).to eq("oof")
|
37
35
|
end
|
38
|
-
|
39
36
|
end
|
data/spec/bus_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe "BusTest" do
|
|
13
13
|
|
14
14
|
it "tests introspection not leaking" do
|
15
15
|
# peek inside the object to see if a cleanup step worked or not
|
16
|
-
some_hash = @bus.instance_eval { @method_call_replies ||
|
16
|
+
some_hash = @bus.instance_eval { @method_call_replies || {} }
|
17
17
|
# fail: "there are leftover method handlers"
|
18
18
|
expect(some_hash.size).to eq(0)
|
19
19
|
end
|
data/spec/byte_array_spec.rb
CHANGED
@@ -8,11 +8,9 @@ describe "ByteArrayTest" do
|
|
8
8
|
@bus = DBus::ASessionBus.new
|
9
9
|
@svc = @bus.service("org.ruby.service")
|
10
10
|
@obj = @svc.object("/org/ruby/MyInstance")
|
11
|
-
@obj.introspect
|
12
11
|
@obj.default_iface = "org.ruby.SampleInterface"
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
14
|
it "tests passing byte array" do
|
17
15
|
data = [0, 77, 255]
|
18
16
|
result = @obj.mirror_byte_array(data).first
|
data/spec/err_msg_spec.rb
CHANGED
@@ -9,34 +9,37 @@ describe "ErrMsgTest" do
|
|
9
9
|
session_bus = DBus::ASessionBus.new
|
10
10
|
svc = session_bus.service("org.ruby.service")
|
11
11
|
@obj = svc.object("/org/ruby/MyInstance")
|
12
|
-
@obj.introspect # necessary
|
13
12
|
@obj.default_iface = "org.ruby.SampleInterface"
|
14
13
|
end
|
15
14
|
|
16
15
|
it "tests report dbus interface" do
|
17
16
|
# a specific exception...
|
18
17
|
# mentioning DBus and the interface
|
19
|
-
expect { @obj.NoSuchMethod }
|
18
|
+
expect { @obj.NoSuchMethod }
|
19
|
+
.to raise_error(NameError, /DBus interface.*#{@obj.default_iface}/)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "tests report short struct" do
|
23
|
-
expect { @obj.test_variant ["(ss)", ["too few"]
|
23
|
+
expect { @obj.test_variant ["(ss)", ["too few"]] }
|
24
|
+
.to raise_error(DBus::TypeException, /1 elements but type info for 2/)
|
24
25
|
end
|
25
26
|
|
26
27
|
it "tests report long struct" do
|
27
|
-
expect { @obj.test_variant ["(ss)", ["a", "b", "too many"]
|
28
|
+
expect { @obj.test_variant ["(ss)", ["a", "b", "too many"]] }
|
29
|
+
.to raise_error(DBus::TypeException, /3 elements but type info for 2/)
|
28
30
|
end
|
29
31
|
|
30
32
|
it "tests report nil" do
|
31
33
|
nils = [
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
["(s)", [nil]], # would get disconnected
|
35
|
+
["i", nil],
|
36
|
+
["a{ss}", { "foo" => nil }]
|
37
|
+
]
|
36
38
|
nils.each do |has_nil|
|
37
|
-
# TODO want backtrace from the perspective of the caller:
|
39
|
+
# TODO: want backtrace from the perspective of the caller:
|
38
40
|
# rescue/reraise in send_sync?
|
39
|
-
expect { @obj.test_variant has_nil }
|
41
|
+
expect { @obj.test_variant has_nil }
|
42
|
+
.to raise_error(DBus::TypeException, /Cannot send nil/)
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
@@ -18,9 +18,9 @@ describe "IntrospectXMLParserTest" do
|
|
18
18
|
</node>
|
19
19
|
EOS
|
20
20
|
|
21
|
-
interfaces,
|
21
|
+
interfaces, _subnodes = DBus::IntrospectXMLParser.new(xml).parse
|
22
22
|
|
23
|
-
foo = interfaces.find {|i| i.name == "org.example.Foo" }
|
23
|
+
foo = interfaces.find { |i| i.name == "org.example.Foo" }
|
24
24
|
expect(foo.methods.keys.size).to eq(2)
|
25
25
|
end
|
26
26
|
end
|
data/spec/introspection_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe "IntrospectionTest" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "tests wrong number of arguments" do
|
15
|
-
expect { @obj.test_variant "too","many","args" }.to raise_error(ArgumentError)
|
15
|
+
expect { @obj.test_variant "too", "many", "args" }.to raise_error(ArgumentError)
|
16
16
|
# not enough
|
17
17
|
expect { @obj.test_variant }.to raise_error(ArgumentError)
|
18
18
|
end
|
data/spec/main_loop_spec.rb
CHANGED
@@ -8,7 +8,6 @@ describe "MainLoopTest" do
|
|
8
8
|
@session_bus = DBus::ASessionBus.new
|
9
9
|
svc = @session_bus.service("org.ruby.service")
|
10
10
|
@obj = svc.object("/org/ruby/MyInstance")
|
11
|
-
@obj.introspect # necessary
|
12
11
|
@obj.default_iface = "org.ruby.Loop"
|
13
12
|
|
14
13
|
@loop = DBus::Main.new
|
@@ -20,13 +19,13 @@ describe "MainLoopTest" do
|
|
20
19
|
# the bus has a chance to join the server messages and a race is reproducible
|
21
20
|
def call_lazily
|
22
21
|
class << @session_bus
|
23
|
-
|
22
|
+
alias_method :wait_for_message_orig, :wait_for_message
|
24
23
|
def wait_for_message_lazy
|
25
24
|
DBus.logger.debug "I am so lazy"
|
26
|
-
sleep 1
|
25
|
+
sleep 1 # Give the server+bus a chance to join the messages
|
27
26
|
wait_for_message_orig
|
28
27
|
end
|
29
|
-
|
28
|
+
alias_method :wait_for_message, :wait_for_message_lazy
|
30
29
|
end
|
31
30
|
|
32
31
|
yield
|
@@ -35,7 +34,7 @@ describe "MainLoopTest" do
|
|
35
34
|
class << @session_bus
|
36
35
|
remove_method :wait_for_message
|
37
36
|
remove_method :wait_for_message_lazy
|
38
|
-
|
37
|
+
alias_method :wait_for_message, :wait_for_message_orig
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
data/spec/property_spec.rb
CHANGED
@@ -7,7 +7,6 @@ describe "PropertyTest" do
|
|
7
7
|
session_bus = DBus::ASessionBus.new
|
8
8
|
@svc = session_bus.service("org.ruby.service")
|
9
9
|
@obj = @svc.object("/org/ruby/MyInstance")
|
10
|
-
@obj.introspect
|
11
10
|
@iface = @obj["org.ruby.SampleInterface"]
|
12
11
|
end
|
13
12
|
|
@@ -17,7 +16,6 @@ describe "PropertyTest" do
|
|
17
16
|
|
18
17
|
it "tests property reading on a V1 object" do
|
19
18
|
obj = @svc["/org/ruby/MyInstance"]
|
20
|
-
obj.introspect
|
21
19
|
iface = obj["org.ruby.SampleInterface"]
|
22
20
|
|
23
21
|
expect(iface["ReadMe"]).to eq("READ ME")
|
@@ -53,7 +51,6 @@ describe "PropertyTest" do
|
|
53
51
|
|
54
52
|
it "tests get all on a V1 object" do
|
55
53
|
obj = @svc["/org/ruby/MyInstance"]
|
56
|
-
obj.introspect
|
57
54
|
iface = obj["org.ruby.SampleInterface"]
|
58
55
|
|
59
56
|
all = iface.all_properties
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
require_relative "spec_helper"
|
3
|
+
require "dbus"
|
4
|
+
|
5
|
+
describe DBus::ProxyObject do
|
6
|
+
around(:each) do |example|
|
7
|
+
with_private_bus do
|
8
|
+
with_service_by_activation(&example)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:bus) { DBus::ASessionBus.new }
|
13
|
+
|
14
|
+
context "when calling org.ruby.service" do
|
15
|
+
let(:svc) { bus["org.ruby.service"] }
|
16
|
+
|
17
|
+
context "when introspection mode is not specified" do
|
18
|
+
describe "#bounce_variant" do
|
19
|
+
it "works without an explicit #introspect call" do
|
20
|
+
obj = svc["/org/ruby/MyInstance"]
|
21
|
+
ifc = obj["org.ruby.SampleInterface"]
|
22
|
+
expect(ifc.bounce_variant(42)).to be_eql 42
|
23
|
+
end
|
24
|
+
|
25
|
+
it "works with one #introspect call" do
|
26
|
+
obj = svc["/org/ruby/MyInstance"]
|
27
|
+
obj.introspect
|
28
|
+
ifc = obj["org.ruby.SampleInterface"]
|
29
|
+
expect(ifc.bounce_variant(42)).to be_eql 42
|
30
|
+
end
|
31
|
+
|
32
|
+
it "works with two #introspect calls" do
|
33
|
+
obj = svc["/org/ruby/MyInstance"]
|
34
|
+
obj.introspect
|
35
|
+
obj.introspect
|
36
|
+
ifc = obj["org.ruby.SampleInterface"]
|
37
|
+
expect(ifc.bounce_variant(42)).to be_eql 42
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -29,7 +29,6 @@ describe "ServerRobustnessTest" do
|
|
29
29
|
|
30
30
|
it "tests a method that raises" do
|
31
31
|
obj = @svc.object "/org/ruby/MyInstance"
|
32
|
-
obj.introspect
|
33
32
|
obj.default_iface = "org.ruby.SampleInterface"
|
34
33
|
expect { obj.will_raise }.to raise_error(DBus::Error) do |e|
|
35
34
|
expect(e).to_not match(/timeout/)
|
@@ -38,7 +37,6 @@ describe "ServerRobustnessTest" do
|
|
38
37
|
|
39
38
|
it "tests a method that raises name error" do
|
40
39
|
obj = @svc.object "/org/ruby/MyInstance"
|
41
|
-
obj.introspect
|
42
40
|
obj.default_iface = "org.ruby.SampleInterface"
|
43
41
|
expect { obj.will_raise_name_error }.to raise_error(DBus::Error) do |e|
|
44
42
|
expect(e).to_not match(/timeout/)
|
data/spec/service_newapi.rb
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
require_relative "spec_helper"
|
5
5
|
SimpleCov.command_name "Service Tests" if Object.const_defined? "SimpleCov"
|
6
6
|
# find the library without external help
|
7
|
-
|
7
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
8
8
|
|
9
|
-
require
|
9
|
+
require "dbus"
|
10
10
|
|
11
|
-
PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties"
|
11
|
+
PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties".freeze
|
12
12
|
|
13
13
|
class Test < DBus::Object
|
14
|
-
INTERFACE = "org.ruby.SampleInterface"
|
14
|
+
INTERFACE = "org.ruby.SampleInterface".freeze
|
15
15
|
def initialize(path)
|
16
16
|
super path
|
17
17
|
@read_me = "READ ME"
|
@@ -81,7 +81,7 @@ class Test < DBus::Object
|
|
81
81
|
end
|
82
82
|
|
83
83
|
dbus_interface "org.ruby.Ticket30" do
|
84
|
-
dbus_method :Sybilla,
|
84
|
+
dbus_method :Sybilla, "in choices:av, out advice:s" do |choices|
|
85
85
|
["Do #{choices[0]}"]
|
86
86
|
end
|
87
87
|
end
|
@@ -98,8 +98,8 @@ class Test < DBus::Object
|
|
98
98
|
dbus_interface "org.ruby.Loop" do
|
99
99
|
# starts doing something long, but returns immediately
|
100
100
|
# and sends a signal when done
|
101
|
-
dbus_method :LongTaskBegin,
|
102
|
-
# FIXME did not complain about mismatch between signature and block args
|
101
|
+
dbus_method :LongTaskBegin, "in delay:i" do |delay|
|
102
|
+
# FIXME: did not complain about mismatch between signature and block args
|
103
103
|
self.LongTaskStart
|
104
104
|
DBus.logger.debug "Long task began"
|
105
105
|
task = Thread.new do
|
@@ -121,50 +121,61 @@ class Test < DBus::Object
|
|
121
121
|
# ReadOrWriteMe:string, returns "READ OR WRITE ME" at first
|
122
122
|
dbus_interface PROPERTY_INTERFACE do
|
123
123
|
dbus_method :Get, "in interface:s, in propname:s, out value:v" do |interface, propname|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
124
|
+
unless interface == INTERFACE
|
125
|
+
raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"),
|
126
|
+
"Interface '#{interface}' not found on object '#{@path}'"
|
127
|
+
end
|
128
|
+
|
129
|
+
case propname
|
130
|
+
when "ReadMe"
|
131
|
+
[@read_me]
|
132
|
+
when "ReadOrWriteMe"
|
133
|
+
[@read_or_write_me]
|
134
|
+
when "WriteMe"
|
135
|
+
raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"),
|
136
|
+
"Property '#{interface}.#{propname}' (on object '#{@path}') is not readable"
|
134
137
|
else
|
135
|
-
|
138
|
+
# what should happen for unknown properties
|
139
|
+
# plasma: InvalidArgs (propname), UnknownInterface (interface)
|
140
|
+
raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"),
|
141
|
+
"Property '#{interface}.#{propname}' not found on object '#{@path}'"
|
136
142
|
end
|
137
|
-
# what should happen for unknown properties
|
138
|
-
# plasma: InvalidArgs (propname), UnknownInterface (interface)
|
139
143
|
end
|
140
144
|
|
141
145
|
dbus_method :Set, "in interface:s, in propname:s, in value:v" do |interface, propname, value|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
146
|
+
unless interface == INTERFACE
|
147
|
+
raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"),
|
148
|
+
"Interface '#{interface}' not found on object '#{@path}'"
|
149
|
+
end
|
150
|
+
|
151
|
+
case propname
|
152
|
+
when "ReadMe"
|
153
|
+
raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"),
|
154
|
+
"Property '#{interface}.#{propname}' (on object '#{@path}') is not writable"
|
155
|
+
when "ReadOrWriteMe"
|
156
|
+
@read_or_write_me = value
|
157
|
+
self.PropertiesChanged(interface, { propname => value }, [])
|
158
|
+
when "WriteMe"
|
159
|
+
@read_me = value
|
160
|
+
self.PropertiesChanged(interface, { "ReadMe" => value }, [])
|
154
161
|
else
|
155
|
-
raise DBus.error("org.freedesktop.DBus.Error.
|
162
|
+
raise DBus.error("org.freedesktop.DBus.Error.InvalidArgs"),
|
163
|
+
"Property '#{interface}.#{propname}' not found on object '#{@path}'"
|
156
164
|
end
|
157
165
|
end
|
158
166
|
|
159
167
|
dbus_method :GetAll, "in interface:s, out value:a{sv}" do |interface|
|
160
|
-
|
161
|
-
|
162
|
-
|
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}'"
|
168
|
+
unless interface == INTERFACE
|
169
|
+
raise DBus.error("org.freedesktop.DBus.Error.UnknownInterface"),
|
170
|
+
"Interface '#{interface}' not found on object '#{@path}'"
|
167
171
|
end
|
172
|
+
|
173
|
+
[
|
174
|
+
{
|
175
|
+
"ReadMe" => @read_me,
|
176
|
+
"ReadOrWriteMe" => @read_or_write_me
|
177
|
+
}
|
178
|
+
]
|
168
179
|
end
|
169
180
|
|
170
181
|
dbus_signal :PropertiesChanged, "interface:s, changed_properties:a{sv}, invalidated_properties:as"
|
@@ -214,4 +225,3 @@ begin
|
|
214
225
|
rescue SystemCallError
|
215
226
|
# the test driver will kill the bus, that's OK
|
216
227
|
end
|
217
|
-
|