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 GVariant
*xml_ret_gvar
;
17 g_dbus_interface_info_generate_xml(spect_data
->interfaces
[0], (guint
)0, xml_ret
);
18 xml_ret_gvar
= g_variant_new_string(xml_ret
->str
);
19 g_dbus_method_invocation_return_value(invc
, xml_ret_gvar
);
23 static GVariant
* handle_get_property(GDBusConnection
*conn
,
25 const gchar
*obj_path
,
26 const gchar
*interf_name
,
27 const gchar
*prop_name
,
36 static gboolean
handle_set_property(GDBusConnection
*conn
,
38 const gchar
*obj_path
,
39 const gchar
*interf_name
,
40 const gchar
*prop_name
,
45 g_dbus_connection_emit_signal(conn
,
48 "org.freedesktop.DBus.Properties",
56 /* "hot" functions initially passed to gdbus */
57 static const GDBusInterfaceVTable interface_vtable
=
64 /* end method/property functions, begin bus name handlers
65 * TODO: these should be intertwined as to handle edge cases
66 * for when the system cannot immediately grab the name, as
67 * well as cases where the system unintendedly loses the name
69 static void on_bus_acquired(GDBusConnection
*conn
,
75 g_print("got bus, name: %s\n", name
);
77 //GDBusObjectSkeleton *hostnamed_dbobj = g_dbus_object_skeleton_new("/org/freedesktop/hostname1");
79 g_dbus_connection_register_object(conn
,
80 "/org/freedesktop/hostname1",
81 spect_data
->interfaces
[0],
86 static void on_name_acquired(GDBusConnection
*conn
,
90 g_print("got name %s\n", name
);
93 static void on_name_lost(GDBusConnection
*conn
,
97 g_print("lost name %s, exiting...", name
);
98 //TODO exit through g_main_loop properly...
102 /* safe call to try and start hostnamed */
103 GError
* hostnamed_init() {
105 guint bus_descriptor
;
107 gchar
**hostnamed_ispect_xml
= g_malloc(3000);
108 gchar
*hostnamed_joined_xml
= g_malloc(3000);
110 g_file_get_contents("conf/hostnamed-ispect.xml", hostnamed_ispect_xml
, NULL
, err
);
111 hostnamed_joined_xml
= g_strjoinv("\n", hostnamed_ispect_xml
);
112 spect_data
= g_dbus_node_info_new_for_xml(hostnamed_joined_xml
, NULL
);
114 bus_descriptor
= g_bus_own_name(G_BUS_TYPE_SYSTEM
,
115 "org.freedesktop.hostname1",
116 G_BUS_NAME_OWNER_FLAGS_NONE
,
123 //TODO: malloc and return reference as if a main() closed