From 630a3e581ccb83c5c69f006ab151655935321b6c Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 4 Jun 2013 09:49:01 +0700 Subject: tools/bluetooth-player: Add queue command Add support for queue command which can be used to add an item to the current playlist. --- tools/bluetooth-player.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tools/bluetooth-player.c') diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c index 91e3ea598..2380e8290 100644 --- a/tools/bluetooth-player.c +++ b/tools/bluetooth-player.c @@ -723,6 +723,46 @@ done: rl_printf("Attempting to list items\n"); } +static void add_to_nowplaying_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 queue: %s\n", error.name); + dbus_error_free(&error); + return; + } + + rl_printf("AddToNowPlaying successful\n"); +} + +static void cmd_queue(int argc, char *argv[]) +{ + GDBusProxy *proxy; + + if (argc < 2) { + rl_printf("Missing item address argument\n"); + return; + } + + proxy = find_item(argv[1]); + if (proxy == NULL) { + rl_printf("Item %s not available\n", argv[1]); + return; + } + + if (g_dbus_proxy_method_call(proxy, "AddtoNowPlaying", NULL, + add_to_nowplaying_reply, NULL, + NULL) == FALSE) { + rl_printf("Failed to play\n"); + return; + } + + rl_printf("Attempting to queue %s\n", argv[1]); +} + static const struct { const char *cmd; const char *arg; @@ -744,6 +784,7 @@ static const struct { "Change current folder" }, { "list-items", "[start] [end]", cmd_list_items, "List items of current folder" }, + { "queue", "", cmd_queue, "Add item to playlist queue" }, { "quit", NULL, cmd_quit, "Quit program" }, { "exit", NULL, cmd_quit }, { "help" }, -- cgit v1.2.1