]>
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> | |
31 | <funcdef>int sd_bus_message_new_method_call</funcdef> | |
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> | |
41 | <funcdef>int sd_bus_message_new_method_return</funcdef> | |
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 ZJS |
72 | |
73 | <para>The <function>sd_bus_message_new_method_call()</function> function creates a new bus | |
74 | message object that is a reply to the method call <parameter>call</parameter> and returns it in | |
75 | the <parameter>m</parameter> output parameter. The <parameter>call</parameter> parameter must be | |
76 | a method call message. The sender of <parameter>call</parameter> is used as the destination. | |
77 | </para> | |
cfe8ee46 ZJS |
78 | </refsect1> |
79 | ||
80 | <refsect1> | |
81 | <title>Return Value</title> | |
82 | ||
83 | <para>This function returns 0 if the message object was successfully created, and a negative | |
84 | errno-style error code otherwise.</para> | |
cfe8ee46 | 85 | |
b1de39de ZJS |
86 | <refsect2 id='errors'> |
87 | <title>Errors</title> | |
cfe8ee46 | 88 | |
b1de39de | 89 | <para>Returned errors may indicate the following problems:</para> |
cfe8ee46 | 90 | |
b1de39de ZJS |
91 | <variablelist> |
92 | <varlistentry> | |
93 | <term><constant>-EINVAL</constant></term> | |
cfe8ee46 | 94 | |
b1de39de ZJS |
95 | <listitem><para>The output parameter <parameter>m</parameter> is |
96 | <constant>NULL</constant>.</para> | |
cfe8ee46 | 97 | |
b1de39de ZJS |
98 | <para>The <parameter>destination</parameter> parameter is non-null and is not a valid D-Bus |
99 | service name (<literal>org.somewhere.Something</literal>), the <parameter>path</parameter> | |
100 | parameter is not a valid D-Bus path (<literal>/an/object/path</literal>), the | |
101 | <parameter>interface</parameter> parameter is non-null and is not a valid D-Bus interface | |
102 | name (<literal>an.interface.name</literal>), or the <parameter>member</parameter> parameter | |
103 | is not a valid D-Bus member (<literal>Name</literal>).</para> | |
7ddee217 | 104 | |
b1de39de ZJS |
105 | <para>The <parameter>call</parameter> parameter is not a method call object.</para> |
106 | </listitem> | |
107 | </varlistentry> | |
cfe8ee46 | 108 | |
b1de39de ZJS |
109 | <varlistentry> |
110 | <term><constant>-ENOTCONN</constant></term> | |
cfe8ee46 | 111 | |
b1de39de ZJS |
112 | <listitem><para>The bus parameter <parameter>bus</parameter> is <constant>NULL</constant> or |
113 | the bus is not connected.</para></listitem> | |
114 | </varlistentry> | |
cfe8ee46 | 115 | |
b1de39de ZJS |
116 | <varlistentry> |
117 | <term><constant>-ENOMEM</constant></term> | |
cfe8ee46 | 118 | |
b1de39de ZJS |
119 | <listitem><para>Memory allocation failed.</para></listitem> |
120 | </varlistentry> | |
7ddee217 | 121 | |
b1de39de ZJS |
122 | <varlistentry> |
123 | <term><constant>-EPERM</constant></term> | |
7ddee217 | 124 | |
b1de39de ZJS |
125 | <listitem> |
126 | <para>The <parameter>call</parameter> parameter is not sealed.</para> | |
127 | </listitem> | |
128 | </varlistentry> | |
7ddee217 | 129 | |
b1de39de ZJS |
130 | <varlistentry> |
131 | <term><constant>-EOPNOTSUPP</constant></term> | |
7ddee217 | 132 | |
b1de39de ZJS |
133 | <listitem> |
134 | <para>The <parameter>call</parameter> message does not have a cookie.</para> | |
135 | </listitem> | |
136 | </varlistentry> | |
137 | </variablelist> | |
138 | </refsect2> | |
cfe8ee46 ZJS |
139 | </refsect1> |
140 | ||
141 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
142 | ||
143 | <refsect1> | |
144 | <title>Examples</title> | |
145 | ||
146 | <example> | |
147 | <title>Make a call to a D-Bus method that takes a single parameter</title> | |
148 | ||
149 | <programlisting><xi:include href="print-unit-path.c" parse="text" /></programlisting> | |
150 | <para>This defines a minimally useful program that will open a connection to the bus, create a | |
151 | message object, send it, wait for the reply, and finally extract and print the answer. It does | |
152 | error handling and proper memory management.</para> | |
153 | </example> | |
154 | </refsect1> | |
155 | ||
156 | <refsect1> | |
157 | <title>See Also</title> | |
158 | ||
159 | <para> | |
160 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
161 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
162 | <citerefentry><refentrytitle>sd_bus_path_encode</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
163 | </para> | |
164 | </refsect1> | |
165 | ||
166 | </refentry> |