X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/8d8b8c1fcf4f786ba3afdf29f49c79c54ba352cc..81e440cef0e926bb730916f50edc635f75822cf1:/server/server.c diff --git a/server/server.c b/server/server.c index 603b7db..413b43e 100644 --- a/server/server.c +++ b/server/server.c @@ -63,6 +63,7 @@ #include "eventlog.h" #include "defs.h" #include "cache.h" +#include "unicode.h" #ifndef NONCE_SIZE # define NONCE_SIZE 16 @@ -224,7 +225,7 @@ static int c_play(struct conn *c, char **vec, * anything. */ if(q == qhead.next && playing) prepare(c->ev, q); - sink_writes(ev_writer_sink(c->w), "250 queued\n"); + sink_printf(ev_writer_sink(c->w), "252 %s\n", q->id); /* If the queue was empty but we are for some reason paused then * unpause. */ if(!playing) resume_playing(0); @@ -579,7 +580,7 @@ static int c_get(struct conn *c, if(vec[1][0] != '_' && (v = trackdb_get(vec[0], vec[1]))) sink_printf(ev_writer_sink(c->w), "252 %s\n", v); else - sink_writes(ev_writer_sink(c->w), "550 not found\n"); + sink_writes(ev_writer_sink(c->w), "555 not found\n"); return 1; } @@ -805,19 +806,6 @@ static int c_log(struct conn *c, return 0; } -static void post_move_cleanup(void) { - struct queue_entry *q; - - /* If we have caused any random tracks to not be at the end then we make them - * no longer be random. */ - for(q = qhead.next; q != &qhead; q = q->next) - if(q->state == playing_random && q->next != &qhead) - q->state = playing_unplayed; - /* That might mean we need to add a new random track. */ - add_random_track(); - queue_write(); -} - static int c_move(struct conn *c, char **vec, int attribute((unused)) nvec) { @@ -836,7 +824,6 @@ static int c_move(struct conn *c, return 1; } n = queue_move(q, atoi(vec[1]), c->who); - post_move_cleanup(); sink_printf(ev_writer_sink(c->w), "252 %d\n", n); /* If we've moved to the head of the queue then prepare the track. */ if(q == qhead.next) @@ -873,7 +860,6 @@ static int c_moveafter(struct conn *c, return 1; } queue_moveafter(q, nvec, qs, c->who); - post_move_cleanup(); sink_printf(ev_writer_sink(c->w), "250 Moved tracks\n"); /* If we've moved to the head of the queue then prepare the track. */ if(q == qhead.next) @@ -921,6 +907,10 @@ static int c_tags(struct conn *c, static int c_set_global(struct conn *c, char **vec, int attribute((unused)) nvec) { + if(vec[0][0] == '_') { + sink_writes(ev_writer_sink(c->w), "550 cannot set internal global preferences\n"); + return 1; + } trackdb_set_global(vec[0], vec[1], c->who); sink_printf(ev_writer_sink(c->w), "250 OK\n"); return 1; @@ -934,7 +924,7 @@ static int c_get_global(struct conn *c, if(s) sink_printf(ev_writer_sink(c->w), "252 %s\n", s); else - sink_writes(ev_writer_sink(c->w), "550 not found\n"); + sink_writes(ev_writer_sink(c->w), "555 not found\n"); return 1; } @@ -1040,6 +1030,11 @@ static int command(struct conn *c, char *line) { int nvec, n; D(("server command %s", line)); + /* We force everything into NFC as early as possible */ + if(!(line = utf8_compose_canon(line, strlen(line), 0))) { + sink_writes(ev_writer_sink(c->w), "500 cannot normalize command\n"); + return 1; + } if(!(vec = split(line, &nvec, SPLIT_QUOTES, command_error, c))) { sink_writes(ev_writer_sink(c->w), "500 cannot parse command\n"); return 1;