1 /* GDBus - GLib D-Bus Library
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: David Zeuthen <davidz@redhat.com>
25 #include "gdbusobject.h"
26 #include "gdbusinterface.h"
27 #include "gdbusutils.h"
33 * @short_description: Base type for D-Bus objects
36 * The #GDBusObject type is the base type for D-Bus objects on both
37 * the service side (see #GDBusObjectSkeleton) and the client side
38 * (see #GDBusObjectProxy). It is essentially just a container of
45 * #GDBusObject is an opaque data structure and can only be accessed
46 * using the following functions.
49 typedef GDBusObjectIface GDBusObjectInterface;
50 G_DEFINE_INTERFACE (GDBusObject, g_dbus_object, G_TYPE_OBJECT)
53 g_dbus_object_default_init (GDBusObjectIface *iface)
56 * GDBusObject::interface-added:
57 * @object: The #GDBusObject emitting the signal.
58 * @interface: The #GDBusInterface that was added.
60 * Emitted when @interface is added to @object.
64 g_signal_new (I_("interface-added"),
65 G_TYPE_FROM_INTERFACE (iface),
67 G_STRUCT_OFFSET (GDBusObjectIface, interface_added),
73 G_TYPE_DBUS_INTERFACE);
76 * GDBusObject::interface-removed:
77 * @object: The #GDBusObject emitting the signal.
78 * @interface: The #GDBusInterface that was removed.
80 * Emitted when @interface is removed from @object.
84 g_signal_new (I_("interface-removed"),
85 G_TYPE_FROM_INTERFACE (iface),
87 G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
93 G_TYPE_DBUS_INTERFACE);
96 /* ---------------------------------------------------------------------------------------------------- */
99 * g_dbus_object_get_object_path:
100 * @object: A #GDBusObject.
102 * Gets the object path for @object.
104 * Returns: A string owned by @object. Do not free.
109 g_dbus_object_get_object_path (GDBusObject *object)
111 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
112 return iface->get_object_path (object);
116 * g_dbus_object_get_interfaces:
117 * @object: A #GDBusObject.
119 * Gets the D-Bus interfaces associated with @object.
121 * Returns: (element-type GDBusInterface) (transfer full): A list of #GDBusInterface instances.
122 * The returned list must be freed by g_list_free() after each element has been freed
123 * with g_object_unref().
128 g_dbus_object_get_interfaces (GDBusObject *object)
130 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
131 return iface->get_interfaces (object);
135 * g_dbus_object_get_interface:
136 * @object: A #GDBusObject.
137 * @interface_name: A D-Bus interface name.
139 * Gets the D-Bus interface with name @interface_name associated with
142 * Returns: (nullable) (transfer full): %NULL if not found, otherwise a
143 * #GDBusInterface that must be freed with g_object_unref().
148 g_dbus_object_get_interface (GDBusObject *object,
149 const gchar *interface_name)
151 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
152 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
153 return iface->get_interface (object, interface_name);