diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-12-14 19:50:59 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-14 19:50:59 +0100 |
commit | f32cddbf94ba0d0cfaa4180e1e7d350c058b2bd0 (patch) | |
tree | 84626c7d94fbc63e706da7faf37b943df7048f62 | |
parent | a0229390824d58ef0b49a4b67ca5be1bc642b088 (diff) |
client: Listen to property change notifications
-rw-r--r-- | client/main.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/client/main.c b/client/main.c index ff861d5b0..a4b674a9f 100644 --- a/client/main.c +++ b/client/main.c @@ -96,33 +96,44 @@ static void print_adapter(GDBusProxy *proxy, const char *description) } -static void print_property(GDBusProxy *proxy, const char *name) +static void print_iter(const char *label, const char *name, + DBusMessageIter *iter) { - DBusMessageIter iter; dbus_bool_t valbool; dbus_uint32_t val32; const char *valstr; - if (g_dbus_proxy_get_property(proxy, name, &iter) == FALSE) - return; - - switch (dbus_message_iter_get_arg_type(&iter)) { + switch (dbus_message_iter_get_arg_type(iter)) { + case DBUS_TYPE_INVALID: + printf("%s%s is inavlid\n", label, name); + break; case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: - dbus_message_iter_get_basic(&iter, &valstr); - printf("\t%s: %s\n", name, valstr); + dbus_message_iter_get_basic(iter, &valstr); + printf("%s%s: %s\n", label, name, valstr); break; case DBUS_TYPE_BOOLEAN: - dbus_message_iter_get_basic(&iter, &valbool); - printf("\t%s: %s\n", name, valbool == TRUE ? "yes" : "no"); + dbus_message_iter_get_basic(iter, &valbool); + printf("%s%s: %s\n", label, name, + valbool == TRUE ? "yes" : "no"); break; case DBUS_TYPE_UINT32: - dbus_message_iter_get_basic(&iter, &val32); - printf("\t%s: 0x%06x\n", name, val32); + dbus_message_iter_get_basic(iter, &val32); + printf("%s%s: 0x%06x\n", label, name, val32); break; } } +static void print_property(GDBusProxy *proxy, const char *name) +{ + DBusMessageIter iter; + + if (g_dbus_proxy_get_property(proxy, name, &iter) == FALSE) + return; + + print_iter("\t", name, &iter); +} + static void proxy_added(GDBusProxy *proxy, void *user_data) { const char *interface; @@ -159,6 +170,14 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) } } +static void property_changed(GDBusProxy *proxy, const char *name, + DBusMessageIter *iter, void *user_data) +{ + begin_message(); + print_iter("[CHANGED] ", name, iter); + end_message(); +} + static void message_handler(DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -702,8 +721,8 @@ int main(int argc, char *argv[]) g_dbus_client_set_disconnect_watch(client, disconnect_handler, NULL); g_dbus_client_set_signal_watch(client, message_handler, NULL); - g_dbus_client_set_proxy_handlers(client, proxy_added, - proxy_removed, NULL); + g_dbus_client_set_proxy_handlers(client, proxy_added, proxy_removed, + property_changed, NULL); g_main_loop_run(main_loop); |