ruby-dbus 0.17.0 → 0.18.0.beta1
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 +15 -0
- data/README.md +1 -1
- data/Rakefile +3 -11
- data/VERSION +1 -1
- data/doc/Reference.md +9 -2
- data/examples/doc/_extract_examples +2 -0
- data/examples/gdbus/gdbus +11 -5
- data/examples/no-introspect/nm-test.rb +2 -0
- data/examples/no-introspect/tracker-test.rb +3 -1
- data/examples/rhythmbox/playpause.rb +2 -1
- data/examples/service/call_service.rb +1 -0
- data/examples/service/service_newapi.rb +1 -1
- data/examples/simple/call_introspect.rb +1 -0
- data/examples/simple/get_id.rb +2 -1
- data/examples/simple/properties.rb +2 -0
- data/examples/utils/listnames.rb +1 -0
- data/examples/utils/notify.rb +1 -0
- data/lib/dbus/api_options.rb +9 -0
- data/lib/dbus/auth.rb +12 -7
- data/lib/dbus/bus.rb +114 -70
- data/lib/dbus/bus_name.rb +12 -8
- data/lib/dbus/error.rb +4 -2
- data/lib/dbus/introspect.rb +29 -18
- data/lib/dbus/logger.rb +3 -1
- data/lib/dbus/marshall.rb +118 -86
- data/lib/dbus/matchrule.rb +16 -16
- data/lib/dbus/message.rb +40 -27
- data/lib/dbus/message_queue.rb +10 -5
- data/lib/dbus/object.rb +34 -13
- data/lib/dbus/object_path.rb +9 -5
- data/lib/dbus/proxy_object.rb +18 -4
- data/lib/dbus/proxy_object_factory.rb +11 -7
- data/lib/dbus/proxy_object_interface.rb +26 -22
- data/lib/dbus/type.rb +41 -34
- data/lib/dbus/xml.rb +28 -17
- data/lib/dbus.rb +7 -7
- data/ruby-dbus.gemspec +4 -2
- data/spec/async_spec.rb +2 -0
- data/spec/binding_spec.rb +2 -0
- data/spec/bus_and_xml_backend_spec.rb +2 -0
- data/spec/bus_driver_spec.rb +2 -0
- data/spec/bus_name_spec.rb +3 -1
- data/spec/bus_spec.rb +2 -0
- data/spec/byte_array_spec.rb +2 -0
- data/spec/client_robustness_spec.rb +4 -2
- data/spec/err_msg_spec.rb +2 -0
- data/spec/introspect_xml_parser_spec.rb +2 -0
- data/spec/introspection_spec.rb +2 -0
- data/spec/main_loop_spec.rb +2 -0
- data/spec/node_spec.rb +23 -0
- data/spec/object_path_spec.rb +2 -0
- data/spec/property_spec.rb +11 -2
- data/spec/proxy_object_spec.rb +2 -0
- data/spec/server_robustness_spec.rb +2 -0
- data/spec/server_spec.rb +2 -0
- data/spec/service_newapi.rb +19 -4
- data/spec/session_bus_spec.rb +3 -1
- data/spec/session_bus_spec_manual.rb +2 -0
- data/spec/signal_spec.rb +2 -0
- data/spec/spec_helper.rb +5 -3
- data/spec/thread_safety_spec.rb +2 -0
- data/spec/type_spec.rb +2 -0
- data/spec/value_spec.rb +16 -1
- data/spec/variant_spec.rb +4 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 491efa855b01f946194979c90d4bb4c1bb6bc4c33e342cd9d3dd76cbd53111cd
|
4
|
+
data.tar.gz: d2c1acaa46d04a7f4799b95722b71f4449c2d39fd87fd993c1c1140dbb5d0732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340b53e7aa449c84705668db9b753ced7c9d24a3229b1d7bafcc95d29508f1b4418001cc5f2749566b9edb8c2068a8d99565c251054c413252ed68450490208b
|
7
|
+
data.tar.gz: 8c6dafbd226ae516dc8aef3ad5f01cabb9850455f3f3866cfe66548b7ece22ac1865272bb17fd9af138e52d69b647e4d8ef824ebd2999605e0de28e688710ff8
|
data/NEWS.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## Ruby D-Bus 0.18.0.beta1 - 2022-02-24
|
6
|
+
|
7
|
+
API:
|
8
|
+
* D-Bus structs have been passed as Ruby arrays. Now these arrays are frozen.
|
9
|
+
* Ruby structs can be used as D-Bus structs.
|
10
|
+
|
11
|
+
Bug fixes:
|
12
|
+
* Returning the value for o.fd.DBus.Properties.Get, use the specific property
|
13
|
+
signature, not the generic Variant ([#97][]).
|
14
|
+
|
15
|
+
Requirements:
|
16
|
+
* Require Ruby 2.4, because of RuboCop 1.0.
|
17
|
+
|
18
|
+
[#97]: https://github.com/mvidner/ruby-dbus/issues/97
|
19
|
+
|
5
20
|
## Ruby D-Bus 0.17.0 - 2022-02-11
|
6
21
|
|
7
22
|
API:
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require "rake"
|
3
5
|
require "fileutils"
|
4
|
-
include FileUtils
|
5
6
|
require "tmpdir"
|
6
7
|
require "rspec/core/rake_task"
|
7
8
|
begin
|
@@ -69,16 +70,7 @@ namespace :doc do
|
|
69
70
|
end
|
70
71
|
|
71
72
|
if Object.const_defined? :RuboCop
|
72
|
-
|
73
|
-
RuboCop::RakeTask.new
|
74
|
-
else
|
75
|
-
desc "Run RuboCop (dummy)"
|
76
|
-
task :rubocop do
|
77
|
-
warn "The code is not adapted to recent RuboCop yet,\n" \
|
78
|
-
"and the old one no longer works with Ruby 3.x.\n" \
|
79
|
-
"Switch back to Ruby 2.x to run it."
|
80
|
-
end
|
81
|
-
end
|
73
|
+
RuboCop::RakeTask.new
|
82
74
|
else
|
83
75
|
desc "Run RuboCop (dummy)"
|
84
76
|
task :rubocop do
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.18.0.beta1
|
data/doc/Reference.md
CHANGED
@@ -153,7 +153,7 @@ To receive signals for a specific object and interface, use
|
|
153
153
|
|
154
154
|
D-Bus booleans, numbers, strings, arrays and dictionaries become their straightforward Ruby counterparts.
|
155
155
|
|
156
|
-
Structs become arrays.
|
156
|
+
Structs become frozen arrays.
|
157
157
|
|
158
158
|
Object paths become strings.
|
159
159
|
|
@@ -190,11 +190,18 @@ If the signature expects a Variant
|
|
190
190
|
type. This will hit you when you rely on method (2) but happen to have
|
191
191
|
a particular string value in an array.
|
192
192
|
|
193
|
+
##### Structs
|
194
|
+
|
195
|
+
If a **STRUCT** `(...)` is expected you may pass
|
196
|
+
|
197
|
+
- an [Array](https://ruby-doc.org/core/Array.html) (frozen is fine)
|
198
|
+
- a [Struct](https://ruby-doc.org/core/Struct.html)
|
199
|
+
|
193
200
|
##### Byte Arrays
|
194
201
|
|
195
202
|
If a byte array (`ay`) is expected you can pass a String too.
|
196
203
|
The bytes sent are according to the string's
|
197
|
-
[encoding](http://ruby-doc.org/core
|
204
|
+
[encoding](http://ruby-doc.org/core/Encoding.html).
|
198
205
|
|
199
206
|
##### nil
|
200
207
|
|
data/examples/gdbus/gdbus
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
#
|
3
5
|
# This is a quite complex example using internal lower level API.
|
4
6
|
# Not a good starting point, but might be usefull if you want to do tricky
|
@@ -103,11 +105,12 @@ class DBusUI
|
|
103
105
|
|
104
106
|
def beautify_method(meth)
|
105
107
|
# Damn, this need to be rewritten :p
|
106
|
-
s = meth.name
|
107
|
-
|
108
|
+
s = "#{meth.name}("
|
109
|
+
case meth
|
110
|
+
when DBus::Method
|
108
111
|
s += (meth.params.collect { |a| "in #{a[0]}:#{a[1]}" } +
|
109
112
|
meth.rets.collect { |a| "out #{a[0]}:#{a[1]}" }).join(", ")
|
110
|
-
|
113
|
+
when DBus::Signal
|
111
114
|
s += (meth.params.collect { |a| "in #{a[0]}:#{a[1]}" }).join(", ")
|
112
115
|
end
|
113
116
|
s += ")"
|
@@ -146,11 +149,12 @@ class DBusUI
|
|
146
149
|
name = view.model.get_iter(path)[0]
|
147
150
|
puts "Clicked on: #{name.inspect}"
|
148
151
|
type = view.model.get_iter(path)[1]
|
149
|
-
|
152
|
+
case type
|
153
|
+
when "M"
|
150
154
|
method = view.model.get_iter(path)[2]
|
151
155
|
intf = view.model.get_iter(path)[3]
|
152
156
|
MethodCallWindow.new(@window, intf, method).run
|
153
|
-
|
157
|
+
when "S"
|
154
158
|
signal = view.model.get_iter(path)[2]
|
155
159
|
intf = view.model.get_iter(path)[3]
|
156
160
|
mr = DBus::MatchRule.new.from_signal(intf, signal)
|
@@ -205,6 +209,7 @@ class DBusUI
|
|
205
209
|
end
|
206
210
|
|
207
211
|
return unless ENABLE_SYSTEM
|
212
|
+
|
208
213
|
DBus::SystemBus.instance.proxy.ListNames do |_msg, names|
|
209
214
|
fill_treeview(DBus::SystemBus.instance, @systemtreeview, names)
|
210
215
|
end
|
@@ -218,6 +223,7 @@ class DBusUI
|
|
218
223
|
end
|
219
224
|
|
220
225
|
return if node.object.nil?
|
226
|
+
|
221
227
|
node.object.interfaces.sort.each do |ifname|
|
222
228
|
subiter = model.append(iter)
|
223
229
|
subiter[0] = ifname
|
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
#
|
3
5
|
# Trivial network interface lister using NetworkManager.
|
4
6
|
# NetworkManager does not support introspection, so the api is not that sexy.
|
@@ -11,4 +13,4 @@ tracker_service = bus.service("org.freedesktop.Tracker")
|
|
11
13
|
tracker_manager = tracker_service.object("/org/freedesktop/tracker")
|
12
14
|
poi = DBus::ProxyObjectInterface.new(tracker_manager, "org.freedesktop.Tracker.Files")
|
13
15
|
poi.define_method("GetMetadataForFilesInFolder", "in live_query_id:i, in uri:s, in fields:as, out values:aas")
|
14
|
-
p poi.GetMetadataForFilesInFolder(-1, ENV["HOME"]
|
16
|
+
p poi.GetMetadataForFilesInFolder(-1, "#{ENV["HOME"]}/Desktop", ["File:Name", "File:Size"])
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "dbus"
|
4
5
|
bus = DBus::SessionBus.instance
|
@@ -13,7 +14,7 @@ mr.type = "signal"
|
|
13
14
|
mr.interface = "org.gnome.Rhythmbox.Player"
|
14
15
|
mr.path = "/org/gnome/Rhythmbox/Player"
|
15
16
|
bus.add_match(mr) do |msg, first_param|
|
16
|
-
print msg.member
|
17
|
+
print "#{msg.member} "
|
17
18
|
puts first_param
|
18
19
|
end
|
19
20
|
|
data/examples/simple/get_id.rb
CHANGED
data/examples/utils/listnames.rb
CHANGED
data/examples/utils/notify.rb
CHANGED
data/lib/dbus/api_options.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of the ruby-dbus project
|
2
4
|
# Copyright (C) 2016 Martin Vidner
|
3
5
|
#
|
@@ -9,6 +11,13 @@
|
|
9
11
|
module DBus
|
10
12
|
class ApiOptions
|
11
13
|
# https://github.com/mvidner/ruby-dbus/issues/30
|
14
|
+
# @return [Boolean]
|
15
|
+
# - true: a proxy (client-side) method will return an array
|
16
|
+
# even for the most common case where the method is declared
|
17
|
+
# to have only one 'out parameter'
|
18
|
+
# - false: a proxy (client-side) method will return
|
19
|
+
# - one value for the only 'out parameter'
|
20
|
+
# - an array with more 'out parameters'
|
12
21
|
attr_accessor :proxy_method_returns_array
|
13
22
|
|
14
23
|
A0 = ApiOptions.new
|
data/lib/dbus/auth.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of the ruby-dbus project
|
2
4
|
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
|
3
5
|
#
|
@@ -100,14 +102,15 @@ module DBus
|
|
100
102
|
# encode plain to hex
|
101
103
|
def hex_encode(plain)
|
102
104
|
return nil if plain.nil?
|
103
|
-
|
105
|
+
|
106
|
+
plain.to_s.unpack1("H*")
|
104
107
|
end
|
105
108
|
|
106
109
|
# decode hex to plain
|
107
110
|
def hex_decode(encoded)
|
108
111
|
encoded.scan(/[[:xdigit:]]{2}/).map { |h| h.hex.chr }.join
|
109
112
|
end
|
110
|
-
end
|
113
|
+
end
|
111
114
|
|
112
115
|
# Note: this following stuff is tested with External authenticator only!
|
113
116
|
|
@@ -148,12 +151,13 @@ module DBus
|
|
148
151
|
# server.
|
149
152
|
def send(meth, *args)
|
150
153
|
o = ([meth] + args).join(" ")
|
151
|
-
@socket.write(o
|
154
|
+
@socket.write("#{o}\r\n")
|
152
155
|
end
|
153
156
|
|
154
157
|
# Try authentication using the next authenticator.
|
155
158
|
def next_authenticator
|
156
159
|
raise AuthenticationFailed if @auth_list.empty?
|
160
|
+
|
157
161
|
@authenticator = @auth_list.shift.new
|
158
162
|
auth_msg = ["AUTH", @authenticator.name, @authenticator.authenticate]
|
159
163
|
DBus.logger.debug "auth_msg: #{auth_msg.inspect}"
|
@@ -169,9 +173,10 @@ module DBus
|
|
169
173
|
data = ""
|
170
174
|
crlf = "\r\n"
|
171
175
|
left = 1024 # 1024 byte, no idea if it's ever getting bigger
|
172
|
-
while left
|
176
|
+
while left.positive?
|
173
177
|
buf = @socket.read(left > 1 ? 1 : left)
|
174
178
|
break if buf.nil?
|
179
|
+
|
175
180
|
left -= buf.bytesize
|
176
181
|
data += buf
|
177
182
|
break if data.include? crlf # crlf means line finished, the TCP socket keeps on listening, so we break
|
@@ -262,6 +267,6 @@ module DBus
|
|
262
267
|
end
|
263
268
|
end
|
264
269
|
true
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|