OSDN Git Service

tools/bluetooth-player: Print playlist name in command show
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 1 Jun 2013 16:21:02 +0000 (23:21 +0700)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 10 Jun 2013 08:06:45 +0000 (11:06 +0300)
This makes command show to print playlist name if available

tools/bluetooth-player.c

index e6d97e2..7e11558 100644 (file)
@@ -431,10 +431,27 @@ static GDBusProxy *find_folder(const char *path)
        return NULL;
 }
 
+static GDBusProxy *find_item(const char *path)
+{
+       GSList *l;
+
+       for (l = items; l; l = g_slist_next(l)) {
+               GDBusProxy *proxy = l->data;
+
+               if (strcmp(path, g_dbus_proxy_get_path(proxy)) == 0)
+                       return proxy;
+       }
+
+       return NULL;
+}
+
 static void cmd_show(int argc, char *argv[])
 {
        GDBusProxy *proxy;
        GDBusProxy *folder;
+       GDBusProxy *item;
+       DBusMessageIter iter;
+       const char *path;
 
        if (argc < 2) {
                if (check_default_player() == FALSE)
@@ -468,6 +485,19 @@ static void cmd_show(int argc, char *argv[])
 
        print_property(folder, "Name");
        print_property(folder, "NumberOfItems");
+
+       if (!g_dbus_proxy_get_property(proxy, "Playlist", &iter))
+               return;
+
+       dbus_message_iter_get_basic(&iter, &path);
+
+       item = find_item(path);
+       if (item == NULL)
+               return;
+
+       rl_printf("Playlist %s\n", path);
+
+       print_property(item, "Name");
 }
 
 static void cmd_select(int argc, char *argv[])