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