X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/00e0c65285bf2e4c345f32bad3ee6b9f72c5c88a..7e9608832e6d7f5be6dc176295b3a4c0507444e6:/disobedience/log.c diff --git a/disobedience/log.c b/disobedience/log.c index affa449..f1c4f79 100644 --- a/disobedience/log.c +++ b/disobedience/log.c @@ -2,20 +2,18 @@ * This file is part of DisOrder. * Copyright (C) 2006, 2007 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 disobedience/log.c * @brief State monitoring @@ -42,22 +40,35 @@ static void log_scratched(void *v, const char *track, const char *user); static void log_state(void *v, unsigned long state); static void log_volume(void *v, int l, int r); static void log_rescanned(void *v); +static void log_rights_changed(void *v, rights_type r); +static void log_adopted(void *v, const char *id, const char *user); +static void log_playlist_created(void *v, + const char *playlist, const char *sharing); +static void log_playlist_modified(void *v, + const char *playlist, const char *sharing); +static void log_playlist_deleted(void *v, + const char *playlist); /** @brief Callbacks for server state monitoring */ const disorder_eclient_log_callbacks log_callbacks = { - log_connected, - log_completed, - log_failed, - log_moved, - log_playing, - log_queue, - log_recent_added, - log_recent_removed, - log_removed, - log_scratched, - log_state, - log_volume, - log_rescanned + .connected = log_connected, + .completed = log_completed, + .failed = log_failed, + .moved = log_moved, + .playing = log_playing, + .queue = log_queue, + .recent_added = log_recent_added, + .recent_removed = log_recent_removed, + .removed = log_removed, + .scratched = log_scratched, + .state = log_state, + .volume = log_volume, + .rescanned = log_rescanned, + .rights_changed = log_rights_changed, + .adopted = log_adopted, + .playlist_created = log_playlist_created, + .playlist_modified = log_playlist_modified, + .playlist_deleted = log_playlist_deleted, }; /** @brief Update everything */ @@ -149,6 +160,7 @@ static const struct { { DISORDER_RANDOM_ENABLED, "random-changed" }, { DISORDER_TRACK_PAUSED, "pause-changed" }, { DISORDER_PLAYING, "playing-changed" }, + { DISORDER_CONNECTED, "connected-changed" }, }; #define NSTATE_EVENTS (sizeof state_events / sizeof *state_events) @@ -192,6 +204,39 @@ static void log_rescanned(void attribute((unused)) *v) { event_raise("rescan-complete", 0); } +/** @brief Called when our rights change */ +static void log_rights_changed(void attribute((unused)) *v, + rights_type new_rights) { + ++suppress_actions; + last_rights = new_rights; + event_raise("rights-changed", 0); + --suppress_actions; +} + +/** @brief Called when a track is adopted */ +static void log_adopted(void attribute((unused)) *v, + const char attribute((unused)) *id, + const char attribute((unused)) *who) { + event_raise("queue-changed", 0); +} + +static void log_playlist_created(void attribute((unused)) *v, + const char *playlist, + const char attribute((unused)) *sharing) { + event_raise("playlist-created", (void *)playlist); +} + +static void log_playlist_modified(void attribute((unused)) *v, + const char *playlist, + const char attribute((unused)) *sharing) { + event_raise("playlist-modified", (void *)playlist); +} + +static void log_playlist_deleted(void attribute((unused)) *v, + const char *playlist) { + event_raise("playlist-deleted", (void *)playlist); +} + /* Local Variables: c-basic-offset:2