From 00861dcb1b67a282893f3d30187459c6384cbee7 Mon Sep 17 00:00:00 2001 Message-Id: <00861dcb1b67a282893f3d30187459c6384cbee7.1715707018.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 5 Jun 2010 14:46:04 +0100 Subject: [PATCH] play command Organization: Straylight/Edgeware From: Richard Kettlewell --- cgi/actions.c | 5 +++-- clients/disorder.c | 3 ++- lib/client-stubs.c | 4 ++++ lib/client-stubs.h | 10 ++++++++++ lib/client.c | 9 --------- lib/client.h | 1 - scripts/protocol | 6 ++++++ 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/cgi/actions.c b/cgi/actions.c index f6755b0..584da76 100644 --- a/cgi/actions.c +++ b/cgi/actions.c @@ -240,16 +240,17 @@ static void act_play(void) { char **tracks; int ntracks, n; struct tracksort_data *tsd; + char *id; if(dcgi_client) { if((track = cgi_get("track"))) { - disorder_play(dcgi_client, track); + disorder_play(dcgi_client, track, &id); } else if((dir = cgi_get("dir"))) { if(disorder_files(dcgi_client, dir, 0, &tracks, &ntracks)) ntracks = 0; tsd = tracksort_init(ntracks, tracks, "track"); for(n = 0; n < ntracks; ++n) - disorder_play(dcgi_client, tsd[n].track); + disorder_play(dcgi_client, tsd[n].track, &id); } } redirect(0); diff --git a/clients/disorder.c b/clients/disorder.c index 48745b6..6e2ec14 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -138,8 +138,9 @@ static void cf_playing(char attribute((unused)) **argv) { } static void cf_play(char **argv) { + char *id; while(*argv) - if(disorder_play(getclient(), *argv++)) exit(EXIT_FAILURE); + if(disorder_play(getclient(), *argv++, &id)) exit(EXIT_FAILURE); } static void cf_remove(char **argv) { diff --git a/lib/client-stubs.c b/lib/client-stubs.c index de9e6cc..3d02139 100644 --- a/lib/client-stubs.c +++ b/lib/client-stubs.c @@ -110,6 +110,10 @@ int disorder_pause(disorder_client *c) { return disorder_simple(c, 0, "pause", (char *)0); } +int disorder_play(disorder_client *c, const char *track, char **idp) { + return dequote(disorder_simple(c, idp, "play", track, (char *)0), idp); +} + int disorder_playlist_delete(disorder_client *c, const char *playlist) { return disorder_simple(c, 0, "playlist-delete", playlist, (char *)0); } diff --git a/lib/client-stubs.h b/lib/client-stubs.h index 8182213..13f0724 100644 --- a/lib/client-stubs.h +++ b/lib/client-stubs.h @@ -203,6 +203,16 @@ int disorder_part(disorder_client *c, const char *track, const char *context, co */ int disorder_pause(disorder_client *c); +/** @brief Play a track + * + * Requires the 'play' right. + * + * @param track Track to play + * @param idp Queue ID of new track + * @return 0 on success, non-0 on error + */ +int disorder_play(disorder_client *c, const char *track, char **idp); + /** @brief Delete a playlist * * Requires the 'play' right and permission to modify the playlist. diff --git a/lib/client.c b/lib/client.c index 33f1d35..1cb73a4 100644 --- a/lib/client.c +++ b/lib/client.c @@ -522,15 +522,6 @@ int disorder_close(disorder_client *c) { return ret; } -/** @brief Play a track - * @param c Client - * @param track Track to play (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_play(disorder_client *c, const char *track) { - return disorder_simple(c, 0, "play", track, (char *)0); -} - /** @brief Move a track * @param c Client * @param track Track to move (UTF-8) diff --git a/lib/client.h b/lib/client.h index c4b19e4..4453fc3 100644 --- a/lib/client.h +++ b/lib/client.h @@ -48,7 +48,6 @@ int disorder_connect_generic(struct config *conf, const char *cookie); int disorder_close(disorder_client *c); int disorder_version(disorder_client *c, char **versionp); -int disorder_play(disorder_client *c, const char *track); int disorder_remove(disorder_client *c, const char *track); int disorder_move(disorder_client *c, const char *track, int delta); int disorder_enable(disorder_client *c); diff --git a/scripts/protocol b/scripts/protocol index ac8c0f7..2cfa644 100755 --- a/scripts/protocol +++ b/scripts/protocol @@ -412,6 +412,12 @@ simple("pause", "Requires the 'pause' right.", []); +string("play", + "Play a track", + "Requires the 'play' right.", + [["track", "Track to play"]], + ["id", "Queue ID of new track"]); + # TODO playafter # TODO playing -- [mdw]