From 40feefe6dc7dd4349182c0b4e7cdf045e4b658fa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 3 Oct 2009 19:18:59 +0200 Subject: [PATCH] screen_file: don't use mpdclient_filelist_get() Use libmpdclient's mpd_send_list_meta() instead. This way, we don't have to use filelist_prepend() to the first NULL entry. --- src/screen_file.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/screen_file.c b/src/screen_file.c index 116d329..43c28c2 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -54,16 +54,29 @@ screen_file_repaint(void) static void screen_file_reload(struct mpdclient *c) { + struct mpd_connection *connection; + if (browser.filelist != NULL) filelist_free(browser.filelist); - browser.filelist = mpdclient_filelist_get(c, current_path); - if (browser.filelist == NULL) - browser.filelist = filelist_new(); - + browser.filelist = filelist_new(); if (*current_path != 0) /* add a dummy entry for ./.. */ - filelist_prepend(browser.filelist, NULL); + filelist_append(browser.filelist, NULL); + + if (!mpdclient_is_connected(c)) + return; + + connection = c->connection; + + mpd_send_list_meta(connection, current_path); + filelist_recv(browser.filelist, connection); + + if (mpd_response_finish(connection)) + filelist_sort_dir_play(browser.filelist, + compare_filelist_entry_path); + else + mpdclient_handle_error(c); } /** -- 2.30.2