chiark / gitweb /
server: docs: remove deprecated configuration and user upgrade.
[disorder] / server / server.c
index 0ebfb4f0782fb8c4d5d8f91184928a4eb6606c5b..44c3a87775793edd1c667bb3f37acf66917109fd 100644 (file)
@@ -201,9 +201,9 @@ static int reader_error(ev_source attribute((unused)) *ev,
 
 static int c_disable(struct conn *c, char **vec, int nvec) {
   if(nvec == 0)
-    disable_playing(c->who);
+    disable_playing(c->who, c->ev);
   else if(nvec == 1 && !strcmp(vec[0], "now"))
-    disable_playing(c->who);
+    disable_playing(c->who, c->ev);
   else {
     sink_writes(ev_writer_sink(c->w), "550 invalid argument\n");
     return 1;                  /* completed */
@@ -634,7 +634,7 @@ static int c_queue(struct conn *c,
       if((l = trackdb_get(playing->track, "_length"))
         && (length = atol(l))) {
        xtime(&when);
-       when += length - playing->sofar + config->gap;
+       when += length - playing->sofar;
       }
     } else
       /* Nothing is playing but playing is enabled, so whatever is
@@ -649,7 +649,7 @@ static int c_queue(struct conn *c,
     if(when) {
       if((l = trackdb_get(q->track, "_length"))
         && (length = atol(l)))
-       when += length + config->gap;
+       when += length;
       else
        when = 0;
     }
@@ -866,7 +866,7 @@ static int c_random_enable(struct conn *c,
 static int c_random_disable(struct conn *c,
                            char attribute((unused)) **vec,
                            int attribute((unused)) nvec) {
-  disable_random(c->who);
+  disable_random(c->who, c->ev);
   sink_writes(ev_writer_sink(c->w), "250 OK\n");
   return 1;                    /* completed */
 }
@@ -1150,8 +1150,19 @@ static int c_set_global(struct conn *c,
     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");
+  /* We special-case the 'magic' preferences here. */
+  if(!strcmp(vec[0], "playing")) {
+    (flag_enabled(vec[1]) ? enable_playing : disable_playing)(c->who, c->ev);
+    sink_printf(ev_writer_sink(c->w), "250 OK\n");
+  } else if(!strcmp(vec[0], "random-play")) {
+    (flag_enabled(vec[1]) ? enable_random : disable_random)(c->who, c->ev);
+    sink_printf(ev_writer_sink(c->w), "250 OK\n");
+  } else {
+    if(!trackdb_set_global(vec[0], vec[1], c->who))
+      sink_printf(ev_writer_sink(c->w), "250 OK\n");
+    else
+      sink_writes(ev_writer_sink(c->w), "550 not found\n");
+  }
   return 1;
 }
 
@@ -1177,7 +1188,7 @@ static int c_nop(struct conn *c,
 static int c_new(struct conn *c,
                 char **vec,
                 int nvec) {
-  int max, n;
+  int max;
   char **tracks;
 
   if(nvec > 0)
@@ -1188,7 +1199,6 @@ static int c_new(struct conn *c,
     max = config->new_max;
   tracks = trackdb_new(0, max);
   sink_printf(ev_writer_sink(c->w), "253 New track list follows\n");
-  n = 0;
   while(*tracks) {
     sink_printf(ev_writer_sink(c->w), "%s%s\n",
                **tracks == '.' ? "." : "", *tracks);
@@ -1835,7 +1845,8 @@ static int c_playlist_unlock(struct conn *c,
   return 1;
 }
 
-static const struct command {
+/** @brief Server's definition of a command */
+static const struct server_command {
   /** @brief Command name */
   const char *name;