(3) add needed GLib headers, move loop and bus descr out of main into global
[systembsd.git] / src / interfaces / timedated / timedated.c
index 3f016cd43c1facdc75ae7d30a8d4446c33451327..8f30d01310630482fd0386a3ddf3c6dc6134f0d1 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <unistd.h>
 #include <limits.h>
+#include <signal.h>
 
 #include <sys/param.h>
 #include <string.h>
 #include <glib-unix.h>
 
 #include "timedated-gen.h"
+#include "timedated.h"
 
 GPtrArray *timedated_freeable;
 Timedate1 *timedated_interf;
 
-/* --- begin method/property/signal code --- */
+GMainLoop *timedated_loop;
+
+guint bus_descriptor;
+gboolean dbus_interface_exported; /* reliable because of gdbus operational guarantees */
+
+/* --- begin method/property/dbus signal code --- */
 
 /*static gboolean
 on_handle_set_hostname(Timedate1 *hn1_passed_interf,
@@ -57,7 +64,7 @@ our_get_hostname() {
        return strncpy(ret, hostname_buf, hostname_divider);
 }*/
 
-/* --- end method/property/signal code, begin bus/name handlers --- */
+/* --- end method/property/dbus signal code, begin bus/name handlers --- */
 
 static void timedated_on_bus_acquired(GDBusConnection *conn,
                                       const gchar *name,
@@ -91,15 +98,6 @@ static void timedated_on_name_acquired(GDBusConnection *conn,
 
 }
 
-/* --- end bus/name handlers, begin misc functions --- */
-
-/* free()'s */
-void timedated_mem_clean() {
-
-    g_ptr_array_foreach(timedated_freeable, (GFunc) g_free, NULL);
-       g_ptr_array_free(timedated_freeable, TRUE);
-}
-
 static void timedated_on_name_lost(GDBusConnection *conn,
                                    const gchar *name,
                                    gpointer user_data) {
@@ -111,10 +109,16 @@ static void timedated_on_name_lost(GDBusConnection *conn,
 
 }
 
-int main() {
+/* --- end bus/name handlers, begin misc unix functions --- */
 
-       guint bus_descriptor;
-       GMainLoop *timedated_loop;
+/* free()'s */
+void timedated_mem_clean() {
+
+    g_ptr_array_foreach(timedated_freeable, (GFunc) g_free, NULL);
+       g_ptr_array_free(timedated_freeable, TRUE);
+}
+
+int main() {
 
        timedated_loop = g_main_loop_new(NULL, TRUE);
        timedated_freeable = g_ptr_array_new();