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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
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
42 typedef GDBusObjectIface GDBusObjectInterface;
43 G_DEFINE_INTERFACE (GDBusObject, g_dbus_object, G_TYPE_OBJECT)
46 g_dbus_object_default_init (GDBusObjectIface *iface)
49 * GDBusObject::interface-added:
50 * @object: The #GDBusObject emitting the signal.
51 * @interface: The #GDBusInterface that was added.
53 * Emitted when @interface is added to @object.
57 g_signal_new ("interface-added",
58 G_TYPE_FROM_INTERFACE (iface),
60 G_STRUCT_OFFSET (GDBusObjectIface, interface_added),
63 g_cclosure_marshal_VOID__OBJECT,
66 G_TYPE_DBUS_INTERFACE);
69 * GDBusObject::interface-removed:
70 * @object: The #GDBusObject emitting the signal.
71 * @interface: The #GDBusInterface that was removed.
73 * Emitted when @interface is removed from @object.
77 g_signal_new ("interface-removed",
78 G_TYPE_FROM_INTERFACE (iface),
80 G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
83 g_cclosure_marshal_VOID__OBJECT,
86 G_TYPE_DBUS_INTERFACE);
89 /* ---------------------------------------------------------------------------------------------------- */
92 * g_dbus_object_get_object_path:
93 * @object: A #GDBusObject.
95 * Gets the object path for @object.
97 * Returns: A string owned by @object. Do not free.
102 g_dbus_object_get_object_path (GDBusObject *object)
104 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
105 return iface->get_object_path (object);
109 * g_dbus_object_get_interfaces:
110 * @object: A #GDBusObject.
112 * Gets the D-Bus interfaces associated with @object.
114 * Returns: (element-type GDBusInterface) (transfer full) : A list of #GDBusInterface instances.
115 * The returned list must be freed by g_list_free() after each element has been freed
116 * with g_object_unref().
121 g_dbus_object_get_interfaces (GDBusObject *object)
123 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
124 return iface->get_interfaces (object);
128 * g_dbus_object_get_interface:
129 * @object: A #GDBusObject.
130 * @interface_name: A D-Bus interface name.
132 * Gets the D-Bus interface with name @interface_name associated with
135 * Returns: (transfer full): %NULL if not found, otherwise a
136 * #GDBusInterface that must be freed with g_object_unref().
141 g_dbus_object_get_interface (GDBusObject *object,
142 const gchar *interface_name)
144 GDBusObjectIface *iface = G_DBUS_OBJECT_GET_IFACE (object);
145 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
146 return iface->get_interface (object, interface_name);