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