1Net::DBus::BaseObject(3U)ser Contributed Perl DocumentatiNoent::DBus::BaseObject(3)
2
3
4

NAME

6       Net::DBus::BaseObject - base class for exporting objects to the bus
7

SYNOPSIS

9         # We're going to be a DBus object
10         use base qw(Net::DBus::BaseObject);
11
12         # Export a 'Greeting' signal taking a stringl string parameter
13         dbus_signal("Greeting", ["string"]);
14
15         # Export 'Hello' as a method accepting a single string
16         # parameter, and returning a single string value
17         dbus_method("Hello", ["string"], ["string"]);
18
19         sub new {
20             my $class = shift;
21             my $service = shift;
22             my $self = $class->SUPER::new($service, "/org/demo/HelloWorld");
23
24             bless $self, $class;
25
26             return $self;
27         }
28
29         sub _dispatch_object {
30             my $self = shift;
31             my $connection = shift;
32             my $message = shift;
33
34             if (....$message refers to a object's method ... ) {
35                ...dispatch this object's interfaces/methods...
36                return $reply;
37             }
38         }
39

DESCRIPTION

41       This the base of all objects which are exported to the message bus. It
42       provides the core support for type introspection required for objects
43       exported to the message. When sub-classing this object, the "_dispatch"
44       object should be implemented to handle processing of incoming messages.
45       The Net::DBus::Exporter module is used to declare which methods (and
46       signals) are being exported to the message bus.
47
48       All packages inheriting from this, will automatically have the
49       interface "org.freedesktop.DBus.Introspectable" registered with
50       Net::DBus::Exporter, and the "Introspect" method within this exported.
51
52       Application developers will rarely want to use this class directly,
53       instead either Net::DBus::Object or "Net::DBus::ProxyObject" are the
54       common choices. This class will only be used if wanting to write a new
55       approach to dispatching incoming method calls.
56

METHODS

58       my $object = Net::DBus::BaseObject->new($service, $path)
59           This creates a new DBus object with an path of $path registered
60           within the service $service. The $path parameter should be a string
61           complying with the usual DBus requirements for object paths, while
62           the $service parameter should be an instance of Net::DBus::Service.
63           The latter is typically obtained by calling the "export_service"
64           method on the Net::DBus object.
65
66       my $object = Net::DBus::BaseObject->new($parentobj, $subpath)
67           This creates a new DBus child object with an path of $subpath
68           relative to its parent $parentobj. The $subpath parameter should be
69           a string complying with the usual DBus requirements for object
70           paths, while the $parentobj parameter should be an instance of
71           Net::DBus::BaseObject.
72
73       $object->disconnect();
74           This method disconnects the object from the bus, such that it will
75           no longer receive messages sent by other clients. Any child objects
76           will be recursively disconnected too. After an object has been
77           disconnected, it is possible for Perl to garbage collect the object
78           instance. It will also make it possible to connect a newly created
79           object to the same path.
80
81       my $bool = $object->is_connected
82           Returns a true value if the object is connected to the bus, and
83           thus capable of being accessed by remote clients. Returns false if
84           the object is disconnected & thus ready for garbage collection. All
85           objects start off in the connected state, and will only transition
86           if the "disconnect" method is called.
87
88       my $service = $object->get_service
89           Retrieves the Net::DBus::Service object within which this object is
90           exported.
91
92       my $path = $object->get_object_path
93           Retrieves the path under which this object is exported
94
95       $object->emit_signal_in($name, $interface, $client, @args);
96           Emits a signal from the object, with a name of $name. If the
97           $interface parameter is defined, the signal will be scoped within
98           that interface. If the $client parameter is defined, the signal
99           will be unicast to that client on the bus. The signal and the data
100           types of the arguments @args must have been registered with
101           Net::DBus::Exporter by calling the "dbus_signal" method.
102
103       $self->emit_signal_to($name, $client, @args);
104           Emits a signal from the object, with a name of $name. The signal
105           and the data types of the arguments @args must have been registered
106           with Net::DBus::Exporter by calling the "dbus_signal" method. The
107           signal will be sent only to the client named by the $client
108           parameter.
109
110       $self->emit_signal($name, @args);
111           Emits a signal from the object, with a name of $name. The signal
112           and the data types of the arguments @args must have been registered
113           with Net::DBus::Exporter by calling the "dbus_signal" method. The
114           signal will be broadcast to all clients on the bus.
115
116       $object->connect_to_signal_in($name, $interface, $coderef);
117           Connects a callback to a signal emitted by the object. The $name
118           parameter is the name of the signal within the object, and $coderef
119           is a reference to an anonymous subroutine. When the signal $name is
120           emitted by the remote object, the subroutine $coderef will be
121           invoked, and passed the parameters from the signal. The $interface
122           parameter is used to specify the explicit interface defining the
123           signal to connect to.
124
125       $object->connect_to_signal($name, $coderef);
126           Connects a callback to a signal emitted by the object. The $name
127           parameter is the name of the signal within the object, and $coderef
128           is a reference to an anonymous subroutine. When the signal $name is
129           emitted by the remote object, the subroutine $coderef will be
130           invoked, and passed the parameters from the signal.
131
132       $reply = $object->_dispatch_object($connection, $message);
133           The "_dispatch_object" method is to be used to handle dispatch of
134           methods implemented by the object. The default implementation is a
135           no-op and should be overridden by subclasses todo whatever
136           processing is required. If the $message could be handled then
137           another "Net::DBus::Binding::Message" instance should be returned
138           for the reply. If "undef" is returned, then a generic error will be
139           returned to the caller.
140
141       $currvalue = $object->_dispatch_property($name); =item
142       $object->_dispatch_property($name, $newvalue);
143           The "_dispatch_property" method is to be used to handle dispatch of
144           property reads and writes. The $name parameter is the name of the
145           property being accessed. If $newvalue is supplied then the property
146           is to be updated, otherwise the current value is to be returned.
147           The default implementation will simply raise an error, so must be
148           overridden in subclasses.
149

AUTHOR

151       Daniel P. Berrange
152
154       Copyright (C) 2005-2011 Daniel P. Berrange
155

SEE ALSO

157       Net::DBus, Net::DBus::Service, Net::DBus::Object,
158       Net::DBus::ProxyObject, Net::DBus::Exporter, Net::DBus::RemoteObject
159
160
161
162perl v5.32.0                      2020-07-28          Net::DBus::BaseObject(3)
Impressum