X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Finterfaces%2Fhostnamed%2Fhostnamed.c;h=231bc4e2cd854def7e2f29c652d4ecfc622cbc37;hb=11475670562275e7c88bf91b988af014dfe8a4ca;hp=f41892d9991b6f4220c458920302d08d03561756;hpb=ff1030d487f7ce362452dac0d5c6e06248b0a38b;p=systembsd.git diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c index f41892d..231bc4e 100644 --- a/src/interfaces/hostnamed/hostnamed.c +++ b/src/interfaces/hostnamed/hostnamed.c @@ -1,7 +1,5 @@ #include -#include "hostnamed.h" -GMainLoop *loop; GDBusNodeInfo *spect_data; static void handle_method_call(GDBusConnection *conn, @@ -13,10 +11,6 @@ static void handle_method_call(GDBusConnection *conn, GDBusMethodInvocation *invc, gpointer usrdat) { - //g_printf("%s wants to call %s, at %s with interface %s\n", sender, method_name, obj_path, interf_name); - - if(g_strcmp0(method_name, "Introspect" - GVariant *xml_ret_gvar; GString *xml_ret; @@ -75,17 +69,18 @@ static const GDBusInterfaceVTable interface_vtable = static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) { - g_print("got bus, name: %s\n", name); - - guint reg_id; - - reg_id = g_dbus_connection_register_object(conn, - "/org/freedesktop/hostname1", - spect_data->interfaces[0], - &interface_vtable, - NULL, - NULL, - NULL); + + GError *err; + + g_print("got bus, name: %s\n", name); + + //GDBusObjectSkeleton *hostnamed_dbobj = g_dbus_object_skeleton_new("/org/freedesktop/hostname1"); + + g_dbus_connection_register_object(conn, + "/org/freedesktop/hostname1", + spect_data->interfaces[0], + &interface_vtable, + NULL, NULL, NULL); } static void on_name_acquired(GDBusConnection *conn, @@ -99,20 +94,25 @@ static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) { - g_print("lost name %s, exiting...\n", name); - //g_print("you might need to run hacks/punch_config.sh\n"); - g_main_loop_quit(loop); + g_print("lost name %s, exiting...", name); + //TODO exit through g_main_loop properly... + exit(0); } /* safe call to try and start hostnamed */ GError * hostnamed_init() { guint bus_descriptor; - GError *err = NULL; + GError *err = NULL; + gchar **hostnamed_ispect_xml = g_malloc(3000); + gchar *hostnamed_joined_xml = g_malloc(3000); - spect_data = g_dbus_node_info_new_for_xml(SYSTEMD_HOSTNAMED_XML, &err); + g_file_get_contents("conf/hostnamed-ispect.xml", hostnamed_ispect_xml, NULL, err); + hostnamed_joined_xml = g_strjoinv("\n", hostnamed_ispect_xml); + spect_data = g_dbus_node_info_new_for_xml(hostnamed_joined_xml, NULL); + bus_descriptor = g_bus_own_name(G_BUS_TYPE_SYSTEM, - (gchar *)"org.freedesktop.hostname1", + "org.freedesktop.hostname1", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, @@ -120,9 +120,6 @@ GError * hostnamed_init() { NULL, NULL); - loop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(loop); - //TODO: malloc and return reference as if a main() closed return err; }