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