Code

mpdclient: removed mpdclient_cmd_play()
authorMax Kellermann <max@duempel.org>
Sat, 17 Oct 2009 22:57:11 +0000 (00:57 +0200)
committerMax Kellermann <max@duempel.org>
Sat, 17 Oct 2009 22:57:11 +0000 (00:57 +0200)
Call mpdclient_run_play_id() directly.

src/mpdclient.c
src/mpdclient.h
src/screen_queue.c

index 748baed5c1e99d42470254ea39240dcf3ff09753..dbe931c7d66e8bdc61a09e7007661eb7966ec875 100644 (file)
@@ -261,23 +261,6 @@ mpdclient_put_connection(struct mpdclient *c)
 /*** MPD Commands  **********************************************************/
 /****************************************************************************/
 
-bool
-mpdclient_cmd_play(struct mpdclient *c, gint idx)
-{
-       struct mpd_connection *connection = mpdclient_get_connection(c);
-       const struct mpd_song *song = playlist_get_song(&c->playlist, idx);
-
-       if (connection == NULL)
-               return false;
-
-       if (song)
-               mpd_send_play_id(connection, mpd_song_get_id(song));
-       else
-               mpd_send_play(connection);
-
-       return mpdclient_finish_command(c);
-}
-
 bool
 mpdclient_cmd_crop(struct mpdclient *c)
 {
index 6c8758f6674d4becdb22a8915d50dd947254c606..9f22d268cc046e05b1c8279b0459231590e77a23 100644 (file)
@@ -92,9 +92,6 @@ mpdclient_ui_error(const char *message);
 
 /*** MPD Commands  **********************************************************/
 
-bool
-mpdclient_cmd_play(struct mpdclient *c, gint index);
-
 bool
 mpdclient_cmd_crop(struct mpdclient *c);
 
index 491d3321070076d6d0827b90bdda861b04c0f33f..01305203e7c91001508b3f9ab403b8b197251dca 100644 (file)
@@ -616,8 +616,16 @@ handle_mouse_event(struct mpdclient *c)
 
        if (bstate & BUTTON1_CLICKED) {
                /* play */
-               if (lw->selected < playlist_length(playlist))
-                       mpdclient_cmd_play(c, lw->start + row);
+               const struct mpd_song *song = screen_queue_selected_song();
+               if (song != NULL) {
+                       struct mpd_connection *connection =
+                               mpdclient_get_connection(c);
+
+                       if (connection != NULL &&
+                           !mpd_run_play_id(connection,
+                                            mpd_song_get_id(song)))
+                               mpdclient_handle_error(c);
+               }
        } else if (bstate & BUTTON3_CLICKED) {
                /* delete */
                if (lw->selected == old_selected)
@@ -640,6 +648,7 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd)
        static command_t cached_cmd = CMD_NONE;
        command_t prev_cmd = cached_cmd;
        struct list_window_range range;
+       const struct mpd_song *song;
 
        cached_cmd = cmd;
 
@@ -729,7 +738,15 @@ screen_queue_cmd(struct mpdclient *c, command_t cmd)
 
        switch(cmd) {
        case CMD_PLAY:
-               mpdclient_cmd_play(c, lw->selected);
+               song = screen_queue_selected_song();
+               if (song == NULL)
+                       return false;
+
+               connection = mpdclient_get_connection(c);
+               if (connection != NULL &&
+                   !mpd_run_play_id(connection, mpd_song_get_id(song)))
+                       mpdclient_handle_error(c);
+
                return true;
 
        case CMD_DELETE: