chiark / gitweb /
More command stubs.
[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 confirmation Confirmation string
61  * @return 0 on success, non-0 on error
62  */
63 int 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  */
71 int disorder_cookie(disorder_client *c, const char *cookie);
72 /** @brief Delete user
73  *
74  * Requires the 'admin' right.
75  *
76  * @param c Client
77  * @param user User to delete
78  * @return 0 on success, non-0 on error
79  */
80 int disorder_deluser(disorder_client *c, const char *user);
81
82 /** @brief List directories in a directory
83  *
84  * 
85  *
86  * @param c Client
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  */
93 int disorder_dirs(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
94
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  *
99  * @param c Client
100  * @return 0 on success, non-0 on error
101  */
102 int 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  *
108  * @param c Client
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  */
114 int 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  *
120  * @param c Client
121  * @return 0 on success, non-0 on error
122  */
123 int disorder_enable(disorder_client *c);
124
125 /** @brief Detect whether play is enabled
126  *
127  * 
128  *
129  * @param c Client
130  * @param enabledp 1 if play is enabled and 0 otherwise
131  * @return 0 on success, non-0 on error
132  */
133 int disorder_enabled(disorder_client *c, int *enabledp);
134
135 /** @brief Test whether a track exists
136  *
137  * 
138  *
139  * @param c Client
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  */
144 int disorder_exists(disorder_client *c, const char *track, int *existsp);
145
146 /** @brief List files in a directory
147  *
148  * 
149  *
150  * @param c Client
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  */
157 int disorder_files(disorder_client *c, const char *dir, const char *re, char ***filesp, int *nfilesp);
158
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  *
163  * @param c Client
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  */
169 int 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  *
175  * @param c Client
176  * @param pref Global preference name
177  * @param valuep Preference value
178  * @return 0 on success, non-0 on error
179  */
180 int disorder_get_global(disorder_client *c, const char *pref, char **valuep);
181
182 /** @brief Get a track's length
183  *
184  * If the track does not exist an error is returned.
185  *
186  * @param c Client
187  * @param track Track name
188  * @param lengthp Track length in seconds
189  * @return 0 on success, non-0 on error
190  */
191 int disorder_length(disorder_client *c, const char *track, long *lengthp);
192
193 /** @brief Create a login cookie for this user
194  *
195  * The cookie may be redeemed via the 'cookie' command
196  *
197  * @param c Client
198  * @param cookiep Newly created cookie
199  * @return 0 on success, non-0 on error
200  */
201 int disorder_make_cookie(disorder_client *c, char **cookiep);
202
203 /** @brief Do nothing
204  *
205  * Used as a keepalive.  No authentication required.
206  *
207  * @param c Client
208  * @return 0 on success, non-0 on error
209  */
210 int 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  *
216  * @param c Client
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  */
223 int 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  *
229  * @param c Client
230  * @return 0 on success, non-0 on error
231  */
232 int disorder_pause(disorder_client *c);
233
234 /** @brief Play a track
235  *
236  * Requires the 'play' right.
237  *
238  * @param c Client
239  * @param track Track to play
240  * @param idp Queue ID of new track
241  * @return 0 on success, non-0 on error
242  */
243 int disorder_play(disorder_client *c, const char *track, char **idp);
244
245 /** @brief Delete a playlist
246  *
247  * Requires the 'play' right and permission to modify the playlist.
248  *
249  * @param c Client
250  * @param playlist Playlist to delete
251  * @return 0 on success, non-0 on error
252  */
253 int disorder_playlist_delete(disorder_client *c, const char *playlist);
254
255 /** @brief List the contents of a playlist
256  *
257  * Requires the 'read' right and oermission to read the playlist.
258  *
259  * @param c Client
260  * @param playlist Playlist name
261  * @param tracksp List of tracks in playlist
262  * @param ntracksp Number of elements in tracksp
263  * @return 0 on success, non-0 on error
264  */
265 int disorder_playlist_get(disorder_client *c, const char *playlist, char ***tracksp, int *ntracksp);
266
267 /** @brief Get a playlist's sharing status
268  *
269  * Requires the 'read' right and permission to read the playlist.
270  *
271  * @param c Client
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  */
276 int disorder_playlist_get_share(disorder_client *c, const char *playlist, char **sharep);
277
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  *
282  * @param c Client
283  * @param playlist Playlist to delete
284  * @return 0 on success, non-0 on error
285  */
286 int disorder_playlist_lock(disorder_client *c, const char *playlist);
287
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  */
298 int disorder_playlist_set(disorder_client *c, const char *playlist, char **tracks, int ntracks);
299
300 /** @brief Set a playlist's sharing status
301  *
302  * Requires the 'play' right and permission to modify the playlist.
303  *
304  * @param c Client
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  */
309 int 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  *
315  * @param c Client
316  * @return 0 on success, non-0 on error
317  */
318 int disorder_playlist_unlock(disorder_client *c);
319
320 /** @brief List playlists
321  *
322  * Requires the 'read' right.  Only playlists that you have permission to read are returned.
323  *
324  * @param c Client
325  * @param playlistsp Playlist names
326  * @param nplaylistsp Number of elements in playlistsp
327  * @return 0 on success, non-0 on error
328  */
329 int disorder_playlists(disorder_client *c, char ***playlistsp, int *nplaylistsp);
330
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  */
339 int disorder_queue(disorder_client *c, struct queue_entry **queuep);
340
341 /** @brief Disable random play
342  *
343  * Requires the 'global prefs' right.
344  *
345  * @param c Client
346  * @return 0 on success, non-0 on error
347  */
348 int disorder_random_disable(disorder_client *c);
349
350 /** @brief Enable random play
351  *
352  * Requires the 'global prefs' right.
353  *
354  * @param c Client
355  * @return 0 on success, non-0 on error
356  */
357 int 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  *
363  * @param c Client
364  * @param enabledp 1 if random play is enabled and 0 otherwise
365  * @return 0 on success, non-0 on error
366  */
367 int disorder_random_enabled(disorder_client *c, int *enabledp);
368
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  */
377 int disorder_recent(disorder_client *c, struct queue_entry **recentp);
378
379 /** @brief Re-read configuraiton file.
380  *
381  * Requires the 'admin' right.
382  *
383  * @param c Client
384  * @return 0 on success, non-0 on error
385  */
386 int 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  *
392  * @param c Client
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  */
399 int 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  *
405  * @param c Client
406  * @param username User to remind
407  * @return 0 on success, non-0 on error
408  */
409 int 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  *
415  * @param c Client
416  * @param id Track ID
417  * @return 0 on success, non-0 on error
418  */
419 int 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  *
425  * @param c Client
426  * @return 0 on success, non-0 on error
427  */
428 int disorder_rescan(disorder_client *c);
429
430 /** @brief Resolve a track name
431  *
432  * Converts aliases to non-alias track names
433  *
434  * @param c Client
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  */
439 int 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  *
445  * @param c Client
446  * @return 0 on success, non-0 on error
447  */
448 int 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  *
454  * @param c Client
455  * @return 0 on success, non-0 on error
456  */
457 int 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  *
463  * @param c Client
464  * @param id Track ID (optional)
465  * @return 0 on success, non-0 on error
466  */
467 int 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  *
473  * @param c Client
474  * @param event ID of event to delete
475  * @return 0 on success, non-0 on error
476  */
477 int disorder_schedule_del(disorder_client *c, const char *event);
478
479 /** @brief List scheduled events
480  *
481  * This just lists IDs.  Use 'schedule-get' to retrieve more detail
482  *
483  * @param c Client
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  */
488 int 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  *
494  * @param c Client
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  */
500 int disorder_search(disorder_client *c, const char *terms, char ***tracksp, int *ntracksp);
501
502 /** @brief Set a track preference
503  *
504  * Requires the 'prefs' right.
505  *
506  * @param c Client
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  */
512 int 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  *
518  * @param c Client
519  * @param pref Preference name
520  * @param value New value
521  * @return 0 on success, non-0 on error
522  */
523 int disorder_set_global(disorder_client *c, const char *pref, const char *value);
524
525 /** @brief Request server shutdown
526  *
527  * Requires the 'admin' right.
528  *
529  * @param c Client
530  * @return 0 on success, non-0 on error
531  */
532 int disorder_shutdown(disorder_client *c);
533
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  *
538  * @param c Client
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  */
543 int 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  *
549  * @param c Client
550  * @param tagsp List of tags
551  * @param ntagsp Number of elements in tagsp
552  * @return 0 on success, non-0 on error
553  */
554 int disorder_tags(disorder_client *c, char ***tagsp, int *ntagsp);
555
556 /** @brief Unset a track preference
557  *
558  * Requires the 'prefs' right.
559  *
560  * @param c Client
561  * @param track Track name
562  * @param pref Preference name
563  * @return 0 on success, non-0 on error
564  */
565 int 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  *
571  * @param c Client
572  * @param pref Preference name
573  * @return 0 on success, non-0 on error
574  */
575 int 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  *
581  * @param c Client
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  */
587 int disorder_userinfo(disorder_client *c, const char *username, const char *property, char **valuep);
588
589 /** @brief Get a list of users
590  *
591  * 
592  *
593  * @param c Client
594  * @param usersp List of users
595  * @param nusersp Number of elements in usersp
596  * @return 0 on success, non-0 on error
597  */
598 int disorder_users(disorder_client *c, char ***usersp, int *nusersp);
599
600 /** @brief Get the server version
601  *
602  * 
603  *
604  * @param c Client
605  * @param versionp Server version string
606  * @return 0 on success, non-0 on error
607  */
608 int disorder_version(disorder_client *c, char **versionp);
609
610 #endif