pangdudu-ruby-dbus 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +782 -0
- data/NEWS +31 -0
- data/README +53 -0
- data/examples/gdbus/gdbus +255 -0
- data/examples/gdbus/gdbus.glade +184 -0
- data/examples/gdbus/launch.sh +4 -0
- data/examples/no-introspect/nm-test.rb +21 -0
- data/examples/no-introspect/tracker-test.rb +16 -0
- data/examples/rhythmbox/playpause.rb +25 -0
- data/examples/service/call_service.rb +25 -0
- data/examples/service/service_newapi.rb +51 -0
- data/examples/simple/call_introspect.rb +34 -0
- data/examples/utils/listnames.rb +11 -0
- data/examples/utils/notify.rb +19 -0
- data/lib/dbus/auth.rb +10 -92
- data/lib/dbus/bus.rb +59 -84
- data/lib/dbus/introspect.rb +2 -2
- data/lib/dbus.rb +2 -8
- metadata +34 -26
- data/README.rdoc +0 -111
- data/config/remote.session.dbus.conf +0 -39
- data/config/start_dbus_session.sh +0 -2
- data/test/simple_socket_test.rb +0 -27
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require "dbus"
|
4
|
+
|
5
|
+
session_bus = DBus::SessionBus.instance
|
6
|
+
|
7
|
+
# Get the Rhythmbox service
|
8
|
+
rhythmbox = session_bus.service("org.gnome.Rhythmbox")
|
9
|
+
|
10
|
+
# Get the object from this service
|
11
|
+
player = rhythmbox.object("/org/gnome/Rhythmbox/Player")
|
12
|
+
|
13
|
+
# Introspect it
|
14
|
+
player.introspect
|
15
|
+
if player.has_iface? "org.gnome.Rhythmbox.Player"
|
16
|
+
puts "We have Rhythmbox Player interface"
|
17
|
+
end
|
18
|
+
|
19
|
+
player_with_iface = player["org.gnome.Rhythmbox.Player"]
|
20
|
+
p player_with_iface.getPlayingUri
|
21
|
+
|
22
|
+
# Maybe support default_iface=(iface_str) on an ProxyObject, so
|
23
|
+
# that this is possible?
|
24
|
+
player.default_iface = "org.gnome.Rhythmbox.Player"
|
25
|
+
puts "default_iface test:"
|
26
|
+
p player.getPlayingUri
|
27
|
+
player.on_signal("elapsedChanged") do |u|
|
28
|
+
puts "elapsedChanged: #{u}"
|
29
|
+
end
|
30
|
+
|
31
|
+
main = DBus::Main.new
|
32
|
+
main << session_bus
|
33
|
+
main.run
|
34
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'dbus'
|
4
|
+
|
5
|
+
if ARGV.size < 2
|
6
|
+
puts "Usage:"
|
7
|
+
puts "notify.rb \"title\" \"body\""
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
d = DBus::SessionBus.instance
|
12
|
+
o = d.service("org.freedesktop.Notifications").object("/org/freedesktop/Notifications")
|
13
|
+
o.introspect
|
14
|
+
|
15
|
+
i = o["org.freedesktop.Notifications"]
|
16
|
+
|
17
|
+
i.Notify('notify.rb', 0, 'info', ARGV[0], ARGV[1], [], {}, 2000) do |ret, param|
|
18
|
+
end
|
19
|
+
|
data/lib/dbus/auth.rb
CHANGED
@@ -29,68 +29,12 @@ module DBus
|
|
29
29
|
# each character and determin hex value "1" => 0x31, "0" => 0x30. You
|
30
30
|
# obtain for "1000" => 31303030 This is what the server is expecting.
|
31
31
|
# Why? I dunno. How did I come to that conclusion? by looking at rbus
|
32
|
-
# code. I have no idea how he found that out.
|
32
|
+
# code. I have no idea how he found that out.
|
33
33
|
return Process.uid.to_s.split(//).collect { |a| "%x" % a[0] }.join
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
37
|
-
# = Authentication class using SHA1 crypto algorithm
|
38
|
-
#
|
39
|
-
# Class for 'CookieSHA1' type authentication.
|
40
|
-
# Implements the AUTH DBUS_COOKIE_SHA1 mechanism.
|
41
|
-
class DBusCookieSHA1 < Authenticator
|
42
|
-
|
43
|
-
#the autenticate method (called in stage one of authentification)
|
44
|
-
def authenticate
|
45
|
-
require 'etc'
|
46
|
-
return "#{hex_encode(Etc.getlogin)}" #server expects it to be binary
|
47
|
-
end
|
48
36
|
|
49
|
-
|
50
|
-
def name
|
51
|
-
return 'DBUS_COOKIE_SHA1'
|
52
|
-
end
|
53
|
-
|
54
|
-
#handles the interesting crypto stuff, check the rbus-project for more info: http://rbus.rubyforge.org/
|
55
|
-
def data(hexdata)
|
56
|
-
require 'digest/sha1'
|
57
|
-
data = hex_decode(hexdata)
|
58
|
-
# name of cookie file, id of cookie in file, servers random challenge
|
59
|
-
context, id, s_challenge = data.split(' ')
|
60
|
-
# Random client challenge
|
61
|
-
c_challenge = Array.new(s_challenge.length/2).map{|obj|obj=rand(255).to_s}.join
|
62
|
-
# Search cookie file for id
|
63
|
-
path = File.join(ENV['HOME'], '.dbus-keyrings', context)
|
64
|
-
dlog "path: #{path.inspect}"
|
65
|
-
File.foreach(path) do |line|
|
66
|
-
if line.index(id) == 0
|
67
|
-
# Right line of file, read cookie
|
68
|
-
cookie = line.split(' ')[2].chomp
|
69
|
-
dlog "cookie: #{cookie.inspect}"
|
70
|
-
# Concatenate and encrypt
|
71
|
-
to_encrypt = [s_challenge, c_challenge, cookie].join(':')
|
72
|
-
sha = Digest::SHA1.hexdigest(to_encrypt)
|
73
|
-
#the almighty tcp server wants everything hex encoded
|
74
|
-
hex_response = hex_encode("#{c_challenge} #{sha}")
|
75
|
-
# Return response
|
76
|
-
response = [:AuthOk, hex_response]
|
77
|
-
return response
|
78
|
-
end
|
79
|
-
end
|
80
|
-
elog "Unable to locate cookie"
|
81
|
-
end
|
82
|
-
|
83
|
-
# encode plain to hex
|
84
|
-
def hex_encode(plain)
|
85
|
-
return nil if plain.nil?
|
86
|
-
plain.to_s.unpack('H*')[0]
|
87
|
-
end
|
88
|
-
|
89
|
-
# decode hex to plain
|
90
|
-
def hex_decode(encoded)
|
91
|
-
encoded.scan(/[[:xdigit:]]{2}/).map{|h|h.hex.chr}.join
|
92
|
-
end
|
93
|
-
end #DBusCookieSHA1 class ends here
|
37
|
+
# Note: this following stuff is tested with External authenticator only!
|
94
38
|
|
95
39
|
# = Authentication client class.
|
96
40
|
#
|
@@ -100,7 +44,7 @@ module DBus
|
|
100
44
|
def initialize(socket)
|
101
45
|
@socket = socket
|
102
46
|
@state = nil
|
103
|
-
@auth_list = [External
|
47
|
+
@auth_list = [External]
|
104
48
|
end
|
105
49
|
|
106
50
|
# Start the authentication process.
|
@@ -128,59 +72,35 @@ module DBus
|
|
128
72
|
|
129
73
|
# Try authentication using the next authenticator.
|
130
74
|
def next_authenticator
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
auth_msg = ["AUTH", @authenticator.name, @authenticator.authenticate]
|
135
|
-
dlog "auth_msg: #{auth_msg.inspect}"
|
136
|
-
send(auth_msg)
|
137
|
-
rescue AuthException
|
138
|
-
@socket.close
|
139
|
-
raise
|
140
|
-
end
|
75
|
+
raise AuthenticationFailed if @auth_list.size == 0
|
76
|
+
@authenticator = @auth_list.shift.new
|
77
|
+
send("AUTH", @authenticator.name, @authenticator.authenticate)
|
141
78
|
end
|
142
79
|
|
143
80
|
|
144
81
|
# Read data (a buffer) from the bus until CR LF is encountered.
|
145
82
|
# Return the buffer without the CR LF characters.
|
146
83
|
def next_msg
|
147
|
-
|
148
|
-
left = 1024 #1024 byte, no idea if it's ever getting bigger
|
149
|
-
while left > 0
|
150
|
-
buf = @socket.read( left > 1 ? 1 : left )
|
151
|
-
break if buf.nil?
|
152
|
-
left -= buf.size
|
153
|
-
data += buf
|
154
|
-
break if data.include? crlf #crlf means line finished, the TCP socket keeps on listening, so we break
|
155
|
-
end
|
156
|
-
readline = data.chomp.split(" ")
|
157
|
-
dlog "readline: #{readline.inspect}"
|
158
|
-
return readline
|
84
|
+
@socket.readline.chomp.split(" ")
|
159
85
|
end
|
160
86
|
|
161
87
|
# Try to reach the next state based on the current state.
|
162
88
|
def next_state
|
163
89
|
msg = next_msg
|
164
90
|
if @state == :Starting
|
165
|
-
dlog ":Starting msg: #{msg[0].inspect}"
|
166
91
|
case msg[0]
|
167
|
-
when "OK"
|
168
|
-
@state = :WaitingForOk
|
169
92
|
when "CONTINUE"
|
170
93
|
@state = :WaitingForData
|
171
|
-
when "
|
172
|
-
@state = :
|
94
|
+
when "OK"
|
95
|
+
@state = :WaitingForOk
|
173
96
|
end
|
174
97
|
end
|
175
|
-
dlog "state: #{@state}"
|
176
98
|
case @state
|
177
99
|
when :WaitingForData
|
178
|
-
dlog ":WaitingForData msg: #{msg[0].inspect}"
|
179
100
|
case msg[0]
|
180
101
|
when "DATA"
|
181
102
|
chall = msg[1]
|
182
103
|
resp, chall = @authenticator.data(chall)
|
183
|
-
dlog ":WaitingForData/DATA resp: #{resp.inspect}"
|
184
104
|
case resp
|
185
105
|
when :AuthContinue
|
186
106
|
send("DATA", chall)
|
@@ -206,7 +126,6 @@ module DBus
|
|
206
126
|
@state = :WaitingForData
|
207
127
|
end
|
208
128
|
when :WaitingForOk
|
209
|
-
dlog ":WaitingForOk msg: #{msg[0].inspect}"
|
210
129
|
case msg[0]
|
211
130
|
when "OK"
|
212
131
|
send("BEGIN")
|
@@ -222,7 +141,6 @@ module DBus
|
|
222
141
|
@state = :WaitingForOk
|
223
142
|
end
|
224
143
|
when :WaitingForReject
|
225
|
-
dlog ":WaitingForReject msg: #{msg[0].inspect}"
|
226
144
|
case msg[0]
|
227
145
|
when "REJECT"
|
228
146
|
next_authenticator
|
@@ -234,5 +152,5 @@ module DBus
|
|
234
152
|
end
|
235
153
|
return true
|
236
154
|
end # def next_state
|
237
|
-
end # class Client
|
155
|
+
end # class Client
|
238
156
|
end # module D-Bus
|
data/lib/dbus/bus.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
# modify it under the terms of the GNU Lesser General Public
|
8
8
|
# License, version 2.1 as published by the Free Software Foundation.
|
9
9
|
# See the file "COPYING" for the exact licensing terms.
|
10
|
+
|
10
11
|
require 'socket'
|
11
12
|
require 'thread'
|
12
13
|
require 'singleton'
|
@@ -77,7 +78,7 @@ module DBus
|
|
77
78
|
n = n[elem]
|
78
79
|
end
|
79
80
|
if n.nil?
|
80
|
-
|
81
|
+
puts "Warning, unknown object #{path}" if $DEBUG
|
81
82
|
end
|
82
83
|
n
|
83
84
|
end
|
@@ -123,9 +124,10 @@ module DBus
|
|
123
124
|
|
124
125
|
# Return an XML string representation of the node.
|
125
126
|
def to_xml
|
126
|
-
xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
127
|
-
|
128
|
-
|
127
|
+
xml = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
128
|
+
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
129
|
+
<node>
|
130
|
+
'
|
129
131
|
self.each_pair do |k, v|
|
130
132
|
xml += "<node name=\"#{k}\" />"
|
131
133
|
end
|
@@ -138,7 +140,7 @@ module DBus
|
|
138
140
|
end
|
139
141
|
end
|
140
142
|
xml += '</node>'
|
141
|
-
|
143
|
+
xml
|
142
144
|
end
|
143
145
|
|
144
146
|
# Return inspect information of the node.
|
@@ -171,10 +173,14 @@ module DBus
|
|
171
173
|
|
172
174
|
# Create a new connection to the bus for a given connect _path_. _path_
|
173
175
|
# format is described in the D-Bus specification:
|
174
|
-
|
176
|
+
# http://dbus.freedesktop.org/doc/dbus-specification.html#addresses
|
175
177
|
# and is something like:
|
176
178
|
# "transport1:key1=value1,key2=value2;transport2:key1=value1,key2=value2"
|
177
|
-
# e.g. "unix:path=/tmp/dbus-test"
|
179
|
+
# e.g. "unix:path=/tmp/dbus-test"
|
180
|
+
#
|
181
|
+
# Current implementation of ruby-dbus supports only a single server
|
182
|
+
# address and only "unix:path=...,guid=..." and
|
183
|
+
# "unix:abstract=...,guid=..." forms
|
178
184
|
def initialize(path)
|
179
185
|
@path = path
|
180
186
|
@unique_name = nil
|
@@ -183,44 +189,14 @@ module DBus
|
|
183
189
|
@method_call_msgs = Hash.new
|
184
190
|
@signal_matchrules = Array.new
|
185
191
|
@proxy = nil
|
192
|
+
# FIXME: can be TCP or any stream
|
193
|
+
@socket = Socket.new(Socket::Constants::PF_UNIX,
|
194
|
+
Socket::Constants::SOCK_STREAM, 0)
|
186
195
|
@object_root = Node.new("/")
|
187
196
|
end
|
188
197
|
|
189
198
|
# Connect to the bus and initialize the connection.
|
190
199
|
def connect
|
191
|
-
connect_to_tcp if @path.include? "tcp:" #connect to tcp socket
|
192
|
-
connect_to_unix if @path.include? "unix:" #connect to unix socket
|
193
|
-
end
|
194
|
-
|
195
|
-
# Connect to a bus over tcp and initialize the connection.
|
196
|
-
def connect_to_tcp
|
197
|
-
#check if the path is sufficient
|
198
|
-
if @path.include? "host=" and @path.include? "port="
|
199
|
-
host,port,family = "","",""
|
200
|
-
#get the parameters
|
201
|
-
@path.split(",").each do |para|
|
202
|
-
host = para.sub("tcp:","").sub("host=","") if para.include? "host="
|
203
|
-
port = para.sub("port=","").to_i if para.include? "port="
|
204
|
-
family = para.sub("family=","") if para.include? "family="
|
205
|
-
end
|
206
|
-
dlog "host,port,family : #{host},#{port},#{family}"
|
207
|
-
begin
|
208
|
-
#initialize the tcp socket
|
209
|
-
@socket = TCPSocket.new(host,port)
|
210
|
-
init_connection
|
211
|
-
rescue
|
212
|
-
elog "Could not establish connection to: #{@path}, will now exit."
|
213
|
-
exit(0) #a little harsh
|
214
|
-
end
|
215
|
-
else
|
216
|
-
#Danger, Will Robinson: the specified "path" is not usable
|
217
|
-
elog "supplied path: #{@path}, unusable! sorry."
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
# Connect to an abstract unix bus and initialize the connection.
|
222
|
-
def connect_to_unix
|
223
|
-
@socket = Socket.new(Socket::Constants::PF_UNIX,Socket::Constants::SOCK_STREAM, 0)
|
224
200
|
parse_session_string
|
225
201
|
if @transport == "unix" and @type == "abstract"
|
226
202
|
if HOST_END == LIL_END
|
@@ -234,32 +210,10 @@ module DBus
|
|
234
210
|
@socket.connect(sockaddr)
|
235
211
|
init_connection
|
236
212
|
end
|
237
|
-
|
238
|
-
# Parse the session string (socket address).
|
239
|
-
def parse_session_string
|
240
|
-
path_parsed = /^([^:]*):([^;]*)$/.match(@path)
|
241
|
-
@transport = path_parsed[1]
|
242
|
-
adr = path_parsed[2]
|
243
|
-
if @transport == "unix"
|
244
|
-
adr.split(",").each do |eqstr|
|
245
|
-
idx, val = eqstr.split("=")
|
246
|
-
case idx
|
247
|
-
when "path"
|
248
|
-
@type = idx
|
249
|
-
@unix = val
|
250
|
-
when "abstract"
|
251
|
-
@type = idx
|
252
|
-
@unix_abstract = val
|
253
|
-
when "guid"
|
254
|
-
@guid = val
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
213
|
|
260
214
|
# Send the buffer _buf_ to the bus using Connection#writel.
|
261
215
|
def send(buf)
|
262
|
-
@socket.write(buf)
|
216
|
+
@socket.write(buf)
|
263
217
|
end
|
264
218
|
|
265
219
|
# Tell a bus to register itself on the glib main loop
|
@@ -446,7 +400,7 @@ module DBus
|
|
446
400
|
# Fill (append) the buffer from data that might be available on the
|
447
401
|
# socket.
|
448
402
|
def update_buffer
|
449
|
-
@buffer += @socket.read_nonblock(MSG_BUF_SIZE)
|
403
|
+
@buffer += @socket.read_nonblock(MSG_BUF_SIZE)
|
450
404
|
end
|
451
405
|
|
452
406
|
# Get one message from the bus and remove it from the buffer.
|
@@ -487,10 +441,6 @@ module DBus
|
|
487
441
|
|
488
442
|
# Wait for a message to arrive. Return it once it is available.
|
489
443
|
def wait_for_message
|
490
|
-
if @socket.nil?
|
491
|
-
elog "Can't wait for messages, @socket is nil."
|
492
|
-
return
|
493
|
-
end
|
494
444
|
ret = pop_message
|
495
445
|
while ret == nil
|
496
446
|
r, d, d = IO.select([@socket])
|
@@ -505,15 +455,11 @@ module DBus
|
|
505
455
|
# Send a message _m_ on to the bus. This is done synchronously, thus
|
506
456
|
# the call will block until a reply message arrives.
|
507
457
|
def send_sync(m, &retc) # :yields: reply/return message
|
508
|
-
return if m.nil? #check if somethings wrong
|
509
458
|
send(m.marshall)
|
510
459
|
@method_call_msgs[m.serial] = m
|
511
460
|
@method_call_replies[m.serial] = retc
|
512
461
|
|
513
462
|
retm = wait_for_message
|
514
|
-
|
515
|
-
return if retm.nil? #check if somethings wrong
|
516
|
-
|
517
463
|
process(retm)
|
518
464
|
until [DBus::Message::ERROR,
|
519
465
|
DBus::Message::METHOD_RETURN].include?(retm.message_type) and
|
@@ -528,7 +474,6 @@ module DBus
|
|
528
474
|
def on_return(m, &retc)
|
529
475
|
# Have a better exception here
|
530
476
|
if m.message_type != Message::METHOD_CALL
|
531
|
-
elog "Funky exception, occured."
|
532
477
|
raise "on_return should only get method_calls"
|
533
478
|
end
|
534
479
|
@method_call_msgs[m.serial] = m
|
@@ -544,14 +489,17 @@ module DBus
|
|
544
489
|
end
|
545
490
|
|
546
491
|
# Process a message _m_ based on its type.
|
492
|
+
# method call:: FIXME...
|
493
|
+
# method call return value:: FIXME...
|
494
|
+
# signal:: FIXME...
|
495
|
+
# error:: FIXME...
|
547
496
|
def process(m)
|
548
|
-
return if m.nil? #check if somethings wrong
|
549
497
|
case m.message_type
|
550
498
|
when Message::ERROR, Message::METHOD_RETURN
|
551
499
|
raise InvalidPacketException if m.reply_serial == nil
|
552
500
|
mcs = @method_call_replies[m.reply_serial]
|
553
501
|
if not mcs
|
554
|
-
|
502
|
+
puts "no return code for #{mcs.inspect} (#{m.inspect})" if $DEBUG
|
555
503
|
else
|
556
504
|
if m.message_type == Message::ERROR
|
557
505
|
mcs.call(Error.new(m))
|
@@ -563,7 +511,7 @@ module DBus
|
|
563
511
|
end
|
564
512
|
when DBus::Message::METHOD_CALL
|
565
513
|
if m.path == "/org/freedesktop/DBus"
|
566
|
-
|
514
|
+
puts "Got method call on /org/freedesktop/DBus" if $DEBUG
|
567
515
|
end
|
568
516
|
# handle introspectable as an exception:
|
569
517
|
if m.interface == "org.freedesktop.DBus.Introspectable" and
|
@@ -591,7 +539,7 @@ module DBus
|
|
591
539
|
end
|
592
540
|
end
|
593
541
|
else
|
594
|
-
|
542
|
+
puts "Unknown message type: #{m.message_type}" if $DEBUG
|
595
543
|
end
|
596
544
|
end
|
597
545
|
|
@@ -631,7 +579,29 @@ module DBus
|
|
631
579
|
m.member = "Hello"
|
632
580
|
send_sync(m) do |rmsg|
|
633
581
|
@unique_name = rmsg.destination
|
634
|
-
|
582
|
+
puts "Got hello reply. Our unique_name is #{@unique_name}" if $DEBUG
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
# Parse the session string (socket address).
|
587
|
+
def parse_session_string
|
588
|
+
path_parsed = /^([^:]*):([^;]*)$/.match(@path)
|
589
|
+
@transport = path_parsed[1]
|
590
|
+
adr = path_parsed[2]
|
591
|
+
if @transport == "unix"
|
592
|
+
adr.split(",").each do |eqstr|
|
593
|
+
idx, val = eqstr.split("=")
|
594
|
+
case idx
|
595
|
+
when "path"
|
596
|
+
@type = idx
|
597
|
+
@unix = val
|
598
|
+
when "abstract"
|
599
|
+
@type = idx
|
600
|
+
@unix_abstract = val
|
601
|
+
when "guid"
|
602
|
+
@guid = val
|
603
|
+
end
|
604
|
+
end
|
635
605
|
end
|
636
606
|
end
|
637
607
|
|
@@ -639,6 +609,11 @@ module DBus
|
|
639
609
|
def init_connection
|
640
610
|
@client = Client.new(@socket)
|
641
611
|
@client.authenticate
|
612
|
+
# TODO: code some real stuff here
|
613
|
+
#writel("AUTH EXTERNAL 31303030")
|
614
|
+
#s = readl
|
615
|
+
# parse OK ?
|
616
|
+
#writel("BEGIN")
|
642
617
|
end
|
643
618
|
end # class Connection
|
644
619
|
|
@@ -648,10 +623,10 @@ module DBus
|
|
648
623
|
# This is a singleton class.
|
649
624
|
class SessionBus < Connection
|
650
625
|
include Singleton
|
651
|
-
|
626
|
+
|
652
627
|
# Get the the default session bus.
|
653
|
-
def initialize
|
654
|
-
super(
|
628
|
+
def initialize
|
629
|
+
super(ENV["DBUS_SESSION_BUS_ADDRESS"])
|
655
630
|
connect
|
656
631
|
send_hello
|
657
632
|
end
|
@@ -665,14 +640,14 @@ module DBus
|
|
665
640
|
include Singleton
|
666
641
|
|
667
642
|
# Get the default system bus.
|
668
|
-
def initialize
|
669
|
-
super(
|
643
|
+
def initialize
|
644
|
+
super(SystemSocketName)
|
670
645
|
connect
|
671
646
|
send_hello
|
672
647
|
end
|
673
648
|
end
|
674
649
|
|
675
|
-
# FIXME: we should get rid of these
|
650
|
+
# FIXME: we should get rid of these
|
676
651
|
|
677
652
|
def DBus.system_bus
|
678
653
|
SystemBus.instance
|
data/lib/dbus/introspect.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# dbus/introspection.rb - module containing a low-level D-Bus introspection implementation
|
2
2
|
#
|
3
3
|
# This file is part of the ruby-dbus project
|
4
4
|
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
|
@@ -237,7 +237,7 @@ module DBus
|
|
237
237
|
end
|
238
238
|
d = Time.now - t
|
239
239
|
if d > 2
|
240
|
-
|
240
|
+
puts "Some XML took more that two secs to parse. Optimize me!" if $DEBUG
|
241
241
|
end
|
242
242
|
[ret, subnodes]
|
243
243
|
end
|
data/lib/dbus.rb
CHANGED
@@ -7,19 +7,16 @@
|
|
7
7
|
# modify it under the terms of the GNU Lesser General Public
|
8
8
|
# License, version 2.1 as published by the Free Software Foundation.
|
9
9
|
# See the file "COPYING" for the exact licensing terms.
|
10
|
-
require 'rubygems'
|
11
|
-
require 'rofl' #http://github.com/pangdudu/rofl/tree/master makes the debug/tracing easy
|
12
|
-
#comes from the Rofl logger/tracer module
|
13
|
-
@logger.level = Logger::DEBUG
|
14
10
|
|
15
11
|
require 'dbus/type'
|
16
12
|
require 'dbus/introspect'
|
17
13
|
require 'dbus/export'
|
18
|
-
require 'dbus/bus'
|
14
|
+
require 'dbus/bus.rb'
|
19
15
|
require 'dbus/marshall'
|
20
16
|
require 'dbus/message'
|
21
17
|
require 'dbus/matchrule'
|
22
18
|
require 'dbus/auth'
|
19
|
+
|
23
20
|
require 'socket'
|
24
21
|
require 'thread'
|
25
22
|
|
@@ -30,9 +27,6 @@ module DBus
|
|
30
27
|
# Default socket name for the system bus.
|
31
28
|
SystemSocketName = "unix:path=/var/run/dbus/system_bus_socket"
|
32
29
|
|
33
|
-
# Socket name for the session bus, not pretty.
|
34
|
-
SessionSocketName = ENV["DBUS_SESSION_BUS_ADDRESS"]
|
35
|
-
|
36
30
|
# Byte signifying big endianness.
|
37
31
|
BIG_END = ?B
|
38
32
|
# Byte signifying little endianness.
|
metadata
CHANGED
@@ -1,39 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pangdudu-ruby-dbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ruby DBUS Team
|
7
|
+
- Ruby DBUS Team
|
8
8
|
autorequire: dbus
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
description: Ruby module for interaction with dbus, panda dev fork.
|
26
|
-
email: pangdudu@github
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: http://trac.luon.net
|
27
18
|
executables: []
|
28
19
|
|
29
20
|
extensions: []
|
30
21
|
|
31
22
|
extra_rdoc_files:
|
32
|
-
-
|
23
|
+
- ChangeLog
|
33
24
|
- COPYING
|
25
|
+
- README
|
26
|
+
- NEWS
|
34
27
|
files:
|
35
|
-
-
|
36
|
-
-
|
28
|
+
- examples/simple
|
29
|
+
- examples/simple/call_introspect.rb
|
30
|
+
- examples/service
|
31
|
+
- examples/service/call_service.rb
|
32
|
+
- examples/service/service_newapi.rb
|
33
|
+
- examples/gdbus
|
34
|
+
- examples/gdbus/gdbus.glade
|
35
|
+
- examples/gdbus/gdbus
|
36
|
+
- examples/gdbus/launch.sh
|
37
|
+
- examples/no-introspect
|
38
|
+
- examples/no-introspect/nm-test.rb
|
39
|
+
- examples/no-introspect/tracker-test.rb
|
40
|
+
- examples/rhythmbox
|
41
|
+
- examples/rhythmbox/playpause.rb
|
42
|
+
- examples/utils
|
43
|
+
- examples/utils/listnames.rb
|
44
|
+
- examples/utils/notify.rb
|
37
45
|
- lib/dbus
|
38
46
|
- lib/dbus/message.rb
|
39
47
|
- lib/dbus/auth.rb
|
@@ -44,12 +52,12 @@ files:
|
|
44
52
|
- lib/dbus/matchrule.rb
|
45
53
|
- lib/dbus/bus.rb
|
46
54
|
- lib/dbus.rb
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
55
|
+
- ChangeLog
|
56
|
+
- COPYING
|
57
|
+
- README
|
58
|
+
- NEWS
|
50
59
|
has_rdoc: true
|
51
|
-
homepage: http://
|
52
|
-
licenses:
|
60
|
+
homepage: http://trac.luon.net/data/ruby-dbus/
|
53
61
|
post_install_message:
|
54
62
|
rdoc_options: []
|
55
63
|
|
@@ -70,9 +78,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
78
|
requirements: []
|
71
79
|
|
72
80
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.2.0
|
74
82
|
signing_key:
|
75
83
|
specification_version: 2
|
76
|
-
summary: Ruby module for interaction with dbus
|
84
|
+
summary: Ruby module for interaction with dbus
|
77
85
|
test_files: []
|
78
86
|
|