Code

include "config.h" in all files using HAVE_* defines
[ncmpc.git] / src / mpdclient.h
index d66bf5b1ae5ba56f701f1bce6ec7bbc6d5d76f18..a93db74baf135392acba5ff418bc3f18d2dffc6d 100644 (file)
@@ -12,6 +12,23 @@ struct mpdclient {
        struct mpdclient_playlist playlist;
 
        struct mpd_connection *connection;
+
+       /**
+        * If this object is non-NULL, it tracks idle events.  It is
+        * automatically called by mpdclient_get_connection() and
+        * mpdclient_put_connection().  It is not created by the
+        * mpdclient library; the user of this library has to
+        * initialize it.  However, it is freed when the MPD
+        * connection is closed.
+        */
+       struct mpd_glib_source *source;
+
+       /**
+        * This attribute is true when the connection is currently in
+        * "idle" mode, and the #mpd_glib_source waits for an event.
+        */
+       bool idle;
+
        struct mpd_status *status;
        const struct mpd_song *song;
 
@@ -40,12 +57,19 @@ mpdclient_is_connected(const struct mpdclient *c)
        return c->connection != NULL;
 }
 
+G_GNUC_PURE
+static inline bool
+mpdclient_is_playing(const struct mpdclient *c)
+{
+       return c->status != NULL &&
+               (mpd_status_get_state(c->status) == MPD_STATE_PLAY ||
+                mpd_status_get_state(c->status) == MPD_STATE_PAUSE);
+}
+
 static inline const struct mpd_song *
 mpdclient_get_current_song(const struct mpdclient *c)
 {
-       return c->song != NULL && c->status != NULL &&
-               (mpd_status_get_state(c->status) == MPD_STATE_PLAY ||
-                mpd_status_get_state(c->status) == MPD_STATE_PAUSE)
+       return c->song != NULL && mpdclient_is_playing(c)
                ? c->song
                : NULL;
 }
@@ -60,6 +84,12 @@ mpdclient_disconnect(struct mpdclient *c);
 bool
 mpdclient_update(struct mpdclient *c);
 
+struct mpd_connection *
+mpdclient_get_connection(struct mpdclient *c);
+
+void
+mpdclient_put_connection(struct mpdclient *c);
+
 /**
  * To be implemented by the application: mpdclient.c calls this to
  * display an error message.
@@ -69,9 +99,6 @@ mpdclient_ui_error(const char *message);
 
 /*** MPD Commands  **********************************************************/
 
-bool
-mpdclient_cmd_play(struct mpdclient *c, gint index);
-
 bool
 mpdclient_cmd_crop(struct mpdclient *c);
 
@@ -100,11 +127,7 @@ bool
 mpdclient_cmd_delete_range(struct mpdclient *c, unsigned start, unsigned end);
 
 bool
-mpdclient_cmd_move(struct mpdclient *c, gint old_index, gint new_index);
-
-/* list functions */
-GList *mpdclient_get_artists(struct mpdclient *c);
-GList *mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8);
+mpdclient_cmd_move(struct mpdclient *c, unsigned dest, unsigned src);
 
 /*** playlist functions  **************************************************/
 
@@ -116,17 +139,6 @@ mpdclient_playlist_update(struct mpdclient *c);
 bool
 mpdclient_playlist_update_changes(struct mpdclient *c);
 
-
-/*** filelist functions  ***************************************************/
-
-struct filelist *
-mpdclient_filelist_get(struct mpdclient *c, const gchar *path);
-
-struct filelist *
-mpdclient_filelist_search(struct mpdclient *c, int exact_match,
-                         enum mpd_tag_type tag,
-                         gchar *filter_utf8);
-
 /* add all songs in filelist to the playlist */
 bool
 mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl);