eefdb288d9d0b88087499c59d7891e4d1b3fd3b0
[platform/upstream/glib.git] / gio / gdbusconnection.h
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 #ifndef __G_DBUS_CONNECTION_H__
22 #define __G_DBUS_CONNECTION_H__
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #include <gio/giotypes.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_DBUS_CONNECTION         (g_dbus_connection_get_type ())
33 #define G_DBUS_CONNECTION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_CONNECTION, GDBusConnection))
34 #define G_IS_DBUS_CONNECTION(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_CONNECTION))
35
36 GLIB_AVAILABLE_IN_ALL
37 GType            g_dbus_connection_get_type                   (void) G_GNUC_CONST;
38
39 /* ---------------------------------------------------------------------------------------------------- */
40
41 GLIB_AVAILABLE_IN_ALL
42 void              g_bus_get                    (GBusType             bus_type,
43                                                 GCancellable        *cancellable,
44                                                 GAsyncReadyCallback  callback,
45                                                 gpointer             user_data);
46 GLIB_AVAILABLE_IN_ALL
47 GDBusConnection  *g_bus_get_finish             (GAsyncResult        *res,
48                                                 GError             **error);
49 GLIB_AVAILABLE_IN_ALL
50 GDBusConnection  *g_bus_get_sync               (GBusType            bus_type,
51                                                 GCancellable       *cancellable,
52                                                 GError            **error);
53
54 /* ---------------------------------------------------------------------------------------------------- */
55
56 GLIB_AVAILABLE_IN_ALL
57 void             g_dbus_connection_new                        (GIOStream              *stream,
58                                                                const gchar            *guid,
59                                                                GDBusConnectionFlags    flags,
60                                                                GDBusAuthObserver      *observer,
61                                                                GCancellable           *cancellable,
62                                                                GAsyncReadyCallback     callback,
63                                                                gpointer                user_data);
64 GLIB_AVAILABLE_IN_ALL
65 GDBusConnection *g_dbus_connection_new_finish                 (GAsyncResult           *res,
66                                                                GError                **error);
67 GLIB_AVAILABLE_IN_ALL
68 GDBusConnection *g_dbus_connection_new_sync                   (GIOStream              *stream,
69                                                                const gchar            *guid,
70                                                                GDBusConnectionFlags    flags,
71                                                                GDBusAuthObserver      *observer,
72                                                                GCancellable           *cancellable,
73                                                                GError                **error);
74
75 GLIB_AVAILABLE_IN_ALL
76 void             g_dbus_connection_new_for_address            (const gchar            *address,
77                                                                GDBusConnectionFlags    flags,
78                                                                GDBusAuthObserver      *observer,
79                                                                GCancellable           *cancellable,
80                                                                GAsyncReadyCallback     callback,
81                                                                gpointer                user_data);
82 GLIB_AVAILABLE_IN_ALL
83 GDBusConnection *g_dbus_connection_new_for_address_finish     (GAsyncResult           *res,
84                                                                GError                **error);
85 GLIB_AVAILABLE_IN_ALL
86 GDBusConnection *g_dbus_connection_new_for_address_sync       (const gchar            *address,
87                                                                GDBusConnectionFlags    flags,
88                                                                GDBusAuthObserver      *observer,
89                                                                GCancellable           *cancellable,
90                                                                GError                **error);
91
92 /* ---------------------------------------------------------------------------------------------------- */
93
94 GLIB_AVAILABLE_IN_2_40
95 gchar     *g_dbus_get_bus_id                                  (GDBusConnection    *connection,
96                                                                GError            **error);
97 GLIB_AVAILABLE_IN_2_40
98 gchar    **g_dbus_get_list_names                              (GDBusConnection    *connection,
99                                                                GError            **error);
100 GLIB_AVAILABLE_IN_2_40
101 gchar    **g_dbus_get_list_activatable_names                  (GDBusConnection    *connection,
102                                                                GError            **error);
103 GLIB_AVAILABLE_IN_2_40
104 gchar    **g_dbus_get_list_queued_owners                      (GDBusConnection    *connection,
105                                                                const gchar        *name,
106                                                                GError            **error);
107 GLIB_AVAILABLE_IN_2_40
108 gchar     *g_dbus_get_name_owner                              (GDBusConnection    *connection,
109                                                                const gchar        *name,
110                                                                GError            **error);
111 GLIB_AVAILABLE_IN_2_40
112 gboolean   g_dbus_name_has_owner                              (GDBusConnection    *connection,
113                                                                const gchar        *name,
114                                                                GError            **error);
115 GLIB_AVAILABLE_IN_2_40
116 guint32    g_dbus_get_connection_pid                          (GDBusConnection    *connection,
117                                                                const gchar        *name,
118                                                                GError            **error);
119 GLIB_AVAILABLE_IN_2_40
120 guint32    g_dbus_get_connection_uid                          (GDBusConnection    *connection,
121                                                                const gchar        *name,
122                                                                GError            **error);
123
124 /* ---------------------------------------------------------------------------------------------------- */
125
126 GLIB_AVAILABLE_IN_ALL
127 void             g_dbus_connection_start_message_processing   (GDBusConnection    *connection);
128 GLIB_AVAILABLE_IN_ALL
129 gboolean         g_dbus_connection_is_closed                  (GDBusConnection    *connection);
130 GLIB_AVAILABLE_IN_ALL
131 GIOStream       *g_dbus_connection_get_stream                 (GDBusConnection    *connection);
132 GLIB_AVAILABLE_IN_ALL
133 const gchar     *g_dbus_connection_get_guid                   (GDBusConnection    *connection);
134 GLIB_AVAILABLE_IN_ALL
135 const gchar     *g_dbus_connection_get_unique_name            (GDBusConnection    *connection);
136 GLIB_AVAILABLE_IN_ALL
137 GCredentials    *g_dbus_connection_get_peer_credentials       (GDBusConnection    *connection);
138
139 GLIB_AVAILABLE_IN_2_34
140 guint32          g_dbus_connection_get_last_serial            (GDBusConnection    *connection);
141
142 GLIB_AVAILABLE_IN_ALL
143 gboolean         g_dbus_connection_get_exit_on_close          (GDBusConnection    *connection);
144 GLIB_AVAILABLE_IN_ALL
145 void             g_dbus_connection_set_exit_on_close          (GDBusConnection    *connection,
146                                                                gboolean            exit_on_close);
147 GLIB_AVAILABLE_IN_ALL
148 GDBusCapabilityFlags  g_dbus_connection_get_capabilities      (GDBusConnection    *connection);
149
150 /* ---------------------------------------------------------------------------------------------------- */
151
152 GLIB_AVAILABLE_IN_ALL
153 void             g_dbus_connection_close                          (GDBusConnection     *connection,
154                                                                    GCancellable        *cancellable,
155                                                                    GAsyncReadyCallback  callback,
156                                                                    gpointer             user_data);
157 GLIB_AVAILABLE_IN_ALL
158 gboolean         g_dbus_connection_close_finish                   (GDBusConnection     *connection,
159                                                                    GAsyncResult        *res,
160                                                                    GError             **error);
161 GLIB_AVAILABLE_IN_ALL
162 gboolean         g_dbus_connection_close_sync                     (GDBusConnection     *connection,
163                                                                    GCancellable        *cancellable,
164                                                                    GError             **error);
165
166 /* ---------------------------------------------------------------------------------------------------- */
167
168 GLIB_AVAILABLE_IN_ALL
169 void             g_dbus_connection_flush                          (GDBusConnection     *connection,
170                                                                    GCancellable        *cancellable,
171                                                                    GAsyncReadyCallback  callback,
172                                                                    gpointer             user_data);
173 GLIB_AVAILABLE_IN_ALL
174 gboolean         g_dbus_connection_flush_finish                   (GDBusConnection     *connection,
175                                                                    GAsyncResult        *res,
176                                                                    GError             **error);
177 GLIB_AVAILABLE_IN_ALL
178 gboolean         g_dbus_connection_flush_sync                     (GDBusConnection     *connection,
179                                                                    GCancellable        *cancellable,
180                                                                    GError             **error);
181
182 /* ---------------------------------------------------------------------------------------------------- */
183
184 GLIB_AVAILABLE_IN_ALL
185 gboolean         g_dbus_connection_send_message                   (GDBusConnection     *connection,
186                                                                    GDBusMessage        *message,
187                                                                    GDBusSendMessageFlags flags,
188                                                                    volatile guint32    *out_serial,
189                                                                    GError             **error);
190 GLIB_AVAILABLE_IN_ALL
191 void             g_dbus_connection_send_message_with_reply        (GDBusConnection     *connection,
192                                                                    GDBusMessage        *message,
193                                                                    GDBusSendMessageFlags flags,
194                                                                    gint                 timeout_msec,
195                                                                    volatile guint32    *out_serial,
196                                                                    GCancellable        *cancellable,
197                                                                    GAsyncReadyCallback  callback,
198                                                                    gpointer             user_data);
199 GLIB_AVAILABLE_IN_ALL
200 GDBusMessage    *g_dbus_connection_send_message_with_reply_finish (GDBusConnection     *connection,
201                                                                    GAsyncResult        *res,
202                                                                    GError             **error);
203 GLIB_AVAILABLE_IN_ALL
204 GDBusMessage    *g_dbus_connection_send_message_with_reply_sync   (GDBusConnection     *connection,
205                                                                    GDBusMessage        *message,
206                                                                    GDBusSendMessageFlags flags,
207                                                                    gint                 timeout_msec,
208                                                                    volatile guint32    *out_serial,
209                                                                    GCancellable        *cancellable,
210                                                                    GError             **error);
211
212 /* ---------------------------------------------------------------------------------------------------- */
213
214 GLIB_AVAILABLE_IN_ALL
215 gboolean  g_dbus_connection_emit_signal                       (GDBusConnection    *connection,
216                                                                const gchar        *destination_bus_name,
217                                                                const gchar        *object_path,
218                                                                const gchar        *interface_name,
219                                                                const gchar        *signal_name,
220                                                                GVariant           *parameters,
221                                                                GError            **error);
222 GLIB_AVAILABLE_IN_ALL
223 void      g_dbus_connection_call                              (GDBusConnection    *connection,
224                                                                const gchar        *bus_name,
225                                                                const gchar        *object_path,
226                                                                const gchar        *interface_name,
227                                                                const gchar        *method_name,
228                                                                GVariant           *parameters,
229                                                                const GVariantType *reply_type,
230                                                                GDBusCallFlags      flags,
231                                                                gint                timeout_msec,
232                                                                GCancellable       *cancellable,
233                                                                GAsyncReadyCallback callback,
234                                                                gpointer            user_data);
235 GLIB_AVAILABLE_IN_ALL
236 GVariant *g_dbus_connection_call_finish                       (GDBusConnection    *connection,
237                                                                GAsyncResult       *res,
238                                                                GError            **error);
239 GLIB_AVAILABLE_IN_ALL
240 GVariant *g_dbus_connection_call_sync                         (GDBusConnection    *connection,
241                                                                const gchar        *bus_name,
242                                                                const gchar        *object_path,
243                                                                const gchar        *interface_name,
244                                                                const gchar        *method_name,
245                                                                GVariant           *parameters,
246                                                                const GVariantType *reply_type,
247                                                                GDBusCallFlags      flags,
248                                                                gint                timeout_msec,
249                                                                GCancellable       *cancellable,
250                                                                GError            **error);
251 GLIB_AVAILABLE_IN_2_30
252 void      g_dbus_connection_call_with_unix_fd_list            (GDBusConnection    *connection,
253                                                                const gchar        *bus_name,
254                                                                const gchar        *object_path,
255                                                                const gchar        *interface_name,
256                                                                const gchar        *method_name,
257                                                                GVariant           *parameters,
258                                                                const GVariantType *reply_type,
259                                                                GDBusCallFlags      flags,
260                                                                gint                timeout_msec,
261                                                                GUnixFDList        *fd_list,
262                                                                GCancellable       *cancellable,
263                                                                GAsyncReadyCallback callback,
264                                                                gpointer            user_data);
265 GLIB_AVAILABLE_IN_2_30
266 GVariant *g_dbus_connection_call_with_unix_fd_list_finish     (GDBusConnection    *connection,
267                                                                GUnixFDList       **out_fd_list,
268                                                                GAsyncResult       *res,
269                                                                GError            **error);
270 GLIB_AVAILABLE_IN_2_30
271 GVariant *g_dbus_connection_call_with_unix_fd_list_sync       (GDBusConnection    *connection,
272                                                                const gchar        *bus_name,
273                                                                const gchar        *object_path,
274                                                                const gchar        *interface_name,
275                                                                const gchar        *method_name,
276                                                                GVariant           *parameters,
277                                                                const GVariantType *reply_type,
278                                                                GDBusCallFlags      flags,
279                                                                gint                timeout_msec,
280                                                                GUnixFDList        *fd_list,
281                                                                GUnixFDList       **out_fd_list,
282                                                                GCancellable       *cancellable,
283                                                                GError            **error);
284
285 /* ---------------------------------------------------------------------------------------------------- */
286
287
288 /**
289  * GDBusInterfaceMethodCallFunc:
290  * @connection: A #GDBusConnection.
291  * @sender: The unique bus name of the remote caller.
292  * @object_path: The object path that the method was invoked on.
293  * @interface_name: The D-Bus interface name the method was invoked on.
294  * @method_name: The name of the method that was invoked.
295  * @parameters: A #GVariant tuple with parameters.
296  * @invocation: (transfer full): A #GDBusMethodInvocation object that must be used to return a value or error.
297  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object().
298  *
299  * The type of the @method_call function in #GDBusInterfaceVTable.
300  *
301  * Since: 2.26
302  */
303 typedef void (*GDBusInterfaceMethodCallFunc) (GDBusConnection       *connection,
304                                               const gchar           *sender,
305                                               const gchar           *object_path,
306                                               const gchar           *interface_name,
307                                               const gchar           *method_name,
308                                               GVariant              *parameters,
309                                               GDBusMethodInvocation *invocation,
310                                               gpointer               user_data);
311
312 /**
313  * GDBusInterfaceGetPropertyFunc:
314  * @connection: A #GDBusConnection.
315  * @sender: The unique bus name of the remote caller.
316  * @object_path: The object path that the method was invoked on.
317  * @interface_name: The D-Bus interface name for the property.
318  * @property_name: The name of the property to get the value of.
319  * @error: Return location for error.
320  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object().
321  *
322  * The type of the @get_property function in #GDBusInterfaceVTable.
323  *
324  * Returns: A #GVariant with the value for @property_name or %NULL if
325  *     @error is set. If the returned #GVariant is floating, it is
326  *     consumed - otherwise its reference count is decreased by one.
327  *
328  * Since: 2.26
329  */
330 typedef GVariant *(*GDBusInterfaceGetPropertyFunc) (GDBusConnection       *connection,
331                                                     const gchar           *sender,
332                                                     const gchar           *object_path,
333                                                     const gchar           *interface_name,
334                                                     const gchar           *property_name,
335                                                     GError               **error,
336                                                     gpointer               user_data);
337
338 /**
339  * GDBusInterfaceSetPropertyFunc:
340  * @connection: A #GDBusConnection.
341  * @sender: The unique bus name of the remote caller.
342  * @object_path: The object path that the method was invoked on.
343  * @interface_name: The D-Bus interface name for the property.
344  * @property_name: The name of the property to get the value of.
345  * @value: The value to set the property to.
346  * @error: Return location for error.
347  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object().
348  *
349  * The type of the @set_property function in #GDBusInterfaceVTable.
350  *
351  * Returns: %TRUE if the property was set to @value, %FALSE if @error is set.
352  *
353  * Since: 2.26
354  */
355 typedef gboolean  (*GDBusInterfaceSetPropertyFunc) (GDBusConnection       *connection,
356                                                     const gchar           *sender,
357                                                     const gchar           *object_path,
358                                                     const gchar           *interface_name,
359                                                     const gchar           *property_name,
360                                                     GVariant              *value,
361                                                     GError               **error,
362                                                     gpointer               user_data);
363
364 /**
365  * GDBusInterfaceVTable:
366  * @method_call: Function for handling incoming method calls.
367  * @get_property: Function for getting a property.
368  * @set_property: Function for setting a property.
369  *
370  * Virtual table for handling properties and method calls for a D-Bus
371  * interface.
372  *
373  * Since 2.38, if you want to handle getting/setting D-Bus properties
374  * asynchronously, give %NULL as your get_property() or set_property()
375  * function. The D-Bus call will be directed to your @method_call function,
376  * with the provided @interface_name set to "org.freedesktop.DBus.Properties".
377  *
378  * Ownership of the #GDBusMethodInvocation object passed to the
379  * method_call() function is transferred to your handler; you must
380  * call one of the methods of #GDBusMethodInvocation to return a reply
381  * (possibly empty), or an error. These functions also take ownership
382  * of the passed-in invocation object, so unless the invocation
383  * object has otherwise been referenced, it will be then be freed.
384  * Calling one of these functions may be done within your
385  * method_call() implementation but it also can be done at a later
386  * point to handle the method asynchronously.
387  *
388  * The usual checks on the validity of the calls is performed. For
389  * `Get` calls, an error is automatically returned if the property does
390  * not exist or the permissions do not allow access. The same checks are
391  * performed for `Set` calls, and the provided value is also checked for
392  * being the correct type.
393  *
394  * For both `Get` and `Set` calls, the #GDBusMethodInvocation
395  * passed to the @method_call handler can be queried with
396  * g_dbus_method_invocation_get_property_info() to get a pointer
397  * to the #GDBusPropertyInfo of the property.
398  *
399  * If you have readable properties specified in your interface info,
400  * you must ensure that you either provide a non-%NULL @get_property()
401  * function or provide implementations of both the `Get` and `GetAll`
402  * methods on org.freedesktop.DBus.Properties interface in your @method_call
403  * function. Note that the required return type of the `Get` call is
404  * `(v)`, not the type of the property. `GetAll` expects a return value
405  * of type `a{sv}`.
406  *
407  * If you have writable properties specified in your interface info,
408  * you must ensure that you either provide a non-%NULL @set_property()
409  * function or provide an implementation of the `Set` call. If implementing
410  * the call, you must return the value of type %G_VARIANT_TYPE_UNIT.
411  *
412  * Since: 2.26
413  */
414 struct _GDBusInterfaceVTable
415 {
416   GDBusInterfaceMethodCallFunc  method_call;
417   GDBusInterfaceGetPropertyFunc get_property;
418   GDBusInterfaceSetPropertyFunc set_property;
419
420   /*< private >*/
421   /* Padding for future expansion - also remember to update
422    * gdbusconnection.c:_g_dbus_interface_vtable_copy() when
423    * changing this.
424    */
425   gpointer padding[8];
426 };
427
428 GLIB_AVAILABLE_IN_ALL
429 guint            g_dbus_connection_register_object            (GDBusConnection            *connection,
430                                                                const gchar                *object_path,
431                                                                GDBusInterfaceInfo         *interface_info,
432                                                                const GDBusInterfaceVTable *vtable,
433                                                                gpointer                    user_data,
434                                                                GDestroyNotify              user_data_free_func,
435                                                                GError                    **error);
436 GLIB_AVAILABLE_IN_ALL
437 gboolean         g_dbus_connection_unregister_object          (GDBusConnection            *connection,
438                                                                guint                       registration_id);
439
440 /* ---------------------------------------------------------------------------------------------------- */
441
442 /**
443  * GDBusSubtreeEnumerateFunc:
444  * @connection: A #GDBusConnection.
445  * @sender: The unique bus name of the remote caller.
446  * @object_path: The object path that was registered with g_dbus_connection_register_subtree().
447  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
448  *
449  * The type of the @enumerate function in #GDBusSubtreeVTable.
450  *
451  * This function is called when generating introspection data and also
452  * when preparing to dispatch incoming messages in the event that the
453  * %G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is not
454  * specified (ie: to verify that the object path is valid).
455  *
456  * Hierarchies are not supported; the items that you return should not
457  * contain the '/' character.
458  *
459  * The return value will be freed with g_strfreev().
460  *
461  * Returns: A newly allocated array of strings for node names that are children of @object_path.
462  *
463  * Since: 2.26
464  */
465 typedef gchar** (*GDBusSubtreeEnumerateFunc) (GDBusConnection       *connection,
466                                               const gchar           *sender,
467                                               const gchar           *object_path,
468                                               gpointer               user_data);
469
470 /**
471  * GDBusSubtreeIntrospectFunc:
472  * @connection: A #GDBusConnection.
473  * @sender: The unique bus name of the remote caller.
474  * @object_path: The object path that was registered with g_dbus_connection_register_subtree().
475  * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree.
476  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
477  *
478  * The type of the @introspect function in #GDBusSubtreeVTable.
479  *
480  * Subtrees are flat.  @node, if non-%NULL, is always exactly one
481  * segment of the object path (ie: it never contains a slash).
482  *
483  * This function should return %NULL to indicate that there is no object
484  * at this node.
485  *
486  * If this function returns non-%NULL, the return value is expected to
487  * be a %NULL-terminated array of pointers to #GDBusInterfaceInfo
488  * structures describing the interfaces implemented by @node.  This
489  * array will have g_dbus_interface_info_unref() called on each item
490  * before being freed with g_free().
491  *
492  * The difference between returning %NULL and an array containing zero
493  * items is that the standard DBus interfaces will returned to the
494  * remote introspector in the empty array case, but not in the %NULL
495  * case.
496  *
497  * Returns: A %NULL-terminated array of pointers to #GDBusInterfaceInfo, or %NULL.
498  *
499  * Since: 2.26
500  */
501 typedef GDBusInterfaceInfo ** (*GDBusSubtreeIntrospectFunc) (GDBusConnection       *connection,
502                                                              const gchar           *sender,
503                                                              const gchar           *object_path,
504                                                              const gchar           *node,
505                                                              gpointer               user_data);
506
507 /**
508  * GDBusSubtreeDispatchFunc:
509  * @connection: A #GDBusConnection.
510  * @sender: The unique bus name of the remote caller.
511  * @object_path: The object path that was registered with g_dbus_connection_register_subtree().
512  * @interface_name: The D-Bus interface name that the method call or property access is for.
513  * @node: A node that is a child of @object_path (relative to @object_path) or %NULL for the root of the subtree.
514  * @out_user_data: Return location for user data to pass to functions in the returned #GDBusInterfaceVTable (never %NULL).
515  * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_subtree().
516  *
517  * The type of the @dispatch function in #GDBusSubtreeVTable.
518  *
519  * Subtrees are flat.  @node, if non-%NULL, is always exactly one
520  * segment of the object path (ie: it never contains a slash).
521  *
522  * Returns: A #GDBusInterfaceVTable or %NULL if you don't want to handle the methods.
523  *
524  * Since: 2.26
525  */
526 typedef const GDBusInterfaceVTable * (*GDBusSubtreeDispatchFunc) (GDBusConnection             *connection,
527                                                                   const gchar                 *sender,
528                                                                   const gchar                 *object_path,
529                                                                   const gchar                 *interface_name,
530                                                                   const gchar                 *node,
531                                                                   gpointer                    *out_user_data,
532                                                                   gpointer                     user_data);
533
534 /**
535  * GDBusSubtreeVTable:
536  * @enumerate: Function for enumerating child nodes.
537  * @introspect: Function for introspecting a child node.
538  * @dispatch: Function for dispatching a remote call on a child node.
539  *
540  * Virtual table for handling subtrees registered with g_dbus_connection_register_subtree().
541  *
542  * Since: 2.26
543  */
544 struct _GDBusSubtreeVTable
545 {
546   GDBusSubtreeEnumerateFunc  enumerate;
547   GDBusSubtreeIntrospectFunc introspect;
548   GDBusSubtreeDispatchFunc   dispatch;
549
550   /*< private >*/
551   /* Padding for future expansion - also remember to update
552    * gdbusconnection.c:_g_dbus_subtree_vtable_copy() when
553    * changing this.
554    */
555   gpointer padding[8];
556 };
557
558 GLIB_AVAILABLE_IN_ALL
559 guint            g_dbus_connection_register_subtree           (GDBusConnection            *connection,
560                                                                const gchar                *object_path,
561                                                                const GDBusSubtreeVTable   *vtable,
562                                                                GDBusSubtreeFlags           flags,
563                                                                gpointer                    user_data,
564                                                                GDestroyNotify              user_data_free_func,
565                                                                GError                    **error);
566 GLIB_AVAILABLE_IN_ALL
567 gboolean         g_dbus_connection_unregister_subtree         (GDBusConnection            *connection,
568                                                                guint                       registration_id);
569
570 /* ---------------------------------------------------------------------------------------------------- */
571
572 /**
573  * GDBusSignalCallback:
574  * @connection: A #GDBusConnection.
575  * @sender_name: The unique bus name of the sender of the signal.
576  * @object_path: The object path that the signal was emitted on.
577  * @interface_name: The name of the interface.
578  * @signal_name: The name of the signal.
579  * @parameters: A #GVariant tuple with parameters for the signal.
580  * @user_data: User data passed when subscribing to the signal.
581  *
582  * Signature for callback function used in g_dbus_connection_signal_subscribe().
583  *
584  * Since: 2.26
585  */
586 typedef void (*GDBusSignalCallback) (GDBusConnection  *connection,
587                                      const gchar      *sender_name,
588                                      const gchar      *object_path,
589                                      const gchar      *interface_name,
590                                      const gchar      *signal_name,
591                                      GVariant         *parameters,
592                                      gpointer          user_data);
593
594 GLIB_AVAILABLE_IN_ALL
595 guint            g_dbus_connection_signal_subscribe           (GDBusConnection     *connection,
596                                                                const gchar         *sender,
597                                                                const gchar         *interface_name,
598                                                                const gchar         *member,
599                                                                const gchar         *object_path,
600                                                                const gchar         *arg0,
601                                                                GDBusSignalFlags     flags,
602                                                                GDBusSignalCallback  callback,
603                                                                gpointer             user_data,
604                                                                GDestroyNotify       user_data_free_func);
605 GLIB_AVAILABLE_IN_ALL
606 void             g_dbus_connection_signal_unsubscribe         (GDBusConnection     *connection,
607                                                                guint                subscription_id);
608
609 /* ---------------------------------------------------------------------------------------------------- */
610
611 /**
612  * GDBusMessageFilterFunction:
613  * @connection: (transfer none): A #GDBusConnection.
614  * @message: (transfer full): A locked #GDBusMessage that the filter function takes ownership of.
615  * @incoming: %TRUE if it is a message received from the other peer, %FALSE if it is
616  * a message to be sent to the other peer.
617  * @user_data: User data passed when adding the filter.
618  *
619  * Signature for function used in g_dbus_connection_add_filter().
620  *
621  * A filter function is passed a #GDBusMessage and expected to return
622  * a #GDBusMessage too. Passive filter functions that don't modify the
623  * message can simply return the @message object:
624  * |[
625  * static GDBusMessage *
626  * passive_filter (GDBusConnection *connection
627  *                 GDBusMessage    *message,
628  *                 gboolean         incoming,
629  *                 gpointer         user_data)
630  * {
631  *   /<!-- -->* inspect @message *<!-- -->/
632  *   return message;
633  * }
634  * ]|
635  * Filter functions that wants to drop a message can simply return %NULL:
636  * |[
637  * static GDBusMessage *
638  * drop_filter (GDBusConnection *connection
639  *              GDBusMessage    *message,
640  *              gboolean         incoming,
641  *              gpointer         user_data)
642  * {
643  *   if (should_drop_message)
644  *     {
645  *       g_object_unref (message);
646  *       message = NULL;
647  *     }
648  *   return message;
649  * }
650  * ]|
651  * Finally, a filter function may modify a message by copying it:
652  * |[
653  * static GDBusMessage *
654  * modifying_filter (GDBusConnection *connection
655  *                   GDBusMessage    *message,
656  *                   gboolean         incoming,
657  *                   gpointer         user_data)
658  * {
659  *   GDBusMessage *copy;
660  *   GError *error;
661  *
662  *   error = NULL;
663  *   copy = g_dbus_message_copy (message, &error);
664  *   /<!-- -->* handle @error being is set *<!-- -->/
665  *   g_object_unref (message);
666  *
667  *   /<!-- -->* modify @copy *<!-- -->/
668  *
669  *   return copy;
670  * }
671  * ]|
672  * If the returned #GDBusMessage is different from @message and cannot
673  * be sent on @connection (it could use features, such as file
674  * descriptors, not compatible with @connection), then a warning is
675  * logged to <emphasis>standard error</emphasis>. Applications can
676  * check this ahead of time using g_dbus_message_to_blob() passing a
677  * #GDBusCapabilityFlags value obtained from @connection.
678  *
679  * Returns: (transfer full) (allow-none): A #GDBusMessage that will be freed with
680  * g_object_unref() or %NULL to drop the message. Passive filter
681  * functions can simply return the passed @message object.
682  *
683  * Since: 2.26
684  */
685 typedef GDBusMessage *(*GDBusMessageFilterFunction) (GDBusConnection *connection,
686                                                      GDBusMessage    *message,
687                                                      gboolean         incoming,
688                                                      gpointer         user_data);
689
690 GLIB_AVAILABLE_IN_ALL
691 guint g_dbus_connection_add_filter (GDBusConnection            *connection,
692                                     GDBusMessageFilterFunction  filter_function,
693                                     gpointer                    user_data,
694                                     GDestroyNotify              user_data_free_func);
695
696 GLIB_AVAILABLE_IN_ALL
697 void  g_dbus_connection_remove_filter (GDBusConnection    *connection,
698                                        guint               filter_id);
699
700 /* ---------------------------------------------------------------------------------------------------- */
701
702
703 G_END_DECLS
704
705 #endif /* __G_DBUS_CONNECTION_H__ */