Code

mpdclient: automatically re-enter idle mode, eliminate mpdclient_put_connection()
[ncmpc.git] / src / mpdclient.h
index 84878466d22e7a08bc40f42330502745f4f048e9..bac33383ab1bc33ccb34a614b5091fda8080f2cf 100644 (file)
@@ -9,6 +9,13 @@
 struct filelist;
 
 struct mpdclient {
+       const char *host;
+       unsigned port;
+
+       unsigned timeout_ms;
+
+       const char *password;
+
        /* playlist */
        struct mpdclient_playlist playlist;
 
@@ -16,13 +23,19 @@ struct mpdclient {
 
        /**
         * Tracks idle events.  It is automatically called by
-        * mpdclient_get_connection() and mpdclient_put_connection().
+        * mpdclient_get_connection().
         */
        struct mpd_glib_source *source;
 
        struct mpd_status *status;
        const struct mpd_song *song;
 
+       /**
+        * The GLib source id which re-enters MPD idle mode before the
+        * next main loop interation.
+        */
+       unsigned enter_idle_source_id;
+
        /**
         * This attribute is incremented whenever the connection changes
         * (i.e. on disconnection and (re-)connection).
@@ -79,7 +92,8 @@ mpdclient_finish_command(struct mpdclient *c)
 }
 
 struct mpdclient *
-mpdclient_new(void);
+mpdclient_new(const gchar *host, unsigned port,
+             unsigned timeout_ms, const gchar *password);
 
 void mpdclient_free(struct mpdclient *c);
 
@@ -120,8 +134,7 @@ mpdclient_get_current_song(const struct mpdclient *c)
 }
 
 bool
-mpdclient_connect(struct mpdclient *c, const gchar *host, gint port,
-                 unsigned timeout_ms, const gchar *password);
+mpdclient_connect(struct mpdclient *c);
 
 void
 mpdclient_disconnect(struct mpdclient *c);
@@ -132,9 +145,6 @@ mpdclient_update(struct mpdclient *c);
 struct mpd_connection *
 mpdclient_get_connection(struct mpdclient *c);
 
-void
-mpdclient_put_connection(struct mpdclient *c);
-
 /*** MPD Commands  **********************************************************/
 
 bool