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