214 lines
5.4 KiB
HTML
214 lines
5.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Net::DBus::ProxyObject</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Net::DBus::ProxyObject</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-12-26<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Net::DBus::ProxyObject - Implement objects to export to the bus
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
# Connecting an object to the bus, under a service
|
|
package main;
|
|
|
|
use Net::DBus;
|
|
|
|
# Attach to the bus
|
|
my $bus = Net::DBus->find;
|
|
|
|
# Create our application's object instance
|
|
my $object = Demo::HelloWorld->new()
|
|
|
|
# Acquire a service 'org.demo.Hello'
|
|
my $service = $bus->export_service("org.demo.Hello");
|
|
|
|
# Finally export the object to the bus
|
|
my $proxy = Demo::HelloWorld::DBus->new($object);
|
|
|
|
....rest of program...
|
|
|
|
|
|
# Define a new package for the object we're going
|
|
# to export
|
|
package Demo::HelloWorld;
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
my $service = shift;
|
|
my $self = {};
|
|
|
|
$self->{sighandler} = undef;
|
|
|
|
bless $self, $class;
|
|
|
|
return $self;
|
|
}
|
|
|
|
sub sighandler {
|
|
my $self = shift;
|
|
my $callback = shift;
|
|
|
|
$self->[sighandler} = $callback;
|
|
}
|
|
|
|
sub Hello {
|
|
my $self = shift;
|
|
my $name = shift;
|
|
|
|
&{$self->{sighandler}}("Greeting", "Hello $name");
|
|
return "Said hello to $name";
|
|
}
|
|
|
|
sub Goodbye {
|
|
my $self = shift;
|
|
my $name = shift;
|
|
|
|
&{$self->{sighandler}}("Greeting", "Goodbye $name");
|
|
return "Said goodbye to $name";
|
|
}
|
|
|
|
|
|
# Define a new package for the object we're going
|
|
# to export
|
|
package Demo::HelloWorld::DBus;
|
|
|
|
# Specify the main interface provided by our object
|
|
use Net::DBus::Exporter qw(org.example.demo.Greeter);
|
|
|
|
# We're going to be a DBus object
|
|
use base qw(Net::DBus::ProxyObject);
|
|
|
|
# Export a 'Greeting' signal taking a stringl string parameter
|
|
dbus_signal("Greeting", ["string"]);
|
|
|
|
# Export 'Hello' as a method accepting a single string
|
|
# parameter, and returning a single string value
|
|
dbus_method("Hello", ["string"], ["string"]);
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
my $service = shift;
|
|
my $impl = shfit;
|
|
my $self = $class->SUPER::new($service, "/org/demo/HelloWorld", $impl);
|
|
|
|
bless $self, $class;
|
|
|
|
$self->sighandler(sub {
|
|
my $signame = shift;
|
|
my $arg = shift;
|
|
$self->emit_signal($signame, $arg);
|
|
});
|
|
|
|
return $self;
|
|
}
|
|
|
|
# Export 'Goodbye' as a method accepting a single string
|
|
# parameter, and returning a single string, but put it
|
|
# in the 'org.exaple.demo.Farewell' interface
|
|
|
|
dbus_method("Goodbye", ["string"], ["string"], "org.example.demo.Farewell");
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This the base for creating a proxy between a bus object and an
|
|
application's object. It allows the application's object model
|
|
to remain separate from the <FONT SIZE="-1">RPC</FONT> object model. The proxy object
|
|
will forward method calls from the bus, to the implementation
|
|
object. The proxy object can also register callbacks against
|
|
the application object, which it can use to then emit signals
|
|
on the bus.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">my $object = Net::DBus::ProxyObject->new($service, $path, $impl)<DD>
|
|
|
|
|
|
|
|
|
|
This creates a new DBus object with an path of <TT>$path</TT>
|
|
registered within the service <TT>$service</TT>. The <TT>$path</TT>
|
|
parameter should be a string complying with the usual
|
|
DBus requirements for object paths, while the <TT>$service</TT>
|
|
parameter should be an instance of Net::DBus::Service.
|
|
The latter is typically obtained by calling the <TT>"export_service"</TT>
|
|
method on the Net::DBus object. The <TT>$impl</TT> parameter is
|
|
the application object which will implement the methods being
|
|
exported to the bus.
|
|
<DT id="2">my $object = Net::DBus::ProxyObject->new($parentobj, $subpath, $impl)<DD>
|
|
|
|
|
|
|
|
|
|
This creates a new DBus child object with an path of <TT>$subpath</TT>
|
|
relative to its parent <TT>$parentobj</TT>. The <TT>$subpath</TT>
|
|
parameter should be a string complying with the usual
|
|
DBus requirements for object paths, while the <TT>$parentobj</TT>
|
|
parameter should be an instance of Net::DBus::BaseObject or
|
|
a subclass. The <TT>$impl</TT> parameter is the application object
|
|
which will implement the methods being exported to the bus.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Daniel P. Berrange
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (C) 2005-2011 Daniel P. Berrange
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
Net::DBus, Net::DBus::Service, Net::DBus::BaseObject,
|
|
Net::DBus::ProxyObject, Net::DBus::Exporter,
|
|
Net::DBus::RemoteObject
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="6"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DT id="7"><A HREF="#lbAF">AUTHOR</A><DD>
|
|
<DT id="8"><A HREF="#lbAG">COPYRIGHT</A><DD>
|
|
<DT id="9"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:49 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|