1 /* #include <glib-2.0/glib.h> */
5 static GDBusNodeInfo
*spect_data
= NULL
;
6 static const gchar spect_xml
[] =
8 " <interface name='org.freedesktop.DBus.Peer'>"
9 " <method name='Ping'/>"
10 " <method name='GetMachineId'>"
11 " <arg type='s' name='machine_uuid' direction='out'/>"
14 " <interface name='org.freedesktop.DBus.Introspectable'>"
15 " <method name='Introspect'>"
16 " <arg name='data' type='s' direction='out'/>"
19 " <interface name='org.freedesktop.DBus.Properties'>"
20 " <method name='Get'>"
21 " <arg name='interface' direction='in' type='s'/>"
22 " <arg name='property' direction='in' type='s'/>"
23 " <arg name='value' direction='out' type='v'/>"
25 " <method name='GetAll'>"
26 " <arg name='interface' direction='in' type='s'/>"
27 " <arg name='properties' direction='out' type='a{sv}'/>"
29 " <method name='Set'>"
30 " <arg name='interface' direction='in' type='s'/>"
31 " <arg name='property' direction='in' type='s'/>"
32 " <arg name='value' direction='in' type='v'/>"
34 " <signal name='PropertiesChanged'>"
35 " <arg type='s' name='interface'/>"
36 " <arg type='a{sv}' name='changed_properties'/>"
37 " <arg type='as' name='invalidated_properties'/>"
40 " <interface name='org.freedesktop.hostname1'>"
41 " <property name='Hostname' type='s' access='read'>"
42 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='false'/>"
44 " <property name='StaticHostname' type='s' access='read'>"
46 " <property name='PrettyHostname' type='s' access='read'>"
48 " <property name='IconName' type='s' access='read'>"
50 " <property name='Chassis' type='s' access='read'>"
52 " <property name='KernelName' type='s' access='read'>"
53 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='const'/>"
55 " <property name='KernelRelease' type='s' access='read'>"
56 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='const'/>"
58 " <property name='KernelVersion' type='s' access='read'>"
59 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='const'/>"
61 " <property name='OperatingSystemPrettyName' type='s' access='read'>"
62 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='const'/>"
64 " <property name='OperatingSystemCPEName' type='s' access='read'>"
65 " <annotation name='org.freedesktop.DBus.Property.EmitsChangedSignal' value='const'/>"
67 " <method name='SetHostname'>"
68 " <arg type='s' direction='in'/>"
69 " <arg type='b' direction='in'/>"
71 " <method name='SetStaticHostname'>"
72 " <arg type='s' direction='in'/>"
73 " <arg type='b' direction='in'/>"
75 " <method name='SetPrettyHostname'>"
76 " <arg type='s' direction='in'/>"
77 " <arg type='b' direction='in'/>"
79 " <method name='SetIconName'>"
80 " <arg type='s' direction='in'/>"
81 " <arg type='b' direction='in'/>"
83 " <method name='SetChassis'>"
84 " <arg type='s' direction='in'/>"
85 " <arg type='b' direction='in'/>"
90 static void handle_method_call() {}
91 static GVariant
* handle_get_property() {return NULL
;}
92 static gboolean
handle_set_property() {return FALSE
;}
94 /* TODO: what's this guy do */
95 static const GDBusInterfaceVTable interface_vtable
=
104 static void on_bus_acquired(GDBusConnection
*conn
, const gchar
*name
, gpointer user_data
) {
105 g_print("got bus, name: %s\n", name
);
107 spect_data
= g_dbus_node_info_new_for_xml(spect_xml
, NULL
);
110 reg_id
= g_dbus_connection_register_object (conn
,
111 "/org/freedesktop/hostname1",
112 spect_data
->interfaces
[0],
117 g_assert(reg_id
> 0);
120 static void on_name_acquired(GDBusConnection
*conn
, const gchar
*name
, gpointer user_data
) {
121 g_print("got name %s\n", name
);
124 static void on_name_lost(GDBusConnection
*conn
, const gchar
*name
, gpointer user_data
) {
125 g_print("lost name %s\n", name
);
128 void hostnamed_init() {
130 guint bus_descriptor
;
133 bus_descriptor
= g_bus_own_name(G_BUS_TYPE_SYSTEM
,
134 (gchar
*)"org.freedesktop.hostname1",
135 G_BUS_NAME_OWNER_FLAGS_NONE
,