7 #include <mpd/client.h>
13 struct mpdclient_playlist playlist
;
15 struct mpd_connection
*connection
;
18 * This attribute is incremented whenever the connection changes
19 * (i.e. on disconnection and (re-)connection).
21 unsigned connection_id
;
24 * If this object is non-NULL, it tracks idle events. It is
25 * automatically called by mpdclient_get_connection() and
26 * mpdclient_put_connection(). It is not created by the
27 * mpdclient library; the user of this library has to
28 * initialize it. However, it is freed when the MPD
29 * connection is closed.
31 struct mpd_glib_source
*source
;
34 * This attribute is true when the connection is currently in
35 * "idle" mode, and the #mpd_glib_source waits for an event.
39 struct mpd_status
*status
;
40 const struct mpd_song
*song
;
46 * A bit mask of idle events occurred since the last update.
53 * all idle events the version of libmpdclient, ncmpc is compiled
56 MPD_IDLE_ALL
= MPD_IDLE_DATABASE
57 | MPD_IDLE_STORED_PLAYLIST
64 #if LIBMPDCLIENT_CHECK_VERSION(2,5,0)
66 | MPD_IDLE_SUBSCRIPTION
71 /** functions ***************************************************************/
74 mpdclient_handle_error(struct mpdclient
*c
);
77 mpdclient_finish_command(struct mpdclient
*c
)
79 return mpd_response_finish(c
->connection
)
80 ? true : mpdclient_handle_error(c
);
86 void mpdclient_free(struct mpdclient
*c
);
90 mpdclient_is_connected(const struct mpdclient
*c
)
92 return c
->connection
!= NULL
;
97 mpdclient_is_playing(const struct mpdclient
*c
)
99 return c
->status
!= NULL
&&
100 (mpd_status_get_state(c
->status
) == MPD_STATE_PLAY
||
101 mpd_status_get_state(c
->status
) == MPD_STATE_PAUSE
);
105 static inline const struct mpd_song
*
106 mpdclient_get_current_song(const struct mpdclient
*c
)
108 return c
->song
!= NULL
&& mpdclient_is_playing(c
)
114 mpdclient_connect(struct mpdclient
*c
, const gchar
*host
, gint port
,
115 unsigned timeout_ms
, const gchar
*password
);
118 mpdclient_disconnect(struct mpdclient
*c
);
121 mpdclient_update(struct mpdclient
*c
);
123 struct mpd_connection
*
124 mpdclient_get_connection(struct mpdclient
*c
);
127 mpdclient_put_connection(struct mpdclient
*c
);
130 * To be implemented by the application: mpdclient.c calls this to
131 * display an error message.
134 mpdclient_ui_error(const char *message
);
136 /*** MPD Commands **********************************************************/
139 mpdclient_cmd_crop(struct mpdclient
*c
);
142 mpdclient_cmd_clear(struct mpdclient
*c
);
145 mpdclient_cmd_volume(struct mpdclient
*c
, gint value
);
148 mpdclient_cmd_volume_up(struct mpdclient
*c
);
151 mpdclient_cmd_volume_down(struct mpdclient
*c
);
154 mpdclient_cmd_add_path(struct mpdclient
*c
, const gchar
*path
);
157 mpdclient_cmd_add(struct mpdclient
*c
, const struct mpd_song
*song
);
160 mpdclient_cmd_delete(struct mpdclient
*c
, gint index
);
163 mpdclient_cmd_delete_range(struct mpdclient
*c
, unsigned start
, unsigned end
);
166 mpdclient_cmd_move(struct mpdclient
*c
, unsigned dest
, unsigned src
);
168 #if LIBMPDCLIENT_CHECK_VERSION(2,5,0)
170 mpdclient_cmd_subscribe(struct mpdclient
*c
, const char *channel
);
173 mpdclient_cmd_unsubscribe(struct mpdclient
*c
, const char *channel
);
176 mpdclient_cmd_send_message(struct mpdclient
*c
, const char *channel
,
180 mpdclient_send_read_messages(struct mpdclient
*c
);
183 mpdclient_recv_message(struct mpdclient
*c
);
186 /*** playlist functions **************************************************/
188 /* update the complete playlist */
190 mpdclient_playlist_update(struct mpdclient
*c
);
192 /* get playlist changes */
194 mpdclient_playlist_update_changes(struct mpdclient
*c
);
196 /* add all songs in filelist to the playlist */
198 mpdclient_filelist_add_all(struct mpdclient
*c
, struct filelist
*fl
);
200 /* sort by song format */
202 gint
compare_filelistentry_format(gconstpointer filelist_entry1
,
203 gconstpointer filelist_entry2
,
204 const char *song_format
);