summaryrefslogtreecommitdiff
path: root/tools/bluetooth-player.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-05-31 10:49:04 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2013-06-10 11:06:45 +0300
commit37f085ae5d62cc5fedbb20520e3e9cb6aa7126e9 (patch)
treedff9baae9021b058bcf5ee75803f26888345e007 /tools/bluetooth-player.c
parentccc7d6726fd92f6d69508ca04db9472ee0163c86 (diff)
downloadbluez-37f085ae5d62cc5fedbb20520e3e9cb6aa7126e9.tar.gz
tools/bluetooth-player: Add list command
Add support for list command which can be used to list available players
Diffstat (limited to 'tools/bluetooth-player.c')
-rw-r--r--tools/bluetooth-player.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
index b94c54ea7..55e7b199b 100644
--- a/tools/bluetooth-player.c
+++ b/tools/bluetooth-player.c
@@ -289,12 +289,47 @@ static void cmd_rewind(int argc, char *argv[])
rl_printf("Rewind playback\n");
}
+static char *player_description(GDBusProxy *proxy, const char *description)
+{
+ const char *path;
+
+ path = g_dbus_proxy_get_path(proxy);
+
+ return g_strdup_printf("%s%s%sPlayer %s ",
+ description ? "[" : "",
+ description ? : "",
+ description ? "] " : "",
+ path);
+}
+
+static void print_player(GDBusProxy *proxy, const char *description)
+{
+ char *str;
+
+ str = player_description(proxy, description);
+
+ rl_printf("%s%s\n", str, default_player == proxy ? "[default]" : "");
+
+ g_free(str);
+}
+
+static void cmd_list(int argc, char *arg[])
+{
+ GSList *l;
+
+ for (l = players; l; l = g_slist_next(l)) {
+ GDBusProxy *proxy = l->data;
+ print_player(proxy, NULL);
+ }
+}
+
static const struct {
const char *cmd;
const char *arg;
void (*func) (int argc, char *argv[]);
const char *desc;
} cmd_table[] = {
+ { "list", NULL, cmd_list, "List available players" },
{ "play", NULL, cmd_play, "Start playback" },
{ "pause", NULL, cmd_pause, "Pause playback" },
{ "stop", NULL, cmd_stop, "Stop playback" },
@@ -515,30 +550,6 @@ static guint setup_standard_input(void)
return source;
}
-static char *player_description(GDBusProxy *proxy, const char *description)
-{
- const char *path;
-
- path = g_dbus_proxy_get_path(proxy);
-
- return g_strdup_printf("%s%s%sPlayer %s ",
- description ? "[" : "",
- description ? : "",
- description ? "] " : "",
- path);
-}
-
-static void print_player(GDBusProxy *proxy, const char *description)
-{
- char *str;
-
- str = player_description(proxy, description);
-
- rl_printf("%s%s\n", str, default_player == proxy ? "[default]" : "");
-
- g_free(str);
-}
-
static void player_added(GDBusProxy *proxy)
{
players = g_slist_append(players, proxy);