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