summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5097800)
raw | patch | inline | side by side (parent: 5097800)
author | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 18:29:32 +0000 (20:29 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 18:29:32 +0000 (20:29 +0200) |
All users have switched to mpdclient.events.
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 5734856636c1fbf0766d9fe6d353c56386b43561..e718cd93771bd15d16e2cf9a05241138f4e1edf6 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
mpdclient_playlist_free(&c->playlist);
- g_list_free(c->playlist_callbacks);
- g_list_free(c->browse_callbacks);
g_free(c);
}
c->events |= MPD_IDLE_DATABASE;
}
- if (c->update_id > 0 &&
- c->update_id != mpd_status_get_update_id(c->status))
- mpdclient_browse_callback(c, BROWSE_DB_UPDATED, NULL);
-
c->update_id = mpd_status_get_update_id(c->status);
if (c->volume != mpd_status_get_volume(c->status))
mpd_send_clear(c->connection);
retval = mpdclient_finish_command(c);
- /* call playlist updated callback */
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_CLEAR, NULL);
+
+ if (retval)
+ c->events |= MPD_IDLE_PLAYLIST;
+
return retval;
}
/* increment the playlist id, so we don't retrieve a new playlist */
c->playlist.id++;
- /* call playlist updated callback */
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_ADD, (gpointer) song);
+ c->events |= MPD_IDLE_PLAYLIST;
#endif
return 0;
/* remove the song from the playlist */
playlist_remove_reuse(&c->playlist, idx);
- /* call playlist updated callback */
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_DELETE, (gpointer) song);
+ c->events |= MPD_IDLE_PLAYLIST;
/* remove references to the song */
if (c->song == song)
c->playlist.id++;
#endif
- /* call playlist updated callback */
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_MOVE, (gpointer) &new_index);
+ c->events |= MPD_IDLE_PLAYLIST;
return 0;
}
mpd_send_save(c->connection, filename_utf8);
if ((retval = mpdclient_finish_command(c)) == 0) {
- mpdclient_browse_callback(c, BROWSE_PLAYLIST_SAVED, NULL);
c->events |= MPD_IDLE_STORED_PLAYLIST;
}
@@ -542,68 +534,13 @@ mpdclient_cmd_delete_playlist(struct mpdclient *c, const gchar *filename_utf8)
return -1;
mpd_send_rm(c->connection, filename_utf8);
- if ((retval = mpdclient_finish_command(c)) == 0) {
- mpdclient_browse_callback(c, BROWSE_PLAYLIST_DELETED, NULL);
+ if ((retval = mpdclient_finish_command(c)) == 0)
c->events |= MPD_IDLE_STORED_PLAYLIST;
- }
return retval;
}
-/****************************************************************************/
-/*** Callback management functions ******************************************/
-/****************************************************************************/
-
-static void
-do_list_callbacks(struct mpdclient *c, GList *list, gint event, gpointer data)
-{
- while (list) {
- mpdc_list_cb_t fn = list->data;
-
- fn(c, event, data);
- list = list->next;
- }
-}
-
-void
-mpdclient_playlist_callback(struct mpdclient *c, int event, gpointer data)
-{
- do_list_callbacks(c, c->playlist_callbacks, event, data);
-}
-
-void
-mpdclient_install_playlist_callback(struct mpdclient *c,mpdc_list_cb_t cb)
-{
- c->playlist_callbacks = g_list_append(c->playlist_callbacks, cb);
-}
-
-void
-mpdclient_remove_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb)
-{
- c->playlist_callbacks = g_list_remove(c->playlist_callbacks, cb);
-}
-
-void
-mpdclient_browse_callback(struct mpdclient *c, int event, gpointer data)
-{
- do_list_callbacks(c, c->browse_callbacks, event, data);
-}
-
-
-void
-mpdclient_install_browse_callback(struct mpdclient *c,mpdc_list_cb_t cb)
-{
- c->browse_callbacks = g_list_append(c->browse_callbacks, cb);
-}
-
-void
-mpdclient_remove_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb)
-{
- c->browse_callbacks = g_list_remove(c->browse_callbacks, cb);
-}
-
-
/****************************************************************************/
/*** Playlist management functions ******************************************/
/****************************************************************************/
c->playlist.id = mpd_status_get_queue_version(c->status);
c->song = NULL;
- /* call playlist updated callbacks */
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_UPDATED, NULL);
-
return mpdclient_finish_command(c) == 0;
}
c->song = NULL;
c->playlist.id = mpd_status_get_queue_version(c->status);
- mpdclient_playlist_callback(c, PLAYLIST_EVENT_UPDATED, NULL);
-
return mpdclient_finish_command(c) == 0;
}
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 2e597d19407f1ce7b54f035799bc3017979601bb..1b83feb01d2c8e573110bf973ce916a378331d90 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
/* playlist */
struct mpdclient_playlist playlist;
- /* Callbacks */
- GList *playlist_callbacks;
- GList *browse_callbacks;
-
struct mpd_connection *connection;
struct mpd_status *status;
const struct mpd_song *song;
mpdclient_playlist_update_changes(struct mpdclient *c);
-/*** mpdclient playlist callbacks *****************************************/
-
-#define PLAYLIST_EVENT_UPDATED 0x01
-#define PLAYLIST_EVENT_CLEAR 0x02
-#define PLAYLIST_EVENT_DELETE 0x03
-#define PLAYLIST_EVENT_ADD 0x04
-#define PLAYLIST_EVENT_MOVE 0x05
-
-
-typedef void (*mpdc_list_cb_t) (struct mpdclient *c, int event, gpointer data);
-
-/* install a playlist callback function */
-void mpdclient_install_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb);
-
-/* remove a playlist callback function */
-void mpdclient_remove_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb);
-
-
-/* issue a playlist callback */
-void mpdclient_playlist_callback(struct mpdclient *c, int event, gpointer data);
-
-
/*** filelist functions ***************************************************/
struct filelist *
int
mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl);
-/*** mpdclient browse callbacks ********************************************/
-
-#define BROWSE_DB_UPDATED 0x01
-#define BROWSE_PLAYLIST_SAVED 0x02
-#define BROWSE_PLAYLIST_DELETED 0x03
-
-
-/* install a playlist callback function */
-void mpdclient_install_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb);
-
-/* remove a playlist callback function */
-void mpdclient_remove_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb);
-
-
-/* issue a playlist callback */
-void mpdclient_browse_callback(struct mpdclient *c, int event, gpointer data);
-
/* sort by list-format */
gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);