summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e0cf698)
raw | patch | inline | side by side (parent: e0cf698)
author | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 18:15:59 +0000 (20:15 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 18:15:59 +0000 (20:15 +0200) |
mpdclient_update() sets the "events" property after it has detected
changes. This helps us eliminate the callback functions, and is a
good preparation for the real "idle" commandd.
changes. This helps us eliminate the callback functions, and is a
good preparation for the real "idle" commandd.
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 3874d112a1832136a2ce468113a7d659304a8866..a03b707d4f47a33809bd4a874ab646573bebe240 100644 (file)
--- a/src/main.c
+++ b/src/main.c
screen_update(mpd);
+ mpd->events = 0;
+
return GPOINTER_TO_INT(data);
}
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 152942e011b97ea79d3ffb48fad82e9a1f6d8202..5734856636c1fbf0766d9fe6d353c56386b43561 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
c = g_new0(struct mpdclient, 1);
playlist_init(&c->playlist);
c->volume = -1;
+ c->events = 0;
return c;
}
if (MPD_ERROR(c))
return false;
+ /* always announce these options as long as we don't have real
+ "idle" support */
+ c->events |= MPD_IDLE_PLAYER|MPD_IDLE_OPTIONS;
+
/* free the old status */
if (c->status)
mpd_status_free(c->status);
if (c->status == NULL)
return mpdclient_handle_error(c) == 0;
+ if (c->update_id != mpd_status_get_update_id(c->status)) {
+ c->events |= MPD_IDLE_UPDATE;
+
+ if (c->update_id > 0)
+ 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))
+ c->events |= MPD_IDLE_MIXER;
+
c->volume = mpd_status_get_volume(c->status);
/* check if the playlist needs an update */
if (c->playlist.id != mpd_status_get_queue_version(c->status)) {
+ c->events |= MPD_IDLE_PLAYLIST;
+
if (!playlist_is_empty(&c->playlist))
retval = mpdclient_playlist_update_changes(c);
else
return -1;
mpd_send_save(c->connection, filename_utf8);
- if ((retval = mpdclient_finish_command(c)) == 0)
+ if ((retval = mpdclient_finish_command(c)) == 0) {
mpdclient_browse_callback(c, BROWSE_PLAYLIST_SAVED, NULL);
+ c->events |= MPD_IDLE_STORED_PLAYLIST;
+ }
+
return retval;
}
return -1;
mpd_send_rm(c->connection, filename_utf8);
- if ((retval = mpdclient_finish_command(c)) == 0)
+ if ((retval = mpdclient_finish_command(c)) == 0) {
mpdclient_browse_callback(c, BROWSE_PLAYLIST_DELETED, NULL);
+ c->events |= MPD_IDLE_STORED_PLAYLIST;
+ }
+
return retval;
}
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 41890daca65a8ffdcb196cd7ce4be2ad2a2a8d26..2e597d19407f1ce7b54f035799bc3017979601bb 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
int volume;
unsigned update_id;
+
+ /**
+ * A bit mask of idle events occured since the last update.
+ */
+ enum mpd_idle events;
};
/** functions ***************************************************************/