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