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