1/* GDBus - GLib D-Bus Library
2 *
3 * Copyright (C) 2008-2010 Red Hat, Inc.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: David Zeuthen <davidz@redhat.com>
21 */
22
23#ifndef __G_DBUS_NAME_OWNING_H__
24#define __G_DBUS_NAME_OWNING_H__
25
26#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27#error "Only <gio/gio.h> can be included directly."
28#endif
29
30#include <gio/giotypes.h>
31
32G_BEGIN_DECLS
33
34/**
35 * GBusAcquiredCallback:
36 * @connection: the connection to a message bus
37 * @name: the name that is requested to be owned
38 * @user_data: user data passed to [func@Gio.bus_own_name]
39 *
40 * Invoked when a connection to a message bus has been obtained.
41 *
42 * Since: 2.26
43 */
44typedef void (*GBusAcquiredCallback) (GDBusConnection *connection,
45 const gchar *name,
46 gpointer user_data);
47
48/**
49 * GBusNameAcquiredCallback:
50 * @connection: the connection on which to acquired the name
51 * @name: the name being owned
52 * @user_data: user data passed to [func@Gio.bus_own_name] or
53 * [func@Gio.bus_own_name_on_connection]
54 *
55 * Invoked when the name is acquired.
56 *
57 * Since: 2.26
58 */
59typedef void (*GBusNameAcquiredCallback) (GDBusConnection *connection,
60 const gchar *name,
61 gpointer user_data);
62
63/**
64 * GBusNameLostCallback:
65 * @connection: the connect on which to acquire the name or `NULL` if
66 * the connection was disconnected
67 * @name: the name being owned
68 * @user_data: user data passed to [func@Gio.bus_own_name] or
69 * [func@Gio.bus_own_name_on_connection]
70 *
71 * Invoked when the name is lost or @connection has been closed.
72 *
73 * Since: 2.26
74 */
75typedef void (*GBusNameLostCallback) (GDBusConnection *connection,
76 const gchar *name,
77 gpointer user_data);
78
79GIO_AVAILABLE_IN_ALL
80guint g_bus_own_name (GBusType bus_type,
81 const gchar *name,
82 GBusNameOwnerFlags flags,
83 GBusAcquiredCallback bus_acquired_handler,
84 GBusNameAcquiredCallback name_acquired_handler,
85 GBusNameLostCallback name_lost_handler,
86 gpointer user_data,
87 GDestroyNotify user_data_free_func);
88
89GIO_AVAILABLE_IN_ALL
90guint g_bus_own_name_on_connection (GDBusConnection *connection,
91 const gchar *name,
92 GBusNameOwnerFlags flags,
93 GBusNameAcquiredCallback name_acquired_handler,
94 GBusNameLostCallback name_lost_handler,
95 gpointer user_data,
96 GDestroyNotify user_data_free_func);
97
98GIO_AVAILABLE_IN_ALL
99guint g_bus_own_name_with_closures (GBusType bus_type,
100 const gchar *name,
101 GBusNameOwnerFlags flags,
102 GClosure *bus_acquired_closure,
103 GClosure *name_acquired_closure,
104 GClosure *name_lost_closure);
105
106GIO_AVAILABLE_IN_ALL
107guint g_bus_own_name_on_connection_with_closures (
108 GDBusConnection *connection,
109 const gchar *name,
110 GBusNameOwnerFlags flags,
111 GClosure *name_acquired_closure,
112 GClosure *name_lost_closure);
113
114GIO_AVAILABLE_IN_ALL
115void g_bus_unown_name (guint owner_id);
116
117G_END_DECLS
118
119#endif /* __G_DBUS_NAME_OWNING_H__ */
120