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 "gdbusobjectmanager.h"
25 #include "gdbusinterface.h"
26 #include "gdbusutils.h"
31 * SECTION:gdbusobjectmanager
32 * @short_description: Base type for D-Bus object managers
35 * The #GDBusObjectManager type is the base type for service- and
36 * client-side implementations of the standardized
37 * [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
40 * See #GDBusObjectManagerClient for the client-side implementation
41 * and #GDBusObjectManagerServer for the service-side implementation.
44 typedef GDBusObjectManagerIface GDBusObjectManagerInterface;
45 G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT)
48 g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
51 * GDBusObjectManager::object-added:
52 * @manager: The #GDBusObjectManager emitting the signal.
53 * @object: The #GDBusObject that was added.
55 * Emitted when @object is added to @manager.
59 g_signal_new ("object-added",
60 G_TYPE_FROM_INTERFACE (iface),
62 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
65 g_cclosure_marshal_VOID__OBJECT,
71 * GDBusObjectManager::object-removed:
72 * @manager: The #GDBusObjectManager emitting the signal.
73 * @object: The #GDBusObject that was removed.
75 * Emitted when @object is removed from @manager.
79 g_signal_new ("object-removed",
80 G_TYPE_FROM_INTERFACE (iface),
82 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
85 g_cclosure_marshal_VOID__OBJECT,
91 * GDBusObjectManager::interface-added:
92 * @manager: The #GDBusObjectManager emitting the signal.
93 * @object: The #GDBusObject on which an interface was added.
94 * @interface: The #GDBusInterface that was added.
96 * Emitted when @interface is added to @object.
98 * This signal exists purely as a convenience to avoid having to
99 * connect signals to all objects managed by @manager.
103 g_signal_new ("interface-added",
104 G_TYPE_FROM_INTERFACE (iface),
106 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_added),
113 G_TYPE_DBUS_INTERFACE);
116 * GDBusObjectManager::interface-removed:
117 * @manager: The #GDBusObjectManager emitting the signal.
118 * @object: The #GDBusObject on which an interface was removed.
119 * @interface: The #GDBusInterface that was removed.
121 * Emitted when @interface has been removed from @object.
123 * This signal exists purely as a convenience to avoid having to
124 * connect signals to all objects managed by @manager.
128 g_signal_new ("interface-removed",
129 G_TYPE_FROM_INTERFACE (iface),
131 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
138 G_TYPE_DBUS_INTERFACE);
142 /* ---------------------------------------------------------------------------------------------------- */
145 * g_dbus_object_manager_get_object_path:
146 * @manager: A #GDBusObjectManager.
148 * Gets the object path that @manager is for.
150 * Returns: A string owned by @manager. Do not free.
155 g_dbus_object_manager_get_object_path (GDBusObjectManager *manager)
157 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
158 return iface->get_object_path (manager);
162 * g_dbus_object_manager_get_objects:
163 * @manager: A #GDBusObjectManager.
165 * Gets all #GDBusObject objects known to @manager.
167 * Returns: (transfer full) (element-type GDBusObject): A list of
168 * #GDBusObject objects. The returned list should be freed with
169 * g_list_free() after each element has been freed with
175 g_dbus_object_manager_get_objects (GDBusObjectManager *manager)
177 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
178 return iface->get_objects (manager);
182 * g_dbus_object_manager_get_object:
183 * @manager: A #GDBusObjectManager.
184 * @object_path: Object path to lookup.
186 * Gets the #GDBusObjectProxy at @object_path, if any.
188 * Returns: (transfer full): A #GDBusObject or %NULL. Free with
194 g_dbus_object_manager_get_object (GDBusObjectManager *manager,
195 const gchar *object_path)
197 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
198 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
199 return iface->get_object (manager, object_path);
203 * g_dbus_object_manager_get_interface:
204 * @manager: A #GDBusObjectManager.
205 * @object_path: Object path to lookup.
206 * @interface_name: D-Bus interface name to lookup.
208 * Gets the interface proxy for @interface_name at @object_path, if
211 * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
212 * with g_object_unref().
217 g_dbus_object_manager_get_interface (GDBusObjectManager *manager,
218 const gchar *object_path,
219 const gchar *interface_name)
221 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
222 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
223 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
224 return iface->get_interface (manager, object_path, interface_name);