"\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) {
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 */
{ "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