2 .\" Copyright (C) 2004-2008 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.
27 You are recommended to check the implementation before believing this document.
29 Everything is encoded using UTF-8.
31 .B "CHARACTER ENCODING"
32 below for more detail on character encoding issues.
34 Commands and responses consist of a line perhaps followed (depending on the
35 command or response) by a body.
37 The line syntax is the same as described in \fBdisorder_config\fR(5) except
38 that comments are prohibited.
40 Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
41 lines, with any initial full stop doubled up, and are terminated by a line
42 consisting of a full stop and a line feed.
44 Commands always have a command name as the first field of the line; responses
45 always have a 3-digit response code as the first field.
46 See below for more details about this field.
48 All commands require the connection to have been already authenticated unless
50 If not stated otherwise, the \fBread\fR right is sufficient to execute
53 Neither commands nor responses have a body unless stated otherwise.
55 .B adduser \fIUSERNAME PASSWORD \fR[\fIRIGHTS\fR]
56 Create a new user with the given username and password.
57 The new user's rights list can be specified; if it is not
58 then the \fBdefault_rights\fR setting applies instead.
59 Requires the \fBadmin\fR right, and only works on local
62 .B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
63 List all the files and directories in \fIDIRECTORY\fR in a response body.
64 If \fIREGEXP\fR is present only matching files and directories are returned.
66 .B confirm \fICONFIRMATION
67 Confirm user registration.
68 \fICONFIRMATION\fR is as returned from \fBregister\fR below.
69 This command can be used without logging in.
72 Log a user back in using a cookie created with \fBmake\-cookie\fR.
73 The response contains the username.
75 .B deluser \fIUSERNAME
76 Delete the named user.
77 Requires the \fBadmin\fR right, and only works on local connections.
79 .B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
80 List all the directories in \fIDIRECTORY\fR in a response body.
81 If \fIREGEXP\fR is present only matching directories are returned.
83 .B disable \fR[\fBnow\fR]
84 Disable further playing.
85 If the optional \fBnow\fR argument is present then the current track
87 Requires the \fBglobal prefs\fR right.
89 .B edituser \fIUSERNAME PROPERTY VALUE
91 With the \fBadmin\fR right any username and property may be specified.
92 Otherwise the \fBuserinfo\fR right is required and only the
93 \fBemail\fR and \fBpassword\fR properties may be set.
96 Re-enable further playing, and is the opposite of \fBdisable\fR.
97 Requires the \fBglobal prefs\fR right.
100 Report whether playing is enabled.
101 The second field of the response line will be \fByes\fR or \fBno\fR.
103 .B exists \fITRACK\fR
104 Report whether the named track exists.
105 The second field of the response line will be \fByes\fR or \fBno\fR.
107 .B files \fIDIRECTORY\fR [\fIREGEXP\fR]
108 List all the files in \fIDIRECTORY\fR in a response body.
109 If \fIREGEXP\fR is present only matching files are returned.
111 .B get \fITRACK\fR \fIPREF\fR
112 Getsa preference value.
113 On success the second field of the response line will have the value.
115 If the track or preference do not exist then the response code is 555.
117 .B get\-global \fIKEY\fR
118 Get a global preference.
120 If the preference does not exist then the response code is 555.
122 .B length \fITRACK\fR
123 Get the length of the track in seconds.
124 On success the second field of the response line will have the value.
127 Send event log messages in a response body.
128 The command will never terminate.
129 Any further data sent to the server will be discarded (explicitly;
130 i.e. it will not accumulate in a buffer somewhere).
132 See \fBEVENT LOG\fR below for more details.
135 Returns an opaque string that can be used by the \fBcookie\fR command to log
136 this user back in on another connection (until the cookie expires).
138 .B move \fITRACK\fR \fIDELTA\fR
139 Move a track in the queue.
140 The track may be identified by ID (preferred) or name (which might cause
141 confusion if it's there twice).
142 \fIDELTA\fR should be an negative or positive integer and indicates how
143 many steps towards the head of the queue the track should be moved.
145 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
146 depending on how the track came to be added to the queue.
148 .B moveafter \fITARGET\fR \fIID\fR ...
149 Move all the tracks in the \fIID\fR list after ID \fITARGET\fR.
150 If \fITARGET\fR is the empty string then the listed tracks are put
151 at the head of the queue.
152 If \fITARGET\fR is listed in the ID list then the tracks are moved
153 to just after the first non-listed track before it, or to the head if there is
156 Requires one of the \fBmove mine\fR, \fBmove random\fR or \fBmove any\fR rights
157 depending on how the tracks came to be added to the queue.
159 .B new \fR[\fIMAX\fR]
160 Send the most recently added \fIMAX\fR tracks in a response body.
161 If the argument is ommitted, the \fBnew_max\fR most recent tracks are
162 listed (see \fBdisorder_config\fR(5)).
168 as a keepalive measure.
169 This command does not require authentication.
171 .B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
172 Get a track name part.
173 Returns an empty string if a name part cannot be constructed.
189 Pause the current track.
190 Requires the \fBpause\fR right.
193 Add a track to the queue.
194 The response contains the queue ID of the track.
195 Requires the \fBplay\fR right.
198 Report what track is playing.
200 If the response is \fB252\fR then the rest of the response line consists of
201 track information (see below).
203 If the response is \fB259\fR then nothing is playing.
206 Send back the preferences for \fITRACK\fR in a response body.
207 Each line of the response has the usual line syntax, the first field being the
208 name of the pref and the second the value.
211 Send back the current queue in a response body, one track to a line, the track
212 at the head of the queue (i.e. next to be be played) first.
213 See below for the track information syntax.
216 Disable random play (but don't stop the current track).
217 Requires the \fBglobal prefs\fR right.
221 Requires the \fBglobal prefs\fR right.
224 Report whether random play is enabled.
225 The second field of the response line will be \fByes\fR or \fBno\fR.
228 Send back the current recently-played list in a response body, one track to a
229 line, the track most recently played last.
230 See below for the track information syntax.
233 Request that DisOrder reconfigure itself.
234 Requires the \fBadmin\fR right.
236 .B register \fIUSER PASSWORD EMAIL
238 Requires the \fBregister\fR right.
239 The result contains a confirmation string; the user will be be able
240 to log in until this has been presented back to the server via the
241 \fBconfirm\fR command.
243 .B reminder \fIUSER\fR
244 Send a password reminder to \fIUSER\fR.
245 If the user has no valid email address, or no password, or a
246 reminder has been sent too recently, then no reminder will be sent.
249 Remove the track identified by \fIID\fR.
250 Requires one of the \fBremove mine\fR, \fBremove random\fR or
251 \fBremove any\fR rights depending on how the
252 track came to be added to the queue.
255 Rescan all roots for new or obsolete tracks.
256 Requires the \fBrescan\fR right.
258 .B resolve \fITRACK\fR
259 Resolve a track name, i.e. if this is an alias then return the real track name.
262 Resume the current track after a \fBpause\fR command.
263 Requires the \fBpause\fR right.
265 .B revoke \fBcookie\fR
266 Revoke a cookie previously created with \fBmake\-cookie\fR.
267 It will not be possible to use this cookie in the future.
270 Report the RTP broadcast (or multicast) address, in the form \fIADDRESS
272 This command does not require authentication.
274 .B scratch \fR[\fIID\fR]
275 Remove the track identified by \fIID\fR, or the currently playing track if no
276 \fIID\fR is specified.
277 Requires one of the \fBscratch mine\fR, \fBscratch random\fR or
278 \fBscratch any\fR rights depending on how the track came to be
281 .B search \fITERMS\fR
282 Search for tracks matching the search terms.
283 The results are put in a response body, one to a line.
285 The search string is split in the usual way, with quoting supported, into a
287 Only tracks matching all terms are included in the results.
289 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
292 All other terms are interpreted as individual words which must be present in
295 Spaces in terms don't currently make sense, but may one day be interpreted to
296 allow searching for phrases.
298 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
300 Requires the \fBprefs\fR right.
302 .B set\-global \fIKEY\fR \fIVALUE\fR
303 Set a global preference.
304 Requires the \fBglobal prefs\fR right.
307 Send server statistics in plain text in a response body.
310 Send the list of currently known tags in a response body.
312 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
314 Requires the \fBprefs\fR right.
316 .B \fBunset\-global\fR \fIKEY\fR
317 Unset a global preference.
318 Requires the \fBglobal prefs\fR right.
320 .B user \fIUSER\fR \fIRESPONSE\fR
321 Authenticate as \fIUSER\fR.
327 Send the list of currently known users in a response body.
330 Send back a response with the server version as the second field.
332 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
333 Get or set the volume.
335 With zero parameters just gets the volume and reports the left and right sides
336 as the 2nd and 3rd fields of the response.
338 With one parameter sets both sides to the same value.
339 With two parameters sets each side independently.
340 Setting the volume requires the \fBvolume\fR right.
342 Responses are three-digit codes.
343 The first digit distinguishes errors from succesful responses:
351 The second digit breaks down the origin of the response:
354 Generic responses not specific to the handling of the command.
355 Mostly this is parse errors.
358 51x errors indicate that the user had insufficient rights for the command.
361 Authentication responses.
364 Responses specific to the handling of the command.
366 The third digit provides extra information about the response:
369 Text part is just commentary.
372 Text part is a constant result e.g. \fBversion\fR.
375 Text part is a potentially variable result.
378 Text part is just commentary; a dot-stuffed body follows.
381 Text part is just commentary; an indefinite dot-stuffed body follows.
382 (Used for \fBlog\fR.)
385 Used with "normal" errors, for instance a preference not being found.
386 The text part is commentary.
389 The text part is just commentary (but would normally be a response for this
390 command) e.g. \fBplaying\fR.
392 Result strings (not bodies) intended for machine parsing (i.e. xx1 and xx2
393 responses) are quoted.
395 When a connection is made the server sends a \fB231\fR response before any
397 This contains a protocol generation, an algorithm name and a
398 challenge encoded in hex, all separated by whitespace.
400 The current protocol generation is \fB2\fR.
402 The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR
404 \fBSHA1\fR etc work as synonyms.
406 The \fBuser\fR response consists of the selected hash of the user's password
407 concatenated with the challenge, encoded in hex.
408 .SH "TRACK INFORMATION"
409 Track information is encoded in a line (i.e. using the usual line syntax) as
411 The first is a name, the second a value.
412 The names have the following meanings:
415 The time the track is expected to be played at.
418 A string uniquely identifying this queue entry.
421 The time the track was played at.
424 The user that scratched the track.
427 The current track state.
432 The player failed (exited with nonzero status but wasn't scratched).
435 The track is actually a scratch.
438 No player could be found for the track.
441 The track was played without any problems.
444 The track was scratched.
447 The track is currently playing.
450 In the queue, hasn't been played yet.
453 The track was terminated because the server is shutting down.
457 The user that submitted the track.
460 The filename of the track.
463 The time the track was added to the queue.
466 The wait status of the player in decimal.
468 Times are decimal integers using the server's \fBtime_t\fR.
470 For file listings, the regexp applies to the basename of the returned file, not
471 the whole filename, and letter case is ignored.
472 \fBpcrepattern\fR(3) describes the regexp syntax.
474 Filenames are in UTF-8 even if the collection they come from uses some other
475 encoding - if you want to access the real file (in such cases as the filenames
476 actually correspond to a real file) you'll have to convert to whatever the
479 The event log consists of lines starting with a hexadecimal timestamp and a
480 keyword followed by (optionally) parameters.
481 The parameters are quoted in the usual DisOrder way.
482 Currently the following keywords are used:
484 .B completed \fITRACK\fR
485 Completed playing \fITRACK\fR
487 .B failed \fITRACK\fR \fIERROR\fR
488 Completed playing \fITRACK\fR with an error status
491 User \fIUSER\fR moved some track(s).
492 Further details aren't included any more.
494 .B playing \fITRACK\fR [\fIUSER\fR]
495 Started playing \fITRACK\fR.
497 .B queue \fIQUEUE-ENTRY\fR...
498 Added \fITRACK\fR to the queue.
500 .B recent_added \fIQUEUE-ENTRY\fR...
501 Added \fIID\fR to the recently played list.
503 .B recent_removed \fIID\fR
504 Removed \fIID\fR from the recently played list.
506 .B removed \fIID\fR [\fIUSER\fR]
507 Queue entry \fIID\fR was removed.
508 This is used both for explicit removal (when \fIUSER\fR is present)
509 and when playing a track (when it is absent).
514 .B scratched \fITRACK\fR \fIUSER\fR
515 \fITRACK\fR was scratched by \fIUSER\fR.
517 .B state \fIKEYWORD\fR
518 Some state change occurred.
519 The current set of keywords is:
523 The current track completed successfully.
526 Playing was disabled.
529 Random play was disabled.
535 Random play was enabled.
538 The current track failed.
541 The current track was paused.
544 A track started playing.
547 The current track was resumed.
550 The current track was scratched.
552 To simplify client implementation, \fBstate\fR commands reflecting the current
553 state are sent at the start of the log.
556 .B volume \fILEFT\fR \fIRIGHT\fR
561 .B "TRACK INFORMATION"
563 .SH "CHARACTER ENCODING"
564 All data sent by both server and client is encoded using UTF-8.
565 Moreover it must be valid UTF-8, i.e. non-minimal sequences are not
566 permitted, nor are surrogates, nor are code points outside the
569 There are no particular normalization requirements on either side of the
571 The server currently converts internally to NFC, the client must
572 normalize the responses returned if it needs some normalized form for further
575 The various characters which divide up lines may not be followed by combining
577 For instance all of the following are prohibited:
580 LINE FEED followed by a combining character.
581 For example the sequence LINE FEED, COMBINING GRAVE ACCENT is never permitted.
584 APOSTROPHE or QUOTATION MARK followed by a combining character when used to
586 For instance a line starting APOSTROPHE, COMBINING CEDILLA is prohibited.
588 Note that such sequences are not prohibited when the quote character cannot be
589 interpreted as a field delimiter.
590 For instance APOSTROPHE, REVERSE SOLIDUS, APOSTROPHE, COMBINING CEDILLA,
591 APOSTROPHE would be permitted.
594 REVERSE SOLIDUS (BACKSLASH) followed by a combining character in a quoted
595 string when it is the first character of an escape sequence.
596 For instance a line starting APOSTROPHE, REVERSE SOLIDUS, COMBINING TILDE
599 As above such sequences are not prohibited when the character is not being used
600 to start an escape sequence.
601 For instance APOSTROPHE, REVERSE SOLIDUS, REVERSE SOLIDS, COMBINING TILDE,
602 APOSTROPHE is permitted.
605 Any of the field-splitting whitespace characters followed by a combining
606 character when not part of a quoted field.
607 For instance a line starting COLON, SPACE, COMBINING CANDRABINDU is prohibited.
609 As above non-delimiter uses are fine.
612 The FULL STOP characters used to quote or delimit a body.
614 Furthermore none of these characters are permitted to appear in the context of
615 a canonical decomposition (i.e. they must still be present when converted to
617 In practice however this is not an issue in Unicode 5.0.
619 These rules are consistent with the observation that the split() function is
620 essentially a naive ASCII parser.
621 The implication is not that these sequences never actually appear in
622 the protocol, merely that the server is not required to honor them in
623 any useful way nor be consistent between versions: in current
624 versions the result will be lines and fields that start with combining
625 characters and are not necessarily split where you expect, but future versions
626 may remove them, reject them or ignore some or all of the delimiters that have
627 following combining characters, and no notice will be given of any change.
633 \fBdisorder_config\fR(5),