6 #include <mpd/client.h>
12 struct mpdclient_playlist playlist
;
14 struct mpd_connection
*connection
;
17 * If this object is non-NULL, it tracks idle events. It is
18 * automatically called by mpdclient_get_connection() and
19 * mpdclient_put_connection(). It is not created by the
20 * mpdclient library; the user of this library has to
21 * initialize it. However, it is freed when the MPD
22 * connection is closed.
24 struct mpd_glib_source
*source
;
27 * This attribute is true when the connection is currently in
28 * "idle" mode, and the #mpd_glib_source waits for an event.
32 struct mpd_status
*status
;
33 const struct mpd_song
*song
;
39 * A bit mask of idle events occurred since the last update.
44 /** functions ***************************************************************/
47 mpdclient_handle_error(struct mpdclient
*c
);
52 void mpdclient_free(struct mpdclient
*c
);
55 mpdclient_is_connected(const struct mpdclient
*c
)
57 return c
->connection
!= NULL
;
62 mpdclient_is_playing(const struct mpdclient
*c
)
64 return c
->status
!= NULL
&&
65 (mpd_status_get_state(c
->status
) == MPD_STATE_PLAY
||
66 mpd_status_get_state(c
->status
) == MPD_STATE_PAUSE
);
69 static inline const struct mpd_song
*
70 mpdclient_get_current_song(const struct mpdclient
*c
)
72 return c
->song
!= NULL
&& mpdclient_is_playing(c
)
78 mpdclient_connect(struct mpdclient
*c
, const gchar
*host
, gint port
,
79 unsigned timeout_ms
, const gchar
*password
);
82 mpdclient_disconnect(struct mpdclient
*c
);
85 mpdclient_update(struct mpdclient
*c
);
87 struct mpd_connection
*
88 mpdclient_get_connection(struct mpdclient
*c
);
91 mpdclient_put_connection(struct mpdclient
*c
);
94 * To be implemented by the application: mpdclient.c calls this to
95 * display an error message.
98 mpdclient_ui_error(const char *message
);
100 /*** MPD Commands **********************************************************/
103 mpdclient_cmd_crop(struct mpdclient
*c
);
106 mpdclient_cmd_clear(struct mpdclient
*c
);
109 mpdclient_cmd_volume(struct mpdclient
*c
, gint value
);
112 mpdclient_cmd_volume_up(struct mpdclient
*c
);
115 mpdclient_cmd_volume_down(struct mpdclient
*c
);
118 mpdclient_cmd_add_path(struct mpdclient
*c
, const gchar
*path
);
121 mpdclient_cmd_add(struct mpdclient
*c
, const struct mpd_song
*song
);
124 mpdclient_cmd_delete(struct mpdclient
*c
, gint index
);
127 mpdclient_cmd_delete_range(struct mpdclient
*c
, unsigned start
, unsigned end
);
130 mpdclient_cmd_move(struct mpdclient
*c
, unsigned dest
, unsigned src
);
132 /*** playlist functions **************************************************/
134 /* update the complete playlist */
136 mpdclient_playlist_update(struct mpdclient
*c
);
138 /* get playlist changes */
140 mpdclient_playlist_update_changes(struct mpdclient
*c
);
142 /* add all songs in filelist to the playlist */
144 mpdclient_filelist_add_all(struct mpdclient
*c
, struct filelist
*fl
);
146 /* sort by list-format */
147 gint
compare_filelistentry_format(gconstpointer filelist_entry1
, gconstpointer filelist_entry2
);