From ea207ed3d155cde4001063c981f7a263c47daf64 Mon Sep 17 00:00:00 2001 From: kremlin Date: Tue, 27 May 2014 20:45:02 -0500 Subject: [PATCH 1/1] begin hostnamed, clean up --- Makefile | 4 ++-- src/main.c | 4 +++- src/modules/hostnamed/hostnamed.c | 35 ++++++++++++++++++++++++++++++- src/modules/hostnamed/tmp | 1 - src/test.c | 7 ------- 5 files changed, 39 insertions(+), 12 deletions(-) delete mode 100644 src/modules/hostnamed/tmp delete mode 100644 src/test.c diff --git a/Makefile b/Makefile index 4870271..27bff7a 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ DEBUGF=-O0 -v -g SRCDIR=src MODDIR=$(SRCDIR)/modules -GLIBF=`pkg-config --cflags --libs glib-2.0 gobject-2.0` +GLIBF=`pkg-config --cflags --libs glib-2.0 gobject-2.0 gio-2.0` hostnamed: - gcc -o bin/out.bin $(CFLAGS) $(DEBUGF) $(GLIBF) $(SRCDIR)/main.c + gcc -o bin/out.bin $(DEBUGF) $(GLIBF) $(SRCDIR)/main.c diff --git a/src/main.c b/src/main.c index 5238699..2ff00fd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,7 @@ #include "modules/hostnamed/hostnamed.c" int main() { + hostnamed_init(); + for(;;) {} return 0; -} +} diff --git a/src/modules/hostnamed/hostnamed.c b/src/modules/hostnamed/hostnamed.c index ee25324..f3632f6 100644 --- a/src/modules/hostnamed/hostnamed.c +++ b/src/modules/hostnamed/hostnamed.c @@ -1,2 +1,35 @@ -#include +/* #include */ +#include + +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); +} diff --git a/src/modules/hostnamed/tmp b/src/modules/hostnamed/tmp deleted file mode 100644 index c32d7ff..0000000 --- a/src/modules/hostnamed/tmp +++ /dev/null @@ -1 +0,0 @@ -TODO: delete me diff --git a/src/test.c b/src/test.c deleted file mode 100644 index 7a0d21a..0000000 --- a/src/test.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -#include - -int main() { - return 0; -} -- 2.41.0