summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b4e56aa)
raw | patch | inline | side by side (parent: b4e56aa)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:58:02 +0000 (20:58 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:58:02 +0000 (20:58 +0200) |
MPD supports having multiple update paths in the queue. Let's just
invoke the "update" command and see what MPD responds.
invoke the "update" command and see what MPD responds.
NEWS | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/screen_client.c | patch | blob | history |
index d6669c6323efaf8c649fe4a541e9c3280f739fe3..566465527cd3d218c56acf42898e33979ffaa12b 100644 (file)
--- a/NEWS
+++ b/NEWS
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 83246989ba99350184d6dedb73e2a1b6c7023e59..f6cd087692482dd8bcdafb8062eed2a3cca7a072 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
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 735c505df7d25828d4ca5a56fb769f9c6e670e82..52fcdb45eb9be8030abbb5e0300ecadc412f649f 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
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 b5b31b5256b475e058d99b70e496be9d106e8183..51b10df9c7661795ad46590f5bab0d5cbca0e746 100644 (file)
--- a/src/screen_client.c
+++ b/src/screen_client.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);