1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* #include <glib-2.0/glib.h> */
#include <gio/gio.h>
static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) {
g_print("got bus, name: %s\n", name);
/* g_print("at %p, data @ %p\n", (void*)conn, user_data); */
}
static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) {
g_print("got name %s\n", name);
/* g_print("at %p, data @ %p\n", (void*)conn, user_data); */
}
static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) {
g_print("lost name %s\n", name);
/* g_print("at %p, data @ %p\n", (void*)conn, user_data); */
}
void hostnamed_init() {
guint bus_descriptor;
GError *err = NULL;
bus_descriptor = g_bus_own_name(G_BUS_TYPE_SYSTEM,
(gchar *)"org.freedesktop.hostname1",
G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired,
on_name_acquired,
on_name_lost,
NULL,
NULL);
}
|