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 "gdbusobjectmanager.h"
27 #include "gio-marshal.h"
28 #include "gdbusinterface.h"
29 #include "gdbusutils.h"
34 * SECTION:gdbusobjectmanager
35 * @short_description: Base type for D-Bus object managers
38 * The #GDBusObjectManager type is the base type for service- and
39 * client-side implementations of the standardized <ulink
40 * url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager">org.freedesktop.DBus.ObjectManager</ulink>
43 * See #GDBusObjectManagerClient for the client-side implementation
44 * and #GDBusObjectManagerServer for the service-side implementation.
53 typedef GDBusObjectManagerIface GDBusObjectManagerInterface;
54 G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT)
57 g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
60 * GDBusObjectManager::object-added:
61 * @manager: The #GDBusObjectManager emitting the signal.
62 * @object: The #GDBusObject that was added.
64 * Emitted when @object is added to @manager.
66 g_signal_new ("object-added",
67 G_TYPE_FROM_INTERFACE (iface),
69 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
72 g_cclosure_marshal_VOID__OBJECT,
78 * GDBusObjectManager::object-removed:
79 * @manager: The #GDBusObjectManager emitting the signal.
80 * @object: The #GDBusObject that was removed.
82 * Emitted when @object is removed from @manager.
84 g_signal_new ("object-removed",
85 G_TYPE_FROM_INTERFACE (iface),
87 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
90 g_cclosure_marshal_VOID__OBJECT,
96 * GDBusObjectManager::interface-added:
97 * @manager: The #GDBusObjectManager emitting the signal.
98 * @object: The #GDBusObject on which an interface was added.
99 * @interface: The #GDBusInterface that was added.
101 * Emitted when @interface is added to @object.
103 * This signal exists purely as a convenience to avoid having to
104 * connect signals to all objects managed by @manager.
106 g_signal_new ("interface-added",
107 G_TYPE_FROM_INTERFACE (iface),
109 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_added),
112 _gio_marshal_VOID__OBJECT_OBJECT,
116 G_TYPE_DBUS_INTERFACE);
119 * GDBusObjectManager::interface-removed:
120 * @manager: The #GDBusObjectManager emitting the signal.
121 * @object: The #GDBusObject on which an interface was removed.
122 * @interface: The #GDBusInterface that was removed.
124 * Emitted when @interface has been removed from @object.
126 * This signal exists purely as a convenience to avoid having to
127 * connect signals to all objects managed by @manager.
129 g_signal_new ("interface-removed",
130 G_TYPE_FROM_INTERFACE (iface),
132 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
135 _gio_marshal_VOID__OBJECT_OBJECT,
139 G_TYPE_DBUS_INTERFACE);
143 /* ---------------------------------------------------------------------------------------------------- */
146 * g_dbus_object_manager_get_object_path:
147 * @manager: A #GDBusObjectManager.
149 * Gets the object path that @manager is for.
151 * Returns: A string owned by @manager. Do not free.
154 g_dbus_object_manager_get_object_path (GDBusObjectManager *manager)
156 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
157 return iface->get_object_path (manager);
161 * g_dbus_object_manager_get_objects:
162 * @manager: A #GDBusObjectManager.
164 * Gets all #GDBusObject objects known to @manager.
166 * Returns: (transfer full) (element-type GDBusObject): A list of
167 * #GDBusObject objects. The returned list should be freed with
168 * g_list_free() after each element has been freed with
172 g_dbus_object_manager_get_objects (GDBusObjectManager *manager)
174 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
175 return iface->get_objects (manager);
179 * g_dbus_object_manager_get_object:
180 * @manager: A #GDBusObjectManager.
181 * @object_path: Object path to lookup.
183 * Gets the #GDBusObjectProxy at @object_path, if any.
185 * Returns: A #GDBusObject or %NULL. Free with g_object_unref().
188 g_dbus_object_manager_get_object (GDBusObjectManager *manager,
189 const gchar *object_path)
191 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
192 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
193 return iface->get_object (manager, object_path);
197 * g_dbus_object_manager_get_interface:
198 * @manager: A #GDBusObjectManager.
199 * @object_path: Object path to lookup.
200 * @interface_name: D-Bus interface name to lookup.
202 * Gets the interface proxy for @interface_name at @object_path, if
205 * Returns: A #GDBusInterface instance or %NULL. Free with g_object_unref().
208 g_dbus_object_manager_get_interface (GDBusObjectManager *manager,
209 const gchar *object_path,
210 const gchar *interface_name)
212 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
213 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
214 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
215 return iface->get_interface (manager, object_path, interface_name);