summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@gmail.com>2014-04-03 23:57:58 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2014-04-04 10:25:33 +0300
commit07a16c4a403ae93c0ea5500315eac8a68fedb7b2 (patch)
tree7094791c6614b66ba79dd17e0ced76b87b60ccca /client
parenta864bd5532afe4e0f4d82189486b51ccacfdc636 (diff)
downloadbluez-07a16c4a403ae93c0ea5500315eac8a68fedb7b2.tar.gz
client: Add support for printing property of array type
This allows to print UUIDs in user friendly fasion. Only string type support is needed. [CHG] Device XX:XX:XX:XX:XX:XX UUIDs: 00000002-0000-1000-8000-0002ee000002 00001101-0000-1000-8000-00805f9b34fb 00001103-0000-1000-8000-00805f9b34fb 00001104-0000-1000-8000-00805f9b34fb 00001105-0000-1000-8000-00805f9b34fb instead of: [CHG] Device XX:XX:XX:XX:XX:XX UUIDs has unsupported type
Diffstat (limited to 'client')
-rw-r--r--client/main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/client/main.c b/client/main.c
index 5791e9566..5a9d41a28 100644
--- a/client/main.c
+++ b/client/main.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <signal.h>
#include <sys/signalfd.h>
@@ -153,6 +154,8 @@ static void print_iter(const char *label, const char *name,
dbus_uint16_t valu16;
dbus_int16_t vals16;
const char *valstr;
+ DBusMessageIter subiter;
+ int type;
if (iter == NULL) {
rl_printf("%s%s is nil\n", label, name);
@@ -185,6 +188,24 @@ static void print_iter(const char *label, const char *name,
dbus_message_iter_get_basic(iter, &vals16);
rl_printf("%s%s: %d\n", label, name, vals16);
break;
+ case DBUS_TYPE_ARRAY:
+ dbus_message_iter_recurse(iter, &subiter);
+ rl_printf("%s%s:\n", label, name);
+
+ do {
+ type = dbus_message_iter_get_arg_type(&subiter);
+ if (type == DBUS_TYPE_INVALID)
+ break;
+
+ if (type == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&subiter, &valstr);
+ rl_printf("\t%s\n", valstr);
+ }
+
+ dbus_message_iter_next(&subiter);
+ } while(true);
+
+ break;
default:
rl_printf("%s%s has unsupported type\n", label, name);
break;