1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6 <refentry id=
"sd_bus_add_object"
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>sd_bus_add_object
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>sd_bus_add_object
</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_add_object
</refname>
21 <refname>sd_bus_add_fallback
</refname>
22 <refname>sd_bus_add_object_vtable
</refname>
23 <refname>sd_bus_add_fallback_vtable
</refname>
24 <refname>sd_bus_add_filter
</refname>
25 <refname>SD_BUS_VTABLE_START
</refname>
26 <refname>SD_BUS_VTABLE_END
</refname>
27 <refname>SD_BUS_METHOD_WITH_NAMES_OFFSET
</refname>
28 <refname>SD_BUS_METHOD_WITH_NAMES
</refname>
29 <refname>SD_BUS_METHOD_WITH_OFFSET
</refname>
30 <refname>SD_BUS_METHOD
</refname>
31 <refname>SD_BUS_SIGNAL_WITH_NAMES
</refname>
32 <refname>SD_BUS_SIGNAL
</refname>
33 <refname>SD_BUS_WRITABLE_PROPERTY
</refname>
34 <refname>SD_BUS_PROPERTY
</refname>
35 <refname>SD_BUS_PARAM
</refname>
37 <refpurpose>Declare properties and methods for a D-Bus path
</refpurpose>
42 <funcsynopsisinfo>#include
<systemd/sd-bus-vtable.h
></funcsynopsisinfo>
44 <xi:include href=
"sd_bus_add_match.xml" xpointer=
"sd_bus_message_handler_t"/>
47 <funcdef>typedef int (*
<function>sd_bus_property_get_t
</function>)
</funcdef>
48 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
49 <paramdef>const char *
<parameter>path
</parameter></paramdef>
50 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
51 <paramdef>const char *
<parameter>property
</parameter></paramdef>
52 <paramdef>sd_bus_message *
<parameter>reply
</parameter></paramdef>
53 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
54 <paramdef>sd_bus_error *
<parameter>ret_error
</parameter></paramdef>
58 <funcdef>typedef int (*
<function>sd_bus_property_set_t
</function>)
</funcdef>
59 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
60 <paramdef>const char *
<parameter>path
</parameter></paramdef>
61 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
62 <paramdef>const char *
<parameter>property
</parameter></paramdef>
63 <paramdef>sd_bus_message *
<parameter>value
</parameter></paramdef>
64 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
65 <paramdef>sd_bus_error *
<parameter>ret_error
</parameter></paramdef>
69 <funcdef>typedef int (*
<function>sd_bus_object_find_t
</function>)
</funcdef>
70 <paramdef>const char *
<parameter>path
</parameter></paramdef>
71 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
72 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
73 <paramdef>void **
<parameter>ret_found
</parameter></paramdef>
74 <paramdef>sd_bus_error *
<parameter>ret_error
</parameter></paramdef>
78 <funcdef>int
<function>sd_bus_add_object
</function></funcdef>
79 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
80 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
81 <paramdef>const char *
<parameter>path
</parameter></paramdef>
82 <paramdef>sd_bus_message_handler_t
<parameter>callback
</parameter></paramdef>
83 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
87 <funcdef>int
<function>sd_bus_add_fallback
</function></funcdef>
88 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
89 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
90 <paramdef>const char *
<parameter>path
</parameter></paramdef>
91 <paramdef>sd_bus_message_handler_t
<parameter>callback
</parameter></paramdef>
92 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
96 <funcdef>int
<function>sd_bus_add_object_vtable
</function></funcdef>
97 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
98 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
99 <paramdef>const char *
<parameter>path
</parameter></paramdef>
100 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
101 <paramdef>const sd_bus_vtable *
<parameter>vtable
</parameter></paramdef>
102 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
106 <funcdef>int
<function>sd_bus_add_fallback_vtable
</function></funcdef>
107 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
108 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
109 <paramdef>const char *
<parameter>prefix
</parameter></paramdef>
110 <paramdef>const char *
<parameter>interface
</parameter></paramdef>
111 <paramdef>const sd_bus_vtable *
<parameter>vtable
</parameter></paramdef>
112 <paramdef>sd_bus_object_find_t
<parameter>find
</parameter></paramdef>
113 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
117 <funcdef>int
<function>sd_bus_add_filter
</function></funcdef>
118 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
119 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
120 <paramdef>sd_bus_message_handler_t
<parameter>callback
</parameter></paramdef>
121 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
125 <constant>SD_BUS_VTABLE_START(
<replaceable>flags
</replaceable>)
</constant>
128 <constant>SD_BUS_VTABLE_END
</constant>
131 <constant>SD_BUS_METHOD_WITH_ARGS_OFFSET(
132 <replaceable>member
</replaceable>,
133 <replaceable>args
</replaceable>,
134 <replaceable>result
</replaceable>,
135 <replaceable>handler
</replaceable>,
136 <replaceable>offset
</replaceable>,
137 <replaceable>flags
</replaceable>)
141 <constant>SD_BUS_METHOD_WITH_ARGS(
142 <replaceable>member
</replaceable>,
143 <replaceable>args
</replaceable>,
144 <replaceable>result
</replaceable>,
145 <replaceable>handler
</replaceable>,
146 <replaceable>flags
</replaceable>)
150 <constant>SD_BUS_METHOD_WITH_NAMES_OFFSET(
151 <replaceable>member
</replaceable>,
152 <replaceable>signature
</replaceable>,
153 <replaceable>in_names
</replaceable>,
154 <replaceable>result
</replaceable>,
155 <replaceable>out_names
</replaceable>,
156 <replaceable>handler
</replaceable>,
157 <replaceable>offset
</replaceable>,
158 <replaceable>flags
</replaceable>)
162 <constant>SD_BUS_METHOD_WITH_NAMES(
163 <replaceable>member
</replaceable>,
164 <replaceable>signature
</replaceable>,
165 <replaceable>in_names
</replaceable>,
166 <replaceable>result
</replaceable>,
167 <replaceable>out_names
</replaceable>,
168 <replaceable>handler
</replaceable>,
169 <replaceable>flags
</replaceable>)
173 <constant>SD_BUS_METHOD_WITH_OFFSET(
174 <replaceable>member
</replaceable>,
175 <replaceable>signature
</replaceable>,
176 <replaceable>result
</replaceable>,
177 <replaceable>handler
</replaceable>,
178 <replaceable>offset
</replaceable>,
179 <replaceable>flags
</replaceable>)
183 <constant>SD_BUS_METHOD(
184 <replaceable>member
</replaceable>,
185 <replaceable>signature
</replaceable>,
186 <replaceable>result
</replaceable>,
187 <replaceable>handler
</replaceable>,
188 <replaceable>flags
</replaceable>)
192 <constant>SD_BUS_SIGNAL_WITH_ARGS(
193 <replaceable>member
</replaceable>,
194 <replaceable>args
</replaceable>,
195 <replaceable>flags
</replaceable>)
199 <constant>SD_BUS_SIGNAL_WITH_NAMES(
200 <replaceable>member
</replaceable>,
201 <replaceable>signature
</replaceable>,
202 <replaceable>names
</replaceable>,
203 <replaceable>flags
</replaceable>)
207 <constant>SD_BUS_SIGNAL(
208 <replaceable>member
</replaceable>,
209 <replaceable>signature
</replaceable>,
210 <replaceable>flags
</replaceable>)
214 <constant>SD_BUS_WRITABLE_PROPERTY(
215 <replaceable>member
</replaceable>,
216 <replaceable>signature
</replaceable>,
217 <replaceable>get
</replaceable>,
218 <replaceable>set
</replaceable>,
219 <replaceable>offset
</replaceable>,
220 <replaceable>flags
</replaceable>)
224 <constant>SD_BUS_PROPERTY(
225 <replaceable>member
</replaceable>,
226 <replaceable>signature
</replaceable>,
227 <replaceable>get
</replaceable>,
228 <replaceable>offset
</replaceable>,
229 <replaceable>flags
</replaceable>)
233 <constant>SD_BUS_PARAM(
<replaceable>name
</replaceable>)
</constant>
234 <constant>SD_BUS_ARGS(
<replaceable>...
</replaceable>)
</constant>
235 <constant>SD_BUS_RESULT(
<replaceable>...
</replaceable>)
</constant>
236 <constant>SD_BUS_NO_ARGS
</constant>
237 <constant>SD_BUS_NO_RESULT
</constant>
243 <title>Description
</title>
245 <para><function>sd_bus_add_object_vtable()
</function> is used to declare attributes for the
246 object path
<parameter>path
</parameter> connected to the bus connection
247 <parameter>bus
</parameter> under the interface
<parameter>interface
</parameter>. The table
248 <parameter>vtable
</parameter> may contain property declarations using
249 <constant>SD_BUS_PROPERTY()
</constant> or
<constant>SD_BUS_WRITABLE_PROPERTY()
</constant>,
250 method declarations using
<constant>SD_BUS_METHOD()
</constant>,
251 <constant>SD_BUS_METHOD_WITH_NAMES()
</constant>,
252 <constant>SD_BUS_METHOD_WITH_OFFSET()
</constant>, or
253 <constant>SD_BUS_METHOD_WITH_NAMES_OFFSET()
</constant>, and signal declarations using
254 <constant>SD_BUS_SIGNAL_WITH_NAMES()
</constant> or
<constant>SD_BUS_SIGNAL()
</constant>, see
255 below. The
<replaceable>userdata
</replaceable> parameter contains a pointer that will be passed
256 to various callback functions. It may be specified as
<constant>NULL
</constant> if no value is
257 necessary. An interface can have any number of vtables attached to it.
</para>
259 <para><function>sd_bus_add_fallback_vtable()
</function> is similar to
260 <function>sd_bus_add_object_vtable()
</function>, but is used to register
"fallback" attributes.
261 When looking for an attribute declaration, bus object paths registered with
262 <function>sd_bus_add_object_vtable()
</function> are checked first. If no match is found, the
263 fallback vtables are checked for each prefix of the bus object path, i.e. with the last
264 slash-separated components successively removed. This allows the vtable to be used for an
265 arbitrary number of dynamically created objects.
</para>
267 <para>Parameter
<replaceable>find
</replaceable> is a function which is used to locate the target
268 object based on the bus object path
<replaceable>path
</replaceable>. It must return
269 <constant>1</constant> and set the
<parameter>ret_found
</parameter> output parameter if the
270 object is found, return
<constant>0</constant> if the object was not found, and return a
271 negative errno-style error code or initialize the error structure
272 <replaceable>ret_error
</replaceable> on error. The pointer passed in
273 <parameter>ret_found
</parameter> will be used as the
<parameter>userdata
</parameter> parameter
274 for the callback functions (offset by the
<parameter>offset
</parameter> offsets as specified in
275 the vtable entries).
</para>
277 <para><function>sd_bus_add_object()
</function> attaches a callback directly to the object path
278 <parameter>path
</parameter>. An object path can have any number of callbacks attached to it.
279 Each callback is prepended to the list of callbacks which are always called in order.
280 <function>sd_bus_add_fallback()
</function> is similar to
281 <function>sd_bus_add_object()
</function> but applies to fallback paths instead.
</para>
283 <para><function>sd_bus_add_filter()
</function> installs a callback that is invoked for each
284 incoming D-Bus message. Filters can be used to handle logic common to all messages received by
285 a service (e.g. authentication or authorization).
</para>
287 <para>When a request is received, any associated callbacks are called sequentially until a
288 callback returns a non-zero integer. Return zero from a callback to give other callbacks the
289 chance to process the request. Callbacks are called in the following order: first, global
290 callbacks installed with
<function>sd_bus_add_filter()
</function> are called. Second, callbacks
291 attached directly to the request object path are called, followed by any D-Bus method callbacks
292 attached to the request object path, interface and member. Finally, the property callbacks
293 attached to the request object path, interface and member are called. If the final callback
294 returns zero, an error reply is sent back to the caller indicating no matching object for the
295 request was found. Note that you can return a positive integer from a callback without
296 immediately sending a reply. This informs sd-bus this callback will take responsibility for
297 replying to the request without forcing the callback to produce a reply immediately. This allows
298 a callback to perform any number of asynchronous operations required to construct a reply. Note
299 that if producing a reply takes too long, the method call will time out at the caller.
</para>
301 <para>If a callback was invoked to handle a request that expects a reply and the callback
302 returns a negative value, the value is interpreted as a negative errno-style error code and sent
303 back to the caller as a D-Bus error as if
304 <citerefentry><refentrytitle>sd_bus_reply_method_errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
305 was called. Additionally, all callbacks take a
<structname>sd_bus_error
</structname> output
306 parameter that can be used to provide more detailed error information. If
307 <parameter>ret_error
</parameter> is set when the callback finishes, the corresponding D-Bus
308 error is sent back to the caller as if
309 <citerefentry><refentrytitle>sd_bus_reply_method_error
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
310 was called. Any error stored in
<parameter>ret_error
</parameter> takes priority over any
311 negative values returned by the same callback when determining which error to send back to
313 <citerefentry><refentrytitle>sd_bus_error_set
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
314 or one of its variants to set
<parameter>ret_error
</parameter> and return a negative integer
315 from a callback with a single function call. To send an error reply after a callback has already
317 <citerefentry><refentrytitle>sd_bus_reply_method_errno
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
318 or one of its variants.
</para>
320 <para>For all functions, a match slot is created internally. If the output parameter
321 <replaceable>slot
</replaceable> is
<constant>NULL
</constant>, a
"floating" slot object is
323 <citerefentry><refentrytitle>sd_bus_slot_set_floating
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
324 Otherwise, a pointer to the slot object is returned. In that case, the reference to the slot
325 object should be dropped when the vtable is not needed anymore, see
326 <citerefentry><refentrytitle>sd_bus_slot_unref
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
330 <title>The
<structname>sd_bus_vtable
</structname> array
</title>
332 <para>The array consists of the structures of type
<structname>sd_bus_vtable
</structname>, but it
333 should never be filled in manually, but through one of the following macros:
</para>
337 <term><constant>SD_BUS_VTABLE_START()
</constant></term>
338 <term><constant>SD_BUS_VTABLE_END
</constant></term>
340 <listitem><para>Those must always be the first and last element.
</para></listitem>
344 <term><constant>SD_BUS_METHOD_WITH_ARGS_OFFSET()
</constant></term>
345 <term><constant>SD_BUS_METHOD_WITH_ARGS()
</constant></term>
347 <listitem><para>Declare a D-Bus method with the name
<replaceable>member
</replaceable>,
348 arguments
<replaceable>args
</replaceable> and result
<replaceable>result
</replaceable>.
349 <replaceable>args
</replaceable> expects a sequence of argument type/name pairs wrapped in the
350 <constant>SD_BUS_ARGS()
</constant> macro. The elements at even indices in this list describe the
351 types of the method's arguments. The method's parameter signature is the concatenation of all the
352 string literals at even indices in
<replaceable>args
</replaceable>. If a method has no parameters,
353 pass
<constant>SD_BUS_NO_ARGS
</constant> to
<replaceable>args
</replaceable>. The elements at uneven
354 indices describe the names of the method's arguments.
<replaceable>result
</replaceable> expects a
355 sequence of type/name pairs wrapped in the
<constant>SD_BUS_RESULT()
</constant> macro in the same
356 format as
<constant>SD_BUS_ARGS()
</constant>. The method's result signature is the concatenation of
357 all the string literals at even indices in
<replaceable>result
</replaceable>. If a method has no
358 result, pass
<constant>SD_BUS_NO_RESULT
</constant> to
<replaceable>result
</replaceable>. Note that
359 argument types are expected to be quoted string literals and argument names are expected to be
360 unquoted string literals. See below for a complete example.
</para>
362 <para>The handler function
<replaceable>handler
</replaceable> must be of type
363 <function>sd_bus_message_handler_t
</function>. It will be called to handle the incoming messages
364 that call this method. It receives a pointer that is the
<replaceable>userdata
</replaceable>
365 parameter passed to the registration function offset by
<replaceable>offset
</replaceable> bytes.
366 This may be used to pass pointers to different fields in the same data structure to different
367 methods in the same vtable. To send a reply from
<parameter>handler
</parameter>, call
368 <citerefentry><refentrytitle>sd_bus_reply_method_return
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
369 with the message the callback was invoked with. Parameter
<replaceable>flags
</replaceable> is a
370 combination of flags, see below.
</para>
372 <constant>SD_BUS_METHOD_WITH_ARGS()
</constant> is a shorthand for calling
373 <constant>SD_BUS_METHOD_WITH_ARGS_OFFSET()
</constant> with an offset of zero.
378 <term><constant>SD_BUS_METHOD_WITH_NAMES_OFFSET()
</constant></term>
379 <term><constant>SD_BUS_METHOD_WITH_NAMES()
</constant></term>
380 <term><constant>SD_BUS_METHOD_WITH_OFFSET()
</constant></term>
381 <term><constant>SD_BUS_METHOD()
</constant></term>
383 <listitem><para>Declare a D-Bus method with the name
<replaceable>member
</replaceable>,
384 parameter signature
<replaceable>signature
</replaceable>, result signature
385 <replaceable>result
</replaceable>. Parameters
<replaceable>in_names
</replaceable> and
386 <replaceable>out_names
</replaceable> specify the argument names of the input and output
387 arguments in the function signature.
<replaceable>in_names
</replaceable> and
388 <replaceable>out_names
</replaceable> should be created using the
389 <constant>SD_BUS_PARAM()
</constant> macro, see below. In all other regards, this macro behaves
390 exactly the same as
<constant>SD_BUS_METHOD_WITH_ARGS_OFFSET()
</constant>.
</para>
392 <para><constant>SD_BUS_METHOD_WITH_NAMES()
</constant>,
393 <constant>SD_BUS_METHOD_WITH_OFFSET()
</constant>, and
<constant>SD_BUS_METHOD()
</constant>
394 are variants which specify zero offset (
<replaceable>userdata
</replaceable> parameter is
395 passed with no change), leave the names unset (i.e. no parameter names), or both.
</para>
397 <para>Prefer using
<constant>SD_BUS_METHOD_WITH_ARGS_OFFSET()
</constant> and
398 <constant>SD_BUS_METHOD_WITH_ARGS()
</constant> over these macros as they allow specifying argument
399 types and names next to each other which is less error-prone than first specifying all argument
400 types followed by specifying all argument names.
</para>
405 <term><constant>SD_BUS_SIGNAL_WITH_ARGS()
</constant></term>
407 <listitem><para>>Declare a D-Bus signal with the name
<replaceable>member
</replaceable> and
408 arguments
<replaceable>args
</replaceable>.
<replaceable>args
</replaceable> expects a sequence of
409 argument type/name pairs wrapped in the
<constant>SD_BUS_ARGS()
</constant> macro. The elements at
410 even indices in this list describe the types of the signal's arguments. The signal's parameter
411 signature is the concatenation of all the string literals at even indices in
412 <replaceable>args
</replaceable>. If a signal has no parameters, pass
413 <constant>SD_BUS_NO_ARGS
</constant> to
<replaceable>args
</replaceable>. The elements at uneven
414 indices describe the names of the signal's arguments. Parameter
<replaceable>flags
</replaceable> is
415 a combination of flags. See below for a complete example.
</para></listitem>
419 <term><constant>SD_BUS_SIGNAL_WITH_NAMES()
</constant></term>
420 <term><constant>SD_BUS_SIGNAL()
</constant></term>
422 <listitem><para>Declare a D-Bus signal with the name
<replaceable>member
</replaceable>,
423 parameter signature
<replaceable>signature
</replaceable>, and argument names
424 <replaceable>names
</replaceable>.
<replaceable>names
</replaceable> should be
425 created using the
<constant>SD_BUS_PARAM()
</constant> macro, see below.
426 Parameter
<replaceable>flags
</replaceable> is a combination of flags, see below.
429 <para><constant>SD_BUS_SIGNAL()
</constant> is equivalent to
430 <constant>SD_BUS_SIGNAL_WITH_NAMES()
</constant> with the
<replaceable>names
</replaceable> parameter
431 unset (i.e. no parameter names).
</para>
433 <para>Prefer using
<constant>SD_BUS_SIGNAL_WITH_ARGS()
</constant> over these macros as it allows
434 specifying argument types and names next to each other which is less error-prone than first
435 specifying all argument types followed by specifying all argument names.
</para>
440 <term><constant>SD_BUS_WRITABLE_PROPERTY()
</constant></term>
441 <term><constant>SD_BUS_PROPERTY()
</constant></term>
443 <listitem><para>Declare a D-Bus property with the name
<replaceable>member
</replaceable>
444 and value signature
<replaceable>signature
</replaceable>. Parameters
445 <replaceable>get
</replaceable> and
<replaceable>set
</replaceable> are the getter and
446 setter methods. They are called with a pointer that is the
447 <replaceable>userdata
</replaceable> parameter passed to the registration function offset
448 by
<replaceable>offset
</replaceable> bytes. This may be used pass pointers to different
449 fields in the same data structure to different setters and getters in the same vtable.
450 Parameter
<replaceable>flags
</replaceable> is a combination of flags, see below.
</para>
452 <para>The setter and getter methods may be omitted (specified as
453 <constant>NULL
</constant>), if the property is one of the basic types or
454 <literal>as
</literal> in case of read-only properties. In those cases, the
455 <replaceable>userdata
</replaceable> and
<replaceable>offset
</replaceable> parameters must
456 together point to a valid variable of the corresponding type. A default setter and getter
457 will be provided, which simply copy the argument between this variable and the message.
460 <para><constant>SD_BUS_PROPERTY()
</constant> is used to define a read-only property.
465 <term><constant>SD_BUS_PARAM()
</constant></term>
466 <listitem><para>Parameter names should be wrapped in this macro, see the example below.
475 <para>The
<replaceable>flags
</replaceable> parameter is used to specify a combination of
476 <ulink url=
"https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format">D-Bus annotations
</ulink>.
481 <term><constant>SD_BUS_VTABLE_DEPRECATED
</constant></term>
483 <listitem><para>Mark this vtable entry as deprecated using the
484 <constant>org.freedesktop.DBus.Deprecated
</constant> annotation in introspection data. If
485 specified for
<constant>SD_BUS_VTABLE_START()
</constant>, the annotation is applied to the
486 enclosing interface.
</para></listitem>
490 <term><constant>SD_BUS_VTABLE_HIDDEN
</constant></term>
492 <listitem><para>Make this vtable entry hidden. It will not be shown in introspection data.
493 If specified for
<constant>SD_BUS_VTABLE_START()
</constant>, all entries in the array are
494 hidden.
</para></listitem>
498 <term><constant>SD_BUS_VTABLE_UNPRIVILEGED
</constant></term>
500 <listitem><para>Mark this vtable entry as unprivileged. If not specified, the
501 <constant>org.freedesktop.systemd1.Privileged
</constant> annotation with value
502 <literal>true
</literal> will be shown in introspection data.
</para></listitem>
506 <term><constant>SD_BUS_VTABLE_METHOD_NO_REPLY
</constant></term>
508 <listitem><para>Mark his vtable entry as a method that will not return a reply using the
509 <constant>org.freedesktop.DBus.Method.NoReply
</constant> annotation in introspection data.
514 <term><constant>SD_BUS_VTABLE_PROPERTY_CONST
</constant></term>
515 <term><constant>SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
</constant></term>
516 <term><constant>SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION
</constant></term>
518 <listitem><para>Those three flags correspond to different values of the
519 <constant>org.freedesktop.DBus.Property.EmitsChangedSignal
</constant> annotation, which
520 specifies whether the
521 <constant>org.freedesktop.DBus.Properties.PropertiesChanged
</constant> signal is emitted
522 whenever the property changes.
<constant>SD_BUS_VTABLE_PROPERTY_CONST
</constant>
523 corresponds to
<constant>const
</constant> and means that the property never changes during
524 the lifetime of the object it belongs to, so no signal needs to be emitted.
525 <constant>SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
</constant> corresponds to
526 <constant>true
</constant> and means that the signal is emitted.
527 <constant>SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION
</constant> corresponds to
528 <constant>invalidates
</constant> and means that the signal is emitted, but the value is
529 not included in the signal.
</para></listitem>
533 <term><constant>SD_BUS_VTABLE_PROPERTY_EXPLICIT
</constant></term>
535 <listitem><para>Mark this vtable property entry as requiring explicit request to for the
536 value to be shown (generally because the value is large or slow to calculate). This entry
537 cannot be combined with
<constant>SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE
</constant>, and will
538 not be shown in property listings by default (e.g.
<command>busctl introspect
</command>).
539 This corresponds to the
<constant>org.freedesktop.systemd1.Explicit
</constant> annotation
540 in introspection data.
</para></listitem>
544 <term><constant>SD_BUS_VTABLE_SENSITIVE
</constant></term>
546 <listitem><para>Mark this vtable method entry as processing sensitive data. When set,
547 incoming method call messages and their outgoing reply messages are marked as sensitive using
548 <citerefentry><refentrytitle>sd_bus_message_sensitive
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
549 so that they are erased from memory when freed.
</para></listitem>
553 <term><constant>SD_BUS_VTABLE_ABSOLUTE_OFFSET
</constant></term>
555 <listitem><para>Mark this vtable method or property entry so that the user data pointer passed to
556 its associated handler functions is determined slightly differently: instead of adding the offset
557 parameter of the entry to the user data pointer specified during vtable registration, the offset is
558 passed directly, converted to a pointer, without taking the user data pointer specified during
559 vtable registration into account.
</para></listitem>
566 <title>Examples
</title>
569 <title>Create a simple listener on the bus
</title>
571 <programlisting><xi:include href=
"vtable-example.c" parse=
"text" /></programlisting>
573 <para>This creates a simple client on the bus (the user bus, when run as normal user). We may
574 use the D-Bus
<constant>org.freedesktop.DBus.Introspectable.Introspect
</constant> call to
575 acquire the XML description of the interface:
</para>
577 <programlisting><xi:include href=
"vtable-example.xml" parse=
"text" /></programlisting>
582 <title>Return Value
</title>
584 <para>On success,
<function>sd_bus_add_object_vtable()
</function> and
585 <function>sd_bus_add_fallback_vtable()
</function> return a non-negative integer. On
586 failure, they return a negative errno-style error code.
</para>
589 <title>Errors
</title>
591 <para>Returned errors may indicate the following problems:
</para>
595 <term><constant>-EINVAL
</constant></term>
597 <listitem><para>One of the required parameters is
<constant>NULL
</constant> or invalid. A
598 reserved D-Bus interface was passed as the
<replaceable>interface
</replaceable> parameter.
603 <term><constant>-ENOPKG
</constant></term>
605 <listitem><para>The bus cannot be resolved.
</para></listitem>
609 <term><constant>-ECHILD
</constant></term>
611 <listitem><para>The bus was created in a different process.
</para></listitem>
615 <term><constant>-ENOMEM
</constant></term>
617 <listitem><para>Memory allocation failed.
</para></listitem>
621 <term><constant>-EPROTOTYPE
</constant></term>
623 <listitem><para><function>sd_bus_add_object_vtable
</function> and
624 <function>sd_bus_add_fallback_vtable
</function> have been both called for the same bus
625 object path, which is not allowed.
</para></listitem>
629 <term><constant>-EEXIST
</constant></term>
631 <listitem><para>This vtable has already been registered for this
632 <replaceable>interface
</replaceable> and
<replaceable>path
</replaceable>.
639 <xi:include href=
"libsystemd-pkgconfig.xml" />
642 <title>See Also
</title>
645 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
646 <citerefentry><refentrytitle>busctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
647 <citerefentry><refentrytitle>sd_bus_emit_properties_changed
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
648 <citerefentry><refentrytitle>sd_bus_emit_object_added
</refentrytitle><manvolnum>3</manvolnum></citerefentry>