diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-04-09 13:17:29 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-04-09 13:59:29 +0300 |
commit | 4899119cb29be10a78d21b8ab81f348eda38d7aa (patch) | |
tree | 398a7cde16ed994631c7ee3020175c02bfec7a17 /tools/obexctl.c | |
parent | 69907d0502ba5bbc3375b1e714508dca2a3d9caf (diff) | |
download | bluez-4899119cb29be10a78d21b8ab81f348eda38d7aa.tar.gz |
tools/obexctl: Add support for listing phonebook size
This adds option -l which in case of PBAP will use GetSize before listing
the contacts of the current folder.
Diffstat (limited to 'tools/obexctl.c')
-rw-r--r-- | tools/obexctl.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/tools/obexctl.c b/tools/obexctl.c index fc051d716..512a145a9 100644 --- a/tools/obexctl.c +++ b/tools/obexctl.c @@ -1281,13 +1281,8 @@ static void list_messages_setup(DBusMessageIter *iter, void *user_data) dbus_message_iter_close_container(iter, &dict); } -static void pbap_ls(GDBusProxy *proxy, int argc, char *argv[]) +static void pbap_list(GDBusProxy *proxy, int argc, char *argv[]) { - if (argc > 1) { - pbap_search(proxy, argc, argv); - return; - } - if (g_dbus_proxy_method_call(proxy, "List", list_setup, list_reply, NULL, NULL) == FALSE) { rl_printf("Failed to List\n"); @@ -1297,6 +1292,51 @@ static void pbap_ls(GDBusProxy *proxy, int argc, char *argv[]) rl_printf("Attempting to List\n"); } +static void get_size_reply(DBusMessage *message, void *user_data) +{ + GDBusProxy *proxy = user_data; + DBusError error; + DBusMessageIter iter; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == TRUE) { + rl_printf("Failed to GetSize: %s\n", error.name); + dbus_error_free(&error); + return; + } + + dbus_message_iter_init(message, &iter); + + print_iter("\t", "Size", &iter); + + pbap_list(proxy, 0, NULL); +} + +static void pbap_get_size(GDBusProxy *proxy, int argc, char *argv[]) +{ + if (g_dbus_proxy_method_call(proxy, "GetSize", NULL, get_size_reply, + proxy, NULL) == FALSE) { + rl_printf("Failed to GetSize\n"); + return; + } + + rl_printf("Attempting to GetSize\n"); +} + +static void pbap_ls(GDBusProxy *proxy, int argc, char *argv[]) +{ + if (argc > 1) { + if (strcmp("-l", argv[1])) + pbap_search(proxy, argc, argv); + else + pbap_get_size(proxy, argc, argv); + return; + } + + pbap_list(proxy, argc, argv); +} + static void map_ls_messages(GDBusProxy *proxy, int argc, char *argv[]) { if (g_dbus_proxy_method_call(proxy, "ListMessages", list_messages_setup, @@ -1940,7 +1980,7 @@ static const struct { { "resume", "<transfer>", cmd_resume, "Resume transfer" }, { "send", "<file>", cmd_send, "Send file" }, { "cd", "<path>", cmd_cd, "Change current folder" }, - { "ls", NULL, cmd_ls, "List current folder" }, + { "ls", "<options>", cmd_ls, "List current folder" }, { "cp", "<source file> <destination file>", cmd_cp, "Copy source file to destination file" }, { "mv", "<source file> <destination file>", cmd_mv, |