3 GDBusNodeInfo
*spect_data
;
5 static void handle_method_call(GDBusConnection
*conn
,
8 const gchar
*interf_name
,
9 const gchar
*method_name
,
11 GDBusMethodInvocation
*invc
,
14 //if(g_strcmp0(method_name, "Introspect"
16 GVariant
*xml_ret_gvar
;
19 g_dbus_interface_info_generate_xml(spect_data
->interfaces
[0], (guint
)0, xml_ret
);
20 xml_ret_gvar
= g_variant_new_string(xml_ret
->str
);
21 g_dbus_method_invocation_return_value(invc
, xml_ret_gvar
);
25 static GVariant
* handle_get_property(GDBusConnection
*conn
,
27 const gchar
*obj_path
,
28 const gchar
*interf_name
,
29 const gchar
*prop_name
,
38 static gboolean
handle_set_property(GDBusConnection
*conn
,
40 const gchar
*obj_path
,
41 const gchar
*interf_name
,
42 const gchar
*prop_name
,
47 g_dbus_connection_emit_signal(conn
,
50 "org.freedesktop.DBus.Properties",
58 /* "hot" functions initially passed to gdbus */
59 static const GDBusInterfaceVTable interface_vtable
=
66 /* end method/property functions, begin bus name handlers
67 * TODO: these should be intertwined as to handle edge cases
68 * for when the system cannot immediately grab the name, as
69 * well as cases where the system unintendedly loses the name
71 static void on_bus_acquired(GDBusConnection
*conn
,
74 g_print("got bus, name: %s\n", name
);
78 reg_id
= g_dbus_connection_register_object(conn
,
79 "/org/freedesktop/hostname1",
80 spect_data
->interfaces
[0],
87 static void on_name_acquired(GDBusConnection
*conn
,
91 g_print("got name %s\n", name
);
94 static void on_name_lost(GDBusConnection
*conn
,
98 g_print("lost name %s, exiting...", name
);
99 //TODO exit through g_main_loop properly...
103 /* safe call to try and start hostnamed */
104 GError
* hostnamed_init() {
106 guint bus_descriptor
;
109 bus_descriptor
= g_bus_own_name(G_BUS_TYPE_SYSTEM
,
110 (gchar
*)"org.freedesktop.hostname1",
111 G_BUS_NAME_OWNER_FLAGS_NONE
,
118 //TODO: malloc and return reference as if a main() closed