Code

main: require MPD 0.16
authorMax Kellermann <max@duempel.org>
Thu, 7 Nov 2013 22:36:48 +0000 (23:36 +0100)
committerMax 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
src/main.c
src/mpdclient.c

diff --git a/NEWS b/NEWS
index c28c2518da86678f787f999dfdb3c4ef5ab97066..4b17bd8c41bd8c8c379ddad2f5d71e2e07efa3f2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 ncmpc 0.22 - not yet released
 * rename "playlist" to "queue"
+* require MPD 0.16
 
 
 ncmpc 0.21 - (2013-04-11)
index ffc310fcee2b183d862c77e9c2bf83f8166929df..33678eecb9c05c76367b76c23bc0459cbb7a8270 100644 (file)
@@ -332,13 +332,13 @@ timer_reconnect(G_GNUC_UNUSED gpointer data)
        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();
 
@@ -349,10 +349,8 @@ timer_reconnect(G_GNUC_UNUSED gpointer data)
        }
 #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);
index e55c1362482ece91917b22875f9dc9f671c339d3..359a765119f8045d877d48a6bedce252ced4a39d 100644 (file)
@@ -295,15 +295,10 @@ mpdclient_cmd_crop(struct 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);
 
@@ -523,32 +518,6 @@ mpdclient_cmd_delete(struct mpdclient *c, gint idx)
        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)
 {
@@ -564,11 +533,6 @@ 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) */