3 # This file is part of DisOrder.
4 # Copyright (C) 2010 Richard Kettlewell
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Variables and utilities -----------------------------------------------------
33 or die "$0: $path: $!\n";
36 # Command classes -------------------------------------------------------------
38 # simple_string_command(CMD, SUMMARY, DETAIL, [[NAME,DESCR], [NAME,DESCR], ...],)
40 # Response is simply success/failure
41 sub simple_string_command {
50 push(@h, "/** \@brief $summary\n",
54 map(" * \@param $_->[0] $_->[1]\n", @$args),
55 " * \@return 0 on success, non-0 on error\n",
57 "int disorder_$cmdc(disorder_client *c",
58 map(", const char *$_->[0]", @$args), ");\n",
60 push(@c, "int disorder_$cmdc(disorder_client *c",
61 map(", const char *$_->[0]", @$args), ") {\n",
62 " return disorder_simple(c, 0, \"$cmd\"",
63 map(", $_->[0]", @$args),
77 # TODO other command classes
79 # Front matter ----------------------------------------------------------------
82 " * This file is part of DisOrder.\n",
83 " * Copyright (C) 2010 Richard Kettlewell\n",
85 " * This program is free software: you can redistribute it and/or modify\n",
86 " * it under the terms of the GNU General Public License as published by\n",
87 " * the Free Software Foundation, either version 3 of the License, or\n",
88 " * (at your option) any later version.\n",
90 " * This program is distributed in the hope that it will be useful,\n",
91 " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
92 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
93 " * GNU General Public License for more details.\n",
95 " * You should have received a copy of the GNU General Public License\n",
96 " * along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
101 "#ifndef CLIENT_STUBS_H\n",
102 "#define CLIENT_STUBS_H\n",
108 # The protocol ----------------------------------------------------------------
110 simple_string_command("adopt",
112 "Makes the calling user owner of a randomly picked track.",
113 [["id", "Track ID"]]);
115 simple_string_command("adduser",
117 "Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands.",
118 [["user", "New username"],
119 ["password", "Initial password"],
120 ["rights", "Initial rights (optional)"]]);
124 simple_string_command("confirm",
125 "Confirm user registration",
126 "The confirmation string is as returned by the register command.",
127 [["confirmation", "Confirmnation string"]]);
131 simple_string_command("deluser",
133 "Requires the 'admin' right.",
134 [["user", "User to delete"]]);
138 simple_string_command("disable",
140 "Play will stop at the end of the current track, if one is playing. Requires the 'global prefs' right.",
143 simple_string_command("edituser",
144 "Set a user property",
145 "With the 'admin' right you can do anything. Otherwise you need the 'userinfo' right and can only set 'email' and 'password'.",
146 [["username", "User to modify"],
147 ["property", "Property name"],
148 ["value", "New property value"]]);
150 simple_string_command("enable",
152 "Requires the 'global prefs' right.",
177 simple_string_command("nop",
179 "Used as a keepalive. No authentication required.",
184 simple_string_command("pause",
185 "Pause the currently playing track",
186 "Requires the 'pause' right.",
193 simple_string_command("playlist-delete",
195 "Requires the 'play' right and permission to modify the playlist.",
196 [["playlist", "Playlist to delete"]]);
200 # TODO playlist-get-share
202 simple_string_command("playlist-lock",
204 "Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.",
205 [["playlist", "Playlist to delete"]]);
209 simple_string_command("playlist-set-share",
210 "Set a playlist's sharing status",
211 "Requires the 'play' right and permission to modify the playlist. ",
212 [["playlist", "Playlist to modify"],
213 ["share", "New sharing status ('public', 'private' or 'shared')"]]);
215 simple_string_command("playlist-unlock",
216 "Unlock the locked playlist playlist",
217 "The playlist to unlock is implicit in the connection.",
226 simple_string_command("random-disable",
227 "Disable random play",
228 "Requires the 'global prefs' right.",
231 simple_string_command("random-enable",
232 "Enable random play",
233 "Requires the 'global prefs' right.",
236 # TODO random-enabled
240 simple_string_command("reconfigure",
241 "Re-read configuraiton file.",
242 "Requires the 'admin' right.",
247 simple_string_command("reminder",
248 "Send a password reminder.",
249 "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.",
250 [["username", "User to remind"]]);
252 simple_string_command("remove",
253 "Remove a track form the queue.",
254 "Requires one of the 'remove mine', 'remove random' or 'remove any' rights depending on how the track came to be added to the queue.",
255 [["id", "Track ID"]]);
257 simple_string_command("rescan",
258 "Rescan all collections for new or obsolete tracks.",
259 "Requires the 'rescan' right.",
260 []); # TODO wait/fresh flags
264 simple_string_command("resume",
265 "Resume the currently playing track",
266 "Requires the 'pause' right.",
269 simple_string_command("revoke",
271 "It will not subsequently be possible to log in with the cookie..",
272 [["cookie", "Cookie to revoke"]]);
276 simple_string_command("scratch",
277 "Terminate the playing track.",
278 "Requires one of the 'scratch mine', 'scratch random' or 'scratch any' rights depending on how the track came to be added to the queue.",
279 [["id", "Track ID (optional)"]]);
283 simple_string_command("schedule-del",
284 "Delete a scheduled event.",
285 "Users can always delete their own scheduled events; with the admin right you can delete any event.",
286 [["event", "ID of event to delete"]]);
294 simple_string_command("set",
295 "Set a track preference",
296 "Requires the 'prefs' right.",
297 [["track", "Track name"],
298 ["pref", "Preference name"],
299 ["value", "New value"]]);
301 simple_string_command("set-global",
302 "Set a global preference",
303 "Requires the 'global prefs' right.",
304 [["pref", "Preference name"],
305 ["value", "New value"]]);
311 simple_string_command("unset",
312 "Unset a track preference",
313 "Requires the 'prefs' right.",
314 [["track", "Track name"],
315 ["pref", "Preference name"]]);
317 simple_string_command("unset-global",
318 "Set a global preference",
319 "Requires the 'global prefs' right.",
320 [["pref", "Preference name"]]);
322 # user is only used by connect functions
332 # End matter ------------------------------------------------------------------
334 push(@h, "#endif\n");
336 # Write it all out ------------------------------------------------------------
338 Write("client-stubs.h", \@h);
339 Write("client-stubs.c", \@c);