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.
47 typedef GDBusObjectManagerIface GDBusObjectManagerInterface;
48 G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT)
51 g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
54 * GDBusObjectManager::object-added:
55 * @manager: The #GDBusObjectManager emitting the signal.
56 * @object: The #GDBusObject that was added.
58 * Emitted when @object is added to @manager.
62 g_signal_new ("object-added",
63 G_TYPE_FROM_INTERFACE (iface),
65 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
68 g_cclosure_marshal_VOID__OBJECT,
74 * GDBusObjectManager::object-removed:
75 * @manager: The #GDBusObjectManager emitting the signal.
76 * @object: The #GDBusObject that was removed.
78 * Emitted when @object is removed from @manager.
82 g_signal_new ("object-removed",
83 G_TYPE_FROM_INTERFACE (iface),
85 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
88 g_cclosure_marshal_VOID__OBJECT,
94 * GDBusObjectManager::interface-added:
95 * @manager: The #GDBusObjectManager emitting the signal.
96 * @object: The #GDBusObject on which an interface was added.
97 * @interface: The #GDBusInterface that was added.
99 * Emitted when @interface is added to @object.
101 * This signal exists purely as a convenience to avoid having to
102 * 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.
131 g_signal_new ("interface-removed",
132 G_TYPE_FROM_INTERFACE (iface),
134 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
137 _gio_marshal_VOID__OBJECT_OBJECT,
141 G_TYPE_DBUS_INTERFACE);
145 /* ---------------------------------------------------------------------------------------------------- */
148 * g_dbus_object_manager_get_object_path:
149 * @manager: A #GDBusObjectManager.
151 * Gets the object path that @manager is for.
153 * Returns: A string owned by @manager. Do not free.
158 g_dbus_object_manager_get_object_path (GDBusObjectManager *manager)
160 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
161 return iface->get_object_path (manager);
165 * g_dbus_object_manager_get_objects:
166 * @manager: A #GDBusObjectManager.
168 * Gets all #GDBusObject objects known to @manager.
170 * Returns: (transfer full) (element-type GDBusObject): A list of
171 * #GDBusObject objects. The returned list should be freed with
172 * g_list_free() after each element has been freed with
178 g_dbus_object_manager_get_objects (GDBusObjectManager *manager)
180 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
181 return iface->get_objects (manager);
185 * g_dbus_object_manager_get_object:
186 * @manager: A #GDBusObjectManager.
187 * @object_path: Object path to lookup.
189 * Gets the #GDBusObjectProxy at @object_path, if any.
191 * Returns: (transfer full): A #GDBusObject or %NULL. Free with
197 g_dbus_object_manager_get_object (GDBusObjectManager *manager,
198 const gchar *object_path)
200 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
201 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
202 return iface->get_object (manager, object_path);
206 * g_dbus_object_manager_get_interface:
207 * @manager: A #GDBusObjectManager.
208 * @object_path: Object path to lookup.
209 * @interface_name: D-Bus interface name to lookup.
211 * Gets the interface proxy for @interface_name at @object_path, if
214 * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
215 * with g_object_unref().
220 g_dbus_object_manager_get_interface (GDBusObjectManager *manager,
221 const gchar *object_path,
222 const gchar *interface_name)
224 GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
225 g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
226 g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
227 return iface->get_interface (manager, object_path, interface_name);