From: Max Kellermann Date: Sun, 18 Oct 2009 00:21:56 +0000 (+0200) Subject: mpdclient: removed mpdclient_cmd_swap() X-Git-Tag: release-0.16~81 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=681ef857bb2522e93b03ab8b3adb74c76977da65;p=ncmpc.git mpdclient: removed mpdclient_cmd_swap() Not used anymore. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index f627936..0a93bc9 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -618,56 +618,6 @@ mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end) return true; } -bool -mpdclient_cmd_swap(struct mpdclient *c, gint old_index, gint new_index) -{ - struct mpd_connection *connection = mpdclient_get_connection(c); - const struct mpd_song *song1, *song2; - struct mpd_status *status; - - if (connection == NULL) - return false; - - if (old_index == new_index || new_index < 0 || - (guint)new_index >= c->playlist.list->len) - return false; - - song1 = playlist_get(&c->playlist, old_index); - song2 = playlist_get(&c->playlist, new_index); - - /* send the delete command to mpd; at the same time, get the - new status (to verify the playlist id) */ - - if (!mpd_command_list_begin(connection, false) || - !mpd_send_swap_id(connection, mpd_song_get_id(song1), - mpd_song_get_id(song2)) || - !mpd_send_status(connection) || - !mpd_command_list_end(connection)) - return mpdclient_handle_error(c); - - c->events |= MPD_IDLE_PLAYLIST; - - status = mpdclient_recv_status(c); - if (status == NULL) - return false; - - if (!mpd_response_finish(connection)) - return mpdclient_handle_error(c); - - if (mpd_status_get_queue_length(status) == playlist_length(&c->playlist) && - mpd_status_get_queue_version(status) == c->playlist.version + 1) { - /* the cheap route: match on the new playlist length - and its version, we can keep our local playlist - copy in sync */ - c->playlist.version = mpd_status_get_queue_version(status); - - /* swap songs in the local playlist */ - playlist_swap(&c->playlist, old_index, new_index); - } - - return true; -} - bool mpdclient_cmd_move(struct mpdclient *c, unsigned dest_pos, unsigned src_pos) { diff --git a/src/mpdclient.h b/src/mpdclient.h index 940b3eb..8309aa3 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -119,9 +119,6 @@ mpdclient_cmd_delete(struct mpdclient *c, gint index); bool mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end); -bool -mpdclient_cmd_swap(struct mpdclient *c, gint old_index, gint new_index); - bool mpdclient_cmd_move(struct mpdclient *c, unsigned dest, unsigned src); diff --git a/src/playlist.h b/src/playlist.h index 8768b9e..c5256e6 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -102,17 +102,6 @@ playlist_remove(struct mpdclient_playlist *playlist, guint idx) mpd_song_free(playlist_remove_reuse(playlist, idx)); } -static inline void -playlist_swap(struct mpdclient_playlist *playlist, guint idx1, guint idx2) -{ - struct mpd_song *song1 = playlist_get(playlist, idx1); - struct mpd_song *song2 = playlist_get(playlist, idx2); - - /* update the array */ - g_ptr_array_index(playlist->list, idx1) = song2; - g_ptr_array_index(playlist->list, idx2) = song1; -} - void playlist_move(struct mpdclient_playlist *playlist, unsigned dest, unsigned src);