class DBus::ProxyService
Used by clients to represent a named service on the other side of the bus.
Formerly this class was intermixed with {ObjectServer} as Service.
@example Usage
svc = DBus.system_bus["org.freedesktop.machine1"] manager = svc["/org/freedesktop/machine1"] p manager.ListImages
Attributes
@return [Connection] The connection we’re using.
@return [BusName,nil] The service name. Will be nil for a {PeerConnection}
Public Class Methods
@param connection [Connection] The connection we’re using.
DBus::NodeTree::new
# File lib/dbus/proxy_service.rb, line 31 def initialize(name, connection) @name = BusName.new(name) @connection = connection super() end
Public Instance Methods
Retrieves an object at the given path. @param path [ObjectPath] @return [ProxyObject]
# File lib/dbus/proxy_service.rb, line 55 def [](path) object(path, api: ApiOptions::A1) end
Determine whether the service name already exists.
# File lib/dbus/proxy_service.rb, line 38 def exists? bus = connection # TODO: raise a better error if this is a peer connection bus.proxy.ListNames[0].member?(@name) end
Perform an introspection on all the objects on the service (starting recursively from the root).
# File lib/dbus/proxy_service.rb, line 45 def introspect raise NotImplementedError if block_given? rec_introspect(@root, "/") self end
Retrieves an object at the given path whose methods always return an array. @param path [ObjectPath] @param api [ApiOptions] @return [ProxyObject]
# File lib/dbus/proxy_service.rb, line 64 def object(path, api: ApiOptions::A0) node = get_node(path, create: true) if node.object.nil? || node.object.api != api node.object = ProxyObject.new( @connection, @name, path, api: api ) end node.object end
Private Instance Methods
Perform a recursive retrospection on the given current node on the given path.
# File lib/dbus/proxy_service.rb, line 79 def rec_introspect(node, path) xml = connection.introspect_data(@name, path) intfs, subnodes = IntrospectXMLParser.new(xml).parse subnodes.each do |nodename| subnode = node[nodename] = Node.new(nodename) subpath = if path == "/" "/#{nodename}" else "#{path}/#{nodename}" end rec_introspect(subnode, subpath) end return if intfs.empty? node.object = ProxyObjectFactory.new(xml, @connection, @name, path).build end