chiark / gitweb /
server half of noticed.db
[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 only terminate (and
94 close the response body with a final dot) when a further command is readable on
95 the control connection.
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 scratch \fR[\fIID\fR]
196 Remove 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
198 configuration then only the user that submitted the track may scratch it.
199 .TP
200 .B search \fITERMS\fR
201 Search for tracks matching the search terms.  The results are put in a response
202 body, one to a line.
203 .IP
204 The search string is split in the usual way, with quoting supported, into a
205 list of terms.  Only tracks matching all terms are included in the results.
206 .IP
207 Any terms of the form \fBtag:\fITAG\fR limits the search to tracks with that
208 tag.
209 .IP
210 All other terms are interpreted as individual words which must be present in
211 the track name.
212 .IP
213 Spaces in terms don't currently make sense, but may one day be interpreted to
214 allow searching for phrases.
215 .TP
216 .B \fBset\fR \fITRACK\fR \fIPREF\fR \fIVALUE\fR
217 Set a preference.
218 .TP
219 .B set-global \fIKEY\fR \fIVALUE\fR
220 Set a global preference.
221 .TP
222 .B stats
223 Send server statistics in plain text in a response body.
224 .TP
225 .B \fBtags\fR
226 Send the list of currently known tags in a response body.
227 .TP
228 .B \fBunset\fR \fITRACK\fR \fIPREF\fR
229 Unset a preference.
230 .TP
231 .B \fBunset-global\fR \fIKEY\fR
232 Unset a global preference.
233 .TP
234 .B user \fIUSER\fR \fIRESPONSE\fR
235 Authenticate as \fIUSER\fR.  See
236 .B AUTHENTICATION
237 below.
238 .TP
239 .B version
240 Send back a response with the server version as the second field.
241 .TP
242 .B volume \fR[\fILEFT\fR [\fIRIGHT\fR]]
243 Get or set the volume.
244 .IP
245 With zero parameters just gets the volume and reports the left and right sides
246 as the 2nd and 3rd fields of the response.
247 .IP
248 With one parameter sets both sides to the same value.  With two parameters sets
249 each side independently.
250 .SH RESPONSES
251 Responses are three-digit codes.  The first digit distinguishes errors from
252 succesful responses:
253 .TP
254 .B 2
255 Operation succeeded.
256 .TP
257 .B 5
258 Operation failed.
259 .PP
260 The second digit breaks down the origin of the response:
261 .TP
262 .B 0
263 Generic responses not specific to the handling of the command.  Mostly this is
264 parse errors.
265 .TP
266 .B 3
267 Authentication responses.
268 .TP
269 .B 5
270 Responses specific to the handling of the command.
271 .PP
272 The third digit provides extra information about the response:
273 .TP
274 .B 0
275 Text part is just commentary.
276 .TP
277 .B 1
278 Text part is a constant result e.g. \fBversion\fR.
279 .TP
280 .B 2
281 Text part is a potentially variable result.
282 .TP
283 .B 3
284 Text part is just commentary; a dot-stuffed body follows.
285 .TP
286 .B 4
287 Text part is just commentary; an indefinite dot-stuffed body follows.  (Used
288 for \fBlog\fR.)
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 scratched \fITRACK\fR \fIUSER\fR
408 \fITRACK\fR was scratched by \fIUSER\fR.
409 .TP
410 .B state \fIKEYWORD\fR
411 Some state change occurred.  The current set of keywords is:
412 .RS
413 .TP
414 .B completed
415 The current track completed successfully.
416 .TP
417 .B disable_play
418 Playing was disabled.
419 .TP
420 .B disable_random
421 Random play was disabled.
422 .TP
423 .B enable_play
424 Playing was enabled.
425 .TP
426 .B enable_random
427 Random play was enabled.
428 .TP
429 .B failed
430 The current track failed.
431 .TP
432 .B pause
433 The current track was paused.
434 .TP
435 .B playing
436 A track started playing.
437 .TP
438 .B resume
439 The current track was resumed.
440 .TP
441 .B scratched
442 The current track was scratched.
443 .PP
444 To simplify client implementation, \fBstate\fR commands reflecting the current
445 state are sent at the start of the log.
446 .RE
447 .TP
448 .B volume \fILEFT\fR \fIRIGHT\fR
449 The volume changed.
450 .PP
451 .IR QUEUE-ENTRY ...
452 is as defined in
453 .B "TRACK INFORMATION"
454 above.
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: