1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
/* GDBus - GLib D-Bus Library
*
* Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#include "config.h"
#include "gdbusobject.h"
#include "gdbusobjectmanager.h"
#include "gdbusinterface.h"
#include "gdbusutils.h"
#include "glibintl.h"
/**
* SECTION:gdbusobjectmanager
* @short_description: Base type for D-Bus object managers
* @include: gio/gio.h
*
* The #GDBusObjectManager type is the base type for service- and
* client-side implementations of the standardized
* [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
* interface.
*
* See #GDBusObjectManagerClient for the client-side implementation
* and #GDBusObjectManagerServer for the service-side implementation.
*/
/**
* GDBusObjectManager:
*
* #GDBusObjectManager is an opaque data structure and can only be accessed
* using the following functions.
*/
typedef GDBusObjectManagerIface GDBusObjectManagerInterface;
G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT)
static void
g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface)
{
/**
* GDBusObjectManager::object-added:
* @manager: The #GDBusObjectManager emitting the signal.
* @object: The #GDBusObject that was added.
*
* Emitted when @object is added to @manager.
*
* Since: 2.30
*/
g_signal_new (I_("object-added"),
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusObjectManagerIface, object_added),
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
G_TYPE_DBUS_OBJECT);
/**
* GDBusObjectManager::object-removed:
* @manager: The #GDBusObjectManager emitting the signal.
* @object: The #GDBusObject that was removed.
*
* Emitted when @object is removed from @manager.
*
* Since: 2.30
*/
g_signal_new (I_("object-removed"),
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusObjectManagerIface, object_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1,
G_TYPE_DBUS_OBJECT);
/**
* GDBusObjectManager::interface-added:
* @manager: The #GDBusObjectManager emitting the signal.
* @object: The #GDBusObject on which an interface was added.
* @interface: The #GDBusInterface that was added.
*
* Emitted when @interface is added to @object.
*
* This signal exists purely as a convenience to avoid having to
* connect signals to all objects managed by @manager.
*
* Since: 2.30
*/
g_signal_new (I_("interface-added"),
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_added),
NULL,
NULL,
NULL,
G_TYPE_NONE,
2,
G_TYPE_DBUS_OBJECT,
G_TYPE_DBUS_INTERFACE);
/**
* GDBusObjectManager::interface-removed:
* @manager: The #GDBusObjectManager emitting the signal.
* @object: The #GDBusObject on which an interface was removed.
* @interface: The #GDBusInterface that was removed.
*
* Emitted when @interface has been removed from @object.
*
* This signal exists purely as a convenience to avoid having to
* connect signals to all objects managed by @manager.
*
* Since: 2.30
*/
g_signal_new (I_("interface-removed"),
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusObjectManagerIface, interface_removed),
NULL,
NULL,
NULL,
G_TYPE_NONE,
2,
G_TYPE_DBUS_OBJECT,
G_TYPE_DBUS_INTERFACE);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
* g_dbus_object_manager_get_object_path:
* @manager: A #GDBusObjectManager.
*
* Gets the object path that @manager is for.
*
* Returns: A string owned by @manager. Do not free.
*
* Since: 2.30
*/
const gchar *
g_dbus_object_manager_get_object_path (GDBusObjectManager *manager)
{
GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
return iface->get_object_path (manager);
}
/**
* g_dbus_object_manager_get_objects:
* @manager: A #GDBusObjectManager.
*
* Gets all #GDBusObject objects known to @manager.
*
* Returns: (transfer full) (element-type GDBusObject): A list of
* #GDBusObject objects. The returned list should be freed with
* g_list_free() after each element has been freed with
* g_object_unref().
*
* Since: 2.30
*/
GList *
g_dbus_object_manager_get_objects (GDBusObjectManager *manager)
{
GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
return iface->get_objects (manager);
}
/**
* g_dbus_object_manager_get_object:
* @manager: A #GDBusObjectManager.
* @object_path: Object path to lookup.
*
* Gets the #GDBusObjectProxy at @object_path, if any.
*
* Returns: (transfer full): A #GDBusObject or %NULL. Free with
* g_object_unref().
*
* Since: 2.30
*/
GDBusObject *
g_dbus_object_manager_get_object (GDBusObjectManager *manager,
const gchar *object_path)
{
GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
return iface->get_object (manager, object_path);
}
/**
* g_dbus_object_manager_get_interface:
* @manager: A #GDBusObjectManager.
* @object_path: Object path to lookup.
* @interface_name: D-Bus interface name to lookup.
*
* Gets the interface proxy for @interface_name at @object_path, if
* any.
*
* Returns: (transfer full): A #GDBusInterface instance or %NULL. Free
* with g_object_unref().
*
* Since: 2.30
*/
GDBusInterface *
g_dbus_object_manager_get_interface (GDBusObjectManager *manager,
const gchar *object_path,
const gchar *interface_name)
{
GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager);
g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
return iface->get_interface (manager, object_path, interface_name);
}
|