def process(m)
return if m.nil?
case m.message_type
when Message::ERROR, Message::METHOD_RETURN
raise InvalidPacketException if m.reply_serial == nil
mcs = @method_call_replies[m.reply_serial]
if not mcs
puts "DEBUG: no return code for mcs: #{mcs.inspect} m: #{m.inspect}" if $DEBUG
else
if m.message_type == Message::ERROR
mcs.call(Error.new(m))
else
mcs.call(m)
end
@method_call_replies.delete(m.reply_serial)
@method_call_msgs.delete(m.reply_serial)
end
when DBus::Message::METHOD_CALL
if m.path == "/org/freedesktop/DBus"
puts "DEBUG: Got method call on /org/freedesktop/DBus" if $DEBUG
end
node = @service.get_node(m.path)
if not node
reply = Message.error(m, "org.freedesktop.DBus.Error.UnknownObject",
"Object #{m.path} doesn't exist")
send(reply.marshall)
elsif m.interface == "org.freedesktop.DBus.Introspectable" and
m.member == "Introspect"
reply = Message.new(Message::METHOD_RETURN).reply_to(m)
reply.sender = @unique_name
reply.add_param(Type::STRING, node.to_xml)
send(reply.marshall)
else
obj = node.object
return if obj.nil?
obj.dispatch(m) if obj
end
when DBus::Message::SIGNAL
@signal_matchrules.each do |mrs, slot|
if DBus::MatchRule.new.from_s(mrs).match(m)
slot.call(m)
end
end
else
puts "DEBUG: Unknown message type: #{m.message_type}" if $DEBUG
end
end