From: Max Kellermann Date: Tue, 29 Sep 2009 18:58:02 +0000 (+0200) Subject: screen_client: allow multiple queued database updates X-Git-Tag: release-0.16~302 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=be657bb1a475f238150124118054525bb248b7a4;p=ncmpc.git screen_client: allow multiple queued database updates MPD supports having multiple update paths in the queue. Let's just invoke the "update" command and see what MPD responds. --- diff --git a/NEWS b/NEWS index d6669c6..5664655 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ncmpc 0.16 - not yet released * using libmpdclient 2.0 instead of built-in libmpdclient +* allow multiple queued database updates ncmpc 0.15 - 2009-09-24 diff --git a/src/mpdclient.c b/src/mpdclient.c index 8324698..f6cd087 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -448,26 +448,6 @@ mpdclient_cmd_crossfade(struct mpdclient *c, gint value) return mpdclient_finish_command(c); } -gint -mpdclient_cmd_db_update(struct mpdclient *c, const gchar *path) -{ - gint ret; - - if (MPD_ERROR(c)) - return -1; - - mpd_send_update(c->connection, path ? path : ""); - ret = mpdclient_finish_command(c); - - if (ret == 0) - /* set updatingDb to make sure the browse callback - gets called even if the update has finished before - status is updated */ - c->updatingdb = 1; - - return ret; -} - gint mpdclient_cmd_volume(struct mpdclient *c, gint value) { diff --git a/src/mpdclient.h b/src/mpdclient.h index 735c505..52fcdb4 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -63,7 +63,6 @@ gint mpdclient_cmd_random(struct mpdclient *c, gint value); gint mpdclient_cmd_single(struct mpdclient *c, gint value); gint mpdclient_cmd_consume(struct mpdclient *c, gint value); gint mpdclient_cmd_crossfade(struct mpdclient *c, gint value); -gint mpdclient_cmd_db_update(struct mpdclient *c, const gchar *path); gint mpdclient_cmd_volume(struct mpdclient *c, gint value); gint mpdclient_cmd_volume_up(struct mpdclient *c); gint mpdclient_cmd_volume_down(struct mpdclient *c); diff --git a/src/screen_client.c b/src/screen_client.c index b5b31b5..51b10df 100644 --- a/src/screen_client.c +++ b/src/screen_client.c @@ -59,17 +59,25 @@ screen_auth(struct mpdclient *c) void screen_database_update(struct mpdclient *c, const char *path) { + unsigned id; + assert(c != NULL); assert(c->connection != NULL); - assert(c->status != NULL); - if (mpd_status_get_update_id(c->status) != 0) { - screen_status_printf(_("Database update running...")); + id = mpd_run_update(c->connection, path); + if (id == 0) { + if (mpd_connection_get_error(c->connection) == MPD_ERROR_SERVER && + mpd_connection_get_server_error(c->connection) == MPD_SERVER_ERROR_UPDATE_ALREADY) { + screen_status_printf(_("Database update running...")); + mpd_connection_clear_error(c->connection); + } else + mpdclient_handle_error(c); return; } - if (mpdclient_cmd_db_update(c, path) != 0) - return; + /* set updatingDb to make sure the browse callback gets called + even if the update has finished before status is updated */ + c->updatingdb = id; if (path != NULL && *path != 0) { char *path_locale = utf8_to_locale(path);