From: Max Kellermann Date: Thu, 7 Nov 2013 22:36:48 +0000 (+0100) Subject: main: require MPD 0.16 X-Git-Tag: v0.22~23 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=14edf79ee47e30911d091c7b32846baa9884e9b7;p=ncmpc.git main: require MPD 0.16 Remove a few version checks and some fallback code. --- diff --git a/NEWS b/NEWS index c28c251..4b17bd8 100644 --- 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) diff --git a/src/main.c b/src/main.c index ffc310f..33678ee 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/mpdclient.c b/src/mpdclient.c index e55c136..359a765 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -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) */