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