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.1 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.
47 * #GDBusObjectManager is an opaque data structure and can only be accessed
48 * using the following functions.
51 typedef GDBusObjectManagerIface GDBusObjectManagerInterface
;
52 G_DEFINE_INTERFACE (GDBusObjectManager
, g_dbus_object_manager
, G_TYPE_OBJECT
)
55 g_dbus_object_manager_default_init (GDBusObjectManagerIface
*iface
)
58 * GDBusObjectManager::object-added:
59 * @manager: The #GDBusObjectManager emitting the signal.
60 * @object: The #GDBusObject that was added.
62 * Emitted when @object is added to @manager.
66 g_signal_new (I_("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.
86 g_signal_new (I_("object-removed"),
87 G_TYPE_FROM_INTERFACE (iface
),
89 G_STRUCT_OFFSET (GDBusObjectManagerIface
, object_removed
),
92 g_cclosure_marshal_VOID__OBJECT
,
98 * GDBusObjectManager::interface-added:
99 * @manager: The #GDBusObjectManager emitting the signal.
100 * @object: The #GDBusObject on which an interface was added.
101 * @interface: The #GDBusInterface that was added.
103 * Emitted when @interface is added to @object.
105 * This signal exists purely as a convenience to avoid having to
106 * connect signals to all objects managed by @manager.
110 g_signal_new (I_("interface-added"),
111 G_TYPE_FROM_INTERFACE (iface
),
113 G_STRUCT_OFFSET (GDBusObjectManagerIface
, interface_added
),
120 G_TYPE_DBUS_INTERFACE
);
123 * GDBusObjectManager::interface-removed:
124 * @manager: The #GDBusObjectManager emitting the signal.
125 * @object: The #GDBusObject on which an interface was removed.
126 * @interface: The #GDBusInterface that was removed.
128 * Emitted when @interface has been removed from @object.
130 * This signal exists purely as a convenience to avoid having to
131 * connect signals to all objects managed by @manager.
135 g_signal_new (I_("interface-removed"),
136 G_TYPE_FROM_INTERFACE (iface
),
138 G_STRUCT_OFFSET (GDBusObjectManagerIface
, interface_removed
),
145 G_TYPE_DBUS_INTERFACE
);
149 /* ---------------------------------------------------------------------------------------------------- */
152 * g_dbus_object_manager_get_object_path:
153 * @manager: A #GDBusObjectManager.
155 * Gets the object path that @manager is for.
157 * Returns: A string owned by @manager. Do not free.
162 g_dbus_object_manager_get_object_path (GDBusObjectManager
*manager
)
164 GDBusObjectManagerIface
*iface
= G_DBUS_OBJECT_MANAGER_GET_IFACE (manager
);
165 return iface
->get_object_path (manager
);
169 * g_dbus_object_manager_get_objects:
170 * @manager: A #GDBusObjectManager.
172 * Gets all #GDBusObject objects known to @manager.
174 * Returns: (transfer full) (element-type GDBusObject): A list of
175 * #GDBusObject objects. The returned list should be freed with
176 * g_list_free() after each element has been freed with
182 g_dbus_object_manager_get_objects (GDBusObjectManager
*manager
)
184 GDBusObjectManagerIface
*iface
= G_DBUS_OBJECT_MANAGER_GET_IFACE (manager
);
185 return iface
->get_objects (manager
);
189 * g_dbus_object_manager_get_object:
190 * @manager: A #GDBusObjectManager.
191 * @object_path: Object path to lookup.
193 * Gets the #GDBusObjectProxy at @object_path, if any.
195 * Returns: (transfer full): A #GDBusObject or %NULL. Free with
201 g_dbus_object_manager_get_object (GDBusObjectManager
*manager
,
202 const gchar
*object_path
)
204 GDBusObjectManagerIface
*iface
= G_DBUS_OBJECT_MANAGER_GET_IFACE (manager
);
205 g_return_val_if_fail (g_variant_is_object_path (object_path
), NULL
);
206 return iface
->get_object (manager
, object_path
);
210 * g_dbus_object_manager_get_interface:
211 * @manager: A #GDBusObjectManager.
212 * @object_path: Object path to lookup.
213 * @interface_name: D-Bus interface name to lookup.
215 * Gets the interface proxy for @interface_name at @object_path, if
218 * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
219 * with g_object_unref().
224 g_dbus_object_manager_get_interface (GDBusObjectManager
*manager
,
225 const gchar
*object_path
,
226 const gchar
*interface_name
)
228 GDBusObjectManagerIface
*iface
= G_DBUS_OBJECT_MANAGER_GET_IFACE (manager
);
229 g_return_val_if_fail (g_variant_is_object_path (object_path
), NULL
);
230 g_return_val_if_fail (g_dbus_is_interface_name (interface_name
), NULL
);
231 return iface
->get_interface (manager
, object_path
, interface_name
);