chiark / gitweb /
protogen: memory hygeine.
[disorder] / scripts / protocol
... / ...
CommitLineData
1#! /usr/bin/perl -w
2#
3# This file is part of DisOrder.
4# Copyright (C) 2010-11 Richard Kettlewell
5#
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.
10#
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.
15#
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/>.
18#
19use strict;
20
21# This file contains the definition of the disorder protocol, plus
22# code to generates stubs for it in the various supported languages.
23#
24# At the time of writing it is a work in progress!
25
26#
27# Types:
28#
29# string A (Unicode) string.
30# string-raw A string that is not subject to de-quoting (return only)
31# integer An integer. Decimal on the wire.
32# time A timestamp. Decimal on the wire.
33# boolean True or false. "yes" or "no" on the wire.
34# list In commands: a list of strings in the command.
35# In returns: a list of lines in the response.
36# pair-list In returns: a list of key-value pairs in a response body.
37# body In commands: a list of strings as a command body.
38# In returns: a list of strings as a response body.
39# queue In returns: a list of queue entries in a response body.
40# queue-one In returns: a queue entry in the response.
41# literal Constant string sent in sequence
42#
43
44# Variables and utilities -----------------------------------------------------
45
46our @h = ();
47our @c = ();
48
49# Write(PATH, LINES)
50#
51# Write array ref LINES to file PATH.
52sub Write {
53 my $path = shift;
54 my $lines = shift;
55
56 (open(F, ">$path")
57 and print F @$lines
58 and close F)
59 or die "$0: $path: $!\n";
60}
61
62# Command classes -------------------------------------------------------------
63
64# c_in_decl([TYPE, NAME])
65#
66# Return the C declaration for an input parameter of type TYPE with
67# name NAME.
68sub c_in_decl {
69 my $arg = shift;
70
71 my $type = $arg->[0];
72 my $name = $arg->[1];
73 if($type eq 'string') {
74 return "const char *$name";
75 } elsif($type eq 'integer') {
76 return "long $name";
77 } elsif($type eq 'time') {
78 return "time_t $name";
79 } elsif($type eq 'list' or $type eq 'body') {
80 return ("char **$name",
81 "int n$name");
82 } elsif($type eq 'literal') {
83 return ();
84 } else {
85 die "$0: c_in_decl: unknown type '$type'\n";
86 }
87}
88
89# c_out_decl([TYPE, NAME])
90#
91# Return the C declaration for an output (reference) parameter of type
92# TYPE with name NAME.
93sub c_out_decl {
94 my $arg = shift;
95
96 return () unless defined $arg;
97 my $type = $arg->[0];
98 my $name = $arg->[1];
99 if($type eq 'string' or $type eq 'string-raw') {
100 return ("char **${name}p");
101 } elsif($type eq 'integer') {
102 return ("long *${name}p");
103 } elsif($type eq 'time') {
104 return ("time_t *${name}p");
105 } elsif($type eq 'boolean') {
106 return ("int *${name}p");
107 } elsif($type eq 'list' or $type eq 'body') {
108 return ("char ***${name}p",
109 "int *n${name}p");
110 } elsif($type eq 'pair-list') {
111 return ("struct kvp **${name}p");
112 } elsif($type eq 'queue' or $type eq 'queue-one') {
113 return ("struct queue_entry **${name}p");
114 } elsif($type eq 'user') {
115 return ();
116 } else {
117 die "$0: c_out_decl: unknown type '$type'\n";
118 }
119}
120
121# c_param_docs([TYPE, NAME})
122#
123# Return the doc string for a C input parameter.
124sub c_param_docs {
125 my $args = shift;
126 my @d = ();
127 for my $arg (@$args) {
128 my $type = $arg->[0];
129 my $name = $arg->[1];
130 my $description = $arg->[2];
131 if($type eq 'body' or $type eq 'list') {
132 push(@d,
133 " * \@param $name $description\n",
134 " * \@param n$name Length of $name\n");
135 } elsif($type ne 'literal') {
136 push(@d, " * \@param $name $description\n");
137 }
138 }
139 return @d;
140}
141
142# c_param_docs([TYPE, NAME})
143#
144# Return the doc string for a C output parameter.
145sub c_return_docs {
146 my $returns = shift;
147 return () unless defined $returns;
148 for my $return (@$returns) {
149 my $type = $return->[0];
150 my $name = $return->[1];
151 my $descr = $return->[2];
152 if($type eq 'string'
153 or $type eq 'string-raw'
154 or $type eq 'integer'
155 or $type eq 'time'
156 or $type eq 'boolean') {
157 return (" * \@param ${name}p $descr\n");
158 } elsif($type eq 'list' or $type eq 'body') {
159 return (" * \@param ${name}p $descr\n",
160 " * \@param n${name}p Number of elements in ${name}p\n");
161 } elsif($type eq 'pair-list') {
162 return (" * \@param ${name}p $descr\n");
163 } elsif($type eq 'queue' or $type eq 'queue-one') {
164 return (" * \@param ${name}p $descr\n");
165 } elsif($type eq 'user') {
166 return ();
167 } else {
168 die "$0: c_return_docs: unknown type '$type'\n";
169 }
170 }
171}
172
173# simple(CMD, SUMMARY, DETAIL,
174# [[TYPE,NAME,DESCR], [TYPE,NAME,DESCR], ...],
175# [[RETURN-TYPE, RETURN-NAME, RETURN_DESCR]])
176#
177# CMD is normally just the name of the command, but can
178# be [COMMAND,FUNCTION] if the function name should differ
179# from the protocol command.
180sub simple {
181 my $cmd = shift;
182 my $summary = shift;
183 my $detail = shift;
184 my $args = shift;
185 my $returns = shift;
186
187 my $cmdc;
188 if(ref $cmd eq 'ARRAY') {
189 $cmdc = $$cmd[1];
190 $cmd = $$cmd[0];
191 } else {
192 $cmdc = $cmd;
193 $cmdc =~ s/-/_/g;
194 }
195 print STDERR "Processing $cmd... ";
196 # Synchronous C API
197 print STDERR "H ";
198 push(@h, "/** \@brief $summary\n",
199 " *\n",
200 " * $detail\n",
201 " *\n",
202 " * \@param c Client\n",
203 c_param_docs($args),
204 c_return_docs($returns),
205 " * \@return 0 on success, non-0 on error\n",
206 " */\n",
207 "int disorder_$cmdc(",
208 join(", ", "disorder_client *c",
209 map(c_in_decl($_), @$args),
210 map(c_out_decl($_), @$returns)),
211 ");\n\n");
212 print STDERR "C ";
213 push(@c, "int disorder_$cmdc(",
214 join(", ", "disorder_client *c",
215 map(c_in_decl($_), @$args),
216 map(c_out_decl($_), @$returns)),
217 ") {\n");
218 my @cargs = ();
219 for my $arg (@$args) {
220 if($arg->[0] eq 'body' or $arg->[0] eq 'list') {
221 push(@cargs, "disorder_$arg->[0]", $arg->[1], "n$arg->[1]");
222 } elsif($arg->[0] eq 'string') {
223 push(@cargs, $arg->[1]);
224 } elsif($arg->[0] eq 'integer') {
225 push(@cargs, "buf_$arg->[1]");
226 push(@c, " char buf_$arg->[1]\[16];\n",
227 " byte_snprintf(buf_$arg->[1], sizeof buf_$arg->[1], \"%ld\", $arg->[1]);\n");
228 } elsif($arg->[0] eq 'time') {
229 push(@cargs, "buf_$arg->[1]");
230 push(@c, " char buf_$arg->[1]\[16];\n",
231 " byte_snprintf(buf_$arg->[1], sizeof buf_$arg->[1], \"%lld\", (long long)$arg->[1]);\n");
232 } elsif($arg->[0] eq 'literal') {
233 push(@cargs, "\"$arg->[1]\"");
234 } else {
235 die "$0: unsupported arg type '$arg->[0]' for '$cmd'\n";
236 }
237 }
238 if(!defined $returns or scalar @$returns == 0) {
239 # Simple case
240 push(@c, " return disorder_simple(",
241 join(", ", "c", "NULL", "\"$cmd\"", @cargs, "(char *)NULL"),
242 ");\n");
243 } elsif(scalar @$returns == 1
244 and $returns->[0]->[0] eq 'queue-one') {
245 # Special case
246 my $return = $$returns[0];
247 push(@c, " return onequeue(c, \"$cmd\", $return->[1]p);\n");
248 } elsif(scalar @$returns == 1
249 and $returns->[0]->[0] eq 'string-raw') {
250 # Special case
251 my $return = $$returns[0];
252 push(@c, " return disorder_simple(",
253 join(", ", "c", "$return->[1]p", "\"$cmd\"", @cargs, "(char *)NULL"),
254 ");\n");
255 } elsif(scalar @$returns == 1
256 and $returns->[0]->[0] eq 'pair-list') {
257 # Special case
258 my $return = $$returns[0];
259 push(@c, " return pairlist(",
260 join(", ", "c", "$return->[1]p", "\"$cmd\"",
261 @cargs,
262 "(char *)NULL"),
263 ");\n");
264 } else {
265 my $expected = 0;
266 for(my $n = 0; $n < scalar @$returns; ++$n) {
267 my $return = $returns->[$n];
268 my $type = $return->[0];
269 my $name = $return->[1];
270 if($type eq 'string'
271 or $type eq 'boolean'
272 or $type eq 'integer'
273 or $type eq 'time'
274 or $type eq 'user') {
275 ++$expected;
276 }
277 }
278 if($expected) {
279 push(@c, " char **v;\n",
280 " int nv, rc = disorder_simple_split(",
281 join(", ",
282 "c",
283 "&v",
284 "&nv",
285 $expected,
286 "\"$cmd\"",
287 @cargs,
288 "(char *)NULL"),
289 ");\n",
290 " if(rc)\n",
291 " return rc;\n");
292 } else {
293 push(@c,
294 " int rc = disorder_simple(",
295 join(", ",
296 "c",
297 "NULL",
298 "\"$cmd\"",
299 @cargs,
300 "(char *)NULL"),
301 ");\n",
302 " if(rc)\n",
303 " return rc;\n");
304 }
305 for(my $n = 0; $n < scalar @$returns; ++$n) {
306 my $return = $returns->[$n];
307 my $type = $return->[0];
308 my $name = $return->[1];
309 if($type eq 'string') {
310 push(@c,
311 " *${name}p = v[$n];\n",
312 " v[$n] = NULL;\n");
313 } elsif($type eq 'boolean') {
314 push(@c,
315 " if(boolean(\"$cmd\", v[$n], ${name}p))\n",
316 " return -1;\n");
317 } elsif($type eq 'integer') {
318 push(@c,
319 " *${name}p = atol(v[$n]);\n");
320 } elsif($type eq 'time') {
321 push(@c,
322 " *${name}p = atoll(v[$n]);\n");
323 } elsif($type eq 'user') {
324 push(@c,
325 " c->user = v[$n];\n",
326 " v[$n] = NULL;\n");
327 } elsif($type eq 'body') {
328 push(@c,
329 " if(readlist(c, ${name}p, n${name}p))\n",
330 " return -1;\n");
331 } elsif($type eq 'queue') {
332 push(@c,
333 " if(readqueue(c, ${name}p))\n",
334 " return -1;\n");
335 } else {
336 die "$0: C API: unknown return type '$type' for '$name'\n";
337 }
338 }
339 if($expected) {
340 push(@c,
341 " free_strings(nv, v);\n");
342 }
343 push(@c, " return 0;\n");
344 }
345 push(@c, "}\n\n");
346
347 # Asynchronous C API
348 # TODO
349
350 # Python API
351 # TODO
352
353 # Java API
354 # TODO
355 print STDERR "\n";
356}
357
358# TODO other command classes
359
360# Front matter ----------------------------------------------------------------
361
362our @generated = ("/*\n",
363 " * Automatically generated file, see scripts/protocol\n",
364 " *\n",
365 " * DO NOT EDIT.\n",
366 " */\n");
367
368our @gpl = ("/*\n",
369 " * This file is part of DisOrder.\n",
370 " * Copyright (C) 2010-11 Richard Kettlewell\n",
371 " *\n",
372 " * This program is free software: you can redistribute it and/or modify\n",
373 " * it under the terms of the GNU General Public License as published by\n",
374 " * the Free Software Foundation, either version 3 of the License, or\n",
375 " * (at your option) any later version.\n",
376 " *\n",
377 " * This program is distributed in the hope that it will be useful,\n",
378 " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
379 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
380 " * GNU General Public License for more details.\n",
381 " *\n",
382 " * You should have received a copy of the GNU General Public License\n",
383 " * along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
384 " */\n");
385
386
387push(@h, @generated, @gpl,
388 "#ifndef CLIENT_STUBS_H\n",
389 "#define CLIENT_STUBS_H\n",
390 "\n");
391
392push(@c, @generated, @gpl,
393 "\n");
394
395# The protocol ----------------------------------------------------------------
396
397simple("adopt",
398 "Adopt a track",
399 "Makes the calling user owner of a randomly picked track.",
400 [["string", "id", "Track ID"]]);
401
402simple("adduser",
403 "Create a user",
404 "Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands.",
405 [["string", "user", "New username"],
406 ["string", "password", "Initial password"],
407 ["string", "rights", "Initial rights (optional)"]]);
408
409simple("allfiles",
410 "List files and directories in a directory",
411 "See 'files' and 'dirs' for more specific lists.",
412 [["string", "dir", "Directory to list (optional)"],
413 ["string", "re", "Regexp that results must match (optional)"]],
414 [["body", "files", "List of matching files and directories"]]);
415
416simple("confirm",
417 "Confirm registration",
418 "The confirmation string must have been created with 'register'. The username is returned so the caller knows who they are.",
419 [["string", "confirmation", "Confirmation string"]],
420 [["user"]]);
421
422simple("cookie",
423 "Log in with a cookie",
424 "The cookie must have been created with 'make-cookie'. The username is returned so the caller knows who they are.",
425 [["string", "cookie", "Cookie string"]],
426 [["user"]]);
427
428simple("deluser",
429 "Delete user",
430 "Requires the 'admin' right.",
431 [["string", "user", "User to delete"]]);
432
433simple("dirs",
434 "List directories in a directory",
435 "",
436 [["string", "dir", "Directory to list (optional)"],
437 ["string", "re", "Regexp that results must match (optional)"]],
438 [["body", "files", "List of matching directories"]]);
439
440simple("disable",
441 "Disable play",
442 "Play will stop at the end of the current track, if one is playing. Requires the 'global prefs' right.",
443 []);
444
445simple("edituser",
446 "Set a user property",
447 "With the 'admin' right you can do anything. Otherwise you need the 'userinfo' right and can only set 'email' and 'password'.",
448 [["string", "username", "User to modify"],
449 ["string", "property", "Property name"],
450 ["string", "value", "New property value"]]);
451
452simple("enable",
453 "Enable play",
454 "Requires the 'global prefs' right.",
455 []);
456
457simple("enabled",
458 "Detect whether play is enabled",
459 "",
460 [],
461 [["boolean", "enabled", "1 if play is enabled and 0 otherwise"]]);
462
463simple("exists",
464 "Test whether a track exists",
465 "",
466 [["string", "track", "Track name"]],
467 [["boolean", "exists", "1 if the track exists and 0 otherwise"]]);
468
469simple("files",
470 "List files in a directory",
471 "",
472 [["string", "dir", "Directory to list (optional)"],
473 ["string", "re", "Regexp that results must match (optional)"]],
474 [["body", "files", "List of matching files"]]);
475
476simple("get",
477 "Get a track preference",
478 "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.",
479 [["string", "track", "Track name"],
480 ["string", "pref", "Preference name"]],
481 [["string", "value", "Preference value"]]);
482
483simple("get-global",
484 "Get a global preference",
485 "If the preference does exist not then a null value is returned.",
486 [["string", "pref", "Global preference name"]],
487 [["string", "value", "Preference value"]]);
488
489simple("length",
490 "Get a track's length",
491 "If the track does not exist an error is returned.",
492 [["string", "track", "Track name"]],
493 [["integer", "length", "Track length in seconds"]]);
494
495# TODO log
496
497simple("make-cookie",
498 "Create a login cookie for this user",
499 "The cookie may be redeemed via the 'cookie' command",
500 [],
501 [["string", "cookie", "Newly created cookie"]]);
502
503simple("move",
504 "Move a track",
505 "Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.",
506 [["string", "track", "Track ID or name"],
507 ["integer", "delta", "How far to move the track towards the head of the queue"]]);
508
509simple("moveafter",
510 "Move multiple tracks",
511 "Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.",
512 [["string", "target", "Move after this track, or to head if \"\""],
513 ["list", "ids", "List of tracks to move by ID"]]);
514
515simple(["new", "new_tracks"],
516 "List recently added tracks",
517 "",
518 [["integer", "max", "Maximum tracks to fetch, or 0 for all available"]],
519 [["body", "tracks", "Recently added tracks"]]);
520
521simple("nop",
522 "Do nothing",
523 "Used as a keepalive. No authentication required.",
524 []);
525
526simple("part",
527 "Get a track name part",
528 "If the name part cannot be constructed an empty string is returned.",
529 [["string", "track", "Track name"],
530 ["string", "context", "Context (\"sort\" or \"display\")"],
531 ["string", "part", "Name part (\"artist\", \"album\" or \"title\")"]],
532 [["string", "part", "Value of name part"]]);
533
534simple("pause",
535 "Pause the currently playing track",
536 "Requires the 'pause' right.",
537 []);
538
539simple("play",
540 "Play a track",
541 "Requires the 'play' right.",
542 [["string", "track", "Track to play"]],
543 [["string-raw", "id", "Queue ID of new track"]]);
544
545simple("playafter",
546 "Play multiple tracks",
547 "Requires the 'play' right.",
548 [["string", "target", "Insert into queue after this track, or at head if \"\""],
549 ["list", "tracks", "List of track names to play"]]);
550
551simple("playing",
552 "Retrieve the playing track",
553 "",
554 [],
555 [["queue-one", "playing", "Details of the playing track"]]);
556
557simple("playlist-delete",
558 "Delete a playlist",
559 "Requires the 'play' right and permission to modify the playlist.",
560 [["string", "playlist", "Playlist to delete"]]);
561
562simple("playlist-get",
563 "List the contents of a playlist",
564 "Requires the 'read' right and oermission to read the playlist.",
565 [["string", "playlist", "Playlist name"]],
566 [["body", "tracks", "List of tracks in playlist"]]);
567
568simple("playlist-get-share",
569 "Get a playlist's sharing status",
570 "Requires the 'read' right and permission to read the playlist.",
571 [["string", "playlist", "Playlist to read"]],
572 [["string-raw", "share", "Sharing status (\"public\", \"private\" or \"shared\")"]]);
573
574simple("playlist-lock",
575 "Lock a playlist",
576 "Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.",
577 [["string", "playlist", "Playlist to delete"]]);
578
579simple("playlist-set",
580 "Set the contents of a playlist",
581 "Requires the 'play' right and permission to modify the playlist, which must be locked.",
582 [["string", "playlist", "Playlist to modify"],
583 ["body", "tracks", "New list of tracks for playlist"]]);
584
585simple("playlist-set-share",
586 "Set a playlist's sharing status",
587 "Requires the 'play' right and permission to modify the playlist.",
588 [["string", "playlist", "Playlist to modify"],
589 ["string", "share", "New sharing status (\"public\", \"private\" or \"shared\")"]]);
590
591simple("playlist-unlock",
592 "Unlock the locked playlist playlist",
593 "The playlist to unlock is implicit in the connection.",
594 []);
595
596simple("playlists",
597 "List playlists",
598 "Requires the 'read' right. Only playlists that you have permission to read are returned.",
599 [],
600 [["body", "playlists", "Playlist names"]]);
601
602simple("prefs",
603 "Get all the preferences for a track",
604 "",
605 [["string", "track", "Track name"]],
606 [["pair-list", "prefs", "Track preferences"]]);
607
608simple("queue",
609 "List the queue",
610 "",
611 [],
612 [["queue", "queue", "Current queue contents"]]);
613
614simple("random-disable",
615 "Disable random play",
616 "Requires the 'global prefs' right.",
617 []);
618
619simple("random-enable",
620 "Enable random play",
621 "Requires the 'global prefs' right.",
622 []);
623
624simple("random-enabled",
625 "Detect whether random play is enabled",
626 "Random play counts as enabled even if play is disabled.",
627 [],
628 [["boolean", "enabled", "1 if random play is enabled and 0 otherwise"]]);
629
630simple("recent",
631 "List recently played tracks",
632 "",
633 [],
634 [["queue", "recent", "Recently played tracks"]]);
635
636simple("reconfigure",
637 "Re-read configuraiton file.",
638 "Requires the 'admin' right.",
639 []);
640
641simple("register",
642 "Register a new user",
643 "Requires the 'register' right which is usually only available to the 'guest' user. Redeem the confirmation string via 'confirm' to complete registration.",
644 [["string", "username", "Requested new username"],
645 ["string", "password", "Requested initial password"],
646 ["string", "email", "New user's email address"]],
647 [["string", "confirmation", "Confirmation string"]]);
648
649simple("reminder",
650 "Send a password reminder.",
651 "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.",
652 [["string", "username", "User to remind"]]);
653
654simple("remove",
655 "Remove a track form the queue.",
656 "Requires one of the 'remove mine', 'remove random' or 'remove any' rights depending on how the track came to be added to the queue.",
657 [["string", "id", "Track ID"]]);
658
659simple("rescan",
660 "Rescan all collections for new or obsolete tracks.",
661 "Requires the 'rescan' right.",
662 []); # TODO wait/fresh flags
663
664simple("resolve",
665 "Resolve a track name",
666 "Converts aliases to non-alias track names",
667 [["string", "track", "Track name (might be an alias)"]],
668 [["string", "resolved", "Resolve track name (definitely not an alias)"]]);
669
670simple("resume",
671 "Resume the currently playing track",
672 "Requires the 'pause' right.",
673 []);
674
675simple("revoke",
676 "Revoke a cookie.",
677 "It will not subsequently be possible to log in with the cookie.",
678 []);
679
680simple("rtp-address",
681 "Get the server's RTP address information",
682 "",
683 [],
684 [["string", "address", "Where to store hostname or address"],
685 ["string", "port", "Where to store service name or port number"]]);
686
687simple("scratch",
688 "Terminate the playing track.",
689 "Requires one of the 'scratch mine', 'scratch random' or 'scratch any' rights depending on how the track came to be added to the queue.",
690 [["string", "id", "Track ID (optional)"]]);
691
692simple(["schedule-add", "schedule_add_play"],
693 "Schedule a track to play in the future",
694 "",
695 [["time", "when", "When to play the track"],
696 ["string", "priority", "Event priority (\"normal\" or \"junk\")"],
697 ["literal", "play", ""],
698 ["string", "track", "Track to play"]]);
699
700simple(["schedule-add", "schedule_add_set_global"],
701 "Schedule a global setting to be changed in the future",
702 "",
703 [["time", "when", "When to change the setting"],
704 ["string", "priority", "Event priority (\"normal\" or \"junk\")"],
705 ["literal", "set-global", ""],
706 ["string", "pref", "Global preference to set"],
707 ["string", "value", "New value of global preference"]]);
708
709simple(["schedule-add", "schedule_add_unset_global"],
710 "Schedule a global setting to be unset in the future",
711 "",
712 [["time", "when", "When to change the setting"],
713 ["string", "priority", "Event priority (\"normal\" or \"junk\")"],
714 ["literal", "set-global", ""],
715 ["string", "pref", "Global preference to set"]]);
716
717simple("schedule-del",
718 "Delete a scheduled event.",
719 "Users can always delete their own scheduled events; with the admin right you can delete any event.",
720 [["string", "event", "ID of event to delete"]]);
721
722simple("schedule-get",
723 "Get the details of scheduled event",
724 "",
725 [["string", "id", "Event ID"]],
726 [["pair-list", "actiondata", "Details of event"]]);
727
728simple("schedule-list",
729 "List scheduled events",
730 "This just lists IDs. Use 'schedule-get' to retrieve more detail",
731 [],
732 [["body", "ids", "List of event IDs"]]);
733
734simple("search",
735 "Search for tracks",
736 "Terms are either keywords or tags formatted as 'tag:TAG-NAME'.",
737 [["string", "terms", "List of search terms"]],
738 [["body", "tracks", "List of matching tracks"]]);
739
740simple("set",
741 "Set a track preference",
742 "Requires the 'prefs' right.",
743 [["string", "track", "Track name"],
744 ["string", "pref", "Preference name"],
745 ["string", "value", "New value"]]);
746
747simple("set-global",
748 "Set a global preference",
749 "Requires the 'global prefs' right.",
750 [["string", "pref", "Preference name"],
751 ["string", "value", "New value"]]);
752
753simple("shutdown",
754 "Request server shutdown",
755 "Requires the 'admin' right.",
756 []);
757
758simple("stats",
759 "Get server statistics",
760 "The details of what the server reports are not really defined. The returned strings are intended to be printed out one to a line.",
761 [],
762 [["body", "stats", "List of server information strings."]]);
763
764simple("tags",
765 "Get a list of known tags",
766 "Only tags which apply to at least one track are returned.",
767 [],
768 [["body", "tags", "List of tags"]]);
769
770simple("unset",
771 "Unset a track preference",
772 "Requires the 'prefs' right.",
773 [["string", "track", "Track name"],
774 ["string", "pref", "Preference name"]]);
775
776simple("unset-global",
777 "Set a global preference",
778 "Requires the 'global prefs' right.",
779 [["string", "pref", "Preference name"]]);
780
781# 'user' only used for authentication
782
783simple("userinfo",
784 "Get a user property.",
785 "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.",
786 [["string", "username", "User to read"],
787 ["string", "property", "Property to read"]],
788 [["string", "value", "Value of property"]]);
789
790simple("users",
791 "Get a list of users",
792 "",
793 [],
794 [["body", "users", "List of users"]]);
795
796simple("version",
797 "Get the server version",
798 "",
799 [],
800 [["string", "version", "Server version string"]]);
801
802simple(["volume", "set_volume"],
803 "Set the volume",
804 "",
805 [["integer", "left", "Left channel volume"],
806 ["integer", "right", "Right channel volume"]]);
807
808simple(["volume", "get_volume"],
809 "Get the volume",
810 "",
811 [],
812 [["integer", "left", "Left channel volume"],
813 ["integer", "right", "Right channel volume"]]);
814
815# End matter ------------------------------------------------------------------
816
817push(@h, "#endif\n");
818
819# Write it all out ------------------------------------------------------------
820
821Write("lib/client-stubs.h", \@h);
822Write("lib/client-stubs.c", \@c);