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