8 #include <mpd/client.h>
13 #ifdef ENABLE_ASYNC_CONNECT
14 struct mpd_settings
*settings
;
25 struct mpdclient_playlist playlist
;
27 #ifdef ENABLE_ASYNC_CONNECT
28 struct aconnect
*async_connect
;
31 struct mpd_connection
*connection
;
34 * Tracks idle events. It is automatically called by
35 * mpdclient_get_connection().
37 struct mpd_glib_source
*source
;
39 struct mpd_status
*status
;
40 const struct mpd_song
*song
;
43 * The GLib source id which re-enters MPD idle mode before the
44 * next main loop interation.
46 unsigned enter_idle_source_id
;
49 * This attribute is incremented whenever the connection changes
50 * (i.e. on disconnection and (re-)connection).
52 unsigned connection_id
;
57 * A bit mask of idle events occurred since the last update.
62 * This attribute is true when the connection is currently in
63 * "idle" mode, and the #mpd_glib_source waits for an event.
68 * Is MPD currently playing?
75 * all idle events the version of libmpdclient, ncmpc is compiled
78 MPD_IDLE_ALL
= MPD_IDLE_DATABASE
79 | MPD_IDLE_STORED_PLAYLIST
87 | MPD_IDLE_SUBSCRIPTION
91 /** functions ***************************************************************/
94 mpdclient_handle_error(struct mpdclient
*c
);
97 mpdclient_finish_command(struct mpdclient
*c
)
99 return mpd_response_finish(c
->connection
)
100 ? true : mpdclient_handle_error(c
);
104 mpdclient_new(const gchar
*host
, unsigned port
,
105 unsigned timeout_ms
, const gchar
*password
);
107 void mpdclient_free(struct mpdclient
*c
);
111 mpdclient_is_connected(const struct mpdclient
*c
)
113 return c
->connection
!= NULL
;
117 * Is this object "dead"? i.e. not connected and not currently doing
118 * anything to connect.
122 mpdclient_is_dead(const struct mpdclient
*c
)
124 return c
->connection
== NULL
125 #ifdef ENABLE_ASYNC_CONNECT
126 && c
->async_connect
== NULL
133 mpdclient_is_playing(const struct mpdclient
*c
)
135 return c
->status
!= NULL
&&
136 (mpd_status_get_state(c
->status
) == MPD_STATE_PLAY
||
137 mpd_status_get_state(c
->status
) == MPD_STATE_PAUSE
);
141 static inline const struct mpd_song
*
142 mpdclient_get_current_song(const struct mpdclient
*c
)
144 return c
->song
!= NULL
&& mpdclient_is_playing(c
)
150 mpdclient_connect(struct mpdclient
*c
);
153 mpdclient_disconnect(struct mpdclient
*c
);
156 mpdclient_update(struct mpdclient
*c
);
158 struct mpd_connection
*
159 mpdclient_get_connection(struct mpdclient
*c
);
161 /*** MPD Commands **********************************************************/
164 mpdclient_cmd_crop(struct mpdclient
*c
);
167 mpdclient_cmd_clear(struct mpdclient
*c
);
170 mpdclient_cmd_volume(struct mpdclient
*c
, gint value
);
173 mpdclient_cmd_volume_up(struct mpdclient
*c
);
176 mpdclient_cmd_volume_down(struct mpdclient
*c
);
179 mpdclient_cmd_add_path(struct mpdclient
*c
, const gchar
*path
);
182 mpdclient_cmd_add(struct mpdclient
*c
, const struct mpd_song
*song
);
185 mpdclient_cmd_delete(struct mpdclient
*c
, gint index
);
188 mpdclient_cmd_delete_range(struct mpdclient
*c
, unsigned start
, unsigned end
);
191 mpdclient_cmd_move(struct mpdclient
*c
, unsigned dest
, unsigned src
);
194 mpdclient_cmd_subscribe(struct mpdclient
*c
, const char *channel
);
197 mpdclient_cmd_unsubscribe(struct mpdclient
*c
, const char *channel
);
200 mpdclient_cmd_send_message(struct mpdclient
*c
, const char *channel
,
204 mpdclient_send_read_messages(struct mpdclient
*c
);
207 mpdclient_recv_message(struct mpdclient
*c
);
209 /*** playlist functions **************************************************/
211 /* update the complete playlist */
213 mpdclient_playlist_update(struct mpdclient
*c
);
215 /* get playlist changes */
217 mpdclient_playlist_update_changes(struct mpdclient
*c
);
219 /* add all songs in filelist to the playlist */
221 mpdclient_filelist_add_all(struct mpdclient
*c
, struct filelist
*fl
);