Code

mpdclient: removed mpdclient_cmd_swap()
authorMax Kellermann <max@duempel.org>
Sun, 18 Oct 2009 00:21:56 +0000 (02:21 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 18 Oct 2009 00:21:56 +0000 (02:21 +0200)
Not used anymore.

src/mpdclient.c
src/mpdclient.h
src/playlist.h

index f62793613cdc504e81651f253e59a697dd3f0e6c..0a93bc9a4bd40a3dcda2e519b465459114a09eb3 100644 (file)
@@ -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)
 {
index 940b3eb1d256227fc6d6b8991b9905969ecfb7c8..8309aa3a30519869c3f16af90c7c9bf5879ad219 100644 (file)
@@ -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);
 
index 8768b9e5a5bcd366cd9438cb591e80d30f7a515a..c5256e63c4dfa69238ac57242059ba2982192b87 100644 (file)
@@ -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);