2 .\" Copyright (C) 2004, 2005, 2006 Richard Kettlewell
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.
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.
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
19 .TH disorder_protocol 5
21 disorder_protocol \- DisOrder communication protocol
23 The DisOrder client and server communicate via the protocol described
26 The protocol is liable to change without notice. You are recommended to check
27 the implementation before believing this document.
29 Everything is encoded using UTF-8. See
30 .B "CHARACTER ENCODING"
31 below for more detail on character encoding issues.
33 Commands and responses consist of a line perhaps followed (depending on the
34 command or response) by a body.
36 The line syntax is the same as described in \fBdisorder_config\fR(5) except
37 that comments are prohibited.
39 Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
40 lines, with any initial full stop doubled up, and are terminated by a line
41 consisting of a full stop and a line feed.
43 Commands always have a command name as the first field of the line; responses
44 always have a 3-digit response code as the first field. See below for more
45 details about this field.
47 All commands require the connection to have been already authenticated unless
48 stated otherwise. If not stated otherwise, the \fBread\fR right is sufficient
49 to execute the command.
51 Neither commands nor responses have a body unless stated otherwise.
53 .B adduser \fIUSERNAME PASSWORD
54 Creates a new user with the given username and password. Requires the
55 \fBadmin\fR right, and only works on local connections.
57 .B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
58 Lists all the files and directories in \fIDIRECTORY\fR in a response body.
59 If \fIREGEXP\fR is present only matching files and directories are returned.
62 Log a user back in using a cookie created with \fBmake-cookie\fR.
64 .B deluser \fIUSERNAME
65 Deletes the named user. Requires the \fBadmin\fR right, and only works on
68 .B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
69 Lists all the directories in \fIDIRECTORY\fR in a response body.
70 If \fIREGEXP\fR is present only matching directories are returned.
72 .B disable \fR[\fBnow\fR]
73 Disables further playing. If the optional \fBnow\fR argument is present then
74 the current track is stopped. Requires the \fBglobal prefs\fR right.
76 .B edituser \fIUSERNAME PROPERTY VALUE
77 Sets a user property. With the \fBadmin\fR right any username and property may
78 be specified. Otherwise the \fBuserinfo\fR right is required and only the
79 \fBemail\fR and \fBpassword\fR properties may be set.
82 Re-enables further playing, and is the opposite of \fBdisable\fR. Requires the
83 \fBglobal prefs\fR right.
86 Reports whether playing is enabled. The second field of the response line will
87 be \fByes\fR or \fBno\fR.
90 Reports whether the named track exists. The second field of the response line
91 will be \fByes\fR or \fBno\fR.
93 .B files \fIDIRECTORY\fR [\fIREGEXP\fR]
94 Lists all the files in \fIDIRECTORY\fR in a response body.
95 If \fIREGEXP\fR is present only matching files are returned.
97 .B get \fITRACK\fR \fIPREF\fR
98 Gets a preference value. On success the second field of the response line will
101 If the track or preference do not exist then the response code is 555.
103 .B get-global \fIKEY\fR
104 Get a global preference.
106 If the preference does not exist then the response code is 555.
108 .B length \fITRACK\fR
109 Gets the length of the track in seconds. On success the second field of the
110 response line will have the value.
113 Sends event log messages in a response body. The command will never terminate.
114 Any further data sent to the server will be discarded (explicitly; i.e. it will
115 not accumulate in a buffer somewhere).
117 See \fBEVENT LOG\fR below for more details.
120 Returns an opaque string that can be used by the \fBcookie\fR command to log
121 this user back in on another connection (until the cookie expires).
123 .B move \fITRACK\fR \fIDELTA\fR
124 Move a track in the queue. The track may be identified by ID (preferred) or
125 name (which might cause confusion if it's there twice). \fIDELTA\fR should be
126 an negative or positive integer and indicates how many steps towards the head
127 of the queue the track should be moved.
129 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
130 depending on how the track came to be added to the queue.
132 .B moveafter \fITARGET\fR \fIID\fR ...
133 Move all the tracks in the \fIID\fR list after ID \fITARGET\fR. If
134 \fITARGET\fR is the empty string then the listed tracks are put at the head of
135 the queue. If \fITARGET\fR is listed in the ID list then the tracks are moved
136 to just after the first non-listed track before it, or to the head if there is
139 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
140 depending on how the tracks came to be added to the queue.
142 .B new \fR[\fIMAX\fR]
143 Sends the most recently added \fIMAX\fR tracks in a response body. If the
144 argument is ommitted, all recently added tracks are listed.
149 as a keepalive measure. This command does not require authentication.
151 .B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
152 Get a track name part. Returns an empty string if a name part cannot be
169 Pause the current track. Requires the \fBpause\R right.
172 Add a track to the queue. The response contains the queue ID of the track.
173 Requires the \fBplay\fR right.
176 Reports what track is playing.
178 If the response is \fB252\fR then the rest of the response line consists of
179 track information (see below).
181 If the response is \fB259\fR then nothing is playing.
184 Sends back the preferences for \fITRACK\fR in a response body.
185 Each line of the response has the usual line syntax, the first field being the
186 name of the pref and the second the value.
189 Sends back the current queue in a response body, one track to a line, the track
190 at the head of the queue (i.e. next to be be played) first. See below for the
191 track information syntax.
194 Disable random play (but don't stop the current track). Requires the \fBglobal
198 Enable random play. Requires the \fBglobal prefs\fR right.
201 Reports whether random play is enabled. The second field of the response line
202 will be \fByes\fR or \fBno\fR.
205 Sends back the current recently-played list in a response body, one track to a
206 line, the track most recently played last. See below for the track
210 Request that DisOrder reconfigure itself. Requires the \fBadmin\fR right.
214 Remove the track identified by \fIID\fR. Requires one of the \fBremove
215 mine\fR, \fBremove random\fR or \fBremove any\fR rights depending on how the
216 track came to be added to the queue.
219 Rescan all roots for new or obsolete tracks. Requires the \fBrescan\fR right.
221 .B resolve \fITRACK\fR
222 Resolve a track name, i.e. if this is an alias then return the real track name.
225 Resume the current track after a \fBpause\fR command. Requires the \fBpause\fR
228 .B revoke \fBcookie\fR
229 Revokes a cookie previously created with \fBmake-cookie\fR. It will not be
230 possible to use this cookie in the future.
233 Reports the RTP broadcast (or multicast) address, in the form \fIADDRESS
234 PORT\fR. This command does not require authentication.
236 .B scratch \fR[\fIID\fR]
237 Remove the track identified by \fIID\fR, or the currently playing track if no
238 \fIID\fR is specified. Requires one of the \fBscratch mine\fR, \fBscratch
239 random\fR or \fBscratch any\fR rights depending on how the track came to be
242 .B search \fITERMS\fR
243 Search for tracks matching the search terms. The results are put in a response
246 The search string is split in the usual way, with quoting supported, into a
247 list of terms. Only tracks matching all terms are included in the results.
249 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
252 All other terms are interpreted as individual words which must be present in
255 Spaces in terms don't currently make sense, but may one day be interpreted to
256 allow searching for phrases.
258 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
259 Set a preference. Requires the \fBprefs\fR right.
261 .B set-global \fIKEY\fR \fIVALUE\fR
262 Set a global preference. Requires the \fBglobal prefs\fR right.
265 Send server statistics in plain text in a response body.
268 Send the list of currently known tags in a response body.
270 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
271 Unset a preference. Requires the \fBprefs\fR right.
273 .B \fBunset-global\fR \fIKEY\fR
274 Unset a global preference. Requires the \fBglobal prefs\fR right.
276 .B user \fIUSER\fR \fIRESPONSE\fR
277 Authenticate as \fIUSER\fR. See
282 Sends the list of currently known users in a response body.
285 Send back a response with the server version as the second field.
287 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
288 Get or set the volume.
290 With zero parameters just gets the volume and reports the left and right sides
291 as the 2nd and 3rd fields of the response.
293 With one parameter sets both sides to the same value. With two parameters sets
294 each side independently. Setting the volume requires the \fBvolume\fR right.
296 Responses are three-digit codes. The first digit distinguishes errors from
305 The second digit breaks down the origin of the response:
308 Generic responses not specific to the handling of the command. Mostly this is
312 Authentication responses.
315 Responses specific to the handling of the command.
317 The third digit provides extra information about the response:
320 Text part is just commentary.
323 Text part is a constant result e.g. \fBversion\fR.
326 Text part is a potentially variable result.
329 Text part is just commentary; a dot-stuffed body follows.
332 Text part is just commentary; an indefinite dot-stuffed body follows. (Used
336 Used with "normal" errors, for instance a preference not being found. The text
340 The text part is just commentary (but would normally be a response for this
341 command) e.g. \fBplaying\fR.
343 Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
344 responses) are quoted.
346 When a connection is made the server sends a \fB231\fR response before any
347 command is received. This contains a protocol generation, an algorithm name
348 and a challenge encoded in hex, all separated by whitespace.
350 The current protocol generation is \fB2\fR.
352 The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
353 and \fBsha512\fR. \fBSHA1\fR etc work as synonyms.
355 The \fBuser\fR response consists of the selected hash of the user's password
356 concatenated with the challenge, encoded in hex.
357 .SH "TRACK INFORMATION"
358 Track information is encoded in a line (i.e. using the usual line syntax) as
359 pairs of fields. The first is a name, the second a value. The names have the
363 The time the track is expected to be played at.
366 A string uniquely identifying this queue entry.
369 The time the track was played at.
372 The user that scratched the track.
375 The current track state. Valid states are:
379 The player failed (exited with nonzero status but wasn't scratched).
382 The track is actually a scratch.
385 No player could be found for the track.
388 The track was played without any problems.
391 The track was scratched.
394 The track is currently playing.
397 In the queue, hasn't been played yet.
400 The track was terminated because the server is shutting down.
404 The user that submitted the track.
407 The filename of the track.
410 The time the track was added to the queue.
413 The wait status of the player in decimal.
415 Times are decimal integers using the server's \fBtime_t\fR.
417 For file listings, the regexp applies to the basename of the returned file, not
418 the whole filename, and letter case is ignored. \fBpcrepattern\fR(3) describes
421 Filenames are in UTF-8 even if the collection they come from uses some other
422 encoding - if you want to access the real file (in such cases as the filenames
423 actually correspond to a real file) you'll have to convert to whatever the
426 The event log consists of lines starting with a hexadecimal timestamp and a
427 keyword followed by (optionally) parameters. The parameters are quoted in the
428 usual DisOrder way. Currently the following keywords are used:
430 .B completed \fITRACK\fR
431 Completed playing \fITRACK\fR
433 .B failed \fITRACK\fR \fIERROR\fR
434 Completed playing \fITRACK\fR with an error status
437 User \fIUSER\fR moved some track(s). Further details aren't included any
440 .B playing \fITRACK\fR [\fIUSER\fR]
441 Started playing \fITRACK\fR.
443 .B queue \fIQUEUE-ENTRY\fR...
444 Added \fITRACK\fR to the queue.
446 .B recent_added \fIQUEUE-ENTRY\fR...
447 Added \fIID\fR to the recently played list.
449 .B recent_removed \fIID\fR
450 Removed \fIID\fR from the recently played list.
452 .B removed \fIID\fR [\fIUSER\fR]
453 Queue entry \fIID\fR was removed. This is used both for explicit removal (when
454 \fIUSER\fR is present) and when playing a track (when it is absent).
459 .B scratched \fITRACK\fR \fIUSER\fR
460 \fITRACK\fR was scratched by \fIUSER\fR.
462 .B state \fIKEYWORD\fR
463 Some state change occurred. The current set of keywords is:
467 The current track completed successfully.
470 Playing was disabled.
473 Random play was disabled.
479 Random play was enabled.
482 The current track failed.
485 The current track was paused.
488 A track started playing.
491 The current track was resumed.
494 The current track was scratched.
496 To simplify client implementation, \fBstate\fR commands reflecting the current
497 state are sent at the start of the log.
500 .B volume \fILEFT\fR \fIRIGHT\fR
505 .B "TRACK INFORMATION"
507 .SH "CHARACTER ENCODING"
508 All data sent by both server and client is encoded using UTF-8. Moreover it
509 must be valid UTF-8, i.e. non-minimal sequences are not permitted, nor are
510 surrogates, nor are code points outside the Unicode code space.
512 There are no particular normalization requirements on either side of the
513 protocol. The server currently converts internally to NFC, the client must
514 normalize the responses returned if it needs some normalized form for further
517 The various characters which divide up lines may not be followed by combining
518 characters. For instance all of the following are prohibited:
521 LINE FEED followed by a combining character. For example the sequence
522 LINE FEED, COMBINING GRAVE ACCENT is never permitted.
525 APOSTROPHE or QUOTATION MARK followed by a combining character when used to
526 delimit fields. For instance a line starting APOSTROPHE, COMBINING CEDILLA
529 Note that such sequences are not prohibited when the quote character cannot be
530 interpreted as a field delimiter. For instance APOSTROPHE, REVERSE SOLIDUS,
531 APOSTROPHE, COMBINING CEDILLA, APOSTROPHE would be permitted.
534 REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
535 string when it is the first character of an escape sequence. For instance a
536 line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE is prohibited.
538 As above such sequences are not prohibited when the character is not being used
539 to start an escape sequence. For instance APOSTROPHE, REVERSE SOLIDUS,
540 REVERSE SOLIDS, COMBINING TILDER, APOSTROPHE is permitted.
543 Any of the field-splitting whitespace characters followed by a combining
544 character when not part of a quoted field. For instance a line starting COLON,
545 SPACE, COMBINING CANDRABINDU is prohibited.
547 As above non-delimiter uses are fine.
550 The FULL STOP characters used to quote or delimit a body.
552 Furthermore none of these characters are permitted to appear in the context of
553 a canonical decomposition (i.e. they must still be present when converted to
554 NFC). In practice however this is not an issue in Unicode 5.0.
556 These rules are consistent with the observation that the split() function is
557 essentially a naive ASCII parser. The implication is not that these sequences
558 never actually appear in the protocol, merely that the server is not required
559 to honor them in any useful way nor be consistent between versions: in current
560 versions the result will be lines and fields that start with combining
561 characters and are not necessarily split where you expect, but future versions
562 may remove them, reject them or ignore some or all of the delimiters that have
563 following combining characters, and no notice will be given of any change.
569 \fBdisorder_config\fR(5),