### Home Classes Methods

### In Files

- lib/dbus/introspect.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #all_properties
- #check_for_eval
- #check_for_quoted_eval
- #define
- #define_method
- #define_method_from_descriptor
- #define_signal_from_descriptor
- #on_signal
- #singleton_class
- #to_str

### Files

- README

### Class/Module Index

Quicksearch

- DBus
- DBus::ASessionBus
- DBus::ASystemBus
- DBus::AuthenticationFailed
- DBus::Authenticator
- DBus::Client
- DBus::Connection
- DBus::Connection::NameRequestError
- DBus::DBusCookieSHA1
- DBus::Error
- DBus::ErrorMessage
- DBus::External
- DBus::FormalParameter
- DBus::IncompleteBufferException
- DBus::Interface
- DBus::InterfaceElement
- DBus::IntrospectXMLParser
- DBus::InvalidClassDefinition
- DBus::InvalidDestinationName
- DBus::InvalidIntrospectionData
- DBus::InvalidMethodName
- DBus::InvalidPacketException
- DBus::InvalidParameters
- DBus::Main
- DBus::MatchRule
- DBus::MatchRuleException
- DBus::Message
- DBus::Method
- DBus::MethodNotImplemented
- DBus::MethodReturnMessage
- DBus::Node
- DBus::Object
- DBus::Object::UndefinedInterface
- DBus::PacketMarshaller
- DBus::PacketUnmarshaller
- DBus::ProxyObject
- DBus::ProxyObjectFactory
- DBus::ProxyObjectInterface
- DBus::RemoteBus
- DBus::Service
- DBus::SessionBus
- DBus::Signal
- DBus::SystemBus
- DBus::Type
- DBus::Type::Parser
- DBus::Type::SignatureException
- DBus::Type::Type
- DBus::TypeException
- DBus::UnknownSignal
- Integer

No matching classes.

# 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/introspect.rb, line 314
    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/introspect.rb, line 411
    def [](propname)
      self.object[PROPERTY_INTERFACE].Get(self.name, propname)[0]
    end

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

Write a property.

    # File lib/dbus/introspect.rb, line 416
    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.

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

check_for_eval(s) click to toggle source

FIXME

    # File lib/dbus/introspect.rb, line 330
    def check_for_eval(s)
      raise RuntimeError, "invalid internal data '#{s}'" if not s.to_s =~ /^[A-Za-z0-9_]*$/
    end

check_for_quoted_eval(s) click to toggle source

FIXME

    # File lib/dbus/introspect.rb, line 335
    def check_for_quoted_eval(s)
      raise RuntimeError, "invalid internal data '#{s}'" if not s.to_s =~ /^[^"]+$/
    end

define(m) click to toggle source

Defines a signal or method based on the descriptor m.

    # File lib/dbus/introspect.rb, line 382
    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/introspect.rb, line 391
    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/introspect.rb, line 340
    def define_method_from_descriptor(m)
      check_for_eval(m.name)
      check_for_quoted_eval(@name)
      methdef = "def #{m.name}("
      methdef += (0..(m.params.size - 1)).to_a.collect { |n|
        "arg#{n}"
      }.push("&reply_handler").join(", ")
      methdef += %{)
              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
            }
      idx = 0
      m.params.each do |fpar|
        par = fpar.type
        check_for_quoted_eval(par)

        # This is the signature validity check
        Type::Parser.new(par).parse

        methdef += %{
          msg.add_param("#{par}", arg#{idx})
        }
        idx += 1
      end
      methdef += "
        @object.bus.send_sync_or_async(msg, &reply_handler)
      end
      "
      singleton_class.class_eval(methdef)
      @methods[m.name] = m
    end

define_signal_from_descriptor(s) click to toggle source

Defines a signal from the descriptor s.

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

on_signal(bus, name, &block) click to toggle source

Registers a handler (code block) for a signal with name arriving over the given bus. If no block is given, the signal is unregistered.

    # File lib/dbus/introspect.rb, line 399
    def on_signal(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/introspect.rb, line 325
    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/introspect.rb, line 320
    def to_str
      @name
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.