From: Jean Guyader Date: Thu, 30 Jul 2009 19:35:31 +0000 (+0100) Subject: Fix the signals handling. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fremotes%2Forigin%2Fmaster;p=xenclient%2Fruby-dbus.git Fix the signals handling. --- diff --git a/lib/dbus/matchrule.rb b/lib/dbus/matchrule.rb index b6f79f5..01e501b 100644 --- a/lib/dbus/matchrule.rb +++ b/lib/dbus/matchrule.rb @@ -33,6 +33,7 @@ module DBus # Create a new match rule def initialize @sender = @interface = @member = @path = @destination = @type = nil + @filter = Hash.new() end # Set the message types to filter to type _t_. @@ -56,12 +57,12 @@ module DBus # Parses a match rule string _s_ and sets the filters on the object. def from_s(str) - s.split(",").each do |eq| + str.split(",").each do |eq| if eq =~ /^(.*)='([^']*)'$/ name = $1 - val = $1 + val = $2 if FILTERS.member?(name.to_sym) - method(name + "=").call(val) + @filter[name] = val else raise MatchRuleException end @@ -73,9 +74,9 @@ module DBus # given interface _intf_. def from_signal(intf, signal) signal = signal.name unless signal.is_a?(String) - self.type = "signal" - self.interface = intf.name - self.member = signal + self.type = @filter["name"] = "signal" + self.interface = @filter["interface"] = intf.name + self.member = @filter["member"] = signal self.path = intf.object.path self end @@ -89,9 +90,9 @@ module DBus return false end end - return false if @interface and @interface != msg.interface - return false if @member and @member != msg.member - return false if @path and @path != msg.path + return false if @filter["interface"] and @filter["interface"] != msg.interface + return false if @filter["member"] and @filter["member"] != msg.member + return false if @filter["path"] and @filter["path"] != msg.path true end end # class MatchRule