X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/830d5c43fc94713788d7c99f7509b41affa0b8c0..0bc1d67cbb413a23b3cf3dce64be13738739b9d3:/scripts/protocol diff --git a/scripts/protocol b/scripts/protocol index dbb6ad1..118fda3 100755 --- a/scripts/protocol +++ b/scripts/protocol @@ -44,6 +44,9 @@ sub c_in_decl { return "const char *$name"; } elsif($type eq 'integer') { return "long $name"; + } elsif($type eq 'list' or $type eq 'body') { + return ("char **$name", + "int n$name"); } else { die "$0: unknown type '$type'\n"; } @@ -64,6 +67,8 @@ sub c_out_decl { } elsif($type eq 'list') { return ("char ***${name}p", "int *n${name}p"); + } elsif($type eq 'queue') { + return ("struct queue_entry **${name}p"); } else { die "$0: unknown type '$type'\n"; } @@ -71,7 +76,17 @@ sub c_out_decl { sub c_param_docs { my $args = shift; - return map(" * \@param $_->[1] $_->[2]\n", @$args); + my @d = (); + for my $arg (@$args) { + if($arg->[0] eq 'body' or $arg->[0] eq 'list') { + push(@d, + " * \@param $arg->[1] $arg->[2]\n", + " * \@param n$arg->[1] Length of $arg->[1]\n"); + } else { + push(@d, " * \@param $arg->[1] $arg->[2]\n"); + } + } + return @d; } sub c_return_docs { @@ -87,6 +102,8 @@ sub c_return_docs { } elsif($type eq 'list') { return (" * \@param ${name}p $descr\n", " * \@param n${name}p Number of elements in ${name}p\n"); + } elsif($type eq 'queue') { + return (" * \@param ${name}p $descr\n"); } else { die "$0: unknown return type '$type'\n"; } @@ -94,7 +111,7 @@ sub c_return_docs { # simple(CMD, SUMMARY, DETAIL, # [[TYPE,NAME,DESCR], [TYPE,NAME,DESCR], ...], -# [RETURN-TYPE, RETURN-NAME, RETURN_DESCR) +# [RETURN-TYPE, RETURN-NAME, RETURN_DESCR]) sub simple { my $cmd = shift; my $summary = shift; @@ -109,6 +126,7 @@ sub simple { " *\n", " * $detail\n", " *\n", + " * \@param c Client\n", c_param_docs($args), c_return_docs($return), " * \@return 0 on success, non-0 on error\n", @@ -124,10 +142,23 @@ sub simple { c_out_decl($return)), ") {\n"); if(!defined $return) { - push(@c, " return disorder_simple(c, 0, \"$cmd\"", - map(", $_->[1]", @$args), - ", (char *)0);\n", - ); + my @cargs = (); + for my $arg (@$args) { + if($arg->[0] eq 'body' or $arg->[0] eq 'list') { + push(@cargs, "disorder_$arg->[0]", $arg->[1], "n$arg->[1]"); + } elsif($arg->[0] eq 'string') { + push(@cargs, $arg->[1]); + } elsif($arg->[0] eq 'integer') { + push(@cargs, "buf_$arg->[1]"); + push(@c, " char buf_$arg->[1]\[16];\n", + " byte_snprintf(buf_$arg->[1], sizeof buf_$arg->[1], \"%ld\", $arg->[1]);\n"); + } else { + die "$0: unsupported arg type '$arg->[0]' for '$cmd'\n"; + } + } + push(@c, " return disorder_simple(", + join(", ", "c", 0, "\"$cmd\"", @cargs, "(char *)0"), + ");\n"); } elsif($return->[0] eq 'string') { push(@c, " return dequote(disorder_simple(c, $return->[1]p, \"$cmd\"", map(", $_->[1]", @$args), @@ -155,6 +186,8 @@ sub simple { push(@c, " return disorder_simple_list(c, $return->[1]p, n$return->[1]p, \"$cmd\"", map(", $_->[1]", @$args), ", (char *)0);\n"); + } elsif($return->[0] eq 'queue') { + push(@c, " return disorder_somequeue(c, \"$cmd\", $return->[1]p);\n"); } else { die "$0: unknown return type '$return->[0]' for '$cmd'\n"; } @@ -356,9 +389,17 @@ simple("make-cookie", [], ["string", "cookie", "Newly created cookie"]); -# TODO move +simple("move", + "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.", + [["string", "track", "Track ID or name"], + ["integer", "delta", "How far to move the track towards the head of the queue"]]); -# TODO moveafter +simple("moveafter", + "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.", + [["string", "target", "Move after this track, or to head if \"\""], + ["list", "ids", "List of tracks to move by ID"]]); # TODO new @@ -386,7 +427,11 @@ simple("play", [["string", "track", "Track to play"]], ["string", "id", "Queue ID of new track"]); -# TODO playafter +simple("playafter", + "Play multiple tracks", + "Requires the 'play' right.", + [["string", "target", "Insert into queue after this track, or at head if \"\""], + ["list", "tracks", "List of track names to play"]]); # TODO playing @@ -412,6 +457,12 @@ simple("playlist-lock", "Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.", [["string", "playlist", "Playlist to delete"]]); +simple("playlist-set", + "Set the contents of a playlist", + "Requires the 'play' right and permission to modify the playlist, which must be locked.", + [["string", "playlist", "Playlist to modify"], + ["body", "tracks", "New list of tracks for playlist"]]); + simple("playlist-set-share", "Set a playlist's sharing status", "Requires the 'play' right and permission to modify the playlist.", @@ -431,7 +482,11 @@ simple("playlists", # TODO prefs -# TODO queue +simple("queue", + "List the queue", + "", + [], + ["queue", "queue", "Current queue contents"]); simple("random-disable", "Disable random play", @@ -449,7 +504,11 @@ simple("random-enabled", [], ["boolean", "enabled", "1 if random play is enabled and 0 otherwise"]); -# TODO recent +simple("recent", + "List recently played tracks", + "", + [], + ["queue", "recent", "Recently played tracks"]); simple("reconfigure", "Re-read configuraiton file.", @@ -493,7 +552,7 @@ simple("resume", simple("revoke", "Revoke a cookie.", "It will not subsequently be possible to log in with the cookie.", - []); # TODO fix docs! + []); # TODO rtp-address