chiark / gitweb /
correct eclient for new hashes
[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
7858930d 112.B nop
113Do nothing. Used by
114.BR disobedience (1)
115as a keepalive measure.
116.TP
460b9539 117.B part \fITRACK\fR \fICONTEXT\fI \fIPART\fR
118Get a track name part. Returns an empty string if a name part cannot be
119constructed.
120.IP
121.I CONTEXT
122is one of
123.B sort
124or
125.B display
126and
127.I PART
128is usually one of
129.BR artist ,
130.B album
131or
132.BR title .
133.TP
134.B pause
135Pause the current track.
136.TP
137.B play \fITRACK\fR
138Add a track to the queue.
139.TP
140.B playing
141Reports what track is playing.
142.IP
143If the response is \fB252\fR then the rest of the response line consists of
144track information (see below).
145.IP
146If the response is \fB259\fR then nothing is playing.
147.TP
148.B prefs \fBTRACK\fR
149Sends back the preferences for \fITRACK\fR in a response body.
150Each line of the response has the usual line syntax, the first field being the
151name of the pref and the second the value.
152.TP
153.B queue
154Sends back the current queue in a response body, one track to a line, the track
155at the head of the queue (i.e. next to be be played) first. See below for the
156track information syntax.
157.TP
158.B random-disable
159Disable random play (but don't stop the current track).
160.TP
161.B random-enable
162Enable random play.
163.TP
164.B random-enabled
165Reports whether random play is enabled. The second field of the response line
166will be \fByes\fR or \fBno\fR.
167.TP
168.B recent
169Sends back the current recently-played list in a response body, one track to a
170line, the track most recently played last. See below for the track
171information syntax.
172.TP
173.B reconfigure
174Request that DisOrder reconfigure itself. Only trusted users may issue this
175command.
176.TP
177.B remove \fIID\fR
178Remove the track identified by \fIID\fR. If \fBrestrict remove\fR is enabled
179in the server's configuration then only the user that submitted the track may
180remove it.
181.TP
182.B rescan
183Rescan all roots for new or obsolete tracks.
184.TP
185.B resolve \fITRACK\fR
186Resolve a track name, i.e. if this is an alias then return the real track name.
187.TP
188.B resume
189Resume the current track after a \fBpause\fR command.
190.TP
191.B scratch \fR[\fIID\fR]
192Remove the track identified by \fIID\fR, or the currently playing track if no
193\fIID\fR is specified. If \fBrestrict scratch\fR is enabled in the server's
194configuration then only the user that submitted the track may scratch it.
195.TP
196.B search \fITERMS\fR
197Search for tracks matching the search terms. The results are put in a response
198body, one to a line.
199.IP
200The search string is split in the usual way, with quoting supported, into a
201list of terms. Only tracks matching all terms are included in the results.
202.IP
203Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
204tag.
205.IP
206All other terms are interpreted as individual words which must be present in
207the track name.
208.IP
209Spaces in terms don't currently make sense, but may one day be interpreted to
210allow searching for phrases.
211.TP
212.B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
213Set a preference.
214.TP
215.B set-global \fIKEY\fR \fIVALUE\fR
216Set a global preference.
217.TP
218.B stats
219Send server statistics in plain text in a response body.
220.TP
221.B \fBtags\fR
222Send the list of currently known tags in a response body.
223.TP
224.B \fBunset\fR \fITRACK\fR \fIPREF\fR
225Unset a preference.
226.TP
227.B \fBunset-global\fR \fIKEY\fR
228Unset a global preference.
229.TP
230.B user \fIUSER\fR \fIRESPONSE\fR
231Authenticate as \fIUSER\fR.
232.IP
233When a connection is made the server sends a \fB221\fR response before any
637fdea3
RK
234command is received. This contains an algorithm name and a challenge encoded
235in hex. Currently the algorithm name is omitted if it is "sha1".
460b9539 236.IP
637fdea3 237The \fIRESPONSE\fR consists of the selected hash of the user's password
460b9539 238concatenated with the challenge, encoded in hex.
239.TP
240.B version
241Send back a response with the server version as the second field.
242.TP
243.B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
244Get or set the volume.
245.IP
246With zero parameters just gets the volume and reports the left and right sides
247as the 2nd and 3rd fields of the response.
248.IP
249With one parameter sets both sides to the same value. With two parameters sets
250each side independently.
251.SH RESPONSES
252Responses are three-digit codes. The first digit distinguishes errors from
253succesful responses:
254.TP
255.B 2
256Operation succeeded.
257.TP
258.B 5
259Operation failed.
260.PP
261The second digit breaks down the origin of the response:
262.TP
263.B 0
264Generic responses not specific to the handling of the command. Mostly this is
265parse errors.
266.TP
267.B 3
268Authentication responses.
269.TP
270.B 5
271Responses specific to the handling of the command.
272.PP
273The third digit provides extra information about the response:
274.TP
275.B 0
276Text part is just commentary.
277.TP
278.B 1
279Text part is a constant result e.g. \fBversion\fR.
280.TP
281.B 2
282Text part is a potentially variable result.
283.TP
284.B 3
285Text part is just commentary; a dot-stuffed body follows.
286.TP
287.B 4
288Text part is just commentary; an indefinite dot-stuffed body follows. (Used
289for \fBlog\fR.)
290.TP
291.B 4
292Text part is just commentary; an indefinite dot-stuffed body follows. (Used
293for \fBlog\fR.)
294.TP
295.B 9
296The text part is just commentary (but would normally be a response for this
297command) e.g. \fBplaying\fR.
298.SH AUTHENTICATION
299The server starts by issuing a challenge line, with response code 231. This
300contains a random challenge encoded in hex.
301.PP
302The client should send back a \fBuser\fR command with username and a
303hex-encoded response. The response is the SHA-1 hash of the user's password
304and the challenge.
305.SH "TRACK INFORMATION"
306Track information is encoded in a line (i.e. using the usual line syntax) as
307pairs of fields. The first is a name, the second a value. The names have the
308following meanings:
309.TP 12
310.B expected
311The time the track is expected to be played at.
312.TP
313.B id
314A string uniquely identifying this queue entry.
315.TP
316.B played
317The time the track was played at.
318.TP
319.B scratched
320The user that scratched the track.
321.TP
322.B state
323The current track state. Valid states are:
324.RS
325.TP 12
326.B failed
327The player failed (exited with nonzero status but wasn't scratched).
328.TP
329.B isscratch
330The track is actually a scratch.
331.TP
332.B no_player
333No player could be found for the track.
334.TP
335.B ok
336The track was played without any problems.
337.TP
338.B scratched
339The track was scratched.
340.TP
341.B started
342The track is currently playing.
343.TP
344.B unplayed
345In the queue, hasn't been played yet.
346.TP
347.B quitting
348The track was terminated because the server is shutting down.
349.RE
350.TP
351.B submitter
352The user that submitted the track.
353.TP
354.B track
355The filename of the track.
356.TP
357.B when
358The time the track was added to the queue.
359.TP
360.B wstat
361The wait status of the player in decimal.
362.SH NOTES
363Times are decimal integers using the server's \fBtime_t\fR.
364.PP
365For file listings, the regexp applies to the basename of the returned file, not
366the whole filename, and letter case is ignored. \fBpcrepattern\fR(3) describes
367the regexp syntax.
368.PP
369Filenames are in UTF-8 even if the collection they come from uses some other
370encoding - if you want to access the real file (in such cases as the filenames
371actually correspond to a real file) you'll have to convert to whatever the
372right encoding is.
373.SH "EVENT LOG"
374The event log consists of lines starting with a hexadecimal timestamp and a
375keyword followed by (optionally) parameters. The parameters are quoted in the
376usual DisOrder way. Currently the following keywords are used:
377.TP
378.B completed \fITRACK\fR
379Completed playing \fITRACK\fR
380.TP
381.B failed \fITRACK\fR \fIERROR\fR
382Completed playing \fITRACK\fR with an error status
383.TP
384.B moved \fIUSER\fR
385User \fIUSER\fR moved some track(s). Further details aren't included any
386more.
387.TP
388.B playing \fITRACK\fR [\fIUSER\fR]
389Started playing \fITRACK\fR.
390.TP
391.B queue \fIQUEUE-ENTRY\fR...
392Added \fITRACK\fR to the queue.
393.TP
394.B recent_added \fIQUEUE-ENTRY\fR...
395Added \fIID\fR to the recently played list.
396.TP
397.B recent_removed \fIID\fR
398Removed \fIID\fR from the recently played list.
399.TP
400.B removed \fIID\fR [\fIUSER\fR]
401Queue entry \fIID\fR was removed. This is used both for explicit removal (when
402\fIUSER\fR is present) and when playing a track (when it is absent).
403.TP
404.B scratched \fITRACK\fR \fIUSER\fR
405\fITRACK\fR was scratched by \fIUSER\fR.
406.TP
407.B state \fIKEYWORD\fR
408Some state change occurred. The current set of keywords is:
409.RS
410.TP
5abe307a
RK
411.B completed
412The current track completed successfully.
413.TP
460b9539 414.B disable_play
415Playing was disabled.
416.TP
417.B disable_random
418Random play was disabled.
419.TP
420.B enable_play
421Playing was enabled.
422.TP
423.B enable_random
424Random play was enabled.
425.TP
5abe307a
RK
426.B failed
427The current track failed.
428.TP
460b9539 429.B pause
430The current track was paused.
431.TP
5abe307a
RK
432.B playing
433A track started playing.
434.TP
460b9539 435.B resume
436The current track was resumed.
5abe307a
RK
437.TP
438.B scratched
439The current track was scratched.
440.PP
441To simplify client implementation, \fBstate\fR commands reflecting the current
442state are sent at the start of the log.
460b9539 443.RE
444.TP
445.B volume \fILEFT\fR \fIRIGHT\fR
446The volume changed.
447.PP
448.IR QUEUE-ENTRY ...
449is as defined in
450.B "TRACK INFORMATION"
451above.
452.SH "SEE ALSO"
453\fBdisorder\fR(1),
454\fBtime\fR(2),
455\fBdisorder\fR(3),
456\fBpcrepattern\fR(3)
457\fBdisorder_config\fR(5),
458\fBdisorderd\fR(8),
459\fButf8\fR(7)
460.\" Local Variables:
461.\" mode:nroff
462.\" fill-column:79
463.\" End: