<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://alteeve.com/w/index.php?action=history&amp;feed=atom&amp;title=Net%3A%3ADBus%3A%3AExporter_Methods</id>
	<title>Net::DBus::Exporter Methods - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://alteeve.com/w/index.php?action=history&amp;feed=atom&amp;title=Net%3A%3ADBus%3A%3AExporter_Methods"/>
	<link rel="alternate" type="text/html" href="https://alteeve.com/w/index.php?title=Net::DBus::Exporter_Methods&amp;action=history"/>
	<updated>2026-04-21T11:59:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://alteeve.com/w/index.php?title=Net::DBus::Exporter_Methods&amp;diff=455&amp;oldid=prev</id>
		<title>Digimer: Created page with &#039;{{dbtut_header}}  = Preface =  There are a couple special types that you need to be aware of before you use this module&#039;s methods.  == MAGIC TYPES ==  There are a couple of &quot;magi…&#039;</title>
		<link rel="alternate" type="text/html" href="https://alteeve.com/w/index.php?title=Net::DBus::Exporter_Methods&amp;diff=455&amp;oldid=prev"/>
		<updated>2009-10-12T02:57:32Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{dbtut_header}}  = Preface =  There are a couple special types that you need to be aware of before you use this module&amp;#039;s methods.  == MAGIC TYPES ==  There are a couple of &amp;quot;magi…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Páàjì titun&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{dbtut_header}}&lt;br /&gt;
&lt;br /&gt;
= Preface =&lt;br /&gt;
&lt;br /&gt;
There are a couple special types that you need to be aware of before you use this module&amp;#039;s methods.&lt;br /&gt;
&lt;br /&gt;
== MAGIC TYPES ==&lt;br /&gt;
&lt;br /&gt;
There are a couple of &amp;quot;magic types&amp;quot; that can be used when specifying introspection data for an exported service. A parameters declared as one of the magic types are not visible to clients. Instead, it&amp;#039;s value is provided automatically be the server-side bindings.&lt;br /&gt;
&lt;br /&gt;
For example, you can use a magic type to automatically pass the unique name of the caller to a method.&lt;br /&gt;
&lt;br /&gt;
=== caller ===&lt;br /&gt;
&lt;br /&gt;
This magic type passes in the [[Net::DBus_Binding_Tutorial#Unique_Connection_Name|unique name]] of the caller to the method.&lt;br /&gt;
&lt;br /&gt;
=== serial ===&lt;br /&gt;
&lt;br /&gt;
*MADI: Link &amp;#039;serial number&amp;#039;&lt;br /&gt;
This magic type passes in the [[serial number]] assigned to the caller for the given method call.&lt;br /&gt;
&lt;br /&gt;
== ANNOTATIONS ==&lt;br /&gt;
&lt;br /&gt;
Annotations are [[metadata]] that can be passed to an exported method, signal or property as a hash reference. These indicate certain bits of information about the method being exported when used by a client.&lt;br /&gt;
&lt;br /&gt;
=== no_reply ===&lt;br /&gt;
&lt;br /&gt;
This annotation informs the caller that the method will not be returning any data. In this way, the caller will know not to bother waiting for a reply.&lt;br /&gt;
&lt;br /&gt;
=== deprecated ===&lt;br /&gt;
&lt;br /&gt;
This tells the caller that the use of the method, signal or property is discouraged as the exported object may disappear in a future version. The client should print out a warning when this annotation has been set.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
Properties have an access flag value that indicates if the property value can be read, written or both. The valid values are &amp;quot;read&amp;quot;, &amp;quot;write&amp;quot; and &amp;quot;readwrite&amp;quot;, respectively.&lt;br /&gt;
&lt;br /&gt;
= Methods =&lt;br /&gt;
&lt;br /&gt;
== dbus_method ==&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeMethod&amp;quot;;&lt;br /&gt;
my @params=(&amp;quot;[\&amp;quot;array\&amp;quot;, \&amp;quot;string\&amp;quot;]&amp;quot;, &amp;quot;[\&amp;quot;int32\&amp;quot;]&amp;quot;); # Some type(s) to be accepted by the method...&lt;br /&gt;
my @return=(&amp;quot;[\&amp;quot;string\&amp;quot;]&amp;quot;);                           # Some returned type(s)...&lt;br /&gt;
my %annotations=();                                    # Optional. If not used, don&amp;#039;t bother including it.&lt;br /&gt;
dbus_method($name, \@params, \@returns, [\%annotations]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeMethod&amp;quot;;&lt;br /&gt;
my @params=(&amp;quot;[\&amp;quot;unint32\&amp;quot;]&amp;quot;);                          # Some type(s) to be accepted by the method...&lt;br /&gt;
my @return=(&amp;quot;[\&amp;quot;string\&amp;quot;]&amp;quot;);                           # Some returned type(s)...&lt;br /&gt;
my $interface=&amp;quot;org.example.foo&amp;quot;;&lt;br /&gt;
my %annotations=(no_reply=&amp;gt;1);                         # Tell the caller not to wait for a reply.&lt;br /&gt;
dbus_method($name, \@params, \@returns, $interface, \%annotations);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This exports a method called &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$name&amp;lt;/span&amp;gt;&amp;#039; that accepts data with the type signature(s) in the array &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;@params&amp;lt;/span&amp;gt;&amp;#039; and returns data with the type signature(s) &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;@return&amp;lt;/span&amp;gt;&amp;#039;. The arrays &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;@params&amp;lt;/span&amp;gt;&amp;#039; and &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;@return&amp;lt;/span&amp;gt;&amp;#039; must be passed as references. If you specify any annotations, pass them as a hash reference at the end of the declaration.&lt;br /&gt;
&lt;br /&gt;
In the first example, no &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$interface&amp;lt;/span&amp;gt;&amp;#039; is specified, so the default one is used. In the second case, an explicit interface is defined so this method will be exported using that interface.&lt;br /&gt;
&lt;br /&gt;
== dbus_signal ==&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeProperty&amp;quot;;&lt;br /&gt;
my @params=&amp;quot;[\&amp;quot;dict\&amp;quot;, \&amp;quot;string\&amp;quot;, \&amp;quot;int32\&amp;quot;], [\&amp;quot;string\&amp;quot;]&amp;quot;; # Signal&amp;#039;s data type.&lt;br /&gt;
my %annotations=();                                  # Optional. If not used, don&amp;#039;t bother including it.&lt;br /&gt;
dbus_signal($name, \@params, [\%annotations]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeProperty&amp;quot;;&lt;br /&gt;
my @params=&amp;quot;[\&amp;quot;string\&amp;quot;]&amp;quot;;                           # Signal&amp;#039;s data type.&lt;br /&gt;
my $interface=&amp;quot;org.example.foo&amp;quot;;&lt;br /&gt;
my %annotations=();                                  # Optional. If not used, don&amp;#039;t bother including it.&lt;br /&gt;
dbus_signal($name, \@params, $interface, [\%annotations]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This exports a signal called &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$name&amp;lt;/span&amp;gt;&amp;#039; that emits data with the type signature defined in &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;@params&amp;lt;/span&amp;gt;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
In the first example, no &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$interface&amp;lt;/span&amp;gt;&amp;#039; is specified, so the default one is used. In the second case, an explicit interface is defined so this signal will be exported using that interface.&lt;br /&gt;
&lt;br /&gt;
== dbus_property ==&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeProperty&amp;quot;;&lt;br /&gt;
my $type=&amp;quot;[\&amp;quot;string\&amp;quot;]&amp;quot;;                             # Property&amp;#039;s data type.&lt;br /&gt;
my $access=&amp;quot;readwrite&amp;quot;;                              # The access flag.&lt;br /&gt;
my %annotations=();                                  # Optional. If not used, don&amp;#039;t bother including it.&lt;br /&gt;
dbus_property($name, $type, $access, [\%annotations]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
OR&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
my $name=&amp;quot;SomeProperty&amp;quot;;&lt;br /&gt;
my $type=&amp;quot;[\&amp;quot;string\&amp;quot;]&amp;quot;;                             # Property&amp;#039;s data type.&lt;br /&gt;
my $access=&amp;quot;readwrite&amp;quot;;                              # The access flag.&lt;br /&gt;
my $interface=&amp;quot;org.example.foo&amp;quot;;&lt;br /&gt;
my %annotations=(deprecated=&amp;gt;1);                     # Tell the caller that this property is going away soon.&lt;br /&gt;
dbus_property($name, $type, $access, $interface, \%annotations);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This exports a property called &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$name&amp;lt;/span&amp;gt;&amp;#039; whose value has the type signature &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$type&amp;lt;/span&amp;gt;&amp;#039; and has the specified &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$access&amp;lt;/span&amp;gt;&amp;#039; flag. &lt;br /&gt;
&lt;br /&gt;
In the first example, no &amp;#039;&amp;lt;span class=&amp;quot;code&amp;quot;&amp;gt;$interface&amp;lt;/span&amp;gt;&amp;#039; is specified, so the default one is used. In the second case, an explicit interface is defined so this property will be exported using that interface.&lt;br /&gt;
&lt;br /&gt;
If not specified, the default &amp;#039;type&amp;#039; is &amp;quot;string&amp;quot; and the default &amp;#039;access&amp;#039; is &amp;quot;readwrite&amp;quot;. Do not leave out &amp;#039;type&amp;#039; is you are specifying &amp;#039;access&amp;#039;. Don&amp;#039;t leave out either if you are specifying an interface.&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
== Simple Method, no parameters or returned data ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
# A method that, when called, simply prints &amp;quot;Hello, World!&amp;quot;.&lt;br /&gt;
sub Hello&lt;br /&gt;
{&lt;br /&gt;
	my $self=shift;&lt;br /&gt;
	print &amp;quot;Hello, World!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Export the method &amp;#039;Hello&amp;#039;, which takes no data and returns no data.&lt;br /&gt;
dbus_export(&amp;quot;Hello&amp;quot;, [], []);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Simple Method, parameter is a single string, return is a boolean ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
# A method that takes a process names, calls &amp;#039;killall&amp;#039; and returns a boolean&lt;br /&gt;
# value indicating success or failure.&lt;br /&gt;
sub KillAll&lt;br /&gt;
{&lt;br /&gt;
	my $self=shift;&lt;br /&gt;
	my $process_name=shift;&lt;br /&gt;
	my $error=system(&amp;quot;killall $process_name&amp;quot;);&lt;br /&gt;
	if ( $error == 0 ) { return(1); } else { return(0); }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Export the method &amp;#039;KillAll&amp;#039;, which takes a &amp;#039;string&amp;#039; and returns a &amp;#039;boolean&amp;#039;.&lt;br /&gt;
dbus_export(&amp;quot;KillAll&amp;quot;, [&amp;quot;string&amp;quot;], [&amp;quot;bool&amp;quot;]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Complex Method, parameter is an array of strings, return is a dictionary ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
# A method that takes an array of file names, stats them to get their last&lt;br /&gt;
# modified time (in UNIX time), and returns a hash with the file name as the&lt;br /&gt;
# key and the modified time as a 32-bit unsigned integer.&lt;br /&gt;
sub LastModified&lt;br /&gt;
{&lt;br /&gt;
	my $self=shift;&lt;br /&gt;
	my $files=shift;&lt;br /&gt;
	&lt;br /&gt;
	my %mtime=();&lt;br /&gt;
	foreach my $file (@{$files})&lt;br /&gt;
	{&lt;br /&gt;
		$mtime{$file}=(stat $file)[9];&lt;br /&gt;
	}&lt;br /&gt;
	return \%mtime;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Export the method &amp;#039;LastModified&amp;#039;, which takes an &amp;#039;array&amp;#039; and returns a&lt;br /&gt;
# &amp;#039;dict&amp;#039;.&lt;br /&gt;
dbus_export(&amp;quot;LastModified&amp;quot;, [&amp;quot;array&amp;quot;, &amp;quot;string&amp;quot;], [&amp;quot;dict&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;int32&amp;quot;]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Deprecated Method whose parameter is a single string, returning nothing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
# This method has been slated for removal. It takes a file name and plays it.&lt;br /&gt;
# It does not return anything to the caller.&lt;br /&gt;
sub PlayMP3&lt;br /&gt;
{&lt;br /&gt;
	my $self=shift;&lt;br /&gt;
	my $track=shift;&lt;br /&gt;
	&lt;br /&gt;
	# Call the &amp;#039;mpg123&amp;#039; program, telling it to play the song in the $file.&lt;br /&gt;
	system &amp;quot;mpg123 $track &amp;amp;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Export this method, but use the annotations to tell the caller that this&lt;br /&gt;
# method is deprecated and also to not bother waiting for a reply.&lt;br /&gt;
dbus_export(&amp;quot;PlayMP3&amp;quot;, [&amp;quot;&amp;quot;string&amp;quot;], [], {deprecated =&amp;gt; 1, no_reply =&amp;gt; 1});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{footer}}&lt;/div&gt;</summary>
		<author><name>Digimer</name></author>
	</entry>
</feed>