Net::DBus::RemoteObject Methods

From Alteeve Wiki
Revision as of 03:01, 12 October 2009 by Digimer (talk | contribs) (Created page with '{{dbtut_header}} Usage: <source lang="perl"> use Net::DBus; my $bus=Net::DBus->find; my $service=$bus->get_service("org.freedesktop.DBus"); my $object=$service->get_object("/org…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

 AN!Tools :: Net::DBus Binding Tutorial :: Net::DBus::RemoteObject Methods

Usage:

use Net::DBus;
my $bus=Net::DBus->find;
my $service=$bus->get_service("org.freedesktop.DBus");
my $object=$service->get_object("/org/freedesktop/DBus");

 

new

Usage:

my $object_path="/path/to/SomeObject";
my $interface="";    # Optional interface needed when a given object name is
                     # duplicated on multiple interfaces within the object.
my $object=Net::DBus::RemoteObject->new($service, $object_path[, $interface]);

This creates a handle to a remote '$object' at the given '$object_path' published on the message bus by the given '$service'. When more than one interface is available under the '$service', you may want to specify which '$interface' to use. This is required when the given '$object_path' exists on two or more interfaces.

This should not be directly called. Instead, it is preferable to use the get_object call as this will cache handles to remote objects, preventing unecessary introspection data lookups.

as_interface

Usage:

my $object=$object->as_interface($interface);

This re-casts the object to the specified '$interface'. This is only needed when the original '$object' name is available on two or more interfaces or when the remote object does not support introspection data lookups.

get_service

Usage:

my $service=$object->get_service;

This gets a handle to the remote '$service' that the remote '$object' is published under.

get_object_path

my $path=$object->get_object_path;

The returns the remote $object's '$path' from within the service.

get_child_object

Usage:

my $subpath="/ChildObject";  # This is RELATIVE to the parent's path, which is
                             # prepended to this value.
my $interface="";            # Optional, immediately casts the object to the
                             # specified interface.
my $child_object=$object->get_child_object($subpath, [$interface]);

This returns a handle to the '$child_object' at the specified '$subpath'. This '$subpath' is appended onto the parent object's path! So, if the parent object's path is '/path/to/SomeObject' and you set '$subpath' to '/ChildObject', the full path will be '/path/to/SomeObject/ChildObject'. The interface can be defined if you want to cast the child object to the specified interface immediately.

connect_to_signal

Usage:

my $name="SomeSignal";
my $coderef=\&some_subroutine;
$object->connect_to_signal($name, $coderef);

This creates a callback attached to the remote method. When the signal with the given '$name' is emitted, the referenced subroutine will be called with the arguments from the signal being passed into it.  

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.