19649ac37d3a3f491cbc2c1b4533d3a49fa00109
[disorder] / lib / client-stubs.h
1 /*
2 * This file is part of DisOrder.
3 * Copyright (C) 2010 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef CLIENT_STUBS_H
19 #define CLIENT_STUBS_H
20
21 /** @brief Adopt a track
22 *
23 * Makes the calling user owner of a randomly picked track.
24 *
25 * @param c Client
26 * @param id Track ID
27 * @return 0 on success, non-0 on error
28 */
29 int disorder_adopt(disorder_client *c, const char *id);
30
31 /** @brief Create a user
32 *
33 * Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands.
34 *
35 * @param c Client
36 * @param user New username
37 * @param password Initial password
38 * @param rights Initial rights (optional)
39 * @return 0 on success, non-0 on error
40 */
41 int disorder_adduser(disorder_client *c, const char *user, const char *password, const char *rights);
42
43 /** @brief List files and directories in a directory
44 *
45 * See 'files' and 'dirs' for more specific lists.
46 *
47 * @param c Client
48 * @param dir Directory to list (optional)
49 * @param re Regexp that results must match (optional)
50 * @param filesp List of matching files and directories
51 * @param nfilesp Number of elements in filesp
52 * @return 0 on success, non-0 on error
53 */
54 int disorder_allfiles(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
55
56 /** @brief Confirm registration
57 *
58 * The confirmation string must have been created with 'register'. The username is returned so the caller knows who they are.
59 *
60 * @param c Client
61 * @param confirmation Confirmation string
62 * @return 0 on success, non-0 on error
63 */
64 int disorder_confirm(disorder_client *c, const char *confirmation);
65
66 /** @brief Log in with a cookie
67 *
68 * The cookie must have been created with 'make-cookie'. The username is returned so the caller knows who they are.
69 *
70 * @param c Client
71 * @param cookie Cookie string
72 * @return 0 on success, non-0 on error
73 */
74 int disorder_cookie(disorder_client *c, const char *cookie);
75
76 /** @brief Delete user
77 *
78 * Requires the 'admin' right.
79 *
80 * @param c Client
81 * @param user User to delete
82 * @return 0 on success, non-0 on error
83 */
84 int disorder_deluser(disorder_client *c, const char *user);
85
86 /** @brief List directories in a directory
87 *
88 *
89 *
90 * @param c Client
91 * @param dir Directory to list (optional)
92 * @param re Regexp that results must match (optional)
93 * @param filesp List of matching directories
94 * @param nfilesp Number of elements in filesp
95 * @return 0 on success, non-0 on error
96 */
97 int disorder_dirs(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
98
99 /** @brief Disable play
100 *
101 * Play will stop at the end of the current track, if one is playing. Requires the 'global prefs' right.
102 *
103 * @param c Client
104 * @return 0 on success, non-0 on error
105 */
106 int disorder_disable(disorder_client *c);
107
108 /** @brief Set a user property
109 *
110 * With the 'admin' right you can do anything. Otherwise you need the 'userinfo' right and can only set 'email' and 'password'.
111 *
112 * @param c Client
113 * @param username User to modify
114 * @param property Property name
115 * @param value New property value
116 * @return 0 on success, non-0 on error
117 */
118 int disorder_edituser(disorder_client *c, const char *username, const char *property, const char *value);
119
120 /** @brief Enable play
121 *
122 * Requires the 'global prefs' right.
123 *
124 * @param c Client
125 * @return 0 on success, non-0 on error
126 */
127 int disorder_enable(disorder_client *c);
128
129 /** @brief Detect whether play is enabled
130 *
131 *
132 *
133 * @param c Client
134 * @param enabledp 1 if play is enabled and 0 otherwise
135 * @return 0 on success, non-0 on error
136 */
137 int disorder_enabled(disorder_client *c, int *enabledp);
138
139 /** @brief Test whether a track exists
140 *
141 *
142 *
143 * @param c Client
144 * @param track Track name
145 * @param existsp 1 if the track exists and 0 otherwise
146 * @return 0 on success, non-0 on error
147 */
148 int disorder_exists(disorder_client *c, const char *track, int *existsp);
149
150 /** @brief List files in a directory
151 *
152 *
153 *
154 * @param c Client
155 * @param dir Directory to list (optional)
156 * @param re Regexp that results must match (optional)
157 * @param filesp List of matching files
158 * @param nfilesp Number of elements in filesp
159 * @return 0 on success, non-0 on error
160 */
161 int disorder_files(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
162
163 /** @brief Get a track preference
164 *
165 * If the track does not exist that is an error. If the track exists but the preference does not then a null value is returned.
166 *
167 * @param c Client
168 * @param track Track name
169 * @param pref Preference name
170 * @param valuep Preference value
171 * @return 0 on success, non-0 on error
172 */
173 int disorder_get(disorder_client *c, const char *track, const char *pref, char **valuep);
174
175 /** @brief Get a global preference
176 *
177 * If the preference does exist not then a null value is returned.
178 *
179 * @param c Client
180 * @param pref Global preference name
181 * @param valuep Preference value
182 * @return 0 on success, non-0 on error
183 */
184 int disorder_get_global(disorder_client *c, const char *pref, char **valuep);
185
186 /** @brief Get a track's length
187 *
188 * If the track does not exist an error is returned.
189 *
190 * @param c Client
191 * @param track Track name
192 * @param lengthp Track length in seconds
193 * @return 0 on success, non-0 on error
194 */
195 int disorder_length(disorder_client *c, const char *track, long *lengthp);
196
197 /** @brief Create a login cookie for this user
198 *
199 * The cookie may be redeemed via the 'cookie' command
200 *
201 * @param c Client
202 * @param cookiep Newly created cookie
203 * @return 0 on success, non-0 on error
204 */
205 int disorder_make_cookie(disorder_client *c, char **cookiep);
206
207 /** @brief Move a track
208 *
209 * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
210 *
211 * @param c Client
212 * @param track Track ID or name
213 * @param delta How far to move the track towards the head of the queue
214 * @return 0 on success, non-0 on error
215 */
216 int disorder_move(disorder_client *c, const char *track, long delta);
217
218 /** @brief Move multiple tracks
219 *
220 * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
221 *
222 * @param c Client
223 * @param target Move after this track, or to head if ""
224 * @param ids List of tracks to move by ID
225 * @param nids Length of ids
226 * @return 0 on success, non-0 on error
227 */
228 int disorder_moveafter(disorder_client *c, const char *target, char **ids, int nids);
229
230 /** @brief Do nothing
231 *
232 * Used as a keepalive. No authentication required.
233 *
234 * @param c Client
235 * @return 0 on success, non-0 on error
236 */
237 int disorder_nop(disorder_client *c);
238
239 /** @brief Get a track name part
240 *
241 * If the name part cannot be constructed an empty string is returned.
242 *
243 * @param c Client
244 * @param track Track name
245 * @param context Context ("sort" or "display")
246 * @param part Name part ("artist", "album" or "title")
247 * @param partp Value of name part
248 * @return 0 on success, non-0 on error
249 */
250 int disorder_part(disorder_client *c, const char *track, const char *context, const char *part, char **partp);
251
252 /** @brief Pause the currently playing track
253 *
254 * Requires the 'pause' right.
255 *
256 * @param c Client
257 * @return 0 on success, non-0 on error
258 */
259 int disorder_pause(disorder_client *c);
260
261 /** @brief Play a track
262 *
263 * Requires the 'play' right.
264 *
265 * @param c Client
266 * @param track Track to play
267 * @param idp Queue ID of new track
268 * @return 0 on success, non-0 on error
269 */
270 int disorder_play(disorder_client *c, const char *track, char **idp);
271
272 /** @brief Play multiple tracks
273 *
274 * Requires the 'play' right.
275 *
276 * @param c Client
277 * @param target Insert into queue after this track, or at head if ""
278 * @param tracks List of track names to play
279 * @param ntracks Length of tracks
280 * @return 0 on success, non-0 on error
281 */
282 int disorder_playafter(disorder_client *c, const char *target, char **tracks, int ntracks);
283
284 /** @brief Delete a playlist
285 *
286 * Requires the 'play' right and permission to modify the playlist.
287 *
288 * @param c Client
289 * @param playlist Playlist to delete
290 * @return 0 on success, non-0 on error
291 */
292 int disorder_playlist_delete(disorder_client *c, const char *playlist);
293
294 /** @brief List the contents of a playlist
295 *
296 * Requires the 'read' right and oermission to read the playlist.
297 *
298 * @param c Client
299 * @param playlist Playlist name
300 * @param tracksp List of tracks in playlist
301 * @param ntracksp Number of elements in tracksp
302 * @return 0 on success, non-0 on error
303 */
304 int disorder_playlist_get(disorder_client *c, const char *playlist, char ***tracksp, int *ntracksp);
305
306 /** @brief Get a playlist's sharing status
307 *
308 * Requires the 'read' right and permission to read the playlist.
309 *
310 * @param c Client
311 * @param playlist Playlist to read
312 * @param sharep Sharing status ("public", "private" or "shared")
313 * @return 0 on success, non-0 on error
314 */
315 int disorder_playlist_get_share(disorder_client *c, const char *playlist, char **sharep);
316
317 /** @brief Lock a playlist
318 *
319 * Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.
320 *
321 * @param c Client
322 * @param playlist Playlist to delete
323 * @return 0 on success, non-0 on error
324 */
325 int disorder_playlist_lock(disorder_client *c, const char *playlist);
326
327 /** @brief Set the contents of a playlist
328 *
329 * Requires the 'play' right and permission to modify the playlist, which must be locked.
330 *
331 * @param c Client
332 * @param playlist Playlist to modify
333 * @param tracks New list of tracks for playlist
334 * @param ntracks Length of tracks
335 * @return 0 on success, non-0 on error
336 */
337 int disorder_playlist_set(disorder_client *c, const char *playlist, char **tracks, int ntracks);
338
339 /** @brief Set a playlist's sharing status
340 *
341 * Requires the 'play' right and permission to modify the playlist.
342 *
343 * @param c Client
344 * @param playlist Playlist to modify
345 * @param share New sharing status ("public", "private" or "shared")
346 * @return 0 on success, non-0 on error
347 */
348 int disorder_playlist_set_share(disorder_client *c, const char *playlist, const char *share);
349
350 /** @brief Unlock the locked playlist playlist
351 *
352 * The playlist to unlock is implicit in the connection.
353 *
354 * @param c Client
355 * @return 0 on success, non-0 on error
356 */
357 int disorder_playlist_unlock(disorder_client *c);
358
359 /** @brief List playlists
360 *
361 * Requires the 'read' right. Only playlists that you have permission to read are returned.
362 *
363 * @param c Client
364 * @param playlistsp Playlist names
365 * @param nplaylistsp Number of elements in playlistsp
366 * @return 0 on success, non-0 on error
367 */
368 int disorder_playlists(disorder_client *c, char ***playlistsp, int *nplaylistsp);
369
370 /** @brief List the queue
371 *
372 *
373 *
374 * @param c Client
375 * @param queuep Current queue contents
376 * @return 0 on success, non-0 on error
377 */
378 int disorder_queue(disorder_client *c, struct queue_entry **queuep);
379
380 /** @brief Disable random play
381 *
382 * Requires the 'global prefs' right.
383 *
384 * @param c Client
385 * @return 0 on success, non-0 on error
386 */
387 int disorder_random_disable(disorder_client *c);
388
389 /** @brief Enable random play
390 *
391 * Requires the 'global prefs' right.
392 *
393 * @param c Client
394 * @return 0 on success, non-0 on error
395 */
396 int disorder_random_enable(disorder_client *c);
397
398 /** @brief Detect whether random play is enabled
399 *
400 * Random play counts as enabled even if play is disabled.
401 *
402 * @param c Client
403 * @param enabledp 1 if random play is enabled and 0 otherwise
404 * @return 0 on success, non-0 on error
405 */
406 int disorder_random_enabled(disorder_client *c, int *enabledp);
407
408 /** @brief List recently played tracks
409 *
410 *
411 *
412 * @param c Client
413 * @param recentp Recently played tracks
414 * @return 0 on success, non-0 on error
415 */
416 int disorder_recent(disorder_client *c, struct queue_entry **recentp);
417
418 /** @brief Re-read configuraiton file.
419 *
420 * Requires the 'admin' right.
421 *
422 * @param c Client
423 * @return 0 on success, non-0 on error
424 */
425 int disorder_reconfigure(disorder_client *c);
426
427 /** @brief Register a new user
428 *
429 * Requires the 'register' right which is usually only available to the 'guest' user. Redeem the confirmation string via 'confirm' to complete registration.
430 *
431 * @param c Client
432 * @param username Requested new username
433 * @param password Requested initial password
434 * @param email New user's email address
435 * @param confirmationp Confirmation string
436 * @return 0 on success, non-0 on error
437 */
438 int disorder_register(disorder_client *c, const char *username, const char *password, const char *email, char **confirmationp);
439
440 /** @brief Send a password reminder.
441 *
442 * If the user has no valid email address, or no password, or a reminder has been sent too recently, then no reminder will be sent.
443 *
444 * @param c Client
445 * @param username User to remind
446 * @return 0 on success, non-0 on error
447 */
448 int disorder_reminder(disorder_client *c, const char *username);
449
450 /** @brief Remove a track form the queue.
451 *
452 * Requires one of the 'remove mine', 'remove random' or 'remove any' rights depending on how the track came to be added to the queue.
453 *
454 * @param c Client
455 * @param id Track ID
456 * @return 0 on success, non-0 on error
457 */
458 int disorder_remove(disorder_client *c, const char *id);
459
460 /** @brief Rescan all collections for new or obsolete tracks.
461 *
462 * Requires the 'rescan' right.
463 *
464 * @param c Client
465 * @return 0 on success, non-0 on error
466 */
467 int disorder_rescan(disorder_client *c);
468
469 /** @brief Resolve a track name
470 *
471 * Converts aliases to non-alias track names
472 *
473 * @param c Client
474 * @param track Track name (might be an alias)
475 * @param resolvedp Resolve track name (definitely not an alias)
476 * @return 0 on success, non-0 on error
477 */
478 int disorder_resolve(disorder_client *c, const char *track, char **resolvedp);
479
480 /** @brief Resume the currently playing track
481 *
482 * Requires the 'pause' right.
483 *
484 * @param c Client
485 * @return 0 on success, non-0 on error
486 */
487 int disorder_resume(disorder_client *c);
488
489 /** @brief Revoke a cookie.
490 *
491 * It will not subsequently be possible to log in with the cookie.
492 *
493 * @param c Client
494 * @return 0 on success, non-0 on error
495 */
496 int disorder_revoke(disorder_client *c);
497
498 /** @brief Terminate the playing track.
499 *
500 * Requires one of the 'scratch mine', 'scratch random' or 'scratch any' rights depending on how the track came to be added to the queue.
501 *
502 * @param c Client
503 * @param id Track ID (optional)
504 * @return 0 on success, non-0 on error
505 */
506 int disorder_scratch(disorder_client *c, const char *id);
507
508 /** @brief Delete a scheduled event.
509 *
510 * Users can always delete their own scheduled events; with the admin right you can delete any event.
511 *
512 * @param c Client
513 * @param event ID of event to delete
514 * @return 0 on success, non-0 on error
515 */
516 int disorder_schedule_del(disorder_client *c, const char *event);
517
518 /** @brief List scheduled events
519 *
520 * This just lists IDs. Use 'schedule-get' to retrieve more detail
521 *
522 * @param c Client
523 * @param idsp List of event IDs
524 * @param nidsp Number of elements in idsp
525 * @return 0 on success, non-0 on error
526 */
527 int disorder_schedule_list(disorder_client *c, char ***idsp, int *nidsp);
528
529 /** @brief Search for tracks
530 *
531 * Terms are either keywords or tags formatted as 'tag:TAG-NAME'.
532 *
533 * @param c Client
534 * @param terms List of search terms
535 * @param tracksp List of matching tracks
536 * @param ntracksp Number of elements in tracksp
537 * @return 0 on success, non-0 on error
538 */
539 int disorder_search(disorder_client *c, const char *terms, char ***tracksp, int *ntracksp);
540
541 /** @brief Set a track preference
542 *
543 * Requires the 'prefs' right.
544 *
545 * @param c Client
546 * @param track Track name
547 * @param pref Preference name
548 * @param value New value
549 * @return 0 on success, non-0 on error
550 */
551 int disorder_set(disorder_client *c, const char *track, const char *pref, const char *value);
552
553 /** @brief Set a global preference
554 *
555 * Requires the 'global prefs' right.
556 *
557 * @param c Client
558 * @param pref Preference name
559 * @param value New value
560 * @return 0 on success, non-0 on error
561 */
562 int disorder_set_global(disorder_client *c, const char *pref, const char *value);
563
564 /** @brief Request server shutdown
565 *
566 * Requires the 'admin' right.
567 *
568 * @param c Client
569 * @return 0 on success, non-0 on error
570 */
571 int disorder_shutdown(disorder_client *c);
572
573 /** @brief Get server statistics
574 *
575 * The details of what the server reports are not really defined. The returned strings are intended to be printed out one to a line..
576 *
577 * @param c Client
578 * @param statsp List of server information strings.
579 * @param nstatsp Number of elements in statsp
580 * @return 0 on success, non-0 on error
581 */
582 int disorder_stats(disorder_client *c, char ***statsp, int *nstatsp);
583
584 /** @brief Get a list of known tags
585 *
586 * Only tags which apply to at least one track are returned.
587 *
588 * @param c Client
589 * @param tagsp List of tags
590 * @param ntagsp Number of elements in tagsp
591 * @return 0 on success, non-0 on error
592 */
593 int disorder_tags(disorder_client *c, char ***tagsp, int *ntagsp);
594
595 /** @brief Unset a track preference
596 *
597 * Requires the 'prefs' right.
598 *
599 * @param c Client
600 * @param track Track name
601 * @param pref Preference name
602 * @return 0 on success, non-0 on error
603 */
604 int disorder_unset(disorder_client *c, const char *track, const char *pref);
605
606 /** @brief Set a global preference
607 *
608 * Requires the 'global prefs' right.
609 *
610 * @param c Client
611 * @param pref Preference name
612 * @return 0 on success, non-0 on error
613 */
614 int disorder_unset_global(disorder_client *c, const char *pref);
615
616 /** @brief Get a user property.
617 *
618 * If the user does not exist an error is returned, if the user exists but the property does not then a null value is returned.
619 *
620 * @param c Client
621 * @param username User to read
622 * @param property Property to read
623 * @param valuep Value of property
624 * @return 0 on success, non-0 on error
625 */
626 int disorder_userinfo(disorder_client *c, const char *username, const char *property, char **valuep);
627
628 /** @brief Get a list of users
629 *
630 *
631 *
632 * @param c Client
633 * @param usersp List of users
634 * @param nusersp Number of elements in usersp
635 * @return 0 on success, non-0 on error
636 */
637 int disorder_users(disorder_client *c, char ***usersp, int *nusersp);
638
639 /** @brief Get the server version
640 *
641 *
642 *
643 * @param c Client
644 * @param versionp Server version string
645 * @return 0 on success, non-0 on error
646 */
647 int disorder_version(disorder_client *c, char **versionp);
648
649 #endif