2 * Automatically generated file, see scripts/protocol
7 * This file is part of DisOrder.
8 * Copyright (C) 2010-11 Richard Kettlewell
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef CLIENT_STUBS_H
24 #define CLIENT_STUBS_H
26 /** @brief Adopt a track
28 * Makes the calling user owner of a randomly picked track.
32 * @return 0 on success, non-0 on error
34 int disorder_adopt(disorder_client *c, const char *id);
36 /** @brief Create a user
38 * Create a new user. Requires the 'admin' right. Email addresses etc must be filled in in separate commands.
41 * @param user New username
42 * @param password Initial password
43 * @param rights Initial rights (optional)
44 * @return 0 on success, non-0 on error
46 int disorder_adduser(disorder_client *c, const char *user, const char *password, const char *rights);
48 /** @brief List files and directories in a directory
50 * See 'files' and 'dirs' for more specific lists.
53 * @param dir Directory to list (optional)
54 * @param re Regexp that results must match (optional)
55 * @param filesp List of matching files and directories
56 * @param nfilesp Number of elements in filesp
57 * @return 0 on success, non-0 on error
59 int disorder_allfiles(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
61 /** @brief Confirm registration
63 * The confirmation string must have been created with 'register'. The username is returned so the caller knows who they are.
66 * @param confirmation Confirmation string
67 * @return 0 on success, non-0 on error
69 int disorder_confirm(disorder_client *c, const char *confirmation);
71 /** @brief Log in with a cookie
73 * The cookie must have been created with 'make-cookie'. The username is returned so the caller knows who they are.
76 * @param cookie Cookie string
77 * @return 0 on success, non-0 on error
79 int disorder_cookie(disorder_client *c, const char *cookie);
81 /** @brief Delete user
83 * Requires the 'admin' right.
86 * @param user User to delete
87 * @return 0 on success, non-0 on error
89 int disorder_deluser(disorder_client *c, const char *user);
91 /** @brief List directories in a directory
96 * @param dir Directory to list (optional)
97 * @param re Regexp that results must match (optional)
98 * @param filesp List of matching directories
99 * @param nfilesp Number of elements in filesp
100 * @return 0 on success, non-0 on error
102 int disorder_dirs(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
104 /** @brief Disable play
106 * Play will stop at the end of the current track, if one is playing. Requires the 'global prefs' right.
109 * @return 0 on success, non-0 on error
111 int disorder_disable(disorder_client *c);
113 /** @brief Set a user property
115 * With the 'admin' right you can do anything. Otherwise you need the 'userinfo' right and can only set 'email' and 'password'.
118 * @param username User to modify
119 * @param property Property name
120 * @param value New property value
121 * @return 0 on success, non-0 on error
123 int disorder_edituser(disorder_client *c, const char *username, const char *property, const char *value);
125 /** @brief Enable play
127 * Requires the 'global prefs' right.
130 * @return 0 on success, non-0 on error
132 int disorder_enable(disorder_client *c);
134 /** @brief Detect whether play is enabled
139 * @param enabledp 1 if play is enabled and 0 otherwise
140 * @return 0 on success, non-0 on error
142 int disorder_enabled(disorder_client *c, int *enabledp);
144 /** @brief Test whether a track exists
149 * @param track Track name
150 * @param existsp 1 if the track exists and 0 otherwise
151 * @return 0 on success, non-0 on error
153 int disorder_exists(disorder_client *c, const char *track, int *existsp);
155 /** @brief List files in a directory
160 * @param dir Directory to list (optional)
161 * @param re Regexp that results must match (optional)
162 * @param filesp List of matching files
163 * @param nfilesp Number of elements in filesp
164 * @return 0 on success, non-0 on error
166 int disorder_files(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
168 /** @brief Get a track preference
170 * 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.
173 * @param track Track name
174 * @param pref Preference name
175 * @param valuep Preference value
176 * @return 0 on success, non-0 on error
178 int disorder_get(disorder_client *c, const char *track, const char *pref, char **valuep);
180 /** @brief Get a global preference
182 * If the preference does exist not then a null value is returned.
185 * @param pref Global preference name
186 * @param valuep Preference value
187 * @return 0 on success, non-0 on error
189 int disorder_get_global(disorder_client *c, const char *pref, char **valuep);
191 /** @brief Get a track's length
193 * If the track does not exist an error is returned.
196 * @param track Track name
197 * @param lengthp Track length in seconds
198 * @return 0 on success, non-0 on error
200 int disorder_length(disorder_client *c, const char *track, long *lengthp);
202 /** @brief Create a login cookie for this user
204 * The cookie may be redeemed via the 'cookie' command
207 * @param cookiep Newly created cookie
208 * @return 0 on success, non-0 on error
210 int disorder_make_cookie(disorder_client *c, char **cookiep);
212 /** @brief Move a track
214 * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
217 * @param track Track ID or name
218 * @param delta How far to move the track towards the head of the queue
219 * @return 0 on success, non-0 on error
221 int disorder_move(disorder_client *c, const char *track, long delta);
223 /** @brief Move multiple tracks
225 * Requires one of the 'move mine', 'move random' or 'move any' rights depending on how the track came to be added to the queue.
228 * @param target Move after this track, or to head if ""
229 * @param ids List of tracks to move by ID
230 * @param nids Length of ids
231 * @return 0 on success, non-0 on error
233 int disorder_moveafter(disorder_client *c, const char *target, char **ids, int nids);
235 /** @brief List recently added tracks
240 * @param max Maximum tracks to fetch, or 0 for all available
241 * @param tracksp Recently added tracks
242 * @param ntracksp Number of elements in tracksp
243 * @return 0 on success, non-0 on error
245 int disorder_new_tracks(disorder_client *c, long max, char ***tracksp, int *ntracksp);
247 /** @brief Do nothing
249 * Used as a keepalive. No authentication required.
252 * @return 0 on success, non-0 on error
254 int disorder_nop(disorder_client *c);
256 /** @brief Get a track name part
258 * If the name part cannot be constructed an empty string is returned.
261 * @param track Track name
262 * @param context Context ("sort" or "display")
263 * @param part Name part ("artist", "album" or "title")
264 * @param partp Value of name part
265 * @return 0 on success, non-0 on error
267 int disorder_part(disorder_client *c, const char *track, const char *context, const char *part, char **partp);
269 /** @brief Pause the currently playing track
271 * Requires the 'pause' right.
274 * @return 0 on success, non-0 on error
276 int disorder_pause(disorder_client *c);
278 /** @brief Play a track
280 * Requires the 'play' right.
283 * @param track Track to play
284 * @param idp Queue ID of new track
285 * @return 0 on success, non-0 on error
287 int disorder_play(disorder_client *c, const char *track, char **idp);
289 /** @brief Play multiple tracks
291 * Requires the 'play' right.
294 * @param target Insert into queue after this track, or at head if ""
295 * @param tracks List of track names to play
296 * @param ntracks Length of tracks
297 * @return 0 on success, non-0 on error
299 int disorder_playafter(disorder_client *c, const char *target, char **tracks, int ntracks);
301 /** @brief Retrieve the playing track
306 * @param playingp Details of the playing track
307 * @return 0 on success, non-0 on error
309 int disorder_playing(disorder_client *c, struct queue_entry **playingp);
311 /** @brief Delete a playlist
313 * Requires the 'play' right and permission to modify the playlist.
316 * @param playlist Playlist to delete
317 * @return 0 on success, non-0 on error
319 int disorder_playlist_delete(disorder_client *c, const char *playlist);
321 /** @brief List the contents of a playlist
323 * Requires the 'read' right and oermission to read the playlist.
326 * @param playlist Playlist name
327 * @param tracksp List of tracks in playlist
328 * @param ntracksp Number of elements in tracksp
329 * @return 0 on success, non-0 on error
331 int disorder_playlist_get(disorder_client *c, const char *playlist, char ***tracksp, int *ntracksp);
333 /** @brief Get a playlist's sharing status
335 * Requires the 'read' right and permission to read the playlist.
338 * @param playlist Playlist to read
339 * @param sharep Sharing status ("public", "private" or "shared")
340 * @return 0 on success, non-0 on error
342 int disorder_playlist_get_share(disorder_client *c, const char *playlist, char **sharep);
344 /** @brief Lock a playlist
346 * Requires the 'play' right and permission to modify the playlist. A given connection may lock at most one playlist.
349 * @param playlist Playlist to delete
350 * @return 0 on success, non-0 on error
352 int disorder_playlist_lock(disorder_client *c, const char *playlist);
354 /** @brief Set the contents of a playlist
356 * Requires the 'play' right and permission to modify the playlist, which must be locked.
359 * @param playlist Playlist to modify
360 * @param tracks New list of tracks for playlist
361 * @param ntracks Length of tracks
362 * @return 0 on success, non-0 on error
364 int disorder_playlist_set(disorder_client *c, const char *playlist, char **tracks, int ntracks);
366 /** @brief Set a playlist's sharing status
368 * Requires the 'play' right and permission to modify the playlist.
371 * @param playlist Playlist to modify
372 * @param share New sharing status ("public", "private" or "shared")
373 * @return 0 on success, non-0 on error
375 int disorder_playlist_set_share(disorder_client *c, const char *playlist, const char *share);
377 /** @brief Unlock the locked playlist playlist
379 * The playlist to unlock is implicit in the connection.
382 * @return 0 on success, non-0 on error
384 int disorder_playlist_unlock(disorder_client *c);
386 /** @brief List playlists
388 * Requires the 'read' right. Only playlists that you have permission to read are returned.
391 * @param playlistsp Playlist names
392 * @param nplaylistsp Number of elements in playlistsp
393 * @return 0 on success, non-0 on error
395 int disorder_playlists(disorder_client *c, char ***playlistsp, int *nplaylistsp);
397 /** @brief Get all the preferences for a track
402 * @param track Track name
403 * @param prefsp Track preferences
404 * @return 0 on success, non-0 on error
406 int disorder_prefs(disorder_client *c, const char *track, struct kvp **prefsp);
408 /** @brief List the queue
413 * @param queuep Current queue contents
414 * @return 0 on success, non-0 on error
416 int disorder_queue(disorder_client *c, struct queue_entry **queuep);
418 /** @brief Disable random play
420 * Requires the 'global prefs' right.
423 * @return 0 on success, non-0 on error
425 int disorder_random_disable(disorder_client *c);
427 /** @brief Enable random play
429 * Requires the 'global prefs' right.
432 * @return 0 on success, non-0 on error
434 int disorder_random_enable(disorder_client *c);
436 /** @brief Detect whether random play is enabled
438 * Random play counts as enabled even if play is disabled.
441 * @param enabledp 1 if random play is enabled and 0 otherwise
442 * @return 0 on success, non-0 on error
444 int disorder_random_enabled(disorder_client *c, int *enabledp);
446 /** @brief List recently played tracks
451 * @param recentp Recently played tracks
452 * @return 0 on success, non-0 on error
454 int disorder_recent(disorder_client *c, struct queue_entry **recentp);
456 /** @brief Re-read configuraiton file.
458 * Requires the 'admin' right.
461 * @return 0 on success, non-0 on error
463 int disorder_reconfigure(disorder_client *c);
465 /** @brief Register a new user
467 * Requires the 'register' right which is usually only available to the 'guest' user. Redeem the confirmation string via 'confirm' to complete registration.
470 * @param username Requested new username
471 * @param password Requested initial password
472 * @param email New user's email address
473 * @param confirmationp Confirmation string
474 * @return 0 on success, non-0 on error
476 int disorder_register(disorder_client *c, const char *username, const char *password, const char *email, char **confirmationp);
478 /** @brief Send a password reminder.
480 * 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.
483 * @param username User to remind
484 * @return 0 on success, non-0 on error
486 int disorder_reminder(disorder_client *c, const char *username);
488 /** @brief Remove a track form the queue.
490 * Requires one of the 'remove mine', 'remove random' or 'remove any' rights depending on how the track came to be added to the queue.
494 * @return 0 on success, non-0 on error
496 int disorder_remove(disorder_client *c, const char *id);
498 /** @brief Rescan all collections for new or obsolete tracks.
500 * Requires the 'rescan' right.
503 * @return 0 on success, non-0 on error
505 int disorder_rescan(disorder_client *c);
507 /** @brief Resolve a track name
509 * Converts aliases to non-alias track names
512 * @param track Track name (might be an alias)
513 * @param resolvedp Resolve track name (definitely not an alias)
514 * @return 0 on success, non-0 on error
516 int disorder_resolve(disorder_client *c, const char *track, char **resolvedp);
518 /** @brief Resume the currently playing track
520 * Requires the 'pause' right.
523 * @return 0 on success, non-0 on error
525 int disorder_resume(disorder_client *c);
527 /** @brief Revoke a cookie.
529 * It will not subsequently be possible to log in with the cookie.
532 * @return 0 on success, non-0 on error
534 int disorder_revoke(disorder_client *c);
536 /** @brief Get the server's RTP address information
541 * @param addressp Where to store hostname or address
542 * @return 0 on success, non-0 on error
544 int disorder_rtp_address(disorder_client *c, char **addressp, char **portp);
546 /** @brief Terminate the playing track.
548 * Requires one of the 'scratch mine', 'scratch random' or 'scratch any' rights depending on how the track came to be added to the queue.
551 * @param id Track ID (optional)
552 * @return 0 on success, non-0 on error
554 int disorder_scratch(disorder_client *c, const char *id);
556 /** @brief Schedule a track to play in the future
561 * @param when When to play the track
562 * @param priority Event priority ("normal" or "junk")
563 * @param track Track to play
564 * @return 0 on success, non-0 on error
566 int disorder_schedule_add_play(disorder_client *c, time_t when, const char *priority, const char *track);
568 /** @brief Schedule a global setting to be changed in the future
573 * @param when When to change the setting
574 * @param priority Event priority ("normal" or "junk")
575 * @param pref Global preference to set
576 * @param value New value of global preference
577 * @return 0 on success, non-0 on error
579 int disorder_schedule_add_set_global(disorder_client *c, time_t when, const char *priority, const char *pref, const char *value);
581 /** @brief Schedule a global setting to be unset in the future
586 * @param when When to change the setting
587 * @param priority Event priority ("normal" or "junk")
588 * @param pref Global preference to set
589 * @return 0 on success, non-0 on error
591 int disorder_schedule_add_unset_global(disorder_client *c, time_t when, const char *priority, const char *pref);
593 /** @brief Delete a scheduled event.
595 * Users can always delete their own scheduled events; with the admin right you can delete any event.
598 * @param event ID of event to delete
599 * @return 0 on success, non-0 on error
601 int disorder_schedule_del(disorder_client *c, const char *event);
603 /** @brief Get the details of scheduled event
609 * @param actiondatap Details of event
610 * @return 0 on success, non-0 on error
612 int disorder_schedule_get(disorder_client *c, const char *id, struct kvp **actiondatap);
614 /** @brief List scheduled events
616 * This just lists IDs. Use 'schedule-get' to retrieve more detail
619 * @param idsp List of event IDs
620 * @param nidsp Number of elements in idsp
621 * @return 0 on success, non-0 on error
623 int disorder_schedule_list(disorder_client *c, char ***idsp, int *nidsp);
625 /** @brief Search for tracks
627 * Terms are either keywords or tags formatted as 'tag:TAG-NAME'.
630 * @param terms List of search terms
631 * @param tracksp List of matching tracks
632 * @param ntracksp Number of elements in tracksp
633 * @return 0 on success, non-0 on error
635 int disorder_search(disorder_client *c, const char *terms, char ***tracksp, int *ntracksp);
637 /** @brief Set a track preference
639 * Requires the 'prefs' right.
642 * @param track Track name
643 * @param pref Preference name
644 * @param value New value
645 * @return 0 on success, non-0 on error
647 int disorder_set(disorder_client *c, const char *track, const char *pref, const char *value);
649 /** @brief Set a global preference
651 * Requires the 'global prefs' right.
654 * @param pref Preference name
655 * @param value New value
656 * @return 0 on success, non-0 on error
658 int disorder_set_global(disorder_client *c, const char *pref, const char *value);
660 /** @brief Request server shutdown
662 * Requires the 'admin' right.
665 * @return 0 on success, non-0 on error
667 int disorder_shutdown(disorder_client *c);
669 /** @brief Get server statistics
671 * The details of what the server reports are not really defined. The returned strings are intended to be printed out one to a line.
674 * @param statsp List of server information strings.
675 * @param nstatsp Number of elements in statsp
676 * @return 0 on success, non-0 on error
678 int disorder_stats(disorder_client *c, char ***statsp, int *nstatsp);
680 /** @brief Get a list of known tags
682 * Only tags which apply to at least one track are returned.
685 * @param tagsp List of tags
686 * @param ntagsp Number of elements in tagsp
687 * @return 0 on success, non-0 on error
689 int disorder_tags(disorder_client *c, char ***tagsp, int *ntagsp);
691 /** @brief Unset a track preference
693 * Requires the 'prefs' right.
696 * @param track Track name
697 * @param pref Preference name
698 * @return 0 on success, non-0 on error
700 int disorder_unset(disorder_client *c, const char *track, const char *pref);
702 /** @brief Set a global preference
704 * Requires the 'global prefs' right.
707 * @param pref Preference name
708 * @return 0 on success, non-0 on error
710 int disorder_unset_global(disorder_client *c, const char *pref);
712 /** @brief Get a user property.
714 * 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.
717 * @param username User to read
718 * @param property Property to read
719 * @param valuep Value of property
720 * @return 0 on success, non-0 on error
722 int disorder_userinfo(disorder_client *c, const char *username, const char *property, char **valuep);
724 /** @brief Get a list of users
729 * @param usersp List of users
730 * @param nusersp Number of elements in usersp
731 * @return 0 on success, non-0 on error
733 int disorder_users(disorder_client *c, char ***usersp, int *nusersp);
735 /** @brief Get the server version
740 * @param versionp Server version string
741 * @return 0 on success, non-0 on error
743 int disorder_version(disorder_client *c, char **versionp);
745 /** @brief Set the volume
750 * @param left Left channel volume
751 * @param right Right channel volume
752 * @return 0 on success, non-0 on error
754 int disorder_set_volume(disorder_client *c, long left, long right);
756 /** @brief Get the volume
761 * @param leftp Left channel volume
762 * @return 0 on success, non-0 on error
764 int disorder_get_volume(disorder_client *c, long *leftp, long *rightp);