1 /* GDBus - GLib D-Bus Library
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Author: David Zeuthen <davidz@redhat.com>
23 #include "gdbusobject.h"
24 #include "gdbusinterface.h"
25 #include "gdbusutils.h"
31 * @short_description: Base type for D-Bus objects
34 * The #GDBusObject type is the base type for D-Bus objects on both
35 * the service side (see #GDBusObjectSkeleton) and the client side
36 * (see #GDBusObjectProxy). It is essentially just a container of
40 typedef GDBusObjectIface GDBusObjectInterface;
41 G_DEFINE_INTERFACE (GDBusObject, g_dbus_object, G_TYPE_OBJECT)
44 g_dbus_object_default_init (GDBusObjectIface *iface)
47 * GDBusObject::interface-added:
48 * @object: The #GDBusObject emitting the signal.
49 * @interface: The #GDBusInterface that was added.
51 * Emitted when @interface is added to @object.
55 g_signal_new ("interface-added",
56 G_TYPE_FROM_INTERFACE (iface),
58 G_STRUCT_OFFSET (GDBusObjectIface, interface_added),
61 g_cclosure_marshal_VOID__OBJECT,
64 G_TYPE_DBUS_INTERFACE);
67 * GDBusObject::interface-removed:
68 * @object: The #GDBusObject emitting the signal.
69 * @interface: The #GDBusInterface that was removed.
71 * Emitted when @interface is removed from @object.
75 g_signal_new ("interface-removed",
76 G_TYPE_FROM_INTERFACE (iface),
78 G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
81 g_cclosure_marshal_VOID__OBJECT,
84 G_TYPE_DBUS_INTERFACE);
87 /* ---------------------------------------------------------------------------------------------------- */
90 * g_dbus_object_get_object_path:
91 * @object: A #GDBusObject.
93 * Gets the object path for @object.
95 * Returns: A string owned by @object. Do not free.
100 g_dbus_object_get_object_path (GDBusObject *object)
102 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
103 return iface->get_object_path (object);
107 * g_dbus_object_get_interfaces:
108 * @object: A #GDBusObject.
110 * Gets the D-Bus interfaces associated with @object.
112 * Returns: (element-type GDBusInterface) (transfer full) : A list of #GDBusInterface instances.
113 * The returned list must be freed by g_list_free() after each element has been freed
114 * with g_object_unref().
119 g_dbus_object_get_interfaces (GDBusObject *object)
121 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
122 return iface->get_interfaces (object);
126 * g_dbus_object_get_interface:
127 * @object: A #GDBusObject.
128 * @interface_name: A D-Bus interface name.
130 * Gets the D-Bus interface with name @interface_name associated with
133 * Returns: (transfer full): %NULL if not found, otherwise a
134 * #GDBusInterface that must be freed with g_object_unref().
139 g_dbus_object_get_interface (GDBusObject *object,
140 const gchar *interface_name)
142 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
143 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
144 return iface->get_interface (object, interface_name);