summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d69c1f)
raw | patch | inline | side by side (parent: 6d69c1f)
author | Max Kellermann <max@duempel.org> | |
Thu, 7 Nov 2013 22:36:48 +0000 (23:36 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 7 Nov 2013 22:36:48 +0000 (23:36 +0100) |
Remove a few version checks and some fallback code.
NEWS | patch | blob | history | |
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history |
index c28c2518da86678f787f999dfdb3c4ef5ab97066..4b17bd8c41bd8c8c379ddad2f5d71e2e07efa3f2 100644 (file)
--- a/NEWS
+++ b/NEWS
ncmpc 0.22 - not yet released
* rename "playlist" to "queue"
+* require MPD 0.16
ncmpc 0.21 - (2013-04-11)
diff --git a/src/main.c b/src/main.c
index ffc310fcee2b183d862c77e9c2bf83f8166929df..33678eecb9c05c76367b76c23bc0459cbb7a8270 100644 (file)
--- a/src/main.c
+++ b/src/main.c
connection = mpdclient_get_connection(mpd);
#ifndef NCMPC_MINI
- /* quit if mpd is pre 0.11.0 - song id not supported by mpd */
- if (mpd_connection_cmp_server_version(connection, 0, 12, 0) < 0) {
+ /* quit if mpd is pre 0.14 - song id not supported by mpd */
+ if (mpd_connection_cmp_server_version(connection, 0, 16, 0) < 0) {
const unsigned *version =
mpd_connection_get_server_version(connection);
screen_status_printf(_("Error: MPD version %d.%d.%d is to old (%s needed)"),
version[0], version[1], version[2],
- "0.12.0");
+ "0.16.0");
mpdclient_disconnect(mpd);
doupdate();
}
#endif
- if (mpd_connection_cmp_server_version(connection,
- 0, 14, 0) >= 0)
- mpd->source = mpd_glib_new(connection,
- idle_callback, mpd);
+ mpd->source = mpd_glib_new(connection,
+ idle_callback, mpd);
name = connection_settings_name(connection);
screen_status_printf(_("Connected to %s"), name);
diff --git a/src/mpdclient.c b/src/mpdclient.c
index e55c1362482ece91917b22875f9dc9f671c339d3..359a765119f8045d877d48a6bedce252ced4a39d 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
mpd_command_list_begin(connection, false);
- if (mpd_connection_cmp_server_version(connection, 0, 16, 0) >= 0) {
- if (current < length - 1)
- mpd_send_delete_range(connection, current + 1, length);
- if (current > 0)
- mpd_send_delete_range(connection, 0, current);
- } else
- while (--length >= 0)
- if (length != current)
- mpd_send_delete(connection, length);
+ if (current < length - 1)
+ mpd_send_delete_range(connection, current + 1, length);
+ if (current > 0)
+ mpd_send_delete_range(connection, 0, current);
mpd_command_list_end(connection);
return true;
}
-/**
- * Fallback for mpdclient_cmd_delete_range() on MPD older than 0.16.
- * It emulates the "delete range" command with a list of simple
- * "delete" commands.
- */
-static bool
-mpdclient_cmd_delete_range_fallback(struct mpdclient *c,
- unsigned start, unsigned end)
-{
- struct mpd_connection *connection = mpdclient_get_connection(c);
- if (connection == NULL)
- return false;
-
- if (!mpd_command_list_begin(connection, false))
- return mpdclient_handle_error(c);
-
- for (; start < end; --end)
- mpd_send_delete(connection, start);
-
- if (!mpd_command_list_end(connection) ||
- !mpd_response_finish(connection))
- return mpdclient_handle_error(c);
-
- return true;
-}
-
bool
mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end)
{
if (connection == NULL)
return false;
- if (mpd_connection_cmp_server_version(connection, 0, 16, 0) < 0)
- return mpdclient_cmd_delete_range_fallback(c, start, end);
-
- /* MPD 0.16 supports "delete" with a range argument */
-
/* send the delete command to mpd; at the same time, get the
new status (to verify the playlist id) */