chiark / gitweb /
protogen: The bulk of the eclient code generation.
authorRichard Kettlewell <rjk@terraraq.org.uk>
Sun, 7 Aug 2011 12:34:04 +0000 (13:34 +0100)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Sun, 7 Aug 2011 12:34:04 +0000 (13:34 +0100)
This is slightly disruptive, as the previous API lacked internal
consistency.

19 files changed:
disobedience/choose-menu.c
disobedience/choose.c
disobedience/choose.h
disobedience/control.c
disobedience/globals.c
disobedience/lookup.c
disobedience/playlists.c
disobedience/properties.c
disobedience/queue-menu.c
disobedience/queue.c
lib/client-common.c
lib/client-common.h
lib/client-stubs.c
lib/client.c
lib/eclient-stubs.c [new file with mode: 0644]
lib/eclient-stubs.h [new file with mode: 0644]
lib/eclient.c
lib/eclient.h
scripts/protocol

index b0f59b5..b4aa0ce 100644 (file)
@@ -29,7 +29,9 @@ static void choose_playchildren_callback(GtkTreeModel *model,
 static void choose_playchildren_received(void *v,
                                          const char *err,
                                          int nvec, char **vec);
-static void choose_playchildren_played(void *v, const char *err);
+static void choose_playchildren_played(void *v,
+                                       const char *err,
+                                       const char *id);
 
 /** @brief Popup menu */
 static GtkWidget *choose_menu;
@@ -116,7 +118,7 @@ static void choose_play_activate(GtkMenuItem attribute((unused)) *item,
                                       choose_gather_selected_files_callback,
                                       v);
   for(int n = 0; n < v->nvec; ++n)
-    disorder_eclient_play(client, v->vec[n], choose_play_completed, 0);
+    disorder_eclient_play(client, choose_play_completed, v->vec[n], 0);
 }
   
 static int choose_properties_sensitive(void *extra) {
@@ -250,11 +252,12 @@ static void choose_playchildren_received(void attribute((unused)) *v,
     return;
   }
   for(int n = 0; n < nvec; ++n)
-    disorder_eclient_play(client, vec[n], choose_playchildren_played, NULL);
+    disorder_eclient_play(client, choose_playchildren_played, vec[n], NULL);
 }
 
 static void choose_playchildren_played(void attribute((unused)) *v,
-                                       const char *err) {
+                                       const char *err,
+                                       const char attribute((unused)) *id) {
   if(err) {
     popup_protocol_error(0, err);
     return;
index a1d50c1..13a1da0 100644 (file)
@@ -364,7 +364,8 @@ static void choose_files_completed(void *v,
 }
 
 void choose_play_completed(void attribute((unused)) *v,
-                           const char *err) {
+                           const char *err,
+                           const char attribute((unused)) *id) {
   if(err)
     popup_protocol_error(0, err);
 }
@@ -386,7 +387,7 @@ static void choose_state_toggled
   const char *track = choose_get_track(it);
   if(queued(track))
     return;
-  disorder_eclient_play(client, track, choose_play_completed, 0);
+  disorder_eclient_play(client, choose_play_completed, track, 0);
   
 }
 
index 5213332..9496abd 100644 (file)
@@ -62,8 +62,9 @@ struct choosedata *choose_path_to_data(GtkTreePath *path);
 gboolean choose_button_event(GtkWidget *widget,
                              GdkEventButton *event,
                              gpointer user_data);
-void choose_play_completed(void attribute((unused)) *v,
-                           const char *err);
+void choose_play_completed(void *v,
+                           const char *err,
+                           const char *id);
 char *choose_get_track(GtkTreeIter *iter);
 char *choose_get_sort(GtkTreeIter *iter);
 char *choose_get_display(GtkTreeIter *iter);
index f45492f..1cdc190 100644 (file)
@@ -468,9 +468,7 @@ static void toggled_menu(GtkCheckMenuItem attribute((unused)) *menuitem,
 
 /** @brief Called when a volume command completes */
 static void volume_completed(void attribute((unused)) *v,
-                             const char *err,
-                             int attribute((unused)) l,
-                             int attribute((unused)) r) {
+                             const char *err) {
   if(err)
     popup_protocol_error(0, err);
   /* We don't set the UI's notion of the volume here, it is set from the log
@@ -498,10 +496,10 @@ static void volume_adjusted(GtkAdjustment attribute((unused)) *a,
     if(backend && backend->set_volume)
       backend->set_volume(&l, &r);
   } else
-    disorder_eclient_volume(client, volume_completed,
-                            nearbyint(left(v, b) * 100),
-                            nearbyint(right(v, b) * 100),
-                            0);
+    disorder_eclient_set_volume(client, volume_completed,
+                                nearbyint(left(v, b) * 100),
+                                nearbyint(right(v, b) * 100),
+                                0);
 }
 
 /** @brief Formats the volume value */
index 2734c32..a6b4ca4 100644 (file)
@@ -217,9 +217,9 @@ void popup_globals(void) {
 }
 
 /** @brief Called when any global pref changes */
-static void globals_pref_changed(const char *event,
+static void globals_pref_changed(const char attribute((unused)) *event,
                                 void *eventdata,
-                                void *callbackdata) {
+                                void attribute((unused)) *callbackdata) {
   const char *pref = eventdata;
   if(!globals_window)
     return;                    /* not paying attention */
index 68939ae..21bacc4 100644 (file)
@@ -74,8 +74,8 @@ static void namepart_fill(const char *track,
   D(("namepart_fill %s %s %s %s", track, context, part, key));
   ++namepart_lookups_outstanding;
   D(("namepart_lookups_outstanding -> %d\n", namepart_lookups_outstanding));
-  disorder_eclient_namepart(client, namepart_completed,
-                            track, context, part, (void *)key);
+  disorder_eclient_part(client, namepart_completed,
+                        track, context, part, (void *)key);
 }
 
 /** @brief Look up a namepart
index c95db43..50e099f 100644 (file)
@@ -253,7 +253,8 @@ static int playlistcmp(const void *ap, const void *bp) {
 /* Playlists menu ----------------------------------------------------------- */
 
 static void playlist_menu_playing(void attribute((unused)) *v,
-                                  const char *err) {
+                                  const char *err,
+                                  const char attribute((unused)) *id) {
   if(err)
     popup_submsg(playlist_window, GTK_MESSAGE_ERROR, err);
 }
@@ -270,7 +271,7 @@ static void playlist_menu_received_content(void attribute((unused)) *v,
     return;
   }
   for(int n = 0; n < nvec; ++n)
-    disorder_eclient_play(client, vec[n], playlist_menu_playing, NULL);
+    disorder_eclient_play(client, playlist_menu_playing, vec[n], NULL);
 }
 
 /** @brief Called to activate a playlist
index 6600cf9..92f2128 100644 (file)
@@ -335,8 +335,8 @@ static void kickoff_namepart(struct prefdata *f) {
    * wanted was the underlying preference, but in fact it should always match
    * and will supply a sane default without having to know how to parse tracks
    * names (which implies knowing collection roots). */
-  disorder_eclient_namepart(client, prefdata_completed,
-                            f->track, "display", f->p->part, f);
+  disorder_eclient_part(client, prefdata_completed,
+                        f->track, "display", f->p->part, f);
 }
 
 static void completed_namepart(struct prefdata *f) {
index ebf8555..faf16cd 100644 (file)
@@ -129,7 +129,7 @@ static void ql_remove_activate_callback(GtkTreeModel *model,
   struct queue_entry *q = ql_iter_to_q(model, iter);
 
   if(q != playing_track)
-    disorder_eclient_remove(client, q->id, ql_remove_completed, q);
+    disorder_eclient_remove(client, ql_remove_completed, q->id, q);
 }
 
 void ql_remove_activate(GtkMenuItem attribute((unused)) *menuitem,
@@ -148,7 +148,8 @@ int ql_play_sensitive(void *extra) {
     && gtk_tree_selection_count_selected_rows(ql->selection) > 0;
 }
 
-static void ql_play_completed(void attribute((unused)) *v, const char *err) {
+static void ql_play_completed(void attribute((unused)) *v, const char *err,
+                              const char attribute((unused)) *id) {
   if(err)
     popup_protocol_error(0, err);
 }
@@ -159,7 +160,7 @@ static void ql_play_activate_callback(GtkTreeModel *model,
                                       gpointer attribute((unused)) data) {
   struct queue_entry *q = ql_iter_to_q(model, iter);
 
-  disorder_eclient_play(client, q->track, ql_play_completed, q);
+  disorder_eclient_play(client, ql_play_completed, q->track, q);
 }
 
 void ql_play_activate(GtkMenuItem attribute((unused)) *menuitem,
index c495bd8..95ff0d5 100644 (file)
@@ -205,9 +205,10 @@ static void queue_drop(struct queuelike attribute((unused)) *ql,
     /* Tell the server to move them.  The log will tell us about the change (if
      * indeed it succeeds!), so no need to rearrange the model now. */
     disorder_eclient_moveafter(client,
+                               queue_drop_completed,
                                after_me ? after_me->id : "",
-                               ntracks, (const char **)ids,
-                               queue_drop_completed, NULL);
+                               (char **)ids, ntracks,
+                               NULL);
   } else {
     /* You can't tell the server to insert after the playing track by ID, you
      * have to send "". */
@@ -215,9 +216,10 @@ static void queue_drop(struct queuelike attribute((unused)) *ql,
       after_me = NULL;
     /* Play the tracks */
     disorder_eclient_playafter(client,
+                               queue_drop_completed,
                                after_me ? after_me->id : "",
-                               ntracks, (const char **)tracks,
-                               queue_drop_completed, NULL);
+                               (char **)tracks, ntracks,
+                               NULL);
   }
 }
 
index d5c61ce..11c17e2 100644 (file)
@@ -74,6 +74,12 @@ socklen_t find_server(struct config *c,
   return len;
 }
 
+/** @brief Marker for a command body */
+const char disorder__body[1];
+
+/** @brief Marker for a list of args */
+const char disorder__list[1];
+
 /*
 Local Variables:
 c-basic-offset:2
index 736ac6f..3ad4198 100644 (file)
 
 socklen_t find_server(struct config *c, struct sockaddr **sap, char **namep);
 
+/** @brief Marker for a command body */
+extern const char disorder__body[1];
+
+/** @brief Marker for a list of args */
+extern const char disorder__list[1];
+
 #endif /* CLIENT_COMMON_H */
 
 /*
index 5898534..1cc03ea 100644 (file)
@@ -166,7 +166,7 @@ int disorder_move(disorder_client *c, const char *track, long delta) {
 }
 
 int disorder_moveafter(disorder_client *c, const char *target, char **ids, int nids) {
-  return disorder_simple(c, NULL, "moveafter", target, disorder_list, ids, nids, (char *)NULL);
+  return disorder_simple(c, NULL, "moveafter", target, disorder__list, ids, nids, (char *)NULL);
 }
 
 int disorder_new_tracks(disorder_client *c, long max, char ***tracksp, int *ntracksp) {
@@ -204,7 +204,7 @@ int disorder_play(disorder_client *c, const char *track, char **idp) {
 }
 
 int disorder_playafter(disorder_client *c, const char *target, char **tracks, int ntracks) {
-  return disorder_simple(c, NULL, "playafter", target, disorder_list, tracks, ntracks, (char *)NULL);
+  return disorder_simple(c, NULL, "playafter", target, disorder__list, tracks, ntracks, (char *)NULL);
 }
 
 int disorder_playing(disorder_client *c, struct queue_entry **playingp) {
@@ -233,7 +233,7 @@ int disorder_playlist_lock(disorder_client *c, const char *playlist) {
 }
 
 int disorder_playlist_set(disorder_client *c, const char *playlist, char **tracks, int ntracks) {
-  return disorder_simple(c, NULL, "playlist-set", playlist, disorder_body, tracks, ntracks, (char *)NULL);
+  return disorder_simple(c, NULL, "playlist-set", playlist, disorder__body, tracks, ntracks, (char *)NULL);
 }
 
 int disorder_playlist_set_share(disorder_client *c, const char *playlist, const char *share) {
index 9f350d8..6f08fec 100644 (file)
@@ -151,12 +151,6 @@ static int check_response(disorder_client *c, char **rp) {
   }
 }
 
-/** @brief Marker for a command body */
-static const char disorder_body[1];
-
-/** @brief Marker for a list of args */
-static const char disorder_list[1];
-
 /** @brief Issue a command and parse a simple response
  * @param c Client
  * @param rp Where to store result, or NULL
@@ -172,12 +166,12 @@ static const char disorder_list[1];
  * NB that the response will NOT be converted to the local encoding
  * nor will quotes be stripped.  See dequote().
  *
- * Put @ref disorder_body in the argument list followed by a char **
+ * Put @ref disorder__body in the argument list followed by a char **
  * and int giving the body to follow the command.  If the int is @c -1
  * then the list is assumed to be NULL-terminated.  This may be used
  * only once.
  *
- * Put @ref disorder_list in the argument list followed by a char **
+ * Put @ref disorder__list in the argument list followed by a char **
  * and int giving a list of arguments to include.  If the int is @c -1
  * then the list is assumed to be NULL-terminated.  This may be used
  * any number of times.
@@ -204,11 +198,11 @@ static int disorder_simple_v(disorder_client *c,
     dynstr_init(&d);
     dynstr_append_string(&d, cmd);
     while((arg = va_arg(ap, const char *))) {
-      if(arg == disorder_body) {
+      if(arg == disorder__body) {
        body = va_arg(ap, char **);
        nbody = va_arg(ap, int);
        has_body = 1;
-      } else if(arg == disorder_list) {
+      } else if(arg == disorder__list) {
        char **list = va_arg(ap, char **);
        int nlist = va_arg(ap, int);
        if(nlist < 0) {
diff --git a/lib/eclient-stubs.c b/lib/eclient-stubs.c
new file mode 100644 (file)
index 0000000..fb48ade
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * Automatically generated file, see scripts/protocol
+ *
+ * DO NOT EDIT.
+ */
+/*
+ * This file is part of DisOrder.
+ * Copyright (C) 2010-11 Richard Kettlewell
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+int disorder_eclient_adopt(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "adopt", id, (char *)0);
+}
+
+int disorder_eclient_adduser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *user, const char *password, const char *rights, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "adduser", user, password, rights, (char *)0);
+}
+
+int disorder_eclient_allfiles(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "allfiles", dir, re, (char *)0);
+}
+
+int disorder_eclient_deluser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *user, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "deluser", user, (char *)0);
+}
+
+int disorder_eclient_dirs(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "dirs", dir, re, (char *)0);
+}
+
+int disorder_eclient_disable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "disable", (char *)0);
+}
+
+int disorder_eclient_edituser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *username, const char *property, const char *value, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "edituser", username, property, value, (char *)0);
+}
+
+int disorder_eclient_enable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "enable", (char *)0);
+}
+
+int disorder_eclient_enabled(disorder_eclient *c, disorder_eclient_integer_response *completed, void *v) {
+  return simple(c, integer_response_opcallback, (void (*)())completed, v, "enabled", (char *)0);
+}
+
+int disorder_eclient_exists(disorder_eclient *c, disorder_eclient_integer_response *completed, const char *track, void *v) {
+  return simple(c, integer_response_opcallback, (void (*)())completed, v, "exists", track, (char *)0);
+}
+
+int disorder_eclient_files(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "files", dir, re, (char *)0);
+}
+
+int disorder_eclient_get(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, const char *pref, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "get", track, pref, (char *)0);
+}
+
+int disorder_eclient_get_global(disorder_eclient *c, disorder_eclient_string_response *completed, const char *pref, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "get-global", pref, (char *)0);
+}
+
+int disorder_eclient_length(disorder_eclient *c, disorder_eclient_integer_response *completed, const char *track, void *v) {
+  return simple(c, integer_response_opcallback, (void (*)())completed, v, "length", track, (char *)0);
+}
+
+int disorder_eclient_make_cookie(disorder_eclient *c, disorder_eclient_string_response *completed, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "make-cookie", (char *)0);
+}
+
+int disorder_eclient_move(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, long delta, void *v) {
+  char buf_delta[16];
+  byte_snprintf(buf_delta, sizeof buf_delta, "%ld", delta);
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "move", track, buf_delta, (char *)0);
+}
+
+int disorder_eclient_moveafter(disorder_eclient *c, disorder_eclient_no_response *completed, const char *target, char **ids, int nids, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "moveafter", target, disorder__list, ids, nids, (char *)0);
+}
+
+int disorder_eclient_new_tracks(disorder_eclient *c, disorder_eclient_list_response *completed, long max, void *v) {
+  char buf_max[16];
+  byte_snprintf(buf_max, sizeof buf_max, "%ld", max);
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "new", buf_max, (char *)0);
+}
+
+int disorder_eclient_nop(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "nop", (char *)0);
+}
+
+int disorder_eclient_part(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, const char *context, const char *part, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "part", track, context, part, (char *)0);
+}
+
+int disorder_eclient_pause(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "pause", (char *)0);
+}
+
+int disorder_eclient_play(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "play", track, (char *)0);
+}
+
+int disorder_eclient_playafter(disorder_eclient *c, disorder_eclient_no_response *completed, const char *target, char **tracks, int ntracks, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playafter", target, disorder__list, tracks, ntracks, (char *)0);
+}
+
+int disorder_eclient_playing(disorder_eclient *c, disorder_eclient_playing_response *completed, void *v) {
+  return simple(c, playing_response_opcallback, (void (*)())completed, v, "playing", (char *)0);
+}
+
+int disorder_eclient_playlist_delete(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playlist-delete", playlist, (char *)0);
+}
+
+int disorder_eclient_playlist_get(disorder_eclient *c, disorder_eclient_list_response *completed, const char *playlist, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "playlist-get", playlist, (char *)0);
+}
+
+int disorder_eclient_playlist_get_share(disorder_eclient *c, disorder_eclient_string_response *completed, const char *playlist, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "playlist-get-share", playlist, (char *)0);
+}
+
+int disorder_eclient_playlist_lock(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playlist-lock", playlist, (char *)0);
+}
+
+int disorder_eclient_playlist_set(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, char **tracks, int ntracks, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playlist-set", playlist, disorder__body, tracks, ntracks, (char *)0);
+}
+
+int disorder_eclient_playlist_set_share(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, const char *share, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playlist-set-share", playlist, share, (char *)0);
+}
+
+int disorder_eclient_playlist_unlock(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "playlist-unlock", (char *)0);
+}
+
+int disorder_eclient_playlists(disorder_eclient *c, disorder_eclient_list_response *completed, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "playlists", (char *)0);
+}
+
+int disorder_eclient_queue(disorder_eclient *c, disorder_eclient_queue_response *completed, void *v) {
+  return simple(c, queue_response_opcallback, (void (*)())completed, v, "queue", (char *)0);
+}
+
+int disorder_eclient_random_disable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "random-disable", (char *)0);
+}
+
+int disorder_eclient_random_enable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "random-enable", (char *)0);
+}
+
+int disorder_eclient_random_enabled(disorder_eclient *c, disorder_eclient_integer_response *completed, void *v) {
+  return simple(c, integer_response_opcallback, (void (*)())completed, v, "random-enabled", (char *)0);
+}
+
+int disorder_eclient_recent(disorder_eclient *c, disorder_eclient_queue_response *completed, void *v) {
+  return simple(c, queue_response_opcallback, (void (*)())completed, v, "recent", (char *)0);
+}
+
+int disorder_eclient_reconfigure(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "reconfigure", (char *)0);
+}
+
+int disorder_eclient_register(disorder_eclient *c, disorder_eclient_string_response *completed, const char *username, const char *password, const char *email, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "register", username, password, email, (char *)0);
+}
+
+int disorder_eclient_reminder(disorder_eclient *c, disorder_eclient_no_response *completed, const char *username, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "reminder", username, (char *)0);
+}
+
+int disorder_eclient_remove(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "remove", id, (char *)0);
+}
+
+int disorder_eclient_rescan(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "rescan", (char *)0);
+}
+
+int disorder_eclient_resolve(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "resolve", track, (char *)0);
+}
+
+int disorder_eclient_resume(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "resume", (char *)0);
+}
+
+int disorder_eclient_revoke(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "revoke", (char *)0);
+}
+
+int disorder_eclient_scratch(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "scratch", id, (char *)0);
+}
+
+int disorder_eclient_schedule_add_play(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *track, void *v) {
+  char buf_when[16];
+  byte_snprintf(buf_when, sizeof buf_when, "%lld", (long long)when);
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "schedule-add", buf_when, priority, "play", track, (char *)0);
+}
+
+int disorder_eclient_schedule_add_set_global(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *pref, const char *value, void *v) {
+  char buf_when[16];
+  byte_snprintf(buf_when, sizeof buf_when, "%lld", (long long)when);
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "schedule-add", buf_when, priority, "set-global", pref, value, (char *)0);
+}
+
+int disorder_eclient_schedule_add_unset_global(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *pref, void *v) {
+  char buf_when[16];
+  byte_snprintf(buf_when, sizeof buf_when, "%lld", (long long)when);
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "schedule-add", buf_when, priority, "set-global", pref, (char *)0);
+}
+
+int disorder_eclient_schedule_del(disorder_eclient *c, disorder_eclient_no_response *completed, const char *event, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "schedule-del", event, (char *)0);
+}
+
+int disorder_eclient_schedule_list(disorder_eclient *c, disorder_eclient_list_response *completed, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "schedule-list", (char *)0);
+}
+
+int disorder_eclient_search(disorder_eclient *c, disorder_eclient_list_response *completed, const char *terms, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "search", terms, (char *)0);
+}
+
+int disorder_eclient_set(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, const char *pref, const char *value, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "set", track, pref, value, (char *)0);
+}
+
+int disorder_eclient_set_global(disorder_eclient *c, disorder_eclient_no_response *completed, const char *pref, const char *value, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "set-global", pref, value, (char *)0);
+}
+
+int disorder_eclient_shutdown(disorder_eclient *c, disorder_eclient_no_response *completed, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "shutdown", (char *)0);
+}
+
+int disorder_eclient_stats(disorder_eclient *c, disorder_eclient_list_response *completed, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "stats", (char *)0);
+}
+
+int disorder_eclient_tags(disorder_eclient *c, disorder_eclient_list_response *completed, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "tags", (char *)0);
+}
+
+int disorder_eclient_unset(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, const char *pref, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "unset", track, pref, (char *)0);
+}
+
+int disorder_eclient_unset_global(disorder_eclient *c, disorder_eclient_no_response *completed, const char *pref, void *v) {
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "unset-global", pref, (char *)0);
+}
+
+int disorder_eclient_userinfo(disorder_eclient *c, disorder_eclient_string_response *completed, const char *username, const char *property, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "userinfo", username, property, (char *)0);
+}
+
+int disorder_eclient_users(disorder_eclient *c, disorder_eclient_list_response *completed, void *v) {
+  return simple(c, list_response_opcallback, (void (*)())completed, v, "users", (char *)0);
+}
+
+int disorder_eclient_version(disorder_eclient *c, disorder_eclient_string_response *completed, void *v) {
+  return simple(c, string_response_opcallback, (void (*)())completed, v, "version", (char *)0);
+}
+
+int disorder_eclient_set_volume(disorder_eclient *c, disorder_eclient_no_response *completed, long left, long right, void *v) {
+  char buf_left[16];
+  byte_snprintf(buf_left, sizeof buf_left, "%ld", left);
+  char buf_right[16];
+  byte_snprintf(buf_right, sizeof buf_right, "%ld", right);
+  return simple(c, no_response_opcallback, (void (*)())completed, v, "volume", buf_left, buf_right, (char *)0);
+}
+
+int disorder_eclient_get_volume(disorder_eclient *c, disorder_eclient_pair_integer_response *completed, void *v) {
+  return simple(c, pair_integer_response_opcallback, (void (*)())completed, v, "volume", (char *)0);
+}
+
diff --git a/lib/eclient-stubs.h b/lib/eclient-stubs.h
new file mode 100644 (file)
index 0000000..2475034
--- /dev/null
@@ -0,0 +1,802 @@
+/*
+ * Automatically generated file, see scripts/protocol
+ *
+ * DO NOT EDIT.
+ */
+/*
+ * This file is part of DisOrder.
+ * Copyright (C) 2010-11 Richard Kettlewell
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef ECLIENT_STUBS_H
+#define ECLIENT_STUBS_H
+
+/** @brief Adopt a track
+ *
+ * Makes the calling user owner of a randomly picked track.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param id Track ID
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_adopt(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v);
+
+/** @brief Create a user
+ *
+ * Create a new user.  Requires the 'admin' right.  Email addresses etc must be filled in in separate commands.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param user New username
+ * @param password Initial password
+ * @param rights Initial rights (optional)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_adduser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *user, const char *password, const char *rights, void *v);
+
+/** @brief List files and directories in a directory
+ *
+ * See 'files' and 'dirs' for more specific lists.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param dir Directory to list (optional)
+ * @param re Regexp that results must match (optional)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_allfiles(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v);
+
+/** @brief Delete user
+ *
+ * Requires the 'admin' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param user User to delete
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_deluser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *user, void *v);
+
+/** @brief List directories in a directory
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param dir Directory to list (optional)
+ * @param re Regexp that results must match (optional)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_dirs(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v);
+
+/** @brief Disable play
+ *
+ * Play will stop at the end of the current track, if one is playing.  Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_disable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Set a user property
+ *
+ * With the 'admin' right you can do anything.  Otherwise you need the 'userinfo' right and can only set 'email' and 'password'.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param username User to modify
+ * @param property Property name
+ * @param value New property value
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_edituser(disorder_eclient *c, disorder_eclient_no_response *completed, const char *username, const char *property, const char *value, void *v);
+
+/** @brief Enable play
+ *
+ * Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_enable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Detect whether play is enabled
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_enabled(disorder_eclient *c, disorder_eclient_integer_response *completed, void *v);
+
+/** @brief Test whether a track exists
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_exists(disorder_eclient *c, disorder_eclient_integer_response *completed, const char *track, void *v);
+
+/** @brief List files in a directory
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param dir Directory to list (optional)
+ * @param re Regexp that results must match (optional)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_files(disorder_eclient *c, disorder_eclient_list_response *completed, const char *dir, const char *re, void *v);
+
+/** @brief Get a track preference
+ *
+ * If the track does not exist that is an error.  If the track exists but the preference does not then a null value is returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param pref Preference name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_get(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, const char *pref, void *v);
+
+/** @brief Get a global preference
+ *
+ * If the preference does exist not then a null value is returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param pref Global preference name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_get_global(disorder_eclient *c, disorder_eclient_string_response *completed, const char *pref, void *v);
+
+/** @brief Get a track's length
+ *
+ * If the track does not exist an error is returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_length(disorder_eclient *c, disorder_eclient_integer_response *completed, const char *track, void *v);
+
+/** @brief Create a login cookie for this user
+ *
+ * The cookie may be redeemed via the 'cookie' command
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_make_cookie(disorder_eclient *c, disorder_eclient_string_response *completed, void *v);
+
+/** @brief Move a track
+ *
+ * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track ID or name
+ * @param delta How far to move the track towards the head of the queue
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_move(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, long delta, void *v);
+
+/** @brief Move multiple tracks
+ *
+ * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param target Move after this track, or to head if ""
+ * @param ids List of tracks to move by ID
+ * @param nids Length of ids
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_moveafter(disorder_eclient *c, disorder_eclient_no_response *completed, const char *target, char **ids, int nids, void *v);
+
+/** @brief List recently added tracks
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param max Maximum tracks to fetch, or 0 for all available
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_new_tracks(disorder_eclient *c, disorder_eclient_list_response *completed, long max, void *v);
+
+/** @brief Do nothing
+ *
+ * Used as a keepalive.  No authentication required.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_nop(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Get a track name part
+ *
+ * If the name part cannot be constructed an empty string is returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param context Context ("sort" or "display")
+ * @param part Name part ("artist", "album" or "title")
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_part(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, const char *context, const char *part, void *v);
+
+/** @brief Pause the currently playing track
+ *
+ * Requires the 'pause' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_pause(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Play a track
+ *
+ * Requires the 'play' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track to play
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_play(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, void *v);
+
+/** @brief Play multiple tracks
+ *
+ * Requires the 'play' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param target Insert into queue after this track, or at head if ""
+ * @param tracks List of track names to play
+ * @param ntracks Length of tracks
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playafter(disorder_eclient *c, disorder_eclient_no_response *completed, const char *target, char **tracks, int ntracks, void *v);
+
+/** @brief Retrieve the playing track
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playing(disorder_eclient *c, disorder_eclient_playing_response *completed, void *v);
+
+/** @brief Delete a playlist
+ *
+ * Requires the 'play' right and permission to modify the playlist.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist to delete
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_delete(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, void *v);
+
+/** @brief List the contents of a playlist
+ *
+ * Requires the 'read' right and oermission to read the playlist.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_get(disorder_eclient *c, disorder_eclient_list_response *completed, const char *playlist, void *v);
+
+/** @brief Get a playlist's sharing status
+ *
+ * Requires the 'read' right and permission to read the playlist.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist to read
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_get_share(disorder_eclient *c, disorder_eclient_string_response *completed, const char *playlist, void *v);
+
+/** @brief Lock a playlist
+ *
+ * Requires the 'play' right and permission to modify the playlist.  A given connection may lock at most one playlist.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist to delete
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_lock(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, void *v);
+
+/** @brief Set the contents of a playlist
+ *
+ * Requires the 'play' right and permission to modify the playlist, which must be locked.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist to modify
+ * @param tracks New list of tracks for playlist
+ * @param ntracks Length of tracks
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_set(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, char **tracks, int ntracks, void *v);
+
+/** @brief Set a playlist's sharing status
+ *
+ * Requires the 'play' right and permission to modify the playlist.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param playlist Playlist to modify
+ * @param share New sharing status ("public", "private" or "shared")
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_set_share(disorder_eclient *c, disorder_eclient_no_response *completed, const char *playlist, const char *share, void *v);
+
+/** @brief Unlock the locked playlist playlist
+ *
+ * The playlist to unlock is implicit in the connection.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlist_unlock(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief List playlists
+ *
+ * Requires the 'read' right.  Only playlists that you have permission to read are returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_playlists(disorder_eclient *c, disorder_eclient_list_response *completed, void *v);
+
+/** @brief List the queue
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_queue(disorder_eclient *c, disorder_eclient_queue_response *completed, void *v);
+
+/** @brief Disable random play
+ *
+ * Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_random_disable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Enable random play
+ *
+ * Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_random_enable(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Detect whether random play is enabled
+ *
+ * Random play counts as enabled even if play is disabled.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_random_enabled(disorder_eclient *c, disorder_eclient_integer_response *completed, void *v);
+
+/** @brief List recently played tracks
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_recent(disorder_eclient *c, disorder_eclient_queue_response *completed, void *v);
+
+/** @brief Re-read configuraiton file.
+ *
+ * Requires the 'admin' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_reconfigure(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Register a new user
+ *
+ * Requires the 'register' right which is usually only available to the 'guest' user.  Redeem the confirmation string via 'confirm' to complete registration.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param username Requested new username
+ * @param password Requested initial password
+ * @param email New user's email address
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_register(disorder_eclient *c, disorder_eclient_string_response *completed, const char *username, const char *password, const char *email, void *v);
+
+/** @brief Send a password reminder.
+ *
+ * If the user has no valid email address, or no password, or a reminder has been sent too recently, then no reminder will be sent.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param username User to remind
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_reminder(disorder_eclient *c, disorder_eclient_no_response *completed, const char *username, void *v);
+
+/** @brief Remove a track form the queue.
+ *
+ * Requires one of the 'remove mine', 'remove random' or 'remove any' rights depending on how the track came to be added to the queue.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param id Track ID
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_remove(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v);
+
+/** @brief Rescan all collections for new or obsolete tracks.
+ *
+ * Requires the 'rescan' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_rescan(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Resolve a track name
+ *
+ * Converts aliases to non-alias track names
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name (might be an alias)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_resolve(disorder_eclient *c, disorder_eclient_string_response *completed, const char *track, void *v);
+
+/** @brief Resume the currently playing track
+ *
+ * Requires the 'pause' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_resume(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Revoke a cookie.
+ *
+ * It will not subsequently be possible to log in with the cookie.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_revoke(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Terminate the playing track.
+ *
+ * Requires one of the 'scratch mine', 'scratch random' or 'scratch any' rights depending on how the track came to be added to the queue.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param id Track ID (optional)
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_scratch(disorder_eclient *c, disorder_eclient_no_response *completed, const char *id, void *v);
+
+/** @brief Schedule a track to play in the future
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param when When to play the track
+ * @param priority Event priority ("normal" or "junk")
+ * @param track Track to play
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_schedule_add_play(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *track, void *v);
+
+/** @brief Schedule a global setting to be changed in the future
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param when When to change the setting
+ * @param priority Event priority ("normal" or "junk")
+ * @param pref Global preference to set
+ * @param value New value of global preference
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_schedule_add_set_global(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *pref, const char *value, void *v);
+
+/** @brief Schedule a global setting to be unset in the future
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param when When to change the setting
+ * @param priority Event priority ("normal" or "junk")
+ * @param pref Global preference to set
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_schedule_add_unset_global(disorder_eclient *c, disorder_eclient_no_response *completed, time_t when, const char *priority, const char *pref, void *v);
+
+/** @brief Delete a scheduled event.
+ *
+ * Users can always delete their own scheduled events; with the admin right you can delete any event.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param event ID of event to delete
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_schedule_del(disorder_eclient *c, disorder_eclient_no_response *completed, const char *event, void *v);
+
+/** @brief List scheduled events
+ *
+ * This just lists IDs.  Use 'schedule-get' to retrieve more detail
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_schedule_list(disorder_eclient *c, disorder_eclient_list_response *completed, void *v);
+
+/** @brief Search for tracks
+ *
+ * Terms are either keywords or tags formatted as 'tag:TAG-NAME'.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param terms List of search terms
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_search(disorder_eclient *c, disorder_eclient_list_response *completed, const char *terms, void *v);
+
+/** @brief Set a track preference
+ *
+ * Requires the 'prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param pref Preference name
+ * @param value New value
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_set(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, const char *pref, const char *value, void *v);
+
+/** @brief Set a global preference
+ *
+ * Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param pref Preference name
+ * @param value New value
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_set_global(disorder_eclient *c, disorder_eclient_no_response *completed, const char *pref, const char *value, void *v);
+
+/** @brief Request server shutdown
+ *
+ * Requires the 'admin' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_shutdown(disorder_eclient *c, disorder_eclient_no_response *completed, void *v);
+
+/** @brief Get server statistics
+ *
+ * The details of what the server reports are not really defined.  The returned strings are intended to be printed out one to a line.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_stats(disorder_eclient *c, disorder_eclient_list_response *completed, void *v);
+
+/** @brief Get a list of known tags
+ *
+ * Only tags which apply to at least one track are returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_tags(disorder_eclient *c, disorder_eclient_list_response *completed, void *v);
+
+/** @brief Unset a track preference
+ *
+ * Requires the 'prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param track Track name
+ * @param pref Preference name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_unset(disorder_eclient *c, disorder_eclient_no_response *completed, const char *track, const char *pref, void *v);
+
+/** @brief Set a global preference
+ *
+ * Requires the 'global prefs' right.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param pref Preference name
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_unset_global(disorder_eclient *c, disorder_eclient_no_response *completed, const char *pref, void *v);
+
+/** @brief Get a user property.
+ *
+ * If the user does not exist an error is returned, if the user exists but the property does not then a null value is returned.
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param username User to read
+ * @param property Property to read
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_userinfo(disorder_eclient *c, disorder_eclient_string_response *completed, const char *username, const char *property, void *v);
+
+/** @brief Get a list of users
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_users(disorder_eclient *c, disorder_eclient_list_response *completed, void *v);
+
+/** @brief Get the server version
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_version(disorder_eclient *c, disorder_eclient_string_response *completed, void *v);
+
+/** @brief Set the volume
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param left Left channel volume
+ * @param right Right channel volume
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_set_volume(disorder_eclient *c, disorder_eclient_no_response *completed, long left, long right, void *v);
+
+/** @brief Get the volume
+ *
+ * 
+ *
+ * @param c Client
+ * @param completed Called upon completion
+ * @param v Passed to @p completed
+ * @return 0 if the command was queued successfuly, non-0 on error
+ */
+int disorder_eclient_get_volume(disorder_eclient *c, disorder_eclient_pair_integer_response *completed, void *v);
+
+#endif
index d03306e..c253b06 100644 (file)
@@ -876,8 +876,21 @@ static void vstash_command(disorder_eclient *c,
   if(cmd) {
     vector_init(&vec);
     vector_append(&vec, (char *)cmd);
-    while((arg = va_arg(ap, char *)))
-      vector_append(&vec, arg);
+    while((arg = va_arg(ap, char *))) {
+      if(arg == disorder__list) {
+       char **list = va_arg(ap, char **);
+       int nlist = va_arg(ap, int);
+       if(nlist < 0) {
+         for(nlist = 0; list[nlist]; ++nlist)
+           ;
+       }
+        vector_append_many(&vec, list, nlist);
+      } else if(arg == disorder__body) {
+       body = va_arg(ap, char **);
+       nbody = va_arg(ap, int);
+      } else
+        vector_append(&vec, arg);
+    }
     stash_command_vector(c, queuejump, opcallback, completed, v, 
                          nbody, body, vec.nvec, vec.vec);
   } else
@@ -1059,16 +1072,16 @@ static void list_response_opcallback(disorder_eclient *c,
 }
 
 /* for volume */
-static void volume_response_opcallback(disorder_eclient *c,
-                                       struct operation *op) {
-  disorder_eclient_volume_response *completed
-    = (disorder_eclient_volume_response *)op->completed;
-  int l, r;
+static void pair_integer_response_opcallback(disorder_eclient *c,
+                                             struct operation *op) {
+  disorder_eclient_pair_integer_response *completed
+    = (disorder_eclient_pair_integer_response *)op->completed;
+  long l, r;
 
   D(("volume_response_callback"));
   if(c->rc / 100 == 2) {
     if(op->completed) {
-      if(sscanf(c->line + 4, "%d %d", &l, &r) != 2 || l < 0 || r < 0)
+      if(sscanf(c->line + 4, "%ld %ld", &l, &r) != 2 || l < 0 || r < 0)
         completed(op->v, "cannot parse volume response", 0, 0);
       else
         completed(op->v, 0, l, r);
@@ -1092,316 +1105,12 @@ static int simple(disorder_eclient *c,
   return 0;
 }
 
-static int simple_body(disorder_eclient *c,
-                       operation_callback *opcallback,
-                       void (*completed)(),
-                       void *v,
-                       int nbody,
-                       char **body,
-                       const char *cmd, ...) {
-  va_list ap;
-
-  va_start(ap, cmd);
-  vstash_command(c, 0/*queuejump*/, opcallback, completed, v, nbody, body, cmd, ap);
-  va_end(ap);
-  /* Give the state machine a kick, since we might be in state_idle */
-  disorder_eclient_polled(c, 0);
-  return 0;
-}
-
 /* Commands ******************************************************************/
-int disorder_eclient_version(disorder_eclient *c,
-                             disorder_eclient_string_response *completed,
-                             void *v) {
-  return simple(c, string_response_opcallback, (void (*)())completed, v,
-                "version", (char *)0);
-}
-
-int disorder_eclient_namepart(disorder_eclient *c,
-                              disorder_eclient_string_response *completed,
-                              const char *track,
-                              const char *context,
-                              const char *part,
-                              void *v) {
-  return simple(c, string_response_opcallback, (void (*)())completed, v,
-                "part", track, context, part, (char *)0);
-}
-
-int disorder_eclient_play(disorder_eclient *c,
-                          const char *track,
-                          disorder_eclient_no_response *completed,
-                          void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "play", track, (char *)0);
-}
-
-int disorder_eclient_playafter(disorder_eclient *c,
-                               const char *target,
-                               int ntracks,
-                               const char **tracks,
-                               disorder_eclient_no_response *completed,
-                               void *v) {
-  struct vector vec;
-  int n;
-
-  if(!target)
-    target = "";
-  vector_init(&vec);
-  vector_append(&vec, (char *)"playafter");
-  vector_append(&vec, (char *)target);
-  for(n = 0; n < ntracks; ++n)
-    vector_append(&vec, (char *)tracks[n]);
-  stash_command_vector(c, 0/*queuejump*/, no_response_opcallback, completed, v,
-                       -1, 0, vec.nvec, vec.vec);
-  disorder_eclient_polled(c, 0);
-  return 0;
-}
-
-int disorder_eclient_pause(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "pause", (char *)0);
-}
-
-int disorder_eclient_resume(disorder_eclient *c,
-                            disorder_eclient_no_response *completed,
-                            void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "resume", (char *)0);
-}
-
-int disorder_eclient_scratch(disorder_eclient *c,
-                             const char *id,
-                             disorder_eclient_no_response *completed,
-                             void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "scratch", id, (char *)0);
-}
 
 int disorder_eclient_scratch_playing(disorder_eclient *c,
                                      disorder_eclient_no_response *completed,
                                      void *v) {
-  return disorder_eclient_scratch(c, 0, completed, v);
-}
-
-int disorder_eclient_remove(disorder_eclient *c,
-                            const char *id,
-                            disorder_eclient_no_response *completed,
-                            void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "remove", id, (char *)0);
-}
-
-int disorder_eclient_moveafter(disorder_eclient *c,
-                               const char *target,
-                               int nids,
-                               const char **ids,
-                               disorder_eclient_no_response *completed,
-                               void *v) {
-  struct vector vec;
-  int n;
-
-  vector_init(&vec);
-  vector_append(&vec, (char *)"moveafter");
-  vector_append(&vec, (char *)target);
-  for(n = 0; n < nids; ++n)
-    vector_append(&vec, (char *)ids[n]);
-  stash_command_vector(c, 0/*queuejump*/, no_response_opcallback, completed, v,
-                       -1, 0, vec.nvec, vec.vec);
-  disorder_eclient_polled(c, 0);
-  return 0;
-}
-
-int disorder_eclient_recent(disorder_eclient *c,
-                            disorder_eclient_queue_response *completed,
-                            void *v) {
-  return simple(c, queue_response_opcallback, (void (*)())completed, v,
-                "recent", (char *)0);
-}
-
-int disorder_eclient_queue(disorder_eclient *c,
-                            disorder_eclient_queue_response *completed,
-                            void *v) {
-  return simple(c, queue_response_opcallback, (void (*)())completed, v,
-                "queue", (char *)0);
-}
-
-int disorder_eclient_files(disorder_eclient *c,
-                           disorder_eclient_list_response *completed,
-                           const char *dir,
-                           const char *re,
-                           void *v) {
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "files", dir, re, (char *)0);
-}
-
-int disorder_eclient_dirs(disorder_eclient *c,
-                          disorder_eclient_list_response *completed,
-                          const char *dir,
-                          const char *re,
-                          void *v) {
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "dirs", dir, re, (char *)0);
-}
-
-int disorder_eclient_playing(disorder_eclient *c,
-                             disorder_eclient_queue_response *completed,
-                             void *v) {
-  return simple(c, playing_response_opcallback, (void (*)())completed, v,
-                "playing", (char *)0);
-}
-
-int disorder_eclient_length(disorder_eclient *c,
-                            disorder_eclient_integer_response *completed,
-                            const char *track,
-                            void *v) {
-  return simple(c, integer_response_opcallback, (void (*)())completed, v,
-                "length", track, (char *)0);
-}
-
-int disorder_eclient_volume(disorder_eclient *c,
-                            disorder_eclient_volume_response *completed,
-                            int l, int r,
-                            void *v) {
-  char sl[64], sr[64];
-
-  if(l < 0 && r < 0) {
-    return simple(c, volume_response_opcallback, (void (*)())completed, v,
-                  "volume", (char *)0);
-  } else if(l >= 0 && r >= 0) {
-    assert(l <= 100);
-    assert(r <= 100);
-    byte_snprintf(sl, sizeof sl, "%d", l);
-    byte_snprintf(sr, sizeof sr, "%d", r);
-    return simple(c, volume_response_opcallback, (void (*)())completed, v,
-                  "volume", sl, sr, (char *)0);
-  } else {
-    assert(!"invalid arguments to disorder_eclient_volume");
-    return -1;                          /* gcc is being dim */
-  }
-}
-
-int disorder_eclient_enable(disorder_eclient *c,
-                            disorder_eclient_no_response *completed,
-                            void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "enable", (char *)0);
-}
-
-int disorder_eclient_disable(disorder_eclient *c,
-                             disorder_eclient_no_response *completed,
-                             void *v){
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "disable", (char *)0);
-}
-
-int disorder_eclient_random_enable(disorder_eclient *c,
-                                   disorder_eclient_no_response *completed,
-                                   void *v){
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "random-enable", (char *)0);
-}
-
-int disorder_eclient_random_disable(disorder_eclient *c,
-                                    disorder_eclient_no_response *completed,
-                                    void *v){
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "random-disable", (char *)0);
-}
-
-int disorder_eclient_get(disorder_eclient *c,
-                         disorder_eclient_string_response *completed,
-                         const char *track, const char *pref,
-                         void *v) {
-  return simple(c, string_response_opcallback, (void (*)())completed, v, 
-                "get", track, pref, (char *)0);
-}
-
-int disorder_eclient_set(disorder_eclient *c,
-                         disorder_eclient_no_response *completed,
-                         const char *track, const char *pref, 
-                         const char *value,
-                         void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "set", track, pref, value, (char *)0);
-}
-
-int disorder_eclient_unset(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           const char *track, const char *pref, 
-                           void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "unset", track, pref, (char *)0);
-}
-
-int disorder_eclient_resolve(disorder_eclient *c,
-                             disorder_eclient_string_response *completed,
-                             const char *track,
-                             void *v) {
-  return simple(c, string_response_opcallback,  (void (*)())completed, v, 
-                "resolve", track, (char *)0);
-}
-
-int disorder_eclient_search(disorder_eclient *c,
-                            disorder_eclient_list_response *completed,
-                            const char *terms,
-                            void *v) {
-  if(!split(terms, 0, SPLIT_QUOTES, 0, 0)) return -1;
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "search", terms, (char *)0);
-}
-
-int disorder_eclient_nop(disorder_eclient *c,
-                         disorder_eclient_no_response *completed,
-                         void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "nop", (char *)0);
-}
-
-int disorder_eclient_get_global(disorder_eclient *c,
-                                disorder_eclient_string_response *completed,
-                                const char *pref,
-                                void *v) {
-  return simple(c, string_response_opcallback, (void (*)())completed, v,
-                "get-global", pref, (char *)0);
-}
-
-int disorder_eclient_set_global(disorder_eclient *c,
-                                disorder_eclient_no_response *completed,
-                                const char *pref,
-                                const char *value,
-                                void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "set-global", pref, value, (char *)0);
-}
-
-int disorder_eclient_unset_global(disorder_eclient *c,
-                                  disorder_eclient_no_response *completed,
-                                  const char *pref,
-                                  void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v,
-                "unset-global", pref, (char *)0);
-}
-
-/** @brief Get the last @p max added tracks
- * @param c Client
- * @param completed Called with list
- * @param max Number of tracks to get, 0 for all
- * @param v Passed to @p completed
- *
- * The first track in the list is the most recently added.
- */
-int disorder_eclient_new_tracks(disorder_eclient *c,
-                                disorder_eclient_list_response *completed,
-                                int max,
-                                void *v) {
-  char limit[32];
-
-  sprintf(limit, "%d", max);
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "new", limit, (char *)0);
+  return disorder_eclient_scratch(c, completed, 0, v);
 }
 
 static void rtp_response_opcallback(disorder_eclient *c,
@@ -1436,217 +1145,6 @@ int disorder_eclient_rtp_address(disorder_eclient *c,
                 "rtp-address", (char *)0);
 }
 
-/** @brief Get the list of users
- * @param c Client
- * @param completed Called with list of users
- * @param v Passed to @p completed
- *
- * The user list is not sorted in any particular order.
- */
-int disorder_eclient_users(disorder_eclient *c,
-                           disorder_eclient_list_response *completed,
-                           void *v) {
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "users", (char *)0);
-}
-
-/** @brief Delete a user
- * @param c Client
- * @param completed Called on completion
- * @param user User to delete
- * @param v Passed to @p completed
- */
-int disorder_eclient_deluser(disorder_eclient *c,
-                             disorder_eclient_no_response *completed,
-                             const char *user,
-                             void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "deluser", user, (char *)0);
-}
-
-/** @brief Get a user property
- * @param c Client
- * @param completed Called on completion
- * @param user User to look up
- * @param property Property to look up
- * @param v Passed to @p completed
- */
-int disorder_eclient_userinfo(disorder_eclient *c,
-                              disorder_eclient_string_response *completed,
-                              const char *user,
-                              const char *property,
-                              void *v) {
-  return simple(c, string_response_opcallback,  (void (*)())completed, v, 
-                "userinfo", user, property, (char *)0);
-}
-
-/** @brief Modify a user property
- * @param c Client
- * @param completed Called on completion
- * @param user User to modify
- * @param property Property to modify
- * @param value New property value
- * @param v Passed to @p completed
- */
-int disorder_eclient_edituser(disorder_eclient *c,
-                              disorder_eclient_no_response *completed,
-                              const char *user,
-                              const char *property,
-                              const char *value,
-                              void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "edituser", user, property, value, (char *)0);
-}
-
-/** @brief Create a new user
- * @param c Client
- * @param completed Called on completion
- * @param user User to create
- * @param password Initial password
- * @param rights Initial rights or NULL
- * @param v Passed to @p completed
- */
-int disorder_eclient_adduser(disorder_eclient *c,
-                             disorder_eclient_no_response *completed,
-                             const char *user,
-                             const char *password,
-                             const char *rights,
-                             void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "adduser", user, password, rights, (char *)0);
-}
-
-/** @brief Adopt a track
- * @param c Client
- * @param completed Called on completion
- * @param id Track ID
- * @param v Passed to @p completed
- */
-int disorder_eclient_adopt(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           const char *id,
-                           void *v) {
-  return simple(c, no_response_opcallback, (void (*)())completed, v, 
-                "adopt", id, (char *)0);
-}
-
-/** @brief Get the list of playlists
- * @param c Client
- * @param completed Called with list of playlists
- * @param v Passed to @p completed
- *
- * The playlist list is not sorted in any particular order.
- */
-int disorder_eclient_playlists(disorder_eclient *c,
-                               disorder_eclient_list_response *completed,
-                               void *v) {
-  return simple(c, list_response_opcallback, (void (*)())completed, v,
-                "playlists", (char *)0);
-}
-
-/** @brief Delete a playlist
- * @param c Client
- * @param completed Called on completion
- * @param playlist Playlist to delete
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_delete(disorder_eclient *c,
-                                     disorder_eclient_no_response *completed,
-                                     const char *playlist,
-                                     void *v) {
-  return simple(c, no_response_opcallback,  (void (*)())completed, v,
-                "playlist-delete", playlist, (char *)0);
-}
-
-/** @brief Lock a playlist
- * @param c Client
- * @param completed Called on completion
- * @param playlist Playlist to lock
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_lock(disorder_eclient *c,
-                                   disorder_eclient_no_response *completed,
-                                   const char *playlist,
-                                   void *v) {
-  return simple(c, no_response_opcallback,  (void (*)())completed, v,
-                "playlist-lock", playlist, (char *)0);
-}
-
-/** @brief Unlock the locked a playlist
- * @param c Client
- * @param completed Called on completion
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_unlock(disorder_eclient *c,
-                                     disorder_eclient_no_response *completed,
-                                     void *v) {
-  return simple(c, no_response_opcallback,  (void (*)())completed, v,
-                "playlist-unlock", (char *)0);
-}
-
-/** @brief Set a playlist's sharing
- * @param c Client
- * @param completed Called on completion
- * @param playlist Playlist to modify
- * @param sharing @c "public" or @c "private"
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_set_share(disorder_eclient *c,
-                                        disorder_eclient_no_response *completed,
-                                        const char *playlist,
-                                        const char *sharing,
-                                        void *v) {
-  return simple(c, no_response_opcallback,  (void (*)())completed, v,
-                "playlist-set-share", playlist, sharing, (char *)0);
-}
-
-/** @brief Get a playlist's sharing
- * @param c Client
- * @param completed Called with sharing status
- * @param playlist Playlist to inspect
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_get_share(disorder_eclient *c,
-                                        disorder_eclient_string_response *completed,
-                                        const char *playlist,
-                                        void *v) {
-  return simple(c, string_response_opcallback,  (void (*)())completed, v,
-                "playlist-get-share", playlist, (char *)0);
-}
-
-/** @brief Set a playlist
- * @param c Client
- * @param completed Called on completion
- * @param playlist Playlist to modify
- * @param tracks List of tracks
- * @param ntracks Number of tracks
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_set(disorder_eclient *c,
-                                  disorder_eclient_no_response *completed,
-                                  const char *playlist,
-                                  char **tracks,
-                                  int ntracks,
-                                  void *v) {
-  return simple_body(c, no_response_opcallback, (void (*)())completed, v,
-                     ntracks, tracks,
-                     "playlist-set", playlist, (char *)0);
-}
-
-/** @brief Get a playlist's contents
- * @param c Client
- * @param completed Called with playlist contents
- * @param playlist Playlist to inspect
- * @param v Passed to @p completed
- */
-int disorder_eclient_playlist_get(disorder_eclient *c,
-                                  disorder_eclient_list_response *completed,
-                                  const char *playlist,
-                                  void *v) {
-  return simple(c, list_response_opcallback,  (void (*)())completed, v,
-                "playlist-get", playlist, (char *)0);
-}
-
 /* Log clients ***************************************************************/
 
 /** @brief Monitor the server log
@@ -1954,6 +1452,8 @@ static void logentry_global_pref(disorder_eclient *c,
     c->log_callbacks->global_pref(c->log_v, vec[0], nvec > 1 ? vec[1] : 0);
 }
 
+#include "eclient-stubs.c"
+
 /*
 Local Variables:
 c-basic-offset:2
index 6abcfdc..371af13 100644 (file)
@@ -267,9 +267,9 @@ typedef void disorder_eclient_integer_response(void *v,
  * @p error will be non-NULL on failure.  In this case @p l and @p r are always
  * 0.
  */
-typedef void disorder_eclient_volume_response(void *v,
-                                              const char *err,
-                                              int l, int r);
+typedef void disorder_eclient_pair_integer_response(void *v,
+                                                    const char *err,
+                                                    long l, long r);
 
 /** @brief Queue request completion callback
  * @param v User data
@@ -287,6 +287,8 @@ typedef void disorder_eclient_queue_response(void *v,
                                              const char *err,
                                              struct queue_entry *q);
 
+#define disorder_eclient_playing_response disorder_eclient_queue_response
+
 /** @brief List request completion callback
  * @param v User data
  * @param err Error string or NULL on success
@@ -317,249 +319,25 @@ void disorder_eclient_polled(disorder_eclient *c, unsigned mode);
 /* Should be called when c's FD is readable and/or writable, and in any case
  * from time to time (so that retries work). */
 
-int disorder_eclient_version(disorder_eclient *c,
-                             disorder_eclient_string_response *completed,
-                             void *v);
-/* fetch the server version */
-
-int disorder_eclient_play(disorder_eclient *c,
-                          const char *track,
-                          disorder_eclient_no_response *completed,
-                          void *v);
-/* add a track to the queue */
-
-int disorder_eclient_playafter(disorder_eclient *c,
-                               const char *target,
-                               int ntracks,
-                               const char **tracks,
-                               disorder_eclient_no_response *completed,
-                               void *v);
-/* insert multiple tracks to an arbitrary point in the queue */
-
-int disorder_eclient_pause(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           void *v);
-/* add a track to the queue */
-
-int disorder_eclient_resume(disorder_eclient *c,
-                            disorder_eclient_no_response *completed,
-                            void *v);
-/* add a track to the queue */
-
-int disorder_eclient_scratch(disorder_eclient *c,
-                             const char *id,
-                             disorder_eclient_no_response *completed,
-                             void *v);
-/* scratch a track by ID */
-
 int disorder_eclient_scratch_playing(disorder_eclient *c,
                                      disorder_eclient_no_response *completed,
                                      void *v);
 /* scratch the playing track whatever it is */
 
-int disorder_eclient_remove(disorder_eclient *c,
-                            const char *id,
-                            disorder_eclient_no_response *completed,
-                            void *v);
-/* remove a track from the queue */
-
-int disorder_eclient_moveafter(disorder_eclient *c,
-                               const char *target,
-                               int nids,
-                               const char **ids,
-                               disorder_eclient_no_response *completed,
-                               void *v);
-/* move tracks within the queue */
-
-int disorder_eclient_playing(disorder_eclient *c,
-                             disorder_eclient_queue_response *completed,
-                             void *v);
-/* find the currently playing track (0 for none) */
-
-int disorder_eclient_queue(disorder_eclient *c,
-                           disorder_eclient_queue_response *completed,
-                           void *v);
-/* list recently played tracks */
-
-int disorder_eclient_recent(disorder_eclient *c,
-                            disorder_eclient_queue_response *completed,
-                            void *v);
-/* list recently played tracks */
-
-int disorder_eclient_files(disorder_eclient *c,
-                           disorder_eclient_list_response *completed,
-                           const char *dir,
-                           const char *re,
-                           void *v);
-/* list files in a directory, matching RE if not a null pointer */
-
-int disorder_eclient_dirs(disorder_eclient *c,
-                          disorder_eclient_list_response *completed,
-                          const char *dir,
-                          const char *re,
-                          void *v);
-/* list directories in a directory, matching RE if not a null pointer */
-
-int disorder_eclient_namepart(disorder_eclient *c,
-                              disorder_eclient_string_response *completed,
-                              const char *track,
-                              const char *context,
-                              const char *part,
-                              void *v);
-/* look up a track name part */
-
-int disorder_eclient_length(disorder_eclient *c,
-                            disorder_eclient_integer_response *completed,
-                            const char *track,
-                            void *v);
-/* look up a track name length */
-
-int disorder_eclient_volume(disorder_eclient *c,
-                            disorder_eclient_volume_response *callback,
-                            int l, int r,
-                            void *v);
-/* If L and R are both -ve gets the volume.
- * If neither are -ve then sets the volume.
- * Otherwise asserts!
- */
-
-int disorder_eclient_enable(disorder_eclient *c,
-                            disorder_eclient_no_response *callback,
-                            void *v);
-int disorder_eclient_disable(disorder_eclient *c,
-                             disorder_eclient_no_response *callback,
-                             void *v);
-int disorder_eclient_random_enable(disorder_eclient *c,
-                                   disorder_eclient_no_response *callback,
-                                   void *v);
-int disorder_eclient_random_disable(disorder_eclient *c,
-                                    disorder_eclient_no_response *callback,
-                                    void *v);
-/* Enable/disable play/random play */
-
-int disorder_eclient_resolve(disorder_eclient *c,
-                             disorder_eclient_string_response *completed,
-                             const char *track,
-                             void *v);
-/* Resolve aliases */
-
 int disorder_eclient_log(disorder_eclient *c,
                          const disorder_eclient_log_callbacks *callbacks,
                          void *v);
 /* Make this a log client (forever - it automatically becomes one again upon
  * reconnection) */
 
-int disorder_eclient_get(disorder_eclient *c,
-                         disorder_eclient_string_response *completed,
-                         const char *track, const char *pref,
-                         void *v);
-int disorder_eclient_set(disorder_eclient *c,
-                         disorder_eclient_no_response *completed,
-                         const char *track, const char *pref, 
-                         const char *value,
-                         void *v);
-int disorder_eclient_unset(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           const char *track, const char *pref, 
-                           void *v);
-/* Get/set preference values */
-
-int disorder_eclient_get_global(disorder_eclient *c,
-                                disorder_eclient_string_response *completed,
-                                const char *pref,
-                                void *v);
-int disorder_eclient_set_global(disorder_eclient *c,
-                                disorder_eclient_no_response *completed,
-                                const char *pref,
-                                const char *value,
-                                void *v);
-int disorder_eclient_unset_global(disorder_eclient *c,
-                                  disorder_eclient_no_response *completed,
-                                  const char *pref,
-                                  void *v);
-/* Get/set global prefs */
-
-int disorder_eclient_search(disorder_eclient *c,
-                            disorder_eclient_list_response *completed,
-                            const char *terms,
-                            void *v);
-
-int disorder_eclient_nop(disorder_eclient *c,
-                         disorder_eclient_no_response *completed,
-                         void *v);
-
-int disorder_eclient_new_tracks(disorder_eclient *c,
-                                disorder_eclient_list_response *completed,
-                                int max,
-                                void *v);
-
 int disorder_eclient_rtp_address(disorder_eclient *c,
                                  disorder_eclient_list_response *completed,
                                  void *v);
 
-int disorder_eclient_users(disorder_eclient *c,
-                           disorder_eclient_list_response *completed,
-                           void *v);
-int disorder_eclient_deluser(disorder_eclient *c,
-                             disorder_eclient_no_response *completed,
-                             const char *user,
-                             void *v);
-int disorder_eclient_userinfo(disorder_eclient *c,
-                              disorder_eclient_string_response *completed,
-                              const char *user,
-                              const char *property,
-                              void *v);
-int disorder_eclient_edituser(disorder_eclient *c,
-                              disorder_eclient_no_response *completed,
-                              const char *user,
-                              const char *property,
-                              const char *value,
-                              void *v);
-int disorder_eclient_adduser(disorder_eclient *c,
-                             disorder_eclient_no_response *completed,
-                             const char *user,
-                             const char *password,
-                             const char *rights,
-                             void *v);
 void disorder_eclient_enable_connect(disorder_eclient *c);
 void disorder_eclient_disable_connect(disorder_eclient *c);
-int disorder_eclient_adopt(disorder_eclient *c,
-                           disorder_eclient_no_response *completed,
-                           const char *id,
-                           void *v);  
-int disorder_eclient_playlists(disorder_eclient *c,
-                               disorder_eclient_list_response *completed,
-                               void *v);
-int disorder_eclient_playlist_delete(disorder_eclient *c,
-                                     disorder_eclient_no_response *completed,
-                                     const char *playlist,
-                                     void *v);
-int disorder_eclient_playlist_lock(disorder_eclient *c,
-                                   disorder_eclient_no_response *completed,
-                                   const char *playlist,
-                                   void *v);
-int disorder_eclient_playlist_unlock(disorder_eclient *c,
-                                     disorder_eclient_no_response *completed,
-                                     void *v);
-int disorder_eclient_playlist_set_share(disorder_eclient *c,
-                                        disorder_eclient_no_response *completed,
-                                        const char *playlist,
-                                        const char *sharing,
-                                        void *v);
-int disorder_eclient_playlist_get_share(disorder_eclient *c,
-                                        disorder_eclient_string_response *completed,
-                                        const char *playlist,
-                                        void *v);
-int disorder_eclient_playlist_set(disorder_eclient *c,
-                                  disorder_eclient_no_response *completed,
-                                  const char *playlist,
-                                  char **tracks,
-                                  int ntracks,
-                                  void *v);
-int disorder_eclient_playlist_get(disorder_eclient *c,
-                                  disorder_eclient_list_response *completed,
-                                  const char *playlist,
-                                  void *v);
+
+#include "eclient-stubs.h"
 
 #endif
 
index 90ccf1b..2362f63 100755 (executable)
@@ -59,7 +59,7 @@ our @eclient_return = (
     ["time_response" => ["time"]],
     ["pair_integer_response" => ["integer", "integer"]],
     ["queue_response" => ["queue"]],
-    ["queue_response" => ["queue-one"]],
+    ["playing_response" => ["queue-one"]],
     ["list_response" => ["body"]],
     );
 
@@ -247,7 +247,7 @@ sub simple {
     my @conversions = ();
     for my $arg (@$args) {
         if($arg->[0] eq 'body' or $arg->[0] eq 'list') {
-            push(@cargs, "disorder_$arg->[0]", $arg->[1], "n$arg->[1]");
+            push(@cargs, "disorder__$arg->[0]", $arg->[1], "n$arg->[1]");
         } elsif($arg->[0] eq 'string') {
             push(@cargs, $arg->[1]);
         } elsif($arg->[0] eq 'integer') {
@@ -408,17 +408,38 @@ sub simple {
             " * $detail\n",
             " *\n",
             " * \@param c Client\n",
-            c_param_docs($args),
             " * \@param completed Called upon completion\n",
+            c_param_docs($args),
+            " * \@param v Passed to \@p completed\n",
             " * \@return 0 if the command was queued successfuly, non-0 on error\n",
             " */\n",
             "int disorder_eclient_$cmdc(",
             join(", ", "disorder_eclient *c",
+                 "disorder_eclient_$variant *completed",
                  map(c_in_decl($_), @$args),
-                 "disorder_eclient_$variant *completed"),
+                 "void *v"),
             ");\n\n");
 
-# TODO implementation
+       print STDERR "AC ";
+       push(@ac,
+            "int disorder_eclient_$cmdc(",
+            join(", ", "disorder_eclient *c",
+                 "disorder_eclient_$variant *completed",
+                 map(c_in_decl($_), @$args),
+                 "void *v"),
+            ") {\n",
+            @conversions);
+       push(@ac, "  return simple(",
+            join(", ", 
+                 "c",
+                 "${variant}_opcallback",
+                 "(void (*)())completed",
+                 "v",
+                 "\"$cmd\"",
+                 @cargs,
+                 "(char *)0"),
+            ");\n");
+       push(@ac, "}\n\n");
     } else {
        push(@missing, "disorder_eclient_$cmdc");
     }