From 7788b7c7236551f3da91981b370d1c68cac0e248 Mon Sep 17 00:00:00 2001 Message-Id: <7788b7c7236551f3da91981b370d1c68cac0e248.1715579465.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 5 Jun 2010 11:23:50 +0100 Subject: [PATCH] Implement more commands. Switch to actually using generated code. Organization: Straylight/Edgeware From: Richard Kettlewell --- cgi/macros-disorder.c | 9 +- clients/disorder.c | 4 +- lib/client-stubs.c | 200 +++++++++++++++++++++ lib/client-stubs.h | 391 ++++++++++++++++++++++++++++++++++++++++ lib/client.c | 408 +----------------------------------------- lib/client.h | 5 +- scripts/protocol | 325 +++++++++++++++++++++++---------- 7 files changed, 829 insertions(+), 513 deletions(-) create mode 100644 lib/client-stubs.c create mode 100644 lib/client-stubs.h diff --git a/cgi/macros-disorder.c b/cgi/macros-disorder.c index 29835bb..7c369e1 100644 --- a/cgi/macros-disorder.c +++ b/cgi/macros-disorder.c @@ -159,10 +159,11 @@ static int exp_part(int nargs, return 0; } if(dcgi_client - && !disorder_part(dcgi_client, (char **)&s, + && !disorder_part(dcgi_client, track, !strcmp(context, "short") ? "display" : context, - part)) { + part, + (char **)&s)) { if(!strcmp(context, "short")) s = truncate_for_display(s, config->short_display); return sink_writes(output, cgi_sgmlquote(s)) < 0 ? -1 : 0; @@ -625,7 +626,7 @@ static int exp_trackstate(int attribute((unused)) nargs, if(!dcgi_client) return 0; - if(disorder_resolve(dcgi_client, &track, args[0])) + if(disorder_resolve(dcgi_client, args[0], &track)) return 0; dcgi_lookup(DCGI_PLAYING); if(dcgi_playing && !strcmp(track, dcgi_playing->track)) @@ -661,7 +662,7 @@ static int exp_resolve(int attribute((unused)) nargs, void attribute((unused)) *u) { char *r; - if(dcgi_client && !disorder_resolve(dcgi_client, &r, args[0])) + if(dcgi_client && !disorder_resolve(dcgi_client, args[0], &r)) return sink_writes(output, r) < 0 ? -1 : 0; return 0; } diff --git a/clients/disorder.c b/clients/disorder.c index 53fce74..a55a6e8 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -344,7 +344,7 @@ static void cf_move(char **argv) { static void cf_part(char **argv) { char *s; - if(disorder_part(getclient(), &s, argv[0], argv[1], argv[2])) exit(EXIT_FAILURE); + if(disorder_part(getclient(), argv[0], argv[1], argv[2], &s)) exit(EXIT_FAILURE); xprintf("%s\n", nullcheck(utf82mb_f(s))); } @@ -359,7 +359,7 @@ static void cf_authorize(char **argv) { static void cf_resolve(char **argv) { char *track; - if(disorder_resolve(getclient(), &track, argv[0])) exit(EXIT_FAILURE); + if(disorder_resolve(getclient(), argv[0], &track)) exit(EXIT_FAILURE); xprintf("%s\n", nullcheck(utf82mb_f(track))); } diff --git a/lib/client-stubs.c b/lib/client-stubs.c new file mode 100644 index 0000000..03047ad --- /dev/null +++ b/lib/client-stubs.c @@ -0,0 +1,200 @@ +/* + * This file is part of DisOrder. + * Copyright (C) 2010 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 . + */ + +int disorder_adopt(disorder_client *c, const char *id) { + return disorder_simple(c, 0, "adopt", id, (char *)0); +} + +int disorder_adduser(disorder_client *c, const char *user, const char *password, const char *rights) { + return disorder_simple(c, 0, "adduser", user, password, rights, (char *)0); +} + +int disorder_confirm(disorder_client *c, const char *confirmation) { + char *u; + int rc; + if((rc = disorder_simple(c, &u, "confirm", confirmation ))) + return rc; + c->user = u; + return 0; +} + +int disorder_cookie(disorder_client *c, const char *cookie) { + char *u; + int rc; + if((rc = disorder_simple(c, &u, "cookie", cookie ))) + return rc; + c->user = u; + return 0; +} + +int disorder_deluser(disorder_client *c, const char *user) { + return disorder_simple(c, 0, "deluser", user, (char *)0); +} + +int disorder_disable(disorder_client *c) { + return disorder_simple(c, 0, "disable", (char *)0); +} + +int disorder_edituser(disorder_client *c, const char *username, const char *property, const char *value) { + return disorder_simple(c, 0, "edituser", username, property, value, (char *)0); +} + +int disorder_enable(disorder_client *c) { + return disorder_simple(c, 0, "enable", (char *)0); +} + +int disorder_enabled(disorder_client *c, int *enabledp) { + char *v; + int rc; + if((rc = disorder_simple(c, &v, "enabled", (char *)0))) + return rc; + return boolean("enabled", v, enabledp); +} + +int disorder_exists(disorder_client *c, const char *track, int *existsp) { + char *v; + int rc; + if((rc = disorder_simple(c, &v, "exists", track, (char *)0))) + return rc; + return boolean("exists", v, existsp); +} + +int disorder_get(disorder_client *c, const char *track, const char *pref, char **valuep) { + return dequote(disorder_simple(c, valuep, "get", track, pref, (char *)0), valuep); +} + +int disorder_get_global(disorder_client *c, const char *pref, char **valuep) { + return dequote(disorder_simple(c, valuep, "get-global", pref, (char *)0), valuep); +} + +int disorder_make_cookie(disorder_client *c, char **cookiep) { + return dequote(disorder_simple(c, cookiep, "make-cookie", (char *)0), cookiep); +} + +int disorder_nop(disorder_client *c) { + return disorder_simple(c, 0, "nop", (char *)0); +} + +int disorder_part(disorder_client *c, const char *track, const char *context, const char *part, char **partp) { + return dequote(disorder_simple(c, partp, "part", track, context, part, (char *)0), partp); +} + +int disorder_pause(disorder_client *c) { + return disorder_simple(c, 0, "pause", (char *)0); +} + +int disorder_playlist_delete(disorder_client *c, const char *playlist) { + return disorder_simple(c, 0, "playlist-delete", playlist, (char *)0); +} + +int disorder_playlist_lock(disorder_client *c, const char *playlist) { + return disorder_simple(c, 0, "playlist-lock", playlist, (char *)0); +} + +int disorder_playlist_get_share(disorder_client *c, const char *playlist, char **sharep) { + return dequote(disorder_simple(c, sharep, "playlist-get-share", playlist, (char *)0), sharep); +} + +int disorder_playlist_set_share(disorder_client *c, const char *playlist, const char *share) { + return disorder_simple(c, 0, "playlist-set-share", playlist, share, (char *)0); +} + +int disorder_playlist_unlock(disorder_client *c) { + return disorder_simple(c, 0, "playlist-unlock", (char *)0); +} + +int disorder_random_disable(disorder_client *c) { + return disorder_simple(c, 0, "random-disable", (char *)0); +} + +int disorder_random_enable(disorder_client *c) { + return disorder_simple(c, 0, "random-enable", (char *)0); +} + +int disorder_random_enabled(disorder_client *c, int *enabledp) { + char *v; + int rc; + if((rc = disorder_simple(c, &v, "random-enabled", (char *)0))) + return rc; + return boolean("random-enabled", v, enabledp); +} + +int disorder_reconfigure(disorder_client *c) { + return disorder_simple(c, 0, "reconfigure", (char *)0); +} + +int disorder_register(disorder_client *c, const char *username, const char *password, const char *email, char **confirmationp) { + return dequote(disorder_simple(c, confirmationp, "register", username, password, email, (char *)0), confirmationp); +} + +int disorder_reminder(disorder_client *c, const char *username) { + return disorder_simple(c, 0, "reminder", username, (char *)0); +} + +int disorder_remove(disorder_client *c, const char *id) { + return disorder_simple(c, 0, "remove", id, (char *)0); +} + +int disorder_rescan(disorder_client *c) { + return disorder_simple(c, 0, "rescan", (char *)0); +} + +int disorder_resolve(disorder_client *c, const char *track, char **resolvedp) { + return dequote(disorder_simple(c, resolvedp, "resolve", track, (char *)0), resolvedp); +} + +int disorder_resume(disorder_client *c) { + return disorder_simple(c, 0, "resume", (char *)0); +} + +int disorder_revoke(disorder_client *c) { + return disorder_simple(c, 0, "revoke", (char *)0); +} + +int disorder_scratch(disorder_client *c, const char *id) { + return disorder_simple(c, 0, "scratch", id, (char *)0); +} + +int disorder_schedule_del(disorder_client *c, const char *event) { + return disorder_simple(c, 0, "schedule-del", event, (char *)0); +} + +int disorder_set(disorder_client *c, const char *track, const char *pref, const char *value) { + return disorder_simple(c, 0, "set", track, pref, value, (char *)0); +} + +int disorder_set_global(disorder_client *c, const char *pref, const char *value) { + return disorder_simple(c, 0, "set-global", pref, value, (char *)0); +} + +int disorder_unset(disorder_client *c, const char *track, const char *pref) { + return disorder_simple(c, 0, "unset", track, pref, (char *)0); +} + +int disorder_unset_global(disorder_client *c, const char *pref) { + return disorder_simple(c, 0, "unset-global", pref, (char *)0); +} + +int disorder_userinfo(disorder_client *c, const char *username, const char *property, char **valuep) { + return dequote(disorder_simple(c, valuep, "userinfo", username, property, (char *)0), valuep); +} + +int disorder_version(disorder_client *c, char **versionp) { + return dequote(disorder_simple(c, versionp, "version", (char *)0), versionp); +} + diff --git a/lib/client-stubs.h b/lib/client-stubs.h new file mode 100644 index 0000000..4e67b01 --- /dev/null +++ b/lib/client-stubs.h @@ -0,0 +1,391 @@ +/* + * This file is part of DisOrder. + * Copyright (C) 2010 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 . + */ +#ifndef CLIENT_STUBS_H +#define CLIENT_STUBS_H + +/** @brief Adopt a track + * + * Makes the calling user owner of a randomly picked track. + * + * @param id Track ID + * @return 0 on success, non-0 on error + */ +int disorder_adopt(disorder_client *c, const char *id); + +/** @brief Create a user + * + * Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands. + * + * @param user New username + * @param password Initial password + * @param rights Initial rights (optional) + * @return 0 on success, non-0 on error + */ +int disorder_adduser(disorder_client *c, const char *user, const char *password, const char *rights); + +/** @brief Confirm registration + * + * The confirmation string must have been created with 'register'. The username is returned so the caller knows who they are. + * + * @param confirmation Confirmation string + * @return 0 on success, non-0 on error + */ +int disorder_confirm(disorder_client *c, const char *confirmation); +/** @brief Log in with a cookie + * + * The cookie must have been created with 'make-cookie'. The username is returned so the caller knows who they are. + * + * @param cookie Cookie string + * @return 0 on success, non-0 on error + */ +int disorder_cookie(disorder_client *c, const char *cookie); +/** @brief Delete user + * + * Requires the 'admin' right. + * + * @param user User to delete + * @return 0 on success, non-0 on error + */ +int disorder_deluser(disorder_client *c, const char *user); + +/** @brief Disable play + * + * Play will stop at the end of the current track, if one is playing. Requires the 'global prefs' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_disable(disorder_client *c); + +/** @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 username User to modify + * @param property Property name + * @param value New property value + * @return 0 on success, non-0 on error + */ +int disorder_edituser(disorder_client *c, const char *username, const char *property, const char *value); + +/** @brief Enable play + * + * Requires the 'global prefs' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_enable(disorder_client *c); + +/** @brief Detect whether play is enabled + * + * + * + * @param enabledp 1 if play is enabled and 0 otherwise + * @return 0 on success, non-0 on error + */ +int disorder_enabled(disorder_client *c, int *enabledp); + +/** @brief Test whether a track exists + * + * + * + * @param track Track name + * @param existsp 1 if the track exists and 0 otherwise + * @return 0 on success, non-0 on error + */ +int disorder_exists(disorder_client *c, const char *track, int *existsp); + +/** @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 track Track name + * @param pref Preference name + * @param valuep Preference value + * @return 0 on success, non-0 on error + */ +int disorder_get(disorder_client *c, const char *track, const char *pref, char **valuep); + +/** @brief Get a global preference + * + * If the preference does exist not then a null value is returned. + * + * @param pref Global preference name + * @param valuep Preference value + * @return 0 on success, non-0 on error + */ +int disorder_get_global(disorder_client *c, const char *pref, char **valuep); + +/** @brief Create a login cookie for this user + * + * The cookie may be redeemed via the 'cookie' command + * + * @param cookiep Newly created cookie + * @return 0 on success, non-0 on error + */ +int disorder_make_cookie(disorder_client *c, char **cookiep); + +/** @brief Do nothing + * + * Used as a keepalive. No authentication required. + * + * @return 0 on success, non-0 on error + */ +int disorder_nop(disorder_client *c); + +/** @brief Get a track name part + * + * If the name part cannot be constructed an empty string is returned. + * + * @param track Track name + * @param context Context ("sort" or "display") + * @param part Name part ("artist", "album" or "title") + * @param partp Value of name part + * @return 0 on success, non-0 on error + */ +int disorder_part(disorder_client *c, const char *track, const char *context, const char *part, char **partp); + +/** @brief Pause the currently playing track + * + * Requires the 'pause' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_pause(disorder_client *c); + +/** @brief Delete a playlist + * + * Requires the 'play' right and permission to modify the playlist. + * + * @param playlist Playlist to delete + * @return 0 on success, non-0 on error + */ +int disorder_playlist_delete(disorder_client *c, const char *playlist); + +/** @brief Lock a playlist + * + * Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist. + * + * @param playlist Playlist to delete + * @return 0 on success, non-0 on error + */ +int disorder_playlist_lock(disorder_client *c, const char *playlist); + +/** @brief Get a playlist's sharing status + * + * Requires the 'read' right and permission to read the playlist. + * + * @param playlist Playlist to read + * @param sharep Sharing status ("public", "private" or "shared") + * @return 0 on success, non-0 on error + */ +int disorder_playlist_get_share(disorder_client *c, const char *playlist, char **sharep); + +/** @brief Set a playlist's sharing status + * + * Requires the 'play' right and permission to modify the playlist. + * + * @param playlist Playlist to modify + * @param share New sharing status ("public", "private" or "shared") + * @return 0 on success, non-0 on error + */ +int disorder_playlist_set_share(disorder_client *c, const char *playlist, const char *share); + +/** @brief Unlock the locked playlist playlist + * + * The playlist to unlock is implicit in the connection. + * + * @return 0 on success, non-0 on error + */ +int disorder_playlist_unlock(disorder_client *c); + +/** @brief Disable random play + * + * Requires the 'global prefs' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_random_disable(disorder_client *c); + +/** @brief Enable random play + * + * Requires the 'global prefs' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_random_enable(disorder_client *c); + +/** @brief Detect whether random play is enabled + * + * Random play counts as enabled even if play is disabled. + * + * @param enabledp 1 if random play is enabled and 0 otherwise + * @return 0 on success, non-0 on error + */ +int disorder_random_enabled(disorder_client *c, int *enabledp); + +/** @brief Re-read configuraiton file. + * + * Requires the 'admin' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_reconfigure(disorder_client *c); + +/** @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 username Requested new username + * @param password Requested initial password + * @param email New user's email address + * @param confirmationp Confirmation string + * @return 0 on success, non-0 on error + */ +int disorder_register(disorder_client *c, const char *username, const char *password, const char *email, char **confirmationp); + +/** @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 username User to remind + * @return 0 on success, non-0 on error + */ +int disorder_reminder(disorder_client *c, const char *username); + +/** @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 id Track ID + * @return 0 on success, non-0 on error + */ +int disorder_remove(disorder_client *c, const char *id); + +/** @brief Rescan all collections for new or obsolete tracks. + * + * Requires the 'rescan' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_rescan(disorder_client *c); + +/** @brief Resolve a track name + * + * Converts aliases to non-alias track names + * + * @param track Track name (might be an alias) + * @param resolvedp Resolve track name (definitely not an alias) + * @return 0 on success, non-0 on error + */ +int disorder_resolve(disorder_client *c, const char *track, char **resolvedp); + +/** @brief Resume the currently playing track + * + * Requires the 'pause' right. + * + * @return 0 on success, non-0 on error + */ +int disorder_resume(disorder_client *c); + +/** @brief Revoke a cookie. + * + * It will not subsequently be possible to log in with the cookie. + * + * @return 0 on success, non-0 on error + */ +int disorder_revoke(disorder_client *c); + +/** @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 id Track ID (optional) + * @return 0 on success, non-0 on error + */ +int disorder_scratch(disorder_client *c, const char *id); + +/** @brief Delete a scheduled event. + * + * Users can always delete their own scheduled events; with the admin right you can delete any event. + * + * @param event ID of event to delete + * @return 0 on success, non-0 on error + */ +int disorder_schedule_del(disorder_client *c, const char *event); + +/** @brief Set a track preference + * + * Requires the 'prefs' right. + * + * @param track Track name + * @param pref Preference name + * @param value New value + * @return 0 on success, non-0 on error + */ +int disorder_set(disorder_client *c, const char *track, const char *pref, const char *value); + +/** @brief Set a global preference + * + * Requires the 'global prefs' right. + * + * @param pref Preference name + * @param value New value + * @return 0 on success, non-0 on error + */ +int disorder_set_global(disorder_client *c, const char *pref, const char *value); + +/** @brief Unset a track preference + * + * Requires the 'prefs' right. + * + * @param track Track name + * @param pref Preference name + * @return 0 on success, non-0 on error + */ +int disorder_unset(disorder_client *c, const char *track, const char *pref); + +/** @brief Set a global preference + * + * Requires the 'global prefs' right. + * + * @param pref Preference name + * @return 0 on success, non-0 on error + */ +int disorder_unset_global(disorder_client *c, const char *pref); + +/** @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 username User to read + * @param property Property to read + * @param valuep Value of property + * @return 0 on success, non-0 on error + */ +int disorder_userinfo(disorder_client *c, const char *username, const char *property, char **valuep); + +/** @brief Get the server version + * + * + * + * @param versionp Server version string + * @return 0 on success, non-0 on error + */ +int disorder_version(disorder_client *c, char **versionp); + +#endif diff --git a/lib/client.c b/lib/client.c index 2cbcfa7..415823a 100644 --- a/lib/client.c +++ b/lib/client.c @@ -531,15 +531,6 @@ int disorder_play(disorder_client *c, const char *track) { return disorder_simple(c, 0, "play", track, (char *)0); } -/** @brief Remove a track - * @param c Client - * @param track Track to remove (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_remove(disorder_client *c, const char *track) { - return disorder_simple(c, 0, "remove", track, (char *)0); -} - /** @brief Move a track * @param c Client * @param track Track to move (UTF-8) @@ -553,31 +544,6 @@ int disorder_move(disorder_client *c, const char *track, int delta) { return disorder_simple(c, 0, "move", track, d, (char *)0); } -/** @brief Enable play - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_enable(disorder_client *c) { - return disorder_simple(c, 0, "enable", (char *)0); -} - -/** @brief Disable play - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_disable(disorder_client *c) { - return disorder_simple(c, 0, "disable", (char *)0); -} - -/** @brief Scratch the currently playing track - * @param id Playing track ID or NULL (UTF-8) - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_scratch(disorder_client *c, const char *id) { - return disorder_simple(c, 0, "scratch", id, (char *)0); -} - /** @brief Shut down the server * @param c Client * @return 0 on success, non-0 on error @@ -586,31 +552,6 @@ int disorder_shutdown(disorder_client *c) { return disorder_simple(c, 0, "shutdown", (char *)0); } -/** @brief Make the server re-read its configuration - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_reconfigure(disorder_client *c) { - return disorder_simple(c, 0, "reconfigure", (char *)0); -} - -/** @brief Rescan tracks - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_rescan(disorder_client *c) { - return disorder_simple(c, 0, "rescan", (char *)0); -} - -/** @brief Get server version number - * @param c Client - * @param rp Where to store version string (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_version(disorder_client *c, char **rp) { - return dequote(disorder_simple(c, rp, "version", (char *)0), rp); -} - static void client_error(const char *msg, void attribute((unused)) *u) { disorder_error(0, "error parsing reply: %s", msg); @@ -804,42 +745,6 @@ char *disorder_user(disorder_client *c) { return c->user; } -/** @brief Set a track preference - * @param c Client - * @param track Track name (UTF-8) - * @param key Preference name (UTF-8) - * @param value Preference value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_set(disorder_client *c, const char *track, - const char *key, const char *value) { - return disorder_simple(c, 0, "set", track, key, value, (char *)0); -} - -/** @brief Unset a track preference - * @param c Client - * @param track Track name (UTF-8) - * @param key Preference name (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_unset(disorder_client *c, const char *track, - const char *key) { - return disorder_simple(c, 0, "unset", track, key, (char *)0); -} - -/** @brief Get a track preference - * @param c Client - * @param track Track name (UTF-8) - * @param key Preference name (UTF-8) - * @param valuep Where to store preference value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_get(disorder_client *c, - const char *track, const char *key, char **valuep) { - return dequote(disorder_simple(c, valuep, "get", track, key, (char *)0), - valuep); -} - static void pref_error_handler(const char *msg, void attribute((unused)) *u) { disorder_error(0, "error handling 'prefs' reply: %s", msg); @@ -893,35 +798,6 @@ static int boolean(const char *cmd, const char *value, return 0; } -/** @brief Test whether a track exists - * @param c Client - * @param track Track name (UTF-8) - * @param existsp Where to store result (non-0 iff does exist) - * @return 0 on success, non-0 on error - */ -int disorder_exists(disorder_client *c, const char *track, int *existsp) { - char *v; - int rc; - - if((rc = disorder_simple(c, &v, "exists", track, (char *)0))) - return rc; - return boolean("exists", v, existsp); -} - -/** @brief Test whether playing is enabled - * @param c Client - * @param enabledp Where to store result (non-0 iff enabled) - * @return 0 on success, non-0 on error - */ -int disorder_enabled(disorder_client *c, int *enabledp) { - char *v; - int rc; - - if((rc = disorder_simple(c, &v, "enabled", (char *)0))) - return rc; - return boolean("enabled", v, enabledp); -} - /** @brief Get the length of a track * @param c Client * @param track Track name (UTF-8) @@ -953,36 +829,6 @@ int disorder_search(disorder_client *c, const char *terms, return disorder_simple_list(c, vecp, nvecp, "search", terms, (char *)0); } -/** @brief Enable random play - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_random_enable(disorder_client *c) { - return disorder_simple(c, 0, "random-enable", (char *)0); -} - -/** @brief Disable random play - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_random_disable(disorder_client *c) { - return disorder_simple(c, 0, "random-disable", (char *)0); -} - -/** @brief Test whether random play is enabled - * @param c Client - * @param enabledp Where to store result (non-0 iff enabled) - * @return 0 on success, non-0 on error - */ -int disorder_random_enabled(disorder_client *c, int *enabledp) { - char *v; - int rc; - - if((rc = disorder_simple(c, &v, "random-enabled", (char *)0))) - return rc; - return boolean("random-enabled", v, enabledp); -} - /** @brief Get server stats * @param c Client * @param vecp Where to store list (UTF-8) @@ -1050,47 +896,6 @@ int disorder_log(disorder_client *c, struct sink *s) { return 0; } -/** @brief Look up a track name part - * @param c Client - * @param partp Where to store result (UTF-8) - * @param track Track name (UTF-8) - * @param context Context (usually "sort" or "display") (UTF-8) - * @param part Track part (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_part(disorder_client *c, char **partp, - const char *track, const char *context, const char *part) { - return dequote(disorder_simple(c, partp, "part", - track, context, part, (char *)0), partp); -} - -/** @brief Resolve aliases - * @param c Client - * @param trackp Where to store canonical name (UTF-8) - * @param track Track name (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_resolve(disorder_client *c, char **trackp, const char *track) { - return dequote(disorder_simple(c, trackp, "resolve", track, (char *)0), - trackp); -} - -/** @brief Pause the current track - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_pause(disorder_client *c) { - return disorder_simple(c, 0, "pause", (char *)0); -} - -/** @brief Resume the current track - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_resume(disorder_client *c) { - return disorder_simple(c, 0, "resume", (char *)0); -} - /** @brief List all known tags * @param c Client * @param vecp Where to store list (UTF-8) @@ -1129,37 +934,6 @@ int disorder_new_tracks(disorder_client *c, return disorder_simple_list(c, vecp, nvecp, "new", limit, (char *)0); } -/** @brief Set a global preference - * @param c Client - * @param key Preference name (UTF-8) - * @param value Preference value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_set_global(disorder_client *c, - const char *key, const char *value) { - return disorder_simple(c, 0, "set-global", key, value, (char *)0); -} - -/** @brief Unset a global preference - * @param c Client - * @param key Preference name (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_unset_global(disorder_client *c, const char *key) { - return disorder_simple(c, 0, "unset-global", key, (char *)0); -} - -/** @brief Get a global preference - * @param c Client - * @param key Preference name (UTF-8) - * @param valuep Where to store preference value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_get_global(disorder_client *c, const char *key, char **valuep) { - return dequote(disorder_simple(c, valuep, "get-global", key, (char *)0), - valuep); -} - /** @brief Get server's RTP address information * @param c Client * @param addressp Where to store address (UTF-8) @@ -1184,111 +958,6 @@ int disorder_rtp_address(disorder_client *c, char **addressp, char **portp) { return 0; } -/** @brief Create a user - * @param c Client - * @param user Username - * @param password Password - * @param rights Initial rights or NULL to use default - * @return 0 on success, non-0 on error - */ -int disorder_adduser(disorder_client *c, - const char *user, const char *password, - const char *rights) { - return disorder_simple(c, 0, "adduser", user, password, rights, (char *)0); -} - -/** @brief Delete a user - * @param c Client - * @param user Username - * @return 0 on success, non-0 on error - */ -int disorder_deluser(disorder_client *c, const char *user) { - return disorder_simple(c, 0, "deluser", user, (char *)0); -} - -/** @brief Get user information - * @param c Client - * @param user Username - * @param key Property name (UTF-8) - * @param valuep Where to store value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_userinfo(disorder_client *c, const char *user, const char *key, - char **valuep) { - return dequote(disorder_simple(c, valuep, "userinfo", user, key, (char *)0), - valuep); -} - -/** @brief Set user information - * @param c Client - * @param user Username - * @param key Property name (UTF-8) - * @param value New property value (UTF-8) - * @return 0 on success, non-0 on error - */ -int disorder_edituser(disorder_client *c, const char *user, - const char *key, const char *value) { - return disorder_simple(c, 0, "edituser", user, key, value, (char *)0); -} - -/** @brief Register a user - * @param c Client - * @param user Username - * @param password Password - * @param email Email address (UTF-8) - * @param confirmp Where to store confirmation string - * @return 0 on success, non-0 on error - */ -int disorder_register(disorder_client *c, const char *user, - const char *password, const char *email, - char **confirmp) { - return dequote(disorder_simple(c, confirmp, "register", - user, password, email, (char *)0), - confirmp); -} - -/** @brief Confirm a user - * @param c Client - * @param confirm Confirmation string - * @return 0 on success, non-0 on error - */ -int disorder_confirm(disorder_client *c, const char *confirm) { - char *u; - int rc; - - if(!(rc = dequote(disorder_simple(c, &u, "confirm", confirm, (char *)0), - &u))) - c->user = u; - return rc; -} - -/** @brief Make a cookie for this login - * @param c Client - * @param cookiep Where to store cookie string - * @return 0 on success, non-0 on error - */ -int disorder_make_cookie(disorder_client *c, char **cookiep) { - return dequote(disorder_simple(c, cookiep, "make-cookie", (char *)0), - cookiep); -} - -/** @brief Revoke the cookie used by this session - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_revoke(disorder_client *c) { - return disorder_simple(c, 0, "revoke", (char *)0); -} - -/** @brief Request a password reminder email - * @param c Client - * @param user Username - * @return 0 on success, non-0 on error - */ -int disorder_reminder(disorder_client *c, const char *user) { - return disorder_simple(c, 0, "reminder", user, (char *)0); -} - /** @brief List scheduled events * @param c Client * @param idsp Where to put list of event IDs @@ -1299,15 +968,6 @@ int disorder_schedule_list(disorder_client *c, char ***idsp, int *nidsp) { return disorder_simple_list(c, idsp, nidsp, "schedule-list", (char *)0); } -/** @brief Delete a scheduled event - * @param c Client - * @param id Event ID to delete - * @return 0 on success, non-0 on error - */ -int disorder_schedule_del(disorder_client *c, const char *id) { - return disorder_simple(c, 0, "schedule-del", id, (char *)0); -} - /** @brief Get details of a scheduled event * @param c Client * @param id Event ID @@ -1377,25 +1037,6 @@ int disorder_schedule_add(disorder_client *c, return rc; } -/** @brief Adopt a track - * @param c Client - * @param id Track ID to adopt - * @return 0 on success, non-0 on error - */ -int disorder_adopt(disorder_client *c, const char *id) { - return disorder_simple(c, 0, "adopt", id, (char *)0); -} - -/** @brief Delete a playlist - * @param c Client - * @param playlist Playlist to delete - * @return 0 on success, non-0 on error - */ -int disorder_playlist_delete(disorder_client *c, - const char *playlist) { - return disorder_simple(c, 0, "playlist-delete", playlist, (char *)0); -} - /** @brief Get the contents of a playlist * @param c Client * @param playlist Playlist to get @@ -1421,53 +1062,6 @@ int disorder_playlists(disorder_client *c, "playlists", (char *)0); } -/** @brief Get the sharing status of a playlist - * @param c Client - * @param playlist Playlist to inspect - * @param sharep Where to put sharing status - * @return 0 on success, non-0 on error - * - * Possible @p sharep values are @c public, @c private and @c shared. - */ -int disorder_playlist_get_share(disorder_client *c, const char *playlist, - char **sharep) { - return disorder_simple(c, sharep, - "playlist-get-share", playlist, (char *)0); -} - -/** @brief Get the sharing status of a playlist - * @param c Client - * @param playlist Playlist to modify - * @param share New sharing status - * @return 0 on success, non-0 on error - * - * Possible @p share values are @c public, @c private and @c shared. - */ -int disorder_playlist_set_share(disorder_client *c, const char *playlist, - const char *share) { - return disorder_simple(c, 0, - "playlist-set-share", playlist, share, (char *)0); -} - -/** @brief Lock a playlist for modifications - * @param c Client - * @param playlist Playlist to lock - * @return 0 on success, non-0 on error - */ -int disorder_playlist_lock(disorder_client *c, const char *playlist) { - return disorder_simple(c, 0, - "playlist-lock", playlist, (char *)0); -} - -/** @brief Unlock the locked playlist - * @param c Client - * @return 0 on success, non-0 on error - */ -int disorder_playlist_unlock(disorder_client *c) { - return disorder_simple(c, 0, - "playlist-unlock", (char *)0); -} - /** @brief Set the contents of a playlst * @param c Client * @param playlist Playlist to modify @@ -1483,6 +1077,8 @@ int disorder_playlist_set(disorder_client *c, "playlist-set", playlist, (char *)0); } +#include "client-stubs.c" + /* Local Variables: c-basic-offset:2 diff --git a/lib/client.h b/lib/client.h index f7ff728..34ac4b3 100644 --- a/lib/client.h +++ b/lib/client.h @@ -89,9 +89,6 @@ int disorder_stats(disorder_client *c, int disorder_set_volume(disorder_client *c, int left, int right); int disorder_get_volume(disorder_client *c, int *left, int *right); int disorder_log(disorder_client *c, struct sink *s); -int disorder_part(disorder_client *c, char **partp, - const char *track, const char *context, const char *part); -int disorder_resolve(disorder_client *c, char **trackp, const char *track); int disorder_pause(disorder_client *c); int disorder_resume(disorder_client *c); int disorder_tags(disorder_client *c, @@ -149,6 +146,8 @@ int disorder_playlist_set(disorder_client *c, char **tracks, int ntracks); +#include "client-stubs.h" + #endif /* CLIENT_H */ /* diff --git a/scripts/protocol b/scripts/protocol index 88d6266..b3ba0fc 100755 --- a/scripts/protocol +++ b/scripts/protocol @@ -30,7 +30,7 @@ sub Write { (open(F, ">$path") and print F @$lines and close F) - or die "$0: $path: $!\n"; + or die "$0: $path: $!\n"; } # Command classes ------------------------------------------------------------- @@ -48,21 +48,110 @@ sub simple { $cmdc =~ s/-/_/g; # Synchronous C API push(@h, "/** \@brief $summary\n", - " *\n", - " * $detail\n", - " *\n", - map(" * \@param $_->[0] $_->[1]\n", @$args), - " * \@return 0 on success, non-0 on error\n", - " */\n", - "int disorder_$cmdc(disorder_client *c", - map(", const char *$_->[0]", @$args), ");\n", - "\n"); + " *\n", + " * $detail\n", + " *\n", + map(" * \@param $_->[0] $_->[1]\n", @$args), + " * \@return 0 on success, non-0 on error\n", + " */\n", + "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), ");\n", + "\n"); push(@c, "int disorder_$cmdc(disorder_client *c", - map(", const char *$_->[0]", @$args), ") {\n", - " return disorder_simple(c, 0, \"$cmd\"", - map(", $_->[0]", @$args), - ", (char *)0);\n", - "}\n\n"); + map(", const char *$_->[0]", @$args), ") {\n", + " return disorder_simple(c, 0, \"$cmd\"", + map(", $_->[0]", @$args), + ", (char *)0);\n", + "}\n\n"); + + # Asynchronous C API + # TODO + + # Python API + # TODO + + # Java API + # TODO +} + +# string(CMD, SUMMARY, DETAIL, [[NAME,DESCR], [NAME,DESCR], ...], [RETURN, DESCR]) +# +# Response is yes/no or failure +sub string { + my $cmd = shift; + my $summary = shift; + my $detail = shift; + my $args = shift; + my $return = shift; + + my $cmdc = $cmd; + $cmdc =~ s/-/_/g; + # Synchronous C API + push(@h, "/** \@brief $summary\n", + " *\n", + " * $detail\n", + " *\n", + map(" * \@param $_->[0] $_->[1]\n", @$args), + " * \@param $return->[0]p $return->[1]\n", + " * \@return 0 on success, non-0 on error\n", + " */\n", + "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), + ", char **$return->[0]p);\n", + "\n"); + push(@c, "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), + ", char **$return->[0]p) {\n", + " return dequote(disorder_simple(c, $return->[0]p, \"$cmd\"", + map(", $_->[0]", @$args), + ", (char *)0), $return->[0]p);\n", + "}\n\n"); + + # Asynchronous C API + # TODO + + # Python API + # TODO + + # Java API + # TODO +} + +# string(CMD, SUMMARY, DETAIL, [[NAME,DESCR], [NAME,DESCR], ...]) +# +# Response is yes/no or failure +sub string_login { + my $cmd = shift; + my $summary = shift; + my $detail = shift; + my $args = shift; + my $return = shift; + + my $cmdc = $cmd; + $cmdc =~ s/-/_/g; + # Synchronous C API + push(@h, "/** \@brief $summary\n", + " *\n", + " * $detail\n", + " *\n", + map(" * \@param $_->[0] $_->[1]\n", @$args), + " * \@return 0 on success, non-0 on error\n", + " */\n", + "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), + ");\n"); + push(@c, "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), + ") {\n", + " char *u;\n", + " int rc;\n", + " if((rc = disorder_simple(c, &u, \"$cmd\"", + map(", $_->[0]", @$args), + " )))\n", + " return rc;\n", + " c->user = u;\n", + " return 0;\n", + "}\n\n"); # Asynchronous C API # TODO @@ -88,34 +177,28 @@ sub boolean { $cmdc =~ s/-/_/g; # Synchronous C API push(@h, "/** \@brief $summary\n", - " *\n", - " * $detail\n", - " *\n", - map(" * \@param $_->[0] $_->[1]\n", @$args), - " * \@param $return->[0] $return->[1]\n", - " * \@return 0 on success, non-0 on error\n", - " */\n", - "int disorder_$cmdc(disorder_client *c", - map(", const char *$_->[0]", @$args), - ", int *$return->[0]);\n", - "\n"); + " *\n", + " * $detail\n", + " *\n", + map(" * \@param $_->[0] $_->[1]\n", @$args), + " * \@param $return->[0]p $return->[1]\n", + " * \@return 0 on success, non-0 on error\n", + " */\n", + "int disorder_$cmdc(disorder_client *c", + map(", const char *$_->[0]", @$args), + ", int *$return->[0]p);\n", + "\n"); push(@c, "int disorder_$cmdc(disorder_client *c", - map(", const char *$_->[0]", @$args), - ", int *$return->[0]) {\n", - " char *v;\n", - " int rc = disorder_simple(c, &v, \"$cmd\"", - map(", $_->[0]", @$args), - ", (char *)0);\n", - " if(rc) return rc;\n", - " if(!strcmp(v, \"yes\")) *$return->[0] = 1;\n", - " if(!strcmp(v, \"no\")) *$return->[0] = 0;\n", - " else {\n", - " disorder_error(0, \"malformed response to '$cmd' command\");\n", - " rc = -1;\n", - " }\n", - " xfree(v);\n", - " return 0;\n", - "}\n\n"); + map(", const char *$_->[0]", @$args), + ", int *$return->[0]p) {\n", + " char *v;\n", + " int rc;\n", + " if((rc = disorder_simple(c, &v, \"$cmd\"", + map(", $_->[0]", @$args), + ", (char *)0)))\n", + " return rc;\n", + " return boolean(\"$cmd\", v, $return->[0]p);\n", + "}\n\n"); # Asynchronous C API # TODO @@ -132,22 +215,22 @@ sub boolean { # Front matter ---------------------------------------------------------------- our @gpl = ("/*\n", - " * This file is part of DisOrder.\n", - " * Copyright (C) 2010 Richard Kettlewell\n", - " *\n", - " * This program is free software: you can redistribute it and/or modify\n", - " * it under the terms of the GNU General Public License as published by\n", - " * the Free Software Foundation, either version 3 of the License, or\n", - " * (at your option) any later version.\n", - " *\n", - " * This program is distributed in the hope that it will be useful,\n", - " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n", - " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", - " * GNU General Public License for more details.\n", - " *\n", - " * You should have received a copy of the GNU General Public License\n", - " * along with this program. If not, see .\n", - " */\n"); + " * This file is part of DisOrder.\n", + " * Copyright (C) 2010 Richard Kettlewell\n", + " *\n", + " * This program is free software: you can redistribute it and/or modify\n", + " * it under the terms of the GNU General Public License as published by\n", + " * the Free Software Foundation, either version 3 of the License, or\n", + " * (at your option) any later version.\n", + " *\n", + " * This program is distributed in the hope that it will be useful,\n", + " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n", + " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", + " * GNU General Public License for more details.\n", + " *\n", + " * You should have received a copy of the GNU General Public License\n", + " * along with this program. If not, see .\n", + " */\n"); push(@h, @gpl, @@ -169,17 +252,21 @@ simple("adduser", "Create a user", "Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands.", [["user", "New username"], - ["password", "Initial password"], - ["rights", "Initial rights (optional)"]]); + ["password", "Initial password"], + ["rights", "Initial rights (optional)"]]); # TODO allfiles -simple("confirm", - "Confirm user registration", - "The confirmation string is as returned by the register command.", - [["confirmation", "Confirmnation string"]]); +string_login("confirm", + "Confirm registration", + "The confirmation string must have been created with 'register'. The username is returned so the caller knows who they are.", + [["confirmation", "Confirmation string"]]); +#TODO update docs - this logs you in -# TODO cookie +string_login("cookie", + "Log in with a cookie", + "The cookie must have been created with 'make-cookie'. The username is returned so the caller knows who they are.", + [["cookie", "Cookie string"]]); simple("deluser", "Delete user", @@ -197,7 +284,7 @@ simple("edituser", "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'.", [["username", "User to modify"], - ["property", "Property name"], + ["property", "Property name"], ["value", "New property value"]]); simple("enable", @@ -206,28 +293,41 @@ simple("enable", []); boolean("enabled", - "Detect whether play is enabled", - "", - [], - ["enabled", "1 if play is enabled and 0 otherwise"]); + "Detect whether play is enabled", + "", + [], + ["enabled", "1 if play is enabled and 0 otherwise"]); boolean("exists", - "Test whether a track exists", - "", - [["track", "Track name"]], - ["exists", "1 if the track exists and 0 otherwise"]); + "Test whether a track exists", + "", + [["track", "Track name"]], + ["exists", "1 if the track exists and 0 otherwise"]); # TODO files -# TODO get +string("get", + "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.", + [["track", "Track name"], + ["pref", "Preference name"]], + ["value", "Preference value"]); -# TODO get-global +string("get-global", + "Get a global preference", + "If the preference does exist not then a null value is returned.", + [["pref", "Global preference name"]], + ["value", "Preference value"]); # TODO length # TODO log -# TODO make-cookie +string("make-cookie", + "Create a login cookie for this user", + "The cookie may be redeemed via the 'cookie' command", + [], + ["cookie", "Newly created cookie"]); # TODO move @@ -240,7 +340,13 @@ simple("nop", "Used as a keepalive. No authentication required.", []); -# TODO part +string("part", + "Get a track name part", + "If the name part cannot be constructed an empty string is returned.", + [["track", "Track name"], + ["context", "Context (\"sort\" or \"display\")"], + ["part", "Name part (\"artist\", \"album\" or \"title\")"]], + ["part", "Value of name part"]); simple("pause", "Pause the currently playing track", @@ -265,13 +371,17 @@ simple("playlist-lock", "Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.", [["playlist", "Playlist to delete"]]); -# TODO playlist-set +string("playlist-get-share", + "Get a playlist's sharing status", + "Requires the 'read' right and permission to read the playlist.", + [["playlist", "Playlist to read"]], + ["share", "Sharing status (\"public\", \"private\" or \"shared\")"]); simple("playlist-set-share", "Set a playlist's sharing status", - "Requires the 'play' right and permission to modify the playlist. ", + "Requires the 'play' right and permission to modify the playlist.", [["playlist", "Playlist to modify"], - ["share", "New sharing status ('public', 'private' or 'shared')"]]); + ["share", "New sharing status (\"public\", \"private\" or \"shared\")"]]); simple("playlist-unlock", "Unlock the locked playlist playlist", @@ -295,12 +405,10 @@ simple("random-enable", []); boolean("random-enabled", - "Detect whether random play is enabled", - "Random play counts as enabled even if play is disabled.", - [], - ["enabled", "1 if random play is enabled and 0 otherwise"]); - -# TODO random-enabled + "Detect whether random play is enabled", + "Random play counts as enabled even if play is disabled.", + [], + ["enabled", "1 if random play is enabled and 0 otherwise"]); # TODO recent @@ -309,7 +417,13 @@ simple("reconfigure", "Requires the 'admin' right.", []); -# TODO register +string("register", + "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.", + [["username", "Requested new username"], + ["password", "Requested initial password"], + ["email", "New user's email address"]], + ["confirmation", "Confirmation string"]); simple("reminder", "Send a password reminder.", @@ -324,9 +438,13 @@ simple("remove", simple("rescan", "Rescan all collections for new or obsolete tracks.", "Requires the 'rescan' right.", - []); # TODO wait/fresh flags + []); # TODO wait/fresh flags -# TODO resolve +string("resolve", + "Resolve a track name", + "Converts aliases to non-alias track names", + [["track", "Track name (might be an alias)"]], + ["resolved", "Resolve track name (definitely not an alias)"]); simple("resume", "Resume the currently playing track", @@ -336,7 +454,7 @@ simple("resume", simple("revoke", "Revoke a cookie.", "It will not subsequently be possible to log in with the cookie.", - [["cookie", "Cookie to revoke"]]); + []); # TODO fix docs! # TODO rtp-address @@ -362,7 +480,7 @@ simple("set", "Set a track preference", "Requires the 'prefs' right.", [["track", "Track name"], - ["pref", "Preference name"], + ["pref", "Preference name"], ["value", "New value"]]); simple("set-global", @@ -371,6 +489,8 @@ simple("set-global", [["pref", "Preference name"], ["value", "New value"]]); +# TODO shutdown (also needs documenting) + # TODO stats # TODO tags @@ -379,20 +499,29 @@ simple("unset", "Unset a track preference", "Requires the 'prefs' right.", [["track", "Track name"], - ["pref", "Preference name"]]); + ["pref", "Preference name"]]); simple("unset-global", "Set a global preference", "Requires the 'global prefs' right.", [["pref", "Preference name"]]); -# user is only used by connect functions +# TODO user? -# TODO userinfo +string("userinfo", + "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.", + [["username", "User to read"], + ["property", "Property to read"]], + ["value", "Value of property"]); # TODO users -# TODO version +string("version", + "Get the server version", + "", + [], + ["version", "Server version string"]); # TODO volume @@ -402,5 +531,5 @@ push(@h, "#endif\n"); # Write it all out ------------------------------------------------------------ -Write("client-stubs.h", \@h); -Write("client-stubs.c", \@c); +Write("lib/client-stubs.h", \@h); +Write("lib/client-stubs.c", \@c); -- [mdw]