File ruby-dbus-0.2.1_to_trunk.patch of Package ruby-dbus
Index: lib/dbus.rb
===================================================================
--- lib/dbus.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus.rb (.../trunk) (revision 160)
@@ -25,7 +25,7 @@
# Module containing all the D-Bus modules and classes.
module DBus
# Default socket name for the system bus.
- SystemSocketName = "unix=/var/run/dbus/system_bus_socket"
+ SystemSocketName = "unix:path=/var/run/dbus/system_bus_socket"
# Byte signifying big endianness.
BIG_END = ?B
Index: lib/dbus/export.rb
===================================================================
--- lib/dbus/export.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus/export.rb (.../trunk) (revision 160)
@@ -62,17 +62,12 @@
meth = @intfs[msg.interface].methods[msg.member.to_sym]
raise MethodNotInInterface if not meth
methname = Object.make_method_name(msg.interface, msg.member)
- retdata = method(methname).call(*msg.params)
+ retdata = method(methname).call(*msg.params).to_a
reply = Message.new.reply_to(msg)
- # I'm sure there is a ruby way to do that
- i = 0
- if meth.rets.size > 0 and not retdata.kind_of?(Array)
- raise InvalidReturnType
+ meth.rets.zip(retdata).each do |rsig, rdata|
+ reply.add_param(rsig[1], rdata)
end
- meth.rets.each do |rsig|
- reply.add_param(rsig[1], retdata[i])
- end
@service.bus.send(reply.marshall)
end
end
Index: lib/dbus/marshall.rb
===================================================================
--- lib/dbus/marshall.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus/marshall.rb (.../trunk) (revision 160)
@@ -312,6 +312,12 @@
when Type::UINT32
align(4)
@packet += [val].pack("L")
+ when Type::UINT64
+ align(8)
+ @packet += [val].pack("Q")
+ when Type::INT64
+ align(8)
+ @packet += [val].pack("q")
when Type::INT32
align(4)
@packet += [val].pack("l")
Index: lib/dbus/matchrule.rb
===================================================================
--- lib/dbus/matchrule.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus/matchrule.rb (.../trunk) (revision 160)
@@ -39,7 +39,7 @@
# Possible message types are: signal, method_call, method_return, and error.
def type=(t)
if not ['signal', 'method_call', 'method_return', 'error'].member?(t)
- raise MatchRuleException
+ raise MatchRuleException
end
@type = t
end
@@ -63,7 +63,7 @@
if FILTERS.member?(name.to_sym)
method(name + "=").call(val)
else
- raise MatchRuleException
+ raise MatchRuleException
end
end
end
Index: lib/dbus/bus.rb
===================================================================
--- lib/dbus/bus.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus/bus.rb (.../trunk) (revision 160)
@@ -171,8 +171,16 @@
# The socket that is used to connect with the bus.
attr_reader :socket
- # Create a new connection to the bus for a given connect _path_
- # (UNIX socket).
+ # Create a new connection to the bus for a given connect _path_. _path_
+ # format is described in the D-Bus specification:
+ # http://dbus.freedesktop.org/doc/dbus-specification.html#addresses
+ # and is something like:
+ # "transport1:key1=value1,key2=value2;transport2:key1=value1,key2=value2"
+ # e.g. "unix:path=/tmp/dbus-test"
+ #
+ # Current implementation of ruby-dbus supports only a single server
+ # address and only "unix:path=...,guid=..." and
+ # "unix:abstract=...,guid=..." forms
def initialize(path)
@path = path
@unique_name = nil
@@ -190,18 +198,17 @@
# Connect to the bus and initialize the connection.
def connect
parse_session_string
- if @type == "unix:abstract"
+ if @transport == "unix" and @type == "abstract"
if HOST_END == LIL_END
sockaddr = "\1\0\0#{@unix_abstract}"
else
sockaddr = "\0\1\0#{@unix_abstract}"
end
- elsif @type == "unix"
+ elsif @transport == "unix" and @type == "path"
sockaddr = Socket.pack_sockaddr_un(@unix)
end
@socket.connect(sockaddr)
init_connection
- send_hello
end
# Send the buffer _buf_ to the bus using Connection#writel.
@@ -578,17 +585,22 @@
# Parse the session string (socket address).
def parse_session_string
- @path.split(",").each do |eqstr|
- idx, val = eqstr.split("=")
- case idx
- when "unix"
- @type = idx
- @unix = val
- when "unix:abstract"
- @type = idx
- @unix_abstract = val
- when "guid"
- @guid = val
+ path_parsed = /^([^:]*):([^;]*)$/.match(@path)
+ @transport = path_parsed[1]
+ adr = path_parsed[2]
+ if @transport == "unix"
+ adr.split(",").each do |eqstr|
+ idx, val = eqstr.split("=")
+ case idx
+ when "path"
+ @type = idx
+ @unix = val
+ when "abstract"
+ @type = idx
+ @unix_abstract = val
+ when "guid"
+ @guid = val
+ end
end
end
end
@@ -616,6 +628,7 @@
def initialize
super(ENV["DBUS_SESSION_BUS_ADDRESS"])
connect
+ send_hello
end
end
@@ -630,6 +643,7 @@
def initialize
super(SystemSocketName)
connect
+ send_hello
end
end
Index: lib/dbus/introspect.rb
===================================================================
--- lib/dbus/introspect.rb (.../tags/0.2.1) (revision 160)
+++ lib/dbus/introspect.rb (.../trunk) (revision 160)
@@ -246,19 +246,21 @@
private
# Parses a method signature XML element _e_ and initialises
- # method _m_.
+ # method/signal _m_.
def parse_methsig(e, m)
e.elements.each("arg") do |ae|
name = ae.attributes["name"]
dir = ae.attributes["direction"]
sig = ae.attributes["type"]
- case dir
- when "in"
+ if m.is_a?(DBus::Signal)
m.add_param([name, sig])
- when "out"
- m.add_return([name, sig])
- when nil # It's a signal, no direction
- m.add_param([name, sig])
+ elsif m.is_a?(DBus::Method)
+ case dir
+ when "in"
+ m.add_param([name, sig])
+ when "out"
+ m.add_return([name, sig])
+ end
else
raise NotImplementedError, dir
end