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-or-later -->
6 <refentry id=
"sd_bus_add_object_manager"
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>sd_bus_add_object_manager
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>sd_bus_add_object_manager
</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_add_object_manager
</refname>
22 <refpurpose>Add a D-Bus object manager for a D-Bus object sub-tree
</refpurpose>
27 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
30 <funcdef>int
<function>sd_bus_add_object_manager
</function></funcdef>
31 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
32 <paramdef>sd_bus_slot **
<parameter>slot
</parameter></paramdef>
33 <paramdef>const char *
<parameter>path
</parameter></paramdef>
39 <title>Description
</title>
41 <para><function>sd_bus_add_object_manager()
</function> installs a handler for the given path
42 that implements the
<function>GetManagedObjects()
</function> method of the
43 <constant>org.freedesktop.DBus.ObjectManager
</constant> interface. See
44 <ulink url=
"https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager">
45 org.freedesktop.DBus.ObjectManager
</ulink> for more information.
</para>
47 <para>To implement the
<function>InterfacesAdded
</function> and
48 <function>InterfacesRemoved
</function> signals of the
49 <constant>org.freedesktop.DBus.ObjectManager
</constant> interface, call
50 <citerefentry><refentrytitle>sd_bus_emit_interfaces_added
</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
51 <citerefentry><refentrytitle>sd_bus_emit_interfaces_removed
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
52 whenever interfaces are added or removed from the sub-tree, respectively.
</para>
54 <para>When
<function>sd_bus_add_object_manager()
</function> succeeds, a slot is created
55 internally. If the output parameter
<replaceable>slot
</replaceable> is
<constant>NULL
</constant>,
56 a
"floating" slot object is created, see
57 <citerefentry><refentrytitle>sd_bus_slot_set_floating
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
58 Otherwise, a pointer to the slot object is returned. In that case, the reference to the slot
59 object should be dropped when the object manager is not needed anymore, see
60 <citerefentry><refentrytitle>sd_bus_slot_unref
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
65 <title>Return Value
</title>
67 <para>On success,
<function>sd_bus_add_object_manager()
</function> returns a non-negative
68 integer. On failure, it returns a negative errno-style error code.
</para>
73 <para>Returned errors may indicate the following problems:
</para>
77 <term><constant>-EINVAL
</constant></term>
79 <listitem><para>One of the required parameters is
<constant>NULL
</constant> or
80 <parameter>path
</parameter> is not a valid object path.
83 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
87 <term><constant>-ENOPKG
</constant></term>
89 <listitem><para>The bus cannot be resolved.
</para>
91 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
95 <term><constant>-ECHILD
</constant></term>
97 <listitem><para>The bus was created in a different process, library or module instance.
</para>
99 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
103 <term><constant>-ENOMEM
</constant></term>
105 <listitem><para>Memory allocation failed.
</para>
107 <xi:include href=
"version-info.xml" xpointer=
"v246"/></listitem>
113 <xi:include href=
"libsystemd-pkgconfig.xml" />
116 <title>History
</title>
117 <para><function>sd_bus_add_object_manager()
</function> was added in version
246.
</para>
121 <title>See Also
</title>
124 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
125 <citerefentry><refentrytitle>busctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
126 <citerefentry><refentrytitle>sd_bus_add_object_vtable
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
127 <citerefentry><refentrytitle>sd_bus_emit_interfaces_added
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
128 <citerefentry><refentrytitle>sd_bus_slot_unref
</refentrytitle><manvolnum>3</manvolnum></citerefentry>