]>
Commit | Line | Data |
---|---|---|
cfe8ee46 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
cfe8ee46 ZJS |
4 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
5 | ||
6 | <refentry id="sd_bus_message_new_method_call" | |
7 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
8 | ||
9 | <refentryinfo> | |
10 | <title>sd_bus_message_new_method_call</title> | |
11 | <productname>systemd</productname> | |
12 | </refentryinfo> | |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>sd_bus_message_new_method_call</refentrytitle> | |
16 | <manvolnum>3</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
20 | <refname>sd_bus_message_new_method_call</refname> | |
7ddee217 | 21 | <refname>sd_bus_message_new_method_return</refname> |
cfe8ee46 ZJS |
22 | |
23 | <refpurpose>Create a method call message</refpurpose> | |
24 | </refnamediv> | |
25 | ||
26 | <refsynopsisdiv> | |
27 | <funcsynopsis> | |
28 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
29 | ||
30 | <funcprototype> | |
9735c644 | 31 | <funcdef>int <function>sd_bus_message_new_method_call</function></funcdef> |
cfe8ee46 ZJS |
32 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
33 | <paramdef>sd_bus_message **<parameter>m</parameter></paramdef> | |
34 | <paramdef>const char *<parameter>destination</parameter></paramdef> | |
35 | <paramdef>const char *<parameter>path</parameter></paramdef> | |
36 | <paramdef>const char *<parameter>interface</parameter></paramdef> | |
37 | <paramdef>const char *<parameter>member</parameter></paramdef> | |
38 | </funcprototype> | |
7ddee217 ZJS |
39 | |
40 | <funcprototype> | |
9735c644 | 41 | <funcdef>int <function>sd_bus_message_new_method_return</function></funcdef> |
7ddee217 ZJS |
42 | <paramdef>sd_bus_message *<parameter>call</parameter></paramdef> |
43 | <paramdef>sd_bus_message **<parameter>m</parameter></paramdef> | |
44 | </funcprototype> | |
cfe8ee46 ZJS |
45 | </funcsynopsis> |
46 | </refsynopsisdiv> | |
47 | ||
48 | <refsect1> | |
49 | <title>Description</title> | |
50 | ||
51 | <para>The <function>sd_bus_message_new_method_call()</function> function creates a new bus | |
52 | message object that encapsulates a D-Bus method call, and returns it in the | |
53 | <parameter>m</parameter> output parameter. The call will be made on the destination | |
54 | <parameter>destination</parameter>, path <parameter>path</parameter>, on the interface | |
55 | <parameter>interface</parameter>, member <parameter>member</parameter>.</para> | |
56 | ||
57 | <para>Briefly, the <emphasis>destination</emphasis> is a dot-separated name that identifies a | |
58 | service connected to the bus. The <emphasis>path</emphasis> is a slash-separated identifier of | |
59 | an object within the destination that resembles a file system path. The meaning of this path is | |
60 | defined by the destination. The <emphasis>interface</emphasis> is a dot-separated name that | |
61 | resembles a Java interface name that identifies a group of methods and signals supported by the | |
62 | object identified by path. Methods and signals are collectively called | |
63 | <emphasis>members</emphasis> and are identified by a simple name composed of ASCII letters, | |
64 | numbers, and underscores. See the <ulink | |
65 | url="https://dbus.freedesktop.org/doc/dbus-tutorial.html#concepts">D-Bus Tutorial</ulink> for an | |
66 | in-depth explanation.</para> | |
67 | ||
68 | <para>The <parameter>destination</parameter> parameter may be <constant>NULL</constant>. The | |
69 | <parameter>interface</parameter> parameter may be <constant>NULL</constant>, if the destination | |
70 | has only a single member with the given name and there is no ambiguity if the interface name is | |
71 | omitted.</para> | |
7ddee217 | 72 | |
9735c644 DDM |
73 | <para>Note that this is a low level interface. See |
74 | <citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
75 | for a more convenient way of calling D-Bus methods.</para> | |
76 | ||
77 | <para>The <function>sd_bus_message_new_method_return()</function> function creates a new bus | |
7ddee217 ZJS |
78 | message object that is a reply to the method call <parameter>call</parameter> and returns it in |
79 | the <parameter>m</parameter> output parameter. The <parameter>call</parameter> parameter must be | |
80 | a method call message. The sender of <parameter>call</parameter> is used as the destination. | |
81 | </para> | |
cfe8ee46 ZJS |
82 | </refsect1> |
83 | ||
84 | <refsect1> | |
85 | <title>Return Value</title> | |
86 | ||
953ee402 | 87 | <para>On success, these functions return a non-negative integer. On failure, they return a |
9735c644 | 88 | negative errno-style error code.</para> |
cfe8ee46 | 89 | |
b1de39de ZJS |
90 | <refsect2 id='errors'> |
91 | <title>Errors</title> | |
cfe8ee46 | 92 | |
b1de39de | 93 | <para>Returned errors may indicate the following problems:</para> |
cfe8ee46 | 94 | |
b1de39de ZJS |
95 | <variablelist> |
96 | <varlistentry> | |
97 | <term><constant>-EINVAL</constant></term> | |
cfe8ee46 | 98 | |
b1de39de ZJS |
99 | <listitem><para>The output parameter <parameter>m</parameter> is |
100 | <constant>NULL</constant>.</para> | |
cfe8ee46 | 101 | |
b1de39de ZJS |
102 | <para>The <parameter>destination</parameter> parameter is non-null and is not a valid D-Bus |
103 | service name (<literal>org.somewhere.Something</literal>), the <parameter>path</parameter> | |
104 | parameter is not a valid D-Bus path (<literal>/an/object/path</literal>), the | |
105 | <parameter>interface</parameter> parameter is non-null and is not a valid D-Bus interface | |
106 | name (<literal>an.interface.name</literal>), or the <parameter>member</parameter> parameter | |
107 | is not a valid D-Bus member (<literal>Name</literal>).</para> | |
7ddee217 | 108 | |
b1de39de ZJS |
109 | <para>The <parameter>call</parameter> parameter is not a method call object.</para> |
110 | </listitem> | |
111 | </varlistentry> | |
cfe8ee46 | 112 | |
b1de39de ZJS |
113 | <varlistentry> |
114 | <term><constant>-ENOTCONN</constant></term> | |
cfe8ee46 | 115 | |
b1de39de ZJS |
116 | <listitem><para>The bus parameter <parameter>bus</parameter> is <constant>NULL</constant> or |
117 | the bus is not connected.</para></listitem> | |
118 | </varlistentry> | |
cfe8ee46 | 119 | |
b1de39de ZJS |
120 | <varlistentry> |
121 | <term><constant>-ENOMEM</constant></term> | |
cfe8ee46 | 122 | |
b1de39de ZJS |
123 | <listitem><para>Memory allocation failed.</para></listitem> |
124 | </varlistentry> | |
7ddee217 | 125 | |
b1de39de ZJS |
126 | <varlistentry> |
127 | <term><constant>-EPERM</constant></term> | |
7ddee217 | 128 | |
b1de39de ZJS |
129 | <listitem> |
130 | <para>The <parameter>call</parameter> parameter is not sealed.</para> | |
131 | </listitem> | |
132 | </varlistentry> | |
7ddee217 | 133 | |
b1de39de ZJS |
134 | <varlistentry> |
135 | <term><constant>-EOPNOTSUPP</constant></term> | |
7ddee217 | 136 | |
b1de39de ZJS |
137 | <listitem> |
138 | <para>The <parameter>call</parameter> message does not have a cookie.</para> | |
139 | </listitem> | |
140 | </varlistentry> | |
141 | </variablelist> | |
142 | </refsect2> | |
cfe8ee46 ZJS |
143 | </refsect1> |
144 | ||
145 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
146 | ||
147 | <refsect1> | |
148 | <title>Examples</title> | |
149 | ||
150 | <example> | |
151 | <title>Make a call to a D-Bus method that takes a single parameter</title> | |
152 | ||
153 | <programlisting><xi:include href="print-unit-path.c" parse="text" /></programlisting> | |
154 | <para>This defines a minimally useful program that will open a connection to the bus, create a | |
155 | message object, send it, wait for the reply, and finally extract and print the answer. It does | |
156 | error handling and proper memory management.</para> | |
157 | </example> | |
158 | </refsect1> | |
159 | ||
160 | <refsect1> | |
161 | <title>See Also</title> | |
162 | ||
163 | <para> | |
164 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
165 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
953ee402 DDM |
166 | <citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
167 | <citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
cfe8ee46 ZJS |
168 | <citerefentry><refentrytitle>sd_bus_path_encode</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
169 | </para> | |
170 | </refsect1> | |
171 | ||
172 | </refentry> |