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 "gdbusinterface.h"
28 #include "gdbusutils.h"
33 * SECTION:gdbusobjectmanager
34 * @short_description: Base type for D-Bus object managers
37 * The #GDBusObjectManager type is the base type for service- and
38 * client-side implementations of the standardized <ulink
39 * url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager">org.freedesktop.DBus.ObjectManager</ulink>
42 * See #GDBusObjectManagerClient for the client-side implementation
43 * and #GDBusObjectManagerServer for the service-side implementation.
46 typedef GDBusObjectManagerIface GDBusObjectManagerInterface;
47 G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT)
50 g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
53 * GDBusObjectManager::object-added:
54 * @manager: The #GDBusObjectManager emitting the signal.
55 * @object: The #GDBusObject that was added.
57 * Emitted when @object is added to @manager.
61 g_signal_new ("object-added",
62 G_TYPE_FROM_INTERFACE (iface),
64 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
67 g_cclosure_marshal_VOID__OBJECT,
73 * GDBusObjectManager::object-removed:
74 * @manager: The #GDBusObjectManager emitting the signal.
75 * @object: The #GDBusObject that was removed.
77 * Emitted when @object is removed from @manager.
81 g_signal_new ("object-removed",
82 G_TYPE_FROM_INTERFACE (iface),
84 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
87 g_cclosure_marshal_VOID__OBJECT,
93 * GDBusObjectManager::interface-added:
94 * @manager: The #GDBusObjectManager emitting the signal.
95 * @object: The #GDBusObject on which an interface was added.
96 * @interface: The #GDBusInterface that was added.
98 * Emitted when @interface is added to @object.
100 * This signal exists purely as a convenience to avoid having to
101 * connect signals to all objects managed by @manager.
105 g_signal_new ("interface-added",
106 G_TYPE_FROM_INTERFACE (iface),
108 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_added),
115 G_TYPE_DBUS_INTERFACE);
118 * GDBusObjectManager::interface-removed:
119 * @manager: The #GDBusObjectManager emitting the signal.
120 * @object: The #GDBusObject on which an interface was removed.
121 * @interface: The #GDBusInterface that was removed.
123 * Emitted when @interface has been removed from @object.
125 * This signal exists purely as a convenience to avoid having to
126 * connect signals to all objects managed by @manager.
130 g_signal_new ("interface-removed",
131 G_TYPE_FROM_INTERFACE (iface),
133 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
140 G_TYPE_DBUS_INTERFACE);
144 /* ---------------------------------------------------------------------------------------------------- */
147 * g_dbus_object_manager_get_object_path:
148 * @manager: A #GDBusObjectManager.
150 * Gets the object path that @manager is for.
152 * Returns: A string owned by @manager. Do not free.
157 g_dbus_object_manager_get_object_path (GDBusObjectManager *manager)
159 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
160 return iface->get_object_path (manager);
164 * g_dbus_object_manager_get_objects:
165 * @manager: A #GDBusObjectManager.
167 * Gets all #GDBusObject objects known to @manager.
169 * Returns: (transfer full) (element-type GDBusObject): A list of
170 * #GDBusObject objects. The returned list should be freed with
171 * g_list_free() after each element has been freed with
177 g_dbus_object_manager_get_objects (GDBusObjectManager *manager)
179 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
180 return iface->get_objects (manager);
184 * g_dbus_object_manager_get_object:
185 * @manager: A #GDBusObjectManager.
186 * @object_path: Object path to lookup.
188 * Gets the #GDBusObjectProxy at @object_path, if any.
190 * Returns: (transfer full): A #GDBusObject or %NULL. Free with
196 g_dbus_object_manager_get_object (GDBusObjectManager *manager,
197 const gchar *object_path)
199 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
200 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
201 return iface->get_object (manager, object_path);
205 * g_dbus_object_manager_get_interface:
206 * @manager: A #GDBusObjectManager.
207 * @object_path: Object path to lookup.
208 * @interface_name: D-Bus interface name to lookup.
210 * Gets the interface proxy for @interface_name at @object_path, if
213 * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
214 * with g_object_unref().
219 g_dbus_object_manager_get_interface (GDBusObjectManager *manager,
220 const gchar *object_path,
221 const gchar *interface_name)
223 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
224 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
225 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
226 return iface->get_interface (manager, object_path, interface_name);