# class DBus::ProxyObjectInterface

# D-Bus proxy object interface class¶ ↑

A class similar to the normal Interface used as a proxy for remote object interfaces.

### Constants

PROPERTY_INTERFACE

### Attributes

methods[RW]

The proxied methods contained in the interface.

name[R]

The name of the interface.

object[R]

The proxy object to which this interface belongs.

signals[RW]

The proxied signals contained in the interface.

### Public Class Methods

new(object, name) click to toggle source

Creates a new proxy interface for the given proxy object and the given name.

    # File lib/dbus/proxy_object_interface.rb, line 27
    def initialize(object, name)
      @object, @name = object, name
      @methods, @signals = Hash.new, Hash.new
    end

### Public Instance Methods

[](propname) click to toggle source

Read a property.

    # File lib/dbus/proxy_object_interface.rb, line 113
    def [](propname)
      self.object[PROPERTY_INTERFACE].Get(self.name, propname)[0]
    end

[]=(propname, value) click to toggle source

Write a property.

    # File lib/dbus/proxy_object_interface.rb, line 118
    def []=(propname, value)
      self.object[PROPERTY_INTERFACE].Set(self.name, propname, value)
    end

all_properties() click to toggle source

Read all properties at once, as a hash. @return [Hash{String}]

    # File lib/dbus/proxy_object_interface.rb, line 124
    def all_properties
      self.object[PROPERTY_INTERFACE].GetAll(self.name)[0]
    end

define(m) click to toggle source

Defines a signal or method based on the descriptor m.

    # File lib/dbus/proxy_object_interface.rb, line 79
    def define(m)
      if m.kind_of?(Method)
        define_method_from_descriptor(m)
      elsif m.kind_of?(Signal)
        define_signal_from_descriptor(m)
      end
    end

define_method(methodname, prototype) click to toggle source

Defines a proxied method on the interface.

    # File lib/dbus/proxy_object_interface.rb, line 88
    def define_method(methodname, prototype)
      m = Method.new(methodname)
      m.from_prototype(prototype)
      define(m)
    end

define_method_from_descriptor(m) click to toggle source

Defines a method on the interface from the Method descriptor m.

    # File lib/dbus/proxy_object_interface.rb, line 43
    def define_method_from_descriptor(m)
      m.params.each do |fpar|
        par = fpar.type
        # This is the signature validity check
        Type::Parser.new(par).parse
      end

      singleton_class.class_eval do
        define_method m.name do |*args, &reply_handler|
          if m.params.size != args.size
            raise ArgumentError, "wrong number of arguments (#{args.size} for #{m.params.size})"
          end

          msg = Message.new(Message::METHOD_CALL)
          msg.path = @object.path
          msg.interface = @name
          msg.destination = @object.destination
          msg.member = m.name
          msg.sender = @object.bus.unique_name
          m.params.each do |fpar|
            par = fpar.type
            msg.add_param(par, args.shift)
          end
          @object.bus.send_sync_or_async(msg, &reply_handler)
        end
      end

      @methods[m.name] = m
    end

define_signal_from_descriptor(s) click to toggle source

Defines a signal from the descriptor s.

    # File lib/dbus/proxy_object_interface.rb, line 74
    def define_signal_from_descriptor(s)
      @signals[s.name] = s
    end

on_signal(bus = @object.bus, name, &block) click to toggle source

@overload #on_signal(name, &block) @overload #on_signal(bus, name, &block) Registers a handler (code block) for a signal with name arriving over the given bus. If no block is given, the signal is unregistered. Note that specifying bus is discouraged and the option is kept only for backward compatibility. @return [void]

    # File lib/dbus/proxy_object_interface.rb, line 101
    def on_signal(bus = @object.bus, name, &block)
      mr = DBus::MatchRule.new.from_signal(self, name)
      if block.nil?
        bus.remove_match(mr)
      else
        bus.add_match(mr) { |msg| block.call(*msg.params) }
      end
    end

singleton_class() click to toggle source

Returns the singleton class of the interface.

    # File lib/dbus/proxy_object_interface.rb, line 38
    def singleton_class
      (class << self ; self ; end)
    end

to_str() click to toggle source

Returns the string representation of the interface (the name).

    # File lib/dbus/proxy_object_interface.rb, line 33
    def to_str
      @name
    end