.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::DBus::Object 3pm" .TH Net::DBus::Object 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Net::DBus::Object \- Implement objects to export to the bus .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& # Connecting an object to the bus, under a service \& package main; \& \& use Net::DBus; \& \& # Attach to the bus \& my $bus = Net::DBus\->find; \& \& # Acquire a service \*(Aqorg.demo.Hello\*(Aq \& my $service = $bus\->export_service("org.demo.Hello"); \& \& # Export our object within the service \& my $object = Demo::HelloWorld\->new($service); \& \& ....rest of program... \& \& # Define a new package for the object we\*(Aqre going \& # to export \& package Demo::HelloWorld; \& \& # Specify the main interface provided by our object \& use Net::DBus::Exporter qw(org.example.demo.Greeter); \& \& # We\*(Aqre going to be a DBus object \& use base qw(Net::DBus::Object); \& \& # Export a \*(AqGreeting\*(Aq signal taking a stringl string parameter \& dbus_signal("Greeting", ["string"]); \& \& # Export \*(AqHello\*(Aq 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 $self = $class\->SUPER::new($service, "/org/demo/HelloWorld"); \& \& bless $self, $class; \& \& return $self; \& } \& \& sub Hello { \& my $self = shift; \& my $name = shift; \& \& $self\->emit_signal("Greeting", "Hello $name"); \& return "Said hello to $name"; \& } \& \& # Export \*(AqGoodbye\*(Aq as a method accepting a single string \& # parameter, and returning a single string, but put it \& # in the \*(Aqorg.exaple.demo.Farewell\*(Aq interface \& \& dbus_method("Goodbye", ["string"], ["string"], "org.example.demo.Farewell"); \& \& sub Goodbye { \& my $self = shift; \& my $name = shift; \& \& $self\->emit_signal("Greeting", "Goodbye $name"); \& return "Said goodbye to $name"; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This the base for implementing objects which are directly exported to the bus. The methods implemented in a subclass are mapped to methods on the bus. By using this class, an application is directly tieing the RPC functionality into its object model. Applications may thus prefer to use the \f(CW\*(C`Net::DBus::ProxyObject\*(C'\fR class which allows the RPC functionality to be maintained separately from the core object model, by proxying RPC method calls. .SH METHODS .IX Header "METHODS" .ie n .IP "my $object = Net::DBus::Object\->new($service, $path)" 4 .el .IP "my \f(CW$object\fR = Net::DBus::Object\->new($service, \f(CW$path\fR)" 4 .IX Item "my $object = Net::DBus::Object->new($service, $path)" This creates a new DBus object with an path of \f(CW$path\fR registered within the service \f(CW$service\fR. The \f(CW$path\fR parameter should be a string complying with the usual DBus requirements for object paths, while the \f(CW$service\fR parameter should be an instance of Net::DBus::Service. The latter is typically obtained by calling the \f(CW\*(C`export_service\*(C'\fR method on the Net::DBus object. .ie n .IP "my $object = Net::DBus::Object\->new($parentobj, $subpath)" 4 .el .IP "my \f(CW$object\fR = Net::DBus::Object\->new($parentobj, \f(CW$subpath\fR)" 4 .IX Item "my $object = Net::DBus::Object->new($parentobj, $subpath)" This creates a new DBus child object with an path of \f(CW$subpath\fR relative to its parent \f(CW$parentobj\fR. The \f(CW$subpath\fR parameter should be a string complying with the usual DBus requirements for object paths, while the \f(CW$parentobj\fR parameter should be an instance of Net::DBus::BaseObject or a subclass. .SH AUTHOR .IX Header "AUTHOR" Daniel P. Berrange .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright (C) 2005\-2011 Daniel P. Berrange .SH "SEE ALSO" .IX Header "SEE ALSO" Net::DBus, Net::DBus::Service, Net::DBus::BaseObject, Net::DBus::ProxyObject, Net::DBus::Exporter, Net::DBus::RemoteObject