chiark / gitweb /
Mention that FreeBSD requires gmake
[disorder] / doc / disorder_protocol.5.in
CommitLineData
460b9539 1.\"
964e027d 2.\" Copyright (C) 2004-2008 Richard Kettlewell
460b9539 3.\"
4.\" This program is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 2 of the License, or
7.\" (at your option) any later version.
8.\"
9.\" This program is distributed in the hope that it will be useful, but
10.\" WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12.\" General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with this program; if not, write to the Free Software
16.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17.\" USA
18.\"
19.TH disorder_protocol 5
20.SH NAME
21disorder_protocol \- DisOrder communication protocol
22.SH DESCRIPTION
23The DisOrder client and server communicate via the protocol described
24in this man page.
25.PP
26The protocol is liable to change without notice. You are recommended to check
27the implementation before believing this document.
28.SH "GENERAL SYNTAX"
f9635e06
RK
29Everything is encoded using UTF-8. See
30.B "CHARACTER ENCODING"
31below for more detail on character encoding issues.
460b9539 32.PP
f9635e06
RK
33Commands and responses consist of a line perhaps followed (depending on the
34command or response) by a body.
460b9539 35.PP
36The line syntax is the same as described in \fBdisorder_config\fR(5) except
37that comments are prohibited.
38.PP
39Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
40lines, with any initial full stop doubled up, and are terminated by a line
41consisting of a full stop and a line feed.
42.SH COMMANDS
43Commands always have a command name as the first field of the line; responses
44always have a 3-digit response code as the first field. See below for more
45details about this field.
46.PP
47All commands require the connection to have been already authenticated unless
eb5dc014
RK
48stated otherwise. If not stated otherwise, the \fBread\fR right is sufficient
49to execute the command.
460b9539 50.PP
51Neither commands nor responses have a body unless stated otherwise.
52.TP
0f55e905 53.B adduser \fIUSERNAME PASSWORD \fR[\fIRIGHTS\fR]
5818980a 54Create a new user with the given username and password. The new user's rights
0f55e905
RK
55list can be specified; if it is not then the \fBdefault_rights\fR setting
56applies instead. Requires the \fBadmin\fR right, and only works on local
57connections.
eb5dc014 58.TP
460b9539 59.B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
5818980a 60List all the files and directories in \fIDIRECTORY\fR in a response body.
460b9539 61If \fIREGEXP\fR is present only matching files and directories are returned.
62.TP
ba39faf6
RK
63.B confirm \fICONFIRMATION
64Confirm user registration. \fICONFIRMATION\fR is as returned from
65\fBregister\fR below. This command can be used without logging in.
66.TP
eb5dc014 67.B cookie \fICOOKIE
0227f67d
RK
68Log a user back in using a cookie created with \fBmake-cookie\fR. The response
69contains the username.
eb5dc014
RK
70.TP
71.B deluser \fIUSERNAME
5818980a 72Delete the named user. Requires the \fBadmin\fR right, and only works on
eb5dc014 73local connections.
460b9539 74.TP
75.B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
5818980a 76List all the directories in \fIDIRECTORY\fR in a response body.
460b9539 77If \fIREGEXP\fR is present only matching directories are returned.
78.TP
79.B disable \fR[\fBnow\fR]
5818980a 80Disable further playing. If the optional \fBnow\fR argument is present then
eb5dc014
RK
81the current track is stopped. Requires the \fBglobal prefs\fR right.
82.TP
83.B edituser \fIUSERNAME PROPERTY VALUE
5818980a 84Set a user property. With the \fBadmin\fR right any username and property may
eb5dc014
RK
85be specified. Otherwise the \fBuserinfo\fR right is required and only the
86\fBemail\fR and \fBpassword\fR properties may be set.
460b9539 87.TP
88.B enable
5818980a 89Re-enable further playing, and is the opposite of \fBdisable\fR. Requires the
eb5dc014 90\fBglobal prefs\fR right.
460b9539 91.TP
92.B enabled
5818980a 93Report whether playing is enabled. The second field of the response line will
460b9539 94be \fByes\fR or \fBno\fR.
95.TP
96.B exists \fITRACK\fR
5818980a 97Report whether the named track exists. The second field of the response line
460b9539 98will be \fByes\fR or \fBno\fR.
99.TP
100.B files \fIDIRECTORY\fR [\fIREGEXP\fR]
5818980a 101List all the files in \fIDIRECTORY\fR in a response body.
460b9539 102If \fIREGEXP\fR is present only matching files are returned.
103.TP
104.B get \fITRACK\fR \fIPREF\fR
5818980a 105Getsa preference value. On success the second field of the response line will
460b9539 106have the value.
fb1bc1f5
RK
107.IP
108If the track or preference do not exist then the response code is 555.
460b9539 109.TP
110.B get-global \fIKEY\fR
111Get a global preference.
fb1bc1f5
RK
112.IP
113If the preference does not exist then the response code is 555.
460b9539 114.TP
115.B length \fITRACK\fR
5818980a 116Get the length of the track in seconds. On success the second field of the
460b9539 117response line will have the value.
118.TP
119.B log
5818980a 120Send event log messages in a response body. The command will never terminate.
397ef7bb
RK
121Any further data sent to the server will be discarded (explicitly; i.e. it will
122not accumulate in a buffer somewhere).
460b9539 123.IP
124See \fBEVENT LOG\fR below for more details.
125.TP
eb5dc014
RK
126.B make-cookie
127Returns an opaque string that can be used by the \fBcookie\fR command to log
128this user back in on another connection (until the cookie expires).
129.TP
460b9539 130.B move \fITRACK\fR \fIDELTA\fR
131Move a track in the queue. The track may be identified by ID (preferred) or
132name (which might cause confusion if it's there twice). \fIDELTA\fR should be
133an negative or positive integer and indicates how many steps towards the head
134of the queue the track should be moved.
eb5dc014
RK
135.IP
136Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
137depending on how the track came to be added to the queue.
460b9539 138.TP
139.B moveafter \fITARGET\fR \fIID\fR ...
140Move all the tracks in the \fIID\fR list after ID \fITARGET\fR. If
141\fITARGET\fR is the empty string then the listed tracks are put at the head of
142the queue. If \fITARGET\fR is listed in the ID list then the tracks are moved
143to just after the first non-listed track before it, or to the head if there is
144no such track.
eb5dc014
RK
145.IP
146Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
147depending on how the tracks came to be added to the queue.
460b9539 148.TP
2a10b70b 149.B new \fR[\fIMAX\fR]
5818980a 150Send the most recently added \fIMAX\fR tracks in a response body. If the
d742bb47
RK
151argument is ommitted, the \fBnew_max\fR most recent tracks are listed (see
152\fBdisorder_config\fR(5)).
2a10b70b 153.TP
7858930d 154.B nop
155Do nothing. Used by
156.BR disobedience (1)
eb5dc014 157as a keepalive measure. This command does not require authentication.
7858930d 158.TP
460b9539 159.B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
160Get a track name part. Returns an empty string if a name part cannot be
161constructed.
162.IP
163.I CONTEXT
164is one of
165.B sort
166or
167.B display
168and
169.I PART
170is usually one of
171.BR artist ,
172.B album
173or
174.BR title .
175.TP
176.B pause
fce810c2 177Pause the current track. Requires the \fBpause\fR right.
460b9539 178.TP
179.B play \fITRACK\fR
81e440ce 180Add a track to the queue. The response contains the queue ID of the track.
eb5dc014 181Requires the \fBplay\fR right.
460b9539 182.TP
183.B playing
5818980a 184Report what track is playing.
460b9539 185.IP
186If the response is \fB252\fR then the rest of the response line consists of
187track information (see below).
188.IP
189If the response is \fB259\fR then nothing is playing.
190.TP
191.B prefs \fBTRACK\fR
5818980a 192Send back the preferences for \fITRACK\fR in a response body.
460b9539 193Each line of the response has the usual line syntax, the first field being the
194name of the pref and the second the value.
195.TP
196.B queue
5818980a 197Send back the current queue in a response body, one track to a line, the track
460b9539 198at the head of the queue (i.e. next to be be played) first. See below for the
199track information syntax.
200.TP
201.B random-disable
eb5dc014
RK
202Disable random play (but don't stop the current track). Requires the \fBglobal
203prefs\fR right.
460b9539 204.TP
205.B random-enable
eb5dc014 206Enable random play. Requires the \fBglobal prefs\fR right.
460b9539 207.TP
208.B random-enabled
5818980a 209Report whether random play is enabled. The second field of the response line
460b9539 210will be \fByes\fR or \fBno\fR.
211.TP
212.B recent
5818980a 213Send back the current recently-played list in a response body, one track to a
460b9539 214line, the track most recently played last. See below for the track
215information syntax.
216.TP
217.B reconfigure
eb5dc014 218Request that DisOrder reconfigure itself. Requires the \fBadmin\fR right.
460b9539 219command.
220.TP
ba39faf6
RK
221.B register \fIUSER PASSWORD EMAIL
222Register a new user. Requires the \fBregister\fR right. The result contains a
223confirmation string; the user will be be able to log in until this has been
224presented back to the server via the \fBconfirm\fR command.
225.TP
6207d2f3 226.B reminder \fIUSER\fR
227Send a password reminder to \fIUSER\fR. If the user has no valid email
228address, or no password, or a reminder has been sent too recently, then no
229reminder will be sent.
230.TP
460b9539 231.B remove \fIID\fR
eb5dc014
RK
232Remove the track identified by \fIID\fR. Requires one of the \fBremove
233mine\fR, \fBremove random\fR or \fBremove any\fR rights depending on how the
234track came to be added to the queue.
460b9539 235.TP
236.B rescan
eb5dc014 237Rescan all roots for new or obsolete tracks. Requires the \fBrescan\fR right.
460b9539 238.TP
239.B resolve \fITRACK\fR
240Resolve a track name, i.e. if this is an alias then return the real track name.
241.TP
242.B resume
eb5dc014
RK
243Resume the current track after a \fBpause\fR command. Requires the \fBpause\fR
244right.
245.TP
246.B revoke \fBcookie\fR
5818980a 247Revoke a cookie previously created with \fBmake-cookie\fR. It will not be
eb5dc014 248possible to use this cookie in the future.
460b9539 249.TP
ca831831 250.B rtp-address
5818980a 251Report the RTP broadcast (or multicast) address, in the form \fIADDRESS
eb5dc014 252PORT\fR. This command does not require authentication.
ca831831 253.TP
460b9539 254.B scratch \fR[\fIID\fR]
255Remove the track identified by \fIID\fR, or the currently playing track if no
eb5dc014
RK
256\fIID\fR is specified. Requires one of the \fBscratch mine\fR, \fBscratch
257random\fR or \fBscratch any\fR rights depending on how the track came to be
258added to the queue.
460b9539 259.TP
260.B search \fITERMS\fR
261Search for tracks matching the search terms. The results are put in a response
262body, one to a line.
263.IP
264The search string is split in the usual way, with quoting supported, into a
265list of terms. Only tracks matching all terms are included in the results.
266.IP
267Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
268tag.
269.IP
270All other terms are interpreted as individual words which must be present in
271the track name.
272.IP
273Spaces in terms don't currently make sense, but may one day be interpreted to
274allow searching for phrases.
275.TP
276.B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
eb5dc014 277Set a preference. Requires the \fBprefs\fR right.
460b9539 278.TP
279.B set-global \fIKEY\fR \fIVALUE\fR
eb5dc014 280Set a global preference. Requires the \fBglobal prefs\fR right.
460b9539 281.TP
282.B stats
283Send server statistics in plain text in a response body.
284.TP
285.B \fBtags\fR
286Send the list of currently known tags in a response body.
287.TP
288.B \fBunset\fR \fITRACK\fR \fIPREF\fR
eb5dc014 289Unset a preference. Requires the \fBprefs\fR right.
460b9539 290.TP
291.B \fBunset-global\fR \fIKEY\fR
eb5dc014 292Unset a global preference. Requires the \fBglobal prefs\fR right.
460b9539 293.TP
294.B user \fIUSER\fR \fIRESPONSE\fR
5e3f9e08
RK
295Authenticate as \fIUSER\fR. See
296.B AUTHENTICATION
297below.
460b9539 298.TP
eb5dc014 299.B users
5818980a 300Send the list of currently known users in a response body.
eb5dc014 301.TP
460b9539 302.B version
303Send back a response with the server version as the second field.
304.TP
305.B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
306Get or set the volume.
307.IP
308With zero parameters just gets the volume and reports the left and right sides
309as the 2nd and 3rd fields of the response.
310.IP
311With one parameter sets both sides to the same value. With two parameters sets
eb5dc014 312each side independently. Setting the volume requires the \fBvolume\fR right.
460b9539 313.SH RESPONSES
314Responses are three-digit codes. The first digit distinguishes errors from
315succesful responses:
316.TP
317.B 2
318Operation succeeded.
319.TP
320.B 5
321Operation failed.
322.PP
323The second digit breaks down the origin of the response:
324.TP
325.B 0
326Generic responses not specific to the handling of the command. Mostly this is
327parse errors.
328.TP
b4a80f69 329.B 1
33051x errors indicate that the user had insufficient rights for the command.
331.TP
460b9539 332.B 3
333Authentication responses.
334.TP
335.B 5
336Responses specific to the handling of the command.
337.PP
338The third digit provides extra information about the response:
339.TP
340.B 0
341Text part is just commentary.
342.TP
343.B 1
344Text part is a constant result e.g. \fBversion\fR.
345.TP
346.B 2
347Text part is a potentially variable result.
348.TP
349.B 3
350Text part is just commentary; a dot-stuffed body follows.
351.TP
352.B 4
353Text part is just commentary; an indefinite dot-stuffed body follows. (Used
354for \fBlog\fR.)
355.TP
fb1bc1f5
RK
356.B 5
357Used with "normal" errors, for instance a preference not being found. The text
358part is commentary.
359.TP
460b9539 360.B 9
361The text part is just commentary (but would normally be a response for this
362command) e.g. \fBplaying\fR.
7b32e917
RK
363.PP
364Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
365responses) are quoted.
460b9539 366.SH AUTHENTICATION
5e3f9e08 367When a connection is made the server sends a \fB231\fR response before any
7b32e917
RK
368command is received. This contains a protocol generation, an algorithm name
369and a challenge encoded in hex, all separated by whitespace.
370.PP
371The current protocol generation is \fB2\fR.
5e3f9e08 372.PP
b3141726
RK
373The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
374and \fBsha512\fR. \fBSHA1\fR etc work as synonyms.
460b9539 375.PP
5e3f9e08
RK
376The \fBuser\fR response consists of the selected hash of the user's password
377concatenated with the challenge, encoded in hex.
460b9539 378.SH "TRACK INFORMATION"
379Track information is encoded in a line (i.e. using the usual line syntax) as
380pairs of fields. The first is a name, the second a value. The names have the
381following meanings:
382.TP 12
383.B expected
384The time the track is expected to be played at.
385.TP
386.B id
387A string uniquely identifying this queue entry.
388.TP
389.B played
390The time the track was played at.
391.TP
392.B scratched
393The user that scratched the track.
394.TP
395.B state
396The current track state. Valid states are:
397.RS
398.TP 12
399.B failed
400The player failed (exited with nonzero status but wasn't scratched).
401.TP
402.B isscratch
403The track is actually a scratch.
404.TP
405.B no_player
406No player could be found for the track.
407.TP
408.B ok
409The track was played without any problems.
410.TP
411.B scratched
412The track was scratched.
413.TP
414.B started
415The track is currently playing.
416.TP
417.B unplayed
418In the queue, hasn't been played yet.
419.TP
420.B quitting
421The track was terminated because the server is shutting down.
422.RE
423.TP
424.B submitter
425The user that submitted the track.
426.TP
427.B track
428The filename of the track.
429.TP
430.B when
431The time the track was added to the queue.
432.TP
433.B wstat
434The wait status of the player in decimal.
435.SH NOTES
436Times are decimal integers using the server's \fBtime_t\fR.
437.PP
438For file listings, the regexp applies to the basename of the returned file, not
439the whole filename, and letter case is ignored. \fBpcrepattern\fR(3) describes
440the regexp syntax.
441.PP
442Filenames are in UTF-8 even if the collection they come from uses some other
443encoding - if you want to access the real file (in such cases as the filenames
444actually correspond to a real file) you'll have to convert to whatever the
445right encoding is.
446.SH "EVENT LOG"
447The event log consists of lines starting with a hexadecimal timestamp and a
448keyword followed by (optionally) parameters. The parameters are quoted in the
449usual DisOrder way. Currently the following keywords are used:
450.TP
451.B completed \fITRACK\fR
452Completed playing \fITRACK\fR
453.TP
454.B failed \fITRACK\fR \fIERROR\fR
455Completed playing \fITRACK\fR with an error status
456.TP
457.B moved \fIUSER\fR
458User \fIUSER\fR moved some track(s). Further details aren't included any
459more.
460.TP
461.B playing \fITRACK\fR [\fIUSER\fR]
462Started playing \fITRACK\fR.
463.TP
464.B queue \fIQUEUE-ENTRY\fR...
465Added \fITRACK\fR to the queue.
466.TP
467.B recent_added \fIQUEUE-ENTRY\fR...
468Added \fIID\fR to the recently played list.
469.TP
470.B recent_removed \fIID\fR
471Removed \fIID\fR from the recently played list.
472.TP
473.B removed \fIID\fR [\fIUSER\fR]
474Queue entry \fIID\fR was removed. This is used both for explicit removal (when
475\fIUSER\fR is present) and when playing a track (when it is absent).
476.TP
e025abff
RK
477.B rescanned
478A rescan completed.
479.TP
460b9539 480.B scratched \fITRACK\fR \fIUSER\fR
481\fITRACK\fR was scratched by \fIUSER\fR.
482.TP
483.B state \fIKEYWORD\fR
484Some state change occurred. The current set of keywords is:
485.RS
486.TP
5abe307a
RK
487.B completed
488The current track completed successfully.
489.TP
460b9539 490.B disable_play
491Playing was disabled.
492.TP
493.B disable_random
494Random play was disabled.
495.TP
496.B enable_play
497Playing was enabled.
498.TP
499.B enable_random
500Random play was enabled.
501.TP
5abe307a
RK
502.B failed
503The current track failed.
504.TP
460b9539 505.B pause
506The current track was paused.
507.TP
5abe307a
RK
508.B playing
509A track started playing.
510.TP
460b9539 511.B resume
512The current track was resumed.
5abe307a
RK
513.TP
514.B scratched
515The current track was scratched.
516.PP
517To simplify client implementation, \fBstate\fR commands reflecting the current
518state are sent at the start of the log.
460b9539 519.RE
520.TP
521.B volume \fILEFT\fR \fIRIGHT\fR
522The volume changed.
523.PP
524.IR QUEUE-ENTRY ...
525is as defined in
526.B "TRACK INFORMATION"
527above.
f9635e06
RK
528.SH "CHARACTER ENCODING"
529All data sent by both server and client is encoded using UTF-8. Moreover it
530must be valid UTF-8, i.e. non-minimal sequences are not permitted, nor are
531surrogates, nor are code points outside the Unicode code space.
532.PP
533There are no particular normalization requirements on either side of the
534protocol. The server currently converts internally to NFC, the client must
535normalize the responses returned if it needs some normalized form for further
536processing.
537.PP
538The various characters which divide up lines may not be followed by combining
539characters. For instance all of the following are prohibited:
540.TP
541.B o
542LINE FEED followed by a combining character. For example the sequence
543LINE FEED, COMBINING GRAVE ACCENT is never permitted.
544.TP
545.B o
546APOSTROPHE or QUOTATION MARK followed by a combining character when used to
547delimit fields. For instance a line starting APOSTROPHE, COMBINING CEDILLA
548is prohibited.
549.IP
550Note that such sequences are not prohibited when the quote character cannot be
551interpreted as a field delimiter. For instance APOSTROPHE, REVERSE SOLIDUS,
552APOSTROPHE, COMBINING CEDILLA, APOSTROPHE would be permitted.
553.TP
554.B o
555REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
556string when it is the first character of an escape sequence. For instance a
557line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE is prohibited.
558.IP
559As above such sequences are not prohibited when the character is not being used
560to start an escape sequence. For instance APOSTROPHE, REVERSE SOLIDUS,
561REVERSE SOLIDS, COMBINING TILDER, APOSTROPHE is permitted.
562.TP
563.B o
564Any of the field-splitting whitespace characters followed by a combining
565character when not part of a quoted field. For instance a line starting COLON,
566SPACE, COMBINING CANDRABINDU is prohibited.
567.IP
568As above non-delimiter uses are fine.
569.TP
570.B o
571The FULL STOP characters used to quote or delimit a body.
572.PP
573Furthermore none of these characters are permitted to appear in the context of
574a canonical decomposition (i.e. they must still be present when converted to
575NFC). In practice however this is not an issue in Unicode 5.0.
576.PP
577These rules are consistent with the observation that the split() function is
578essentially a naive ASCII parser. The implication is not that these sequences
579never actually appear in the protocol, merely that the server is not required
580to honor them in any useful way nor be consistent between versions: in current
581versions the result will be lines and fields that start with combining
582characters and are not necessarily split where you expect, but future versions
583may remove them, reject them or ignore some or all of the delimiters that have
584following combining characters, and no notice will be given of any change.
460b9539 585.SH "SEE ALSO"
586\fBdisorder\fR(1),
587\fBtime\fR(2),
588\fBdisorder\fR(3),
589\fBpcrepattern\fR(3)
590\fBdisorder_config\fR(5),
591\fBdisorderd\fR(8),
592\fButf8\fR(7)
593.\" Local Variables:
594.\" mode:nroff
595.\" fill-column:79
596.\" End: