chiark / gitweb /
Fix service file to match installed elogind binary location
[elogind.git] / man / sd_bus_request_name.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of elogind.
7
8   Copyright 2013 Lennart Poettering
9
10   elogind is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   elogind is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with elogind; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_bus_request_name">
25
26   <refentryinfo>
27     <title>sd_bus_request_name</title>
28     <productname>elogind</productname>
29
30     <authorgroup>
31       <author>
32         <contrib>Developer</contrib>
33         <firstname>Lennart</firstname>
34         <surname>Poettering</surname>
35         <email>lennart@poettering.net</email>
36       </author>
37     </authorgroup>
38   </refentryinfo>
39
40   <refmeta>
41     <refentrytitle>sd_bus_request_name</refentrytitle>
42     <manvolnum>3</manvolnum>
43   </refmeta>
44
45   <refnamediv>
46     <refname>sd_bus_request_name</refname>
47     <refname>sd_bus_release_name</refname>
48     <refpurpose>Request or release a well-known service name on a bus</refpurpose>
49   </refnamediv>
50
51   <refsynopsisdiv>
52     <funcsynopsis>
53       <funcsynopsisinfo>#include &lt;elogind/sd-bus.h&gt;</funcsynopsisinfo>
54
55       <funcprototype>
56         <funcdef>int <function>sd_bus_request_name</function></funcdef>
57         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
58         <paramdef>const char *<parameter>name</parameter></paramdef>
59         <paramdef>uint64_t <parameter>flags</parameter></paramdef>
60       </funcprototype>
61
62       <funcprototype>
63         <funcdef>int <function>sd_bus_release_name</function></funcdef>
64         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
65         <paramdef>const char *<parameter>name</parameter></paramdef>
66       </funcprototype>
67     </funcsynopsis>
68   </refsynopsisdiv>
69
70   <refsect1>
71     <title>Description</title>
72
73     <para><function>sd_bus_request_name()</function> requests a
74     well-known service name on a bus. It takes a bus connection, a
75     valid bus name and a flags parameter. The flags parameter is a
76     combination of the following flags:</para>
77
78     <variablelist>
79       <varlistentry>
80         <term><varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname></term>
81
82         <listitem><para>After acquiring the name successfully, permit
83         other peers to take over the name when they try to acquire it
84         with the <varname>SD_BUS_NAME_REPLACE_EXISTING</varname> flag
85         set. If <varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname> is
86         not set on the original request, such a request by other peers
87         will be denied.</para></listitem>
88       </varlistentry>
89
90       <varlistentry>
91         <term><varname>SD_BUS_NAME_REPLACE_EXISTING</varname></term>
92
93         <listitem><para>Take over the name if it is already acquired
94         by another peer, and that other peer has permitted takeover by
95         setting <varname>SD_BUS_NAME_ALLOW_REPLACEMENT</varname> while
96         acquiring it.</para></listitem>
97       </varlistentry>
98
99       <varlistentry>
100         <term><varname>SD_BUS_NAME_QUEUE</varname></term>
101
102         <listitem><para>Queue the acquisition of the name when the
103         name is already taken.</para></listitem>
104       </varlistentry>
105     </variablelist>
106
107     <para><function>sd_bus_release_name()</function> releases an
108     acquired well-known name. It takes a bus connection and a valid
109     bus name as parameters.</para>
110   </refsect1>
111
112   <refsect1>
113     <title>Return Value</title>
114
115     <para>On success, these calls return 0 or a positive integer. On
116     failure, these calls return a negative errno-style error
117     code.</para>
118
119     <para>If <varname>SD_BUS_NAME_QUEUE</varname> is specified,
120     <function>sd_bus_request_name()</function> will return 0 when the
121     name is already taken by another peer and the client has been
122     added to the queue for the name. In that case, the caller can
123     subscribe to <literal>NameOwnerChanged</literal> signals to be
124     notified when the name is successfully acquired.
125     <function>sd_bus_request_name()</function> returns &gt; 0 when the
126     name has immediately been acquired successfully.</para>
127   </refsect1>
128
129   <refsect1>
130     <title>Errors</title>
131
132     <para>Returned errors may indicate the following problems:</para>
133
134     <variablelist>
135       <varlistentry>
136         <term><constant>-EALREADY</constant></term>
137
138         <listitem><para>The caller already is the owner of the
139         specified name.</para></listitem>
140       </varlistentry>
141
142       <varlistentry>
143         <term><constant>-EEXIST</constant></term>
144
145         <listitem><para>The name has already been acquired by a
146         different peer, and SD_BUS_NAME_REPLACE_EXISTING was not
147         specified or the other peer did not specify
148         SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the
149         name.</para></listitem>
150       </varlistentry>
151
152       <varlistentry>
153         <term><constant>-ESRCH</constant></term>
154
155         <listitem><para>It was attempted to release a name that is
156         currently not registered on the bus.</para></listitem>
157       </varlistentry>
158
159       <varlistentry>
160         <term><constant>-EADDRINUSE</constant></term>
161
162         <listitem><para>It was attempted to release a name that is
163         owned by a different peer on the bus.</para></listitem>
164       </varlistentry>
165
166       <varlistentry>
167         <term><constant>-EINVAL</constant></term>
168
169         <listitem><para>A specified parameter is invalid. This is also
170         generated when the requested name is a special service name
171         reserved by the D-Bus specification, or when the operation is
172         requested on a connection that does not refer to a
173         bus.</para></listitem>
174       </varlistentry>
175
176       <varlistentry>
177         <term><constant>-ENOTCONN</constant></term>
178
179         <listitem><para>The bus connection has been
180         disconnected.</para></listitem>
181       </varlistentry>
182
183       <varlistentry>
184         <term><constant>-ECHILD</constant></term>
185
186         <listitem><para>The bus connection has been created in a
187         different process than the current one.</para></listitem>
188       </varlistentry>
189     </variablelist>
190   </refsect1>
191
192   <refsect1>
193     <title>Notes</title>
194
195     <para>The <function>sd_bus_acquire_name()</function> and
196     <function>sd_bus_release_name()</function> interfaces are
197     available as a shared library, which can be compiled and linked to
198     with the
199     <constant>libelogind</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
200     file.</para>
201   </refsect1>
202
203   <refsect1>
204     <title>See Also</title>
205
206     <para>
207       <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
208       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
209       <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
210     </para>
211   </refsect1>
212
213 </refentry>