X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/ad492e00c1aafb3aec7c385e1a29606742433e7e..16b0fea8ae1a581d568dbee2efa2932aa4e6fcce:/lib/eclient.h diff --git a/lib/eclient.h b/lib/eclient.h index be5730c..876e2c6 100644 --- a/lib/eclient.h +++ b/lib/eclient.h @@ -1,24 +1,24 @@ /* * This file is part of DisOrder. - * Copyright (C) 2006, 2007 Richard Kettlewell + * Copyright (C) 2006-2008 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ /** @file lib/eclient.h * @brief Client code for event-driven programs + * + * See @ref lib/eclient-stubs.h for the (generated) per-command entry points. */ #ifndef ECLIENT_H @@ -127,7 +127,7 @@ typedef struct disorder_eclient_log_callbacks { /** @brief Called when @p id is removed from the recent list */ void (*recent_removed)(void *v, const char *id); - /** @brief Called when @id is removed from the queue + /** @brief Called when @p id is removed from the queue * * @p user might be 0. */ @@ -167,6 +167,21 @@ typedef struct disorder_eclient_log_callbacks { /** @brief Called when your rights change */ void (*rights_changed)(void *v, rights_type new_rights); + + /** @brief Called when a track is adopted */ + void (*adopted)(void *v, const char *id, const char *who); + + /** @brief Called when a new playlist is created */ + void (*playlist_created)(void *v, const char *playlist, const char *sharing); + + /** @brief Called when a playlist is modified */ + void (*playlist_modified)(void *v, const char *playlist, const char *sharing); + + /** @brief Called when a new playlist is deleted */ + void (*playlist_deleted)(void *v, const char *playlist); + + /** @brief Called when a global pref is changed or delete */ + void (*global_pref)(void *v, const char *pref, const char *value/*or NULL*/); } disorder_eclient_log_callbacks; /* State bits */ @@ -209,29 +224,30 @@ struct sink; /** @brief Trivial completion callback * @param v User data - * @param error Error string or NULL on succes + * @param err Error string or NULL on succes */ typedef void disorder_eclient_no_response(void *v, - const char *error); + const char *err); /** @brief String result completion callback * @param v User data - * @param error Error string or NULL on succes + * @param err Error string or NULL on succes * @param value Result or NULL * * @p error will be NULL on success. In this case @p value will be the result * (which might be NULL for disorder_eclient_get(), - * disorder_eclient_get_global() and disorder_eclient_userinfo()). + * disorder_eclient_get_global(), disorder_eclient_userinfo() and + * disorder_eclient_playlist_get_share()). * * @p error will be non-NULL on failure. In this case @p value is always NULL. */ typedef void disorder_eclient_string_response(void *v, - const char *error, + const char *err, const char *value); -/** @brief String result completion callback +/** @brief Integer result completion callback * @param v User data - * @param error Error string or NULL on succes + * @param err Error string or NULL on succes * @param value Result or 0 * * @p error will be NULL on success. In this case @p value will be the result. @@ -239,11 +255,11 @@ typedef void disorder_eclient_string_response(void *v, * @p error will be non-NULL on failure. In this case @p value is always 0. */ typedef void disorder_eclient_integer_response(void *v, - const char *error, + const char *err, long value); /** @brief Volume completion callback * @param v User data - * @param error Error string or NULL on success + * @param err Error string or NULL on success * @param l Left channel volume * @param r Right channel volume * @@ -253,13 +269,13 @@ typedef void disorder_eclient_integer_response(void *v, * @p error will be non-NULL on failure. In this case @p l and @p r are always * 0. */ -typedef void disorder_eclient_volume_response(void *v, - const char *error, - int l, int r); +typedef void disorder_eclient_pair_integer_response(void *v, + const char *err, + long l, long r); /** @brief Queue request completion callback * @param v User data - * @param error Error string or NULL on success + * @param err Error string or NULL on success * @param q Head of queue data list * * @p error will be NULL on success. In this case @p q will be the (head of @@ -270,23 +286,26 @@ typedef void disorder_eclient_volume_response(void *v, * be ignored in the error case. */ typedef void disorder_eclient_queue_response(void *v, - const char *error, + const char *err, struct queue_entry *q); +#define disorder_eclient_playing_response disorder_eclient_queue_response + /** @brief List request completion callback * @param v User data - * @param error Error string or NULL on success + * @param err Error string or NULL on success * @param nvec Number of elements in response list * @param vec Pointer to response list * * @p error will be NULL on success. In this case @p nvec and @p vec will give - * the result. + * the result, or be -1 and NULL respectively e.g. from + * disorder_eclient_playlist_get() if there is no such playlist. * * @p error will be non-NULL on failure. In this case @p nvec and @p vec will * be 0 and NULL. */ typedef void disorder_eclient_list_response(void *v, - const char *error, + const char *err, int nvec, char **vec); disorder_eclient *disorder_eclient_new(const disorder_eclient_callbacks *cb, @@ -302,187 +321,25 @@ void disorder_eclient_polled(disorder_eclient *c, unsigned mode); /* Should be called when c's FD is readable and/or writable, and in any case * from time to time (so that retries work). */ -int disorder_eclient_version(disorder_eclient *c, - disorder_eclient_string_response *completed, - void *v); -/* fetch the server version */ - -int disorder_eclient_play(disorder_eclient *c, - const char *track, - disorder_eclient_no_response *completed, - void *v); -/* add a track to the queue */ - -int disorder_eclient_pause(disorder_eclient *c, - disorder_eclient_no_response *completed, - void *v); -/* add a track to the queue */ - -int disorder_eclient_resume(disorder_eclient *c, - disorder_eclient_no_response *completed, - void *v); -/* add a track to the queue */ - -int disorder_eclient_scratch(disorder_eclient *c, - const char *id, - disorder_eclient_no_response *completed, - void *v); -/* scratch a track by ID */ - int disorder_eclient_scratch_playing(disorder_eclient *c, disorder_eclient_no_response *completed, void *v); /* scratch the playing track whatever it is */ -int disorder_eclient_remove(disorder_eclient *c, - const char *id, - disorder_eclient_no_response *completed, - void *v); -/* remove a track from the queue */ - -int disorder_eclient_moveafter(disorder_eclient *c, - const char *target, - int nids, - const char **ids, - disorder_eclient_no_response *completed, - void *v); -/* move tracks within the queue */ - -int disorder_eclient_playing(disorder_eclient *c, - disorder_eclient_queue_response *completed, - void *v); -/* find the currently playing track (0 for none) */ - -int disorder_eclient_queue(disorder_eclient *c, - disorder_eclient_queue_response *completed, - void *v); -/* list recently played tracks */ - -int disorder_eclient_recent(disorder_eclient *c, - disorder_eclient_queue_response *completed, - void *v); -/* list recently played tracks */ - -int disorder_eclient_files(disorder_eclient *c, - disorder_eclient_list_response *completed, - const char *dir, - const char *re, - void *v); -/* list files in a directory, matching RE if not a null pointer */ - -int disorder_eclient_dirs(disorder_eclient *c, - disorder_eclient_list_response *completed, - const char *dir, - const char *re, - void *v); -/* list directories in a directory, matching RE if not a null pointer */ - -int disorder_eclient_namepart(disorder_eclient *c, - disorder_eclient_string_response *completed, - const char *track, - const char *context, - const char *part, - void *v); -/* look up a track name part */ - -int disorder_eclient_length(disorder_eclient *c, - disorder_eclient_integer_response *completed, - const char *track, - void *v); -/* look up a track name length */ - -int disorder_eclient_volume(disorder_eclient *c, - disorder_eclient_volume_response *callback, - int l, int r, - void *v); -/* If L and R are both -ve gets the volume. - * If neither are -ve then sets the volume. - * Otherwise asserts! - */ - -int disorder_eclient_enable(disorder_eclient *c, - disorder_eclient_no_response *callback, - void *v); -int disorder_eclient_disable(disorder_eclient *c, - disorder_eclient_no_response *callback, - void *v); -int disorder_eclient_random_enable(disorder_eclient *c, - disorder_eclient_no_response *callback, - void *v); -int disorder_eclient_random_disable(disorder_eclient *c, - disorder_eclient_no_response *callback, - void *v); -/* Enable/disable play/random play */ - -int disorder_eclient_resolve(disorder_eclient *c, - disorder_eclient_string_response *completed, - const char *track, - void *v); -/* Resolve aliases */ - int disorder_eclient_log(disorder_eclient *c, const disorder_eclient_log_callbacks *callbacks, void *v); /* Make this a log client (forever - it automatically becomes one again upon * reconnection) */ -int disorder_eclient_get(disorder_eclient *c, - disorder_eclient_string_response *completed, - const char *track, const char *pref, - void *v); -int disorder_eclient_set(disorder_eclient *c, - disorder_eclient_no_response *completed, - const char *track, const char *pref, - const char *value, - void *v); -int disorder_eclient_unset(disorder_eclient *c, - disorder_eclient_no_response *completed, - const char *track, const char *pref, - void *v); -/* Get/set preference values */ - -int disorder_eclient_search(disorder_eclient *c, - disorder_eclient_list_response *completed, - const char *terms, - void *v); - -int disorder_eclient_nop(disorder_eclient *c, - disorder_eclient_no_response *completed, - void *v); - -int disorder_eclient_new_tracks(disorder_eclient *c, - disorder_eclient_list_response *completed, - int max, - void *v); - int disorder_eclient_rtp_address(disorder_eclient *c, disorder_eclient_list_response *completed, void *v); -int disorder_eclient_users(disorder_eclient *c, - disorder_eclient_list_response *completed, - void *v); -int disorder_eclient_deluser(disorder_eclient *c, - disorder_eclient_no_response *completed, - const char *user, - void *v); -int disorder_eclient_userinfo(disorder_eclient *c, - disorder_eclient_string_response *completed, - const char *user, - const char *property, - void *v); -int disorder_eclient_edituser(disorder_eclient *c, - disorder_eclient_no_response *completed, - const char *user, - const char *property, - const char *value, - void *v); -int disorder_eclient_adduser(disorder_eclient *c, - disorder_eclient_no_response *completed, - const char *user, - const char *password, - const char *rights, - void *v); +void disorder_eclient_enable_connect(disorder_eclient *c); +void disorder_eclient_disable_connect(disorder_eclient *c); + +#include "eclient-stubs.h" #endif