nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* GDBus - GLib D-Bus Library |
2 | * |
||
3 | * Copyright (C) 2008-2010 Red Hat, Inc. |
||
4 | * |
||
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. |
||
9 | * |
||
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. |
||
14 | * |
||
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/>. |
||
17 | * |
||
18 | * Author: David Zeuthen <davidz@redhat.com> |
||
19 | */ |
||
20 | |||
21 | #include "config.h" |
||
22 | |||
23 | #include "gdbusobject.h" |
||
24 | #include "gdbusobjectmanager.h" |
||
25 | #include "gdbusinterface.h" |
||
26 | #include "gdbusutils.h" |
||
27 | |||
28 | #include "glibintl.h" |
||
29 | |||
30 | /** |
||
31 | * SECTION:gdbusobjectmanager |
||
32 | * @short_description: Base type for D-Bus object managers |
||
33 | * @include: gio/gio.h |
||
34 | * |
||
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. |
||
39 | * |
||
40 | * See #GDBusObjectManagerClient for the client-side implementation |
||
41 | * and #GDBusObjectManagerServer for the service-side implementation. |
||
42 | */ |
||
43 | |||
44 | /** |
||
45 | * GDBusObjectManager: |
||
46 | * |
||
47 | * #GDBusObjectManager is an opaque data structure and can only be accessed |
||
48 | * using the following functions. |
||
49 | */ |
||
50 | |||
51 | typedef GDBusObjectManagerIface GDBusObjectManagerInterface; |
||
52 | G_DEFINE_INTERFACE (GDBusObjectManager, g_dbus_object_manager, G_TYPE_OBJECT) |
||
53 | |||
54 | static void |
||
55 | g_dbus_object_manager_default_init (GDBusObjectManagerIface *iface) |
||
56 | { |
||
57 | /** |
||
58 | * GDBusObjectManager::object-added: |
||
59 | * @manager: The #GDBusObjectManager emitting the signal. |
||
60 | * @object: The #GDBusObject that was added. |
||
61 | * |
||
62 | * Emitted when @object is added to @manager. |
||
63 | * |
||
64 | * Since: 2.30 |
||
65 | */ |
||
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, |
||
74 | 1, |
||
75 | G_TYPE_DBUS_OBJECT); |
||
76 | |||
77 | /** |
||
78 | * GDBusObjectManager::object-removed: |
||
79 | * @manager: The #GDBusObjectManager emitting the signal. |
||
80 | * @object: The #GDBusObject that was removed. |
||
81 | * |
||
82 | * Emitted when @object is removed from @manager. |
||
83 | * |
||
84 | * Since: 2.30 |
||
85 | */ |
||
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, |
||
94 | 1, |
||
95 | G_TYPE_DBUS_OBJECT); |
||
96 | |||
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. |
||
102 | * |
||
103 | * Emitted when @interface is added to @object. |
||
104 | * |
||
105 | * This signal exists purely as a convenience to avoid having to |
||
106 | * connect signals to all objects managed by @manager. |
||
107 | * |
||
108 | * Since: 2.30 |
||
109 | */ |
||
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, |
||
118 | 2, |
||
119 | G_TYPE_DBUS_OBJECT, |
||
120 | G_TYPE_DBUS_INTERFACE); |
||
121 | |||
122 | /** |
||
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. |
||
127 | * |
||
128 | * Emitted when @interface has been removed from @object. |
||
129 | * |
||
130 | * This signal exists purely as a convenience to avoid having to |
||
131 | * connect signals to all objects managed by @manager. |
||
132 | * |
||
133 | * Since: 2.30 |
||
134 | */ |
||
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, |
||
143 | 2, |
||
144 | G_TYPE_DBUS_OBJECT, |
||
145 | G_TYPE_DBUS_INTERFACE); |
||
146 | |||
147 | } |
||
148 | |||
149 | /* ---------------------------------------------------------------------------------------------------- */ |
||
150 | |||
151 | /** |
||
152 | * g_dbus_object_manager_get_object_path: |
||
153 | * @manager: A #GDBusObjectManager. |
||
154 | * |
||
155 | * Gets the object path that @manager is for. |
||
156 | * |
||
157 | * Returns: A string owned by @manager. Do not free. |
||
158 | * |
||
159 | * Since: 2.30 |
||
160 | */ |
||
161 | const gchar * |
||
162 | g_dbus_object_manager_get_object_path (GDBusObjectManager *manager) |
||
163 | { |
||
164 | GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager); |
||
165 | return iface->get_object_path (manager); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * g_dbus_object_manager_get_objects: |
||
170 | * @manager: A #GDBusObjectManager. |
||
171 | * |
||
172 | * Gets all #GDBusObject objects known to @manager. |
||
173 | * |
||
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(). |
||
178 | * |
||
179 | * Since: 2.30 |
||
180 | */ |
||
181 | GList * |
||
182 | g_dbus_object_manager_get_objects (GDBusObjectManager *manager) |
||
183 | { |
||
184 | GDBusObjectManagerIface *iface = G_DBUS_OBJECT_MANAGER_GET_IFACE (manager); |
||
185 | return iface->get_objects (manager); |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * g_dbus_object_manager_get_object: |
||
190 | * @manager: A #GDBusObjectManager. |
||
191 | * @object_path: Object path to lookup. |
||
192 | * |
||
193 | * Gets the #GDBusObjectProxy at @object_path, if any. |
||
194 | * |
||
195 | * Returns: (transfer full): A #GDBusObject or %NULL. Free with |
||
196 | * g_object_unref(). |
||
197 | * |
||
198 | * Since: 2.30 |
||
199 | */ |
||
200 | GDBusObject * |
||
201 | g_dbus_object_manager_get_object (GDBusObjectManager *manager, |
||
202 | const gchar *object_path) |
||
203 | { |
||
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); |
||
207 | } |
||
208 | |||
209 | /** |
||
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. |
||
214 | * |
||
215 | * Gets the interface proxy for @interface_name at @object_path, if |
||
216 | * any. |
||
217 | * |
||
218 | * Returns: (transfer full): A #GDBusInterface instance or %NULL. Free |
||
219 | * with g_object_unref(). |
||
220 | * |
||
221 | * Since: 2.30 |
||
222 | */ |
||
223 | GDBusInterface * |
||
224 | g_dbus_object_manager_get_interface (GDBusObjectManager *manager, |
||
225 | const gchar *object_path, |
||
226 | const gchar *interface_name) |
||
227 | { |
||
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); |
||
232 | } |