chiark / gitweb /
use dist-hook to ship bzr changelog
[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"
29Everything is encoded using UTF-8.
30.PP
31Commands and responses consist of a line followed (depending on the
32command or response) by a message.
33.PP
34The line syntax is the same as described in \fBdisorder_config\fR(5) except
35that comments are prohibited.
36.PP
37Bodies borrow their syntax from RFC821; they consist of zero or more ordinary
38lines, with any initial full stop doubled up, and are terminated by a line
39consisting of a full stop and a line feed.
40.SH COMMANDS
41Commands always have a command name as the first field of the line; responses
42always have a 3-digit response code as the first field. See below for more
43details about this field.
44.PP
45All commands require the connection to have been already authenticated unless
46stated otherwise.
47.PP
48Neither commands nor responses have a body unless stated otherwise.
49.TP
50.B allfiles \fIDIRECTORY\fR [\fIREGEXP\fR]
51Lists all the files and directories in \fIDIRECTORY\fR in a response body.
52If \fIREGEXP\fR is present only matching files and directories are returned.
53.TP
54.B become \fIUSER\fR
55Instructs the server to treat the connection as if \fIUSER\fR had
56authenticated it. Only trusted users may issue this command.
57.TP
58.B dirs \fIDIRECTORY\fR [\fIREGEXP\fR]
59Lists all the directories in \fIDIRECTORY\fR in a response body.
60If \fIREGEXP\fR is present only matching directories are returned.
61.TP
62.B disable \fR[\fBnow\fR]
63Disables further playing. If the optional \fBnow\fR argument is present then
64the current track is stopped.
65.TP
66.B enable
67Re-enables further playing, and is the opposite of \fBdisable\fR.
68.TP
69.B enabled
70Reports whether playing is enabled. The second field of the response line will
71be \fByes\fR or \fBno\fR.
72.TP
73.B exists \fITRACK\fR
74Reports whether the named track exists. The second field of the response line
75will be \fByes\fR or \fBno\fR.
76.TP
77.B files \fIDIRECTORY\fR [\fIREGEXP\fR]
78Lists all the files in \fIDIRECTORY\fR in a response body.
79If \fIREGEXP\fR is present only matching files are returned.
80.TP
81.B get \fITRACK\fR \fIPREF\fR
82Gets a preference value. On success the second field of the response line will
83have the value.
84.TP
85.B get-global \fIKEY\fR
86Get a global preference.
87.TP
88.B length \fITRACK\fR
89Gets the length of the track in seconds. On success the second field of the
90response line will have the value.
91.TP
92.B log
93Sends event log messages in a response body. The command will only terminate (and
94close the response body with a final dot) when a further command is readable on
95the control connection.
96.IP
97See \fBEVENT LOG\fR below for more details.
98.TP
99.B move \fITRACK\fR \fIDELTA\fR
100Move a track in the queue. The track may be identified by ID (preferred) or
101name (which might cause confusion if it's there twice). \fIDELTA\fR should be
102an negative or positive integer and indicates how many steps towards the head
103of the queue the track should be moved.
104.TP
105.B moveafter \fITARGET\fR \fIID\fR ...
106Move all the tracks in the \fIID\fR list after ID \fITARGET\fR. If
107\fITARGET\fR is the empty string then the listed tracks are put at the head of
108the queue. If \fITARGET\fR is listed in the ID list then the tracks are moved
109to just after the first non-listed track before it, or to the head if there is
110no such track.
111.TP
112.B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
113Get a track name part. Returns an empty string if a name part cannot be
114constructed.
115.IP
116.I CONTEXT
117is one of
118.B sort
119or
120.B display
121and
122.I PART
123is usually one of
124.BR artist ,
125.B album
126or
127.BR title .
128.TP
129.B pause
130Pause the current track.
131.TP
132.B play \fITRACK\fR
133Add a track to the queue.
134.TP
135.B playing
136Reports what track is playing.
137.IP
138If the response is \fB252\fR then the rest of the response line consists of
139track information (see below).
140.IP
141If the response is \fB259\fR then nothing is playing.
142.TP
143.B prefs \fBTRACK\fR
144Sends back the preferences for \fITRACK\fR in a response body.
145Each line of the response has the usual line syntax, the first field being the
146name of the pref and the second the value.
147.TP
148.B queue
149Sends back the current queue in a response body, one track to a line, the track
150at the head of the queue (i.e. next to be be played) first. See below for the
151track information syntax.
152.TP
153.B random-disable
154Disable random play (but don't stop the current track).
155.TP
156.B random-enable
157Enable random play.
158.TP
159.B random-enabled
160Reports whether random play is enabled. The second field of the response line
161will be \fByes\fR or \fBno\fR.
162.TP
163.B recent
164Sends back the current recently-played list in a response body, one track to a
165line, the track most recently played last. See below for the track
166information syntax.
167.TP
168.B reconfigure
169Request that DisOrder reconfigure itself. Only trusted users may issue this
170command.
171.TP
172.B remove \fIID\fR
173Remove the track identified by \fIID\fR. If \fBrestrict remove\fR is enabled
174in the server's configuration then only the user that submitted the track may
175remove it.
176.TP
177.B rescan
178Rescan all roots for new or obsolete tracks.
179.TP
180.B resolve \fITRACK\fR
181Resolve a track name, i.e. if this is an alias then return the real track name.
182.TP
183.B resume
184Resume the current track after a \fBpause\fR command.
185.TP
186.B scratch \fR[\fIID\fR]
187Remove the track identified by \fIID\fR, or the currently playing track if no
188\fIID\fR is specified. If \fBrestrict scratch\fR is enabled in the server's
189configuration then only the user that submitted the track may scratch it.
190.TP
191.B search \fITERMS\fR
192Search for tracks matching the search terms. The results are put in a response
193body, one to a line.
194.IP
195The search string is split in the usual way, with quoting supported, into a
196list of terms. Only tracks matching all terms are included in the results.
197.IP
198Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
199tag.
200.IP
201All other terms are interpreted as individual words which must be present in
202the track name.
203.IP
204Spaces in terms don't currently make sense, but may one day be interpreted to
205allow searching for phrases.
206.TP
207.B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
208Set a preference.
209.TP
210.B set-global \fIKEY\fR \fIVALUE\fR
211Set a global preference.
212.TP
213.B stats
214Send server statistics in plain text in a response body.
215.TP
216.B \fBtags\fR
217Send the list of currently known tags in a response body.
218.TP
219.B \fBunset\fR \fITRACK\fR \fIPREF\fR
220Unset a preference.
221.TP
222.B \fBunset-global\fR \fIKEY\fR
223Unset a global preference.
224.TP
225.B user \fIUSER\fR \fIRESPONSE\fR
226Authenticate as \fIUSER\fR.
227.IP
228When a connection is made the server sends a \fB221\fR response before any
229command is received. As its first field this contains a challenge string
230encoded in hex.
231.IP
232The \fIRESPONSE\fR consists of the SHA-1 hash of the user's password
233concatenated with the challenge, encoded in hex.
234.TP
235.B version
236Send back a response with the server version as the second field.
237.TP
238.B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
239Get or set the volume.
240.IP
241With zero parameters just gets the volume and reports the left and right sides
242as the 2nd and 3rd fields of the response.
243.IP
244With one parameter sets both sides to the same value. With two parameters sets
245each side independently.
246.SH RESPONSES
247Responses are three-digit codes. The first digit distinguishes errors from
248succesful responses:
249.TP
250.B 2
251Operation succeeded.
252.TP
253.B 5
254Operation failed.
255.PP
256The second digit breaks down the origin of the response:
257.TP
258.B 0
259Generic responses not specific to the handling of the command. Mostly this is
260parse errors.
261.TP
262.B 3
263Authentication responses.
264.TP
265.B 5
266Responses specific to the handling of the command.
267.PP
268The third digit provides extra information about the response:
269.TP
270.B 0
271Text part is just commentary.
272.TP
273.B 1
274Text part is a constant result e.g. \fBversion\fR.
275.TP
276.B 2
277Text part is a potentially variable result.
278.TP
279.B 3
280Text part is just commentary; a dot-stuffed body follows.
281.TP
282.B 4
283Text part is just commentary; an indefinite dot-stuffed body follows. (Used
284for \fBlog\fR.)
285.TP
286.B 4
287Text part is just commentary; an indefinite dot-stuffed body follows. (Used
288for \fBlog\fR.)
289.TP
290.B 9
291The text part is just commentary (but would normally be a response for this
292command) e.g. \fBplaying\fR.
293.SH AUTHENTICATION
294The server starts by issuing a challenge line, with response code 231. This
295contains a random challenge encoded in hex.
296.PP
297The client should send back a \fBuser\fR command with username and a
298hex-encoded response. The response is the SHA-1 hash of the user's password
299and the challenge.
300.SH "TRACK INFORMATION"
301Track information is encoded in a line (i.e. using the usual line syntax) as
302pairs of fields. The first is a name, the second a value. The names have the
303following meanings:
304.TP 12
305.B expected
306The time the track is expected to be played at.
307.TP
308.B id
309A string uniquely identifying this queue entry.
310.TP
311.B played
312The time the track was played at.
313.TP
314.B scratched
315The user that scratched the track.
316.TP
317.B state
318The current track state. Valid states are:
319.RS
320.TP 12
321.B failed
322The player failed (exited with nonzero status but wasn't scratched).
323.TP
324.B isscratch
325The track is actually a scratch.
326.TP
327.B no_player
328No player could be found for the track.
329.TP
330.B ok
331The track was played without any problems.
332.TP
333.B scratched
334The track was scratched.
335.TP
336.B started
337The track is currently playing.
338.TP
339.B unplayed
340In the queue, hasn't been played yet.
341.TP
342.B quitting
343The track was terminated because the server is shutting down.
344.RE
345.TP
346.B submitter
347The user that submitted the track.
348.TP
349.B track
350The filename of the track.
351.TP
352.B when
353The time the track was added to the queue.
354.TP
355.B wstat
356The wait status of the player in decimal.
357.SH NOTES
358Times are decimal integers using the server's \fBtime_t\fR.
359.PP
360For file listings, the regexp applies to the basename of the returned file, not
361the whole filename, and letter case is ignored. \fBpcrepattern\fR(3) describes
362the regexp syntax.
363.PP
364Filenames are in UTF-8 even if the collection they come from uses some other
365encoding - if you want to access the real file (in such cases as the filenames
366actually correspond to a real file) you'll have to convert to whatever the
367right encoding is.
368.SH "EVENT LOG"
369The event log consists of lines starting with a hexadecimal timestamp and a
370keyword followed by (optionally) parameters. The parameters are quoted in the
371usual DisOrder way. Currently the following keywords are used:
372.TP
373.B completed \fITRACK\fR
374Completed playing \fITRACK\fR
375.TP
376.B failed \fITRACK\fR \fIERROR\fR
377Completed playing \fITRACK\fR with an error status
378.TP
379.B moved \fIUSER\fR
380User \fIUSER\fR moved some track(s). Further details aren't included any
381more.
382.TP
383.B playing \fITRACK\fR [\fIUSER\fR]
384Started playing \fITRACK\fR.
385.TP
386.B queue \fIQUEUE-ENTRY\fR...
387Added \fITRACK\fR to the queue.
388.TP
389.B recent_added \fIQUEUE-ENTRY\fR...
390Added \fIID\fR to the recently played list.
391.TP
392.B recent_removed \fIID\fR
393Removed \fIID\fR from the recently played list.
394.TP
395.B removed \fIID\fR [\fIUSER\fR]
396Queue entry \fIID\fR was removed. This is used both for explicit removal (when
397\fIUSER\fR is present) and when playing a track (when it is absent).
398.TP
399.B scratched \fITRACK\fR \fIUSER\fR
400\fITRACK\fR was scratched by \fIUSER\fR.
401.TP
402.B state \fIKEYWORD\fR
403Some state change occurred. The current set of keywords is:
404.RS
405.TP
406.B disable_play
407Playing was disabled.
408.TP
409.B disable_random
410Random play was disabled.
411.TP
412.B enable_play
413Playing was enabled.
414.TP
415.B enable_random
416Random play was enabled.
417.TP
418.B pause
419The current track was paused.
420.TP
421.B resume
422The current track was resumed.
423.RE
424.TP
425.B volume \fILEFT\fR \fIRIGHT\fR
426The volume changed.
427.PP
428.IR QUEUE-ENTRY ...
429is as defined in
430.B "TRACK INFORMATION"
431above.
432.SH "SEE ALSO"
433\fBdisorder\fR(1),
434\fBtime\fR(2),
435\fBdisorder\fR(3),
436\fBpcrepattern\fR(3)
437\fBdisorder_config\fR(5),
438\fBdisorderd\fR(8),
439\fButf8\fR(7)
440.\" Local Variables:
441.\" mode:nroff
442.\" fill-column:79
443.\" End: