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