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