X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Finterfaces%2Fhostnamed%2Fhostnamed.c;h=dff5115875f1e03b1ab01e5f07655aa6e9be8404;hb=7ce16a3590b7a8822dc56fe17dddf15035a0dfdb;hp=9f152dfb22a781121c51091e4571e66cca8b3088;hpb=44741a6edf0e14ce15c9e5a467b486b35a4372e0;p=systembsd.git diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c index 9f152df..dff5115 100644 --- a/src/interfaces/hostnamed/hostnamed.c +++ b/src/interfaces/hostnamed/hostnamed.c @@ -25,13 +25,54 @@ GPtrArray *hostnamed_freeable; GDBusNodeInfo *spect_data; +Hostname1 *hostnamed_interf; + +static gboolean +on_handle_set_hostname(Hostname1 *hn1_passed_interf, + GDBusMethodInvocation *invoc, + const gchar *greet, + gpointer data) { + return FALSE; +} + +static gboolean +on_handle_set_static_hostname(Hostname1 *hn1_passed_interf, + GDBusMethodInvocation *invoc, + const gchar *greet, + gpointer data) { + return FALSE; +} + +static gboolean +on_handle_set_pretty_hostname(Hostname1 *hn1_passed_interf, + GDBusMethodInvocation *invoc, + const gchar *greet, + gpointer data) { + return FALSE; +} + +static gboolean +on_handle_set_chassis(Hostname1 *hn1_passed_interf, + GDBusMethodInvocation *invoc, + const gchar *greet, + gpointer data) { + return FALSE; +} + +static gboolean +on_handle_set_icon_name(Hostname1 *hn1_passed_interf, + GDBusMethodInvocation *invoc, + const gchar *greet, + gpointer data) { + return FALSE; +} + +/* end method/property/signal code, begin bus/name handlers */ static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) { - GError *err; - g_print("got bus, name: %s\n", name); } @@ -40,7 +81,25 @@ static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) { - g_print("got name %s\n", name); + g_print("got '%s' on system bus\n", name); + + hostnamed_interf = hostname1_skeleton_new(); + + /* attach function pointers to generated vfunc table struct */ + g_signal_connect(hostnamed_interf, "handle-set-hostname", G_CALLBACK(on_handle_set_hostname), NULL); + g_signal_connect(hostnamed_interf, "handle-set-static-hostname", G_CALLBACK(on_handle_set_static_hostname), NULL); + g_signal_connect(hostnamed_interf, "handle-set-pretty-hostname", G_CALLBACK(on_handle_set_pretty_hostname), NULL); + g_signal_connect(hostnamed_interf, "handle-set-chassis", G_CALLBACK(on_handle_set_chassis), NULL); + g_signal_connect(hostnamed_interf, "handle-set-icon-name", G_CALLBACK(on_handle_set_icon_name), NULL); + + if(!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(hostnamed_interf), + conn, + "/org/freedesktop/hostname1", + NULL)) { + + g_printf("failed to export hostname1's interface on system bus!"); + } + } static void on_name_lost(GDBusConnection *conn, @@ -50,6 +109,7 @@ static void on_name_lost(GDBusConnection *conn, g_print("lost name %s, exiting...", name); hostnamed_mem_clean(); + g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(hostnamed_interf)); /* TODO exit through g_main_loop properly... */ }