6 #include <mpd/client.h>
12 struct mpdclient_playlist playlist
;
14 struct mpd_connection
*connection
;
17 * This attribute is incremented whenever the connection changes
18 * (i.e. on disconnection and (re-)connection).
20 unsigned connection_id
;
23 * If this object is non-NULL, it tracks idle events. It is
24 * automatically called by mpdclient_get_connection() and
25 * mpdclient_put_connection(). It is not created by the
26 * mpdclient library; the user of this library has to
27 * initialize it. However, it is freed when the MPD
28 * connection is closed.
30 struct mpd_glib_source
*source
;
33 * This attribute is true when the connection is currently in
34 * "idle" mode, and the #mpd_glib_source waits for an event.
38 struct mpd_status
*status
;
39 const struct mpd_song
*song
;
45 * A bit mask of idle events occurred since the last update.
52 * all idle events the version of libmpdclient, ncmpc is compiled
55 MPD_IDLE_ALL
= MPD_IDLE_DATABASE
56 | MPD_IDLE_STORED_PLAYLIST
63 #if LIBMPDCLIENT_CHECK_VERSION(2,5,0)
65 | MPD_IDLE_SUBSCRIPTION
70 /** functions ***************************************************************/
73 mpdclient_handle_error(struct mpdclient
*c
);
76 mpdclient_finish_command(struct mpdclient
*c
)
78 return mpd_response_finish(c
->connection
)
79 ? true : mpdclient_handle_error(c
);
85 void mpdclient_free(struct mpdclient
*c
);
89 mpdclient_is_connected(const struct mpdclient
*c
)
91 return c
->connection
!= NULL
;
96 mpdclient_is_playing(const struct mpdclient
*c
)
98 return c
->status
!= NULL
&&
99 (mpd_status_get_state(c
->status
) == MPD_STATE_PLAY
||
100 mpd_status_get_state(c
->status
) == MPD_STATE_PAUSE
);
104 static inline const struct mpd_song
*
105 mpdclient_get_current_song(const struct mpdclient
*c
)
107 return c
->song
!= NULL
&& mpdclient_is_playing(c
)
113 mpdclient_connect(struct mpdclient
*c
, const gchar
*host
, gint port
,
114 unsigned timeout_ms
, const gchar
*password
);
117 mpdclient_disconnect(struct mpdclient
*c
);
120 mpdclient_update(struct mpdclient
*c
);
122 struct mpd_connection
*
123 mpdclient_get_connection(struct mpdclient
*c
);
126 mpdclient_put_connection(struct mpdclient
*c
);
129 * To be implemented by the application: mpdclient.c calls this to
130 * display an error message.
133 mpdclient_ui_error(const char *message
);
135 /*** MPD Commands **********************************************************/
138 mpdclient_cmd_crop(struct mpdclient
*c
);
141 mpdclient_cmd_clear(struct mpdclient
*c
);
144 mpdclient_cmd_volume(struct mpdclient
*c
, gint value
);
147 mpdclient_cmd_volume_up(struct mpdclient
*c
);
150 mpdclient_cmd_volume_down(struct mpdclient
*c
);
153 mpdclient_cmd_add_path(struct mpdclient
*c
, const gchar
*path
);
156 mpdclient_cmd_add(struct mpdclient
*c
, const struct mpd_song
*song
);
159 mpdclient_cmd_delete(struct mpdclient
*c
, gint index
);
162 mpdclient_cmd_delete_range(struct mpdclient
*c
, unsigned start
, unsigned end
);
165 mpdclient_cmd_move(struct mpdclient
*c
, unsigned dest
, unsigned src
);
167 #if LIBMPDCLIENT_CHECK_VERSION(2,5,0)
169 mpdclient_cmd_subscribe(struct mpdclient
*c
, const char *channel
);
172 mpdclient_cmd_unsubscribe(struct mpdclient
*c
, const char *channel
);
175 mpdclient_cmd_send_message(struct mpdclient
*c
, const char *channel
,
179 mpdclient_send_read_messages(struct mpdclient
*c
);
182 mpdclient_recv_message(struct mpdclient
*c
);
185 /*** playlist functions **************************************************/
187 /* update the complete playlist */
189 mpdclient_playlist_update(struct mpdclient
*c
);
191 /* get playlist changes */
193 mpdclient_playlist_update_changes(struct mpdclient
*c
);
195 /* add all songs in filelist to the playlist */
197 mpdclient_filelist_add_all(struct mpdclient
*c
, struct filelist
*fl
);
199 /* sort by list-format */
200 gint
compare_filelistentry_format(gconstpointer filelist_entry1
, gconstpointer filelist_entry2
);