diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-06-01 23:42:47 +0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-06-10 11:06:45 +0300 |
commit | e3c4a32f930c531666f6e9868218dfa40dc3231d (patch) | |
tree | 28d7358451809ab8d98460387bcfc0919340758a /tools/bluetooth-player.c | |
parent | 7c804e29bb2823da9c3fa193134ce1fd92be6503 (diff) | |
download | bluez-e3c4a32f930c531666f6e9868218dfa40dc3231d.tar.gz |
tools/bluetooth-player: Add change-folder command
Add support for change-folder command which can be used to change
current folder.
Diffstat (limited to 'tools/bluetooth-player.c')
-rw-r--r-- | tools/bluetooth-player.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c index 7e115585e..c99e24c35 100644 --- a/tools/bluetooth-player.c +++ b/tools/bluetooth-player.c @@ -522,6 +522,55 @@ static void cmd_select(int argc, char *argv[]) print_player(proxy, NULL); } +static void change_folder_reply(DBusMessage *message, void *user_data) +{ + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == TRUE) { + rl_printf("Failed to change folder: %s\n", error.name); + dbus_error_free(&error); + return; + } + + rl_printf("ChangeFolder successful\n"); +} + +static void change_folder_setup(DBusMessageIter *iter, void *user_data) +{ + const char *path = user_data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path); +} + +static void cmd_change_folder(int argc, char *argv[]) +{ + GDBusProxy *proxy; + + if (argc < 2) { + rl_printf("Missing item argument\n"); + return; + } + + if (check_default_player() == FALSE) + return; + + proxy = find_folder(g_dbus_proxy_get_path(default_player)); + if (proxy == NULL) { + rl_printf("Operation not supported\n"); + return; + } + + if (g_dbus_proxy_method_call(proxy, "ChangeFolder", change_folder_setup, + change_folder_reply, argv[1], NULL) == FALSE) { + rl_printf("Failed to change current folder\n"); + return; + } + + rl_printf("Attempting to change folder\n"); +} + static const struct { const char *cmd; const char *arg; @@ -539,6 +588,8 @@ static const struct { { "fast-forward", NULL, cmd_fast_forward, "Fast forward playback" }, { "rewind", NULL, cmd_rewind, "Rewind playback" }, + { "change-folder", "<item>", cmd_change_folder, + "Change current folder" }, { "quit", NULL, cmd_quit, "Quit program" }, { "exit", NULL, cmd_quit }, { "help" }, |