chiark / gitweb /
relax config file checking for non-server programs
[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.
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 nop
113Do nothing. Used by
114.BR disobedience (1)
115as a keepalive measure.
116.TP
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. See
232.B AUTHENTICATION
233below.
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
294When a connection is made the server sends a \fB231\fR response before any
295command is received. This contains an algorithm name and a challenge encoded
296in hex.
297.PP
298Currently the algorithm name is omitted if it is \fBsha1\fR (but this will
299probably change in a future version). The other options are \fBsha256\fR,
300\fBsha384\fR and \fBsha512\fR. \fBSHA1\fR etc work as synonyms.
301.PP
302The \fBuser\fR response consists of the selected hash of the user's password
303concatenated with the challenge, encoded in hex.
304.SH "TRACK INFORMATION"
305Track information is encoded in a line (i.e. using the usual line syntax) as
306pairs of fields. The first is a name, the second a value. The names have the
307following meanings:
308.TP 12
309.B expected
310The time the track is expected to be played at.
311.TP
312.B id
313A string uniquely identifying this queue entry.
314.TP
315.B played
316The time the track was played at.
317.TP
318.B scratched
319The user that scratched the track.
320.TP
321.B state
322The current track state. Valid states are:
323.RS
324.TP 12
325.B failed
326The player failed (exited with nonzero status but wasn't scratched).
327.TP
328.B isscratch
329The track is actually a scratch.
330.TP
331.B no_player
332No player could be found for the track.
333.TP
334.B ok
335The track was played without any problems.
336.TP
337.B scratched
338The track was scratched.
339.TP
340.B started
341The track is currently playing.
342.TP
343.B unplayed
344In the queue, hasn't been played yet.
345.TP
346.B quitting
347The track was terminated because the server is shutting down.
348.RE
349.TP
350.B submitter
351The user that submitted the track.
352.TP
353.B track
354The filename of the track.
355.TP
356.B when
357The time the track was added to the queue.
358.TP
359.B wstat
360The wait status of the player in decimal.
361.SH NOTES
362Times are decimal integers using the server's \fBtime_t\fR.
363.PP
364For file listings, the regexp applies to the basename of the returned file, not
365the whole filename, and letter case is ignored. \fBpcrepattern\fR(3) describes
366the regexp syntax.
367.PP
368Filenames are in UTF-8 even if the collection they come from uses some other
369encoding - if you want to access the real file (in such cases as the filenames
370actually correspond to a real file) you'll have to convert to whatever the
371right encoding is.
372.SH "EVENT LOG"
373The event log consists of lines starting with a hexadecimal timestamp and a
374keyword followed by (optionally) parameters. The parameters are quoted in the
375usual DisOrder way. Currently the following keywords are used:
376.TP
377.B completed \fITRACK\fR
378Completed playing \fITRACK\fR
379.TP
380.B failed \fITRACK\fR \fIERROR\fR
381Completed playing \fITRACK\fR with an error status
382.TP
383.B moved \fIUSER\fR
384User \fIUSER\fR moved some track(s). Further details aren't included any
385more.
386.TP
387.B playing \fITRACK\fR [\fIUSER\fR]
388Started playing \fITRACK\fR.
389.TP
390.B queue \fIQUEUE-ENTRY\fR...
391Added \fITRACK\fR to the queue.
392.TP
393.B recent_added \fIQUEUE-ENTRY\fR...
394Added \fIID\fR to the recently played list.
395.TP
396.B recent_removed \fIID\fR
397Removed \fIID\fR from the recently played list.
398.TP
399.B removed \fIID\fR [\fIUSER\fR]
400Queue entry \fIID\fR was removed. This is used both for explicit removal (when
401\fIUSER\fR is present) and when playing a track (when it is absent).
402.TP
403.B scratched \fITRACK\fR \fIUSER\fR
404\fITRACK\fR was scratched by \fIUSER\fR.
405.TP
406.B state \fIKEYWORD\fR
407Some state change occurred. The current set of keywords is:
408.RS
409.TP
410.B completed
411The current track completed successfully.
412.TP
413.B disable_play
414Playing was disabled.
415.TP
416.B disable_random
417Random play was disabled.
418.TP
419.B enable_play
420Playing was enabled.
421.TP
422.B enable_random
423Random play was enabled.
424.TP
425.B failed
426The current track failed.
427.TP
428.B pause
429The current track was paused.
430.TP
431.B playing
432A track started playing.
433.TP
434.B resume
435The current track was resumed.
436.TP
437.B scratched
438The current track was scratched.
439.PP
440To simplify client implementation, \fBstate\fR commands reflecting the current
441state are sent at the start of the log.
442.RE
443.TP
444.B volume \fILEFT\fR \fIRIGHT\fR
445The volume changed.
446.PP
447.IR QUEUE-ENTRY ...
448is as defined in
449.B "TRACK INFORMATION"
450above.
451.SH "SEE ALSO"
452\fBdisorder\fR(1),
453\fBtime\fR(2),
454\fBdisorder\fR(3),
455\fBpcrepattern\fR(3)
456\fBdisorder_config\fR(5),
457\fBdisorderd\fR(8),
458\fButf8\fR(7)
459.\" Local Variables:
460.\" mode:nroff
461.\" fill-column:79
462.\" End: