Add a wrapper for the AddFull document portal api
[glib.git] / gio / gdbusobjectmanager.c
blob0eaec3f8c972d48cfc91864679e4750cf379afa2
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>
21 #include "config.h"
23 #include "gdbusobject.h"
24 #include "gdbusobjectmanager.h"
25 #include "gdbusinterface.h"
26 #include "gdbusutils.h"
28 #include "glibintl.h"
30 /**
31 * SECTION:gdbusobjectmanager
32 * @short_description: Base type for D-Bus object managers
33 * @include: gio/gio.h
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)
38 * interface.
40 * See #GDBusObjectManagerClient for the client-side implementation
41 * and #GDBusObjectManagerServer for the service-side implementation.
44 /**
45 * GDBusObjectManager:
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)
54 static void
55 g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
57 /**
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.
64 * Since: 2.30
66 g_signal_new (I_("object-added"),
67 G_TYPE_FROM_INTERFACE (iface),
68 G_SIGNAL_RUN_LAST,
69 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
70 NULL,
71 NULL,
72 g_cclosure_marshal_VOID__OBJECT,
73 G_TYPE_NONE,
75 G_TYPE_DBUS_OBJECT);
77 /**
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 * Since: 2.30
86 g_signal_new (I_("object-removed"),
87 G_TYPE_FROM_INTERFACE (iface),
88 G_SIGNAL_RUN_LAST,
89 G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
90 NULL,
91 NULL,
92 g_cclosure_marshal_VOID__OBJECT,
93 G_TYPE_NONE,
95 G_TYPE_DBUS_OBJECT);
97 /**
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.
108 * Since: 2.30
110 g_signal_new (I_("interface-added"),
111 G_TYPE_FROM_INTERFACE (iface),
112 G_SIGNAL_RUN_LAST,
113 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_added),
114 NULL,
115 NULL,
116 NULL,
117 G_TYPE_NONE,
119 G_TYPE_DBUS_OBJECT,
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.
133 * Since: 2.30
135 g_signal_new (I_("interface-removed"),
136 G_TYPE_FROM_INTERFACE (iface),
137 G_SIGNAL_RUN_LAST,
138 G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
139 NULL,
140 NULL,
141 NULL,
142 G_TYPE_NONE,
144 G_TYPE_DBUS_OBJECT,
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.
159 * Since: 2.30
161 const gchar *
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
177 * g_object_unref().
179 * Since: 2.30
181 GList *
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
196 * g_object_unref().
198 * Since: 2.30
200 GDBusObject *
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
216 * any.
218 * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
219 * with g_object_unref().
221 * Since: 2.30
223 GDBusInterface *
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);