X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/1e97629da2ea6c1ae328912ba82d4595eb08b700..1a3dba678a4edf1df3d7de2cc29f8e32d6fea080:/server/actions.c diff --git a/server/actions.c b/server/actions.c index 7b69932..aca4db0 100644 --- a/server/actions.c +++ b/server/actions.c @@ -92,7 +92,7 @@ static void act_playing(void) { "\n", refresh, url, dcgi_cookie_header()) < 0) fatal(errno, "error writing to stdout"); - dcgi_expand(action ? action : "playing"); + dcgi_expand("playing"); } static void act_disable(void) { @@ -119,6 +119,37 @@ static void act_random_enable(void) { redirect(0); } +static void act_remove(void) { + const char *id; + struct queue_entry *q; + + if(dcgi_client) { + if(!(id = cgi_get("id"))) + error(0, "missing 'id' argument"); + else if(!(q = dcgi_findtrack(id))) + error(0, "unknown queue id %s", id); + else switch(q->state) { + case playing_isscratch: + case playing_failed: + case playing_no_player: + case playing_ok: + case playing_quitting: + case playing_scratched: + error(0, "does not make sense to scratch %s", id); + break; + case playing_paused: /* started but paused */ + case playing_started: /* started to play */ + disorder_scratch(dcgi_client, id); + break; + case playing_random: /* unplayed randomly chosen track */ + case playing_unplayed: /* haven't played this track yet */ + disorder_remove(dcgi_client, id); + break; + } + } + redirect(0); +} + /** @brief Table of actions */ static const struct action { /** @brief Action name */ @@ -130,8 +161,9 @@ static const struct action { { "enable", act_enable }, { "manage", act_playing }, { "playing", act_playing }, - { "random-disable", act_random_disable }, - { "random-enable", act_random_enable }, + { "randomdisable", act_random_disable }, + { "randomenable", act_random_enable }, + { "remove", act_remove }, }; /** @brief Expand a template