Code

mpdclient: removed all callbacks
[ncmpc.git] / src / mpdclient.h
1 #ifndef MPDCLIENT_H
2 #define MPDCLIENT_H
4 #include "playlist.h"
6 #include <mpd/client.h>
8 struct filelist;
10 struct mpdclient {
11         /* playlist */
12         struct mpdclient_playlist playlist;
14         struct mpd_connection *connection;
15         struct mpd_status *status;
16         const struct mpd_song *song;
18         int volume;
19         unsigned update_id;
21         /**
22          * A bit mask of idle events occured since the last update.
23          */
24         enum mpd_idle events;
25 };
27 /** functions ***************************************************************/
29 gint
30 mpdclient_handle_error(struct mpdclient *c);
32 struct mpdclient *
33 mpdclient_new(void);
35 void mpdclient_free(struct mpdclient *c);
37 static inline bool
38 mpdclient_is_connected(const struct mpdclient *c)
39 {
40         return c->connection != NULL;
41 }
43 bool
44 mpdclient_connect(struct mpdclient *c, const gchar *host, gint port,
45                   gfloat timeout_, const gchar *password);
47 void
48 mpdclient_disconnect(struct mpdclient *c);
50 bool
51 mpdclient_update(struct mpdclient *c);
53 /**
54  * To be implemented by the application: mpdclient.c calls this to
55  * display an error message.
56  */
57 void
58 mpdclient_ui_error(const char *message);
60 /*** MPD Commands  **********************************************************/
61 gint mpdclient_cmd_play(struct mpdclient *c, gint index);
62 gint
63 mpdclient_cmd_crop(struct mpdclient *c);
64 gint mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end);
65 gint mpdclient_cmd_clear(struct mpdclient *c);
66 gint mpdclient_cmd_volume(struct mpdclient *c, gint value);
67 gint mpdclient_cmd_volume_up(struct mpdclient *c);
68 gint mpdclient_cmd_volume_down(struct mpdclient *c);
69 gint mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path);
71 gint mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song);
72 gint mpdclient_cmd_delete(struct mpdclient *c, gint index);
73 gint mpdclient_cmd_move(struct mpdclient *c, gint old_index, gint new_index);
75 gint mpdclient_cmd_save_playlist(struct mpdclient *c, const gchar *filename);
76 gint mpdclient_cmd_load_playlist(struct mpdclient *c, const gchar *filename_utf8);
77 gint mpdclient_cmd_delete_playlist(struct mpdclient *c, const gchar *filename_utf8);
79 /* list functions */
80 GList *mpdclient_get_artists(struct mpdclient *c);
81 GList *mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8);
84 /*** error callbacks *****************************************************/
86 #define GET_ACK_ERROR_CODE(n) ((n & 0xFF00) >> 8)
88 /*** playlist functions  **************************************************/
90 /* update the complete playlist */
91 bool
92 mpdclient_playlist_update(struct mpdclient *c);
94 /* get playlist changes */
95 bool
96 mpdclient_playlist_update_changes(struct mpdclient *c);
99 /*** filelist functions  ***************************************************/
101 struct filelist *
102 mpdclient_filelist_get(struct mpdclient *c, const gchar *path);
104 struct filelist *
105 mpdclient_filelist_search(struct mpdclient *c, int exact_match,
106                           enum mpd_tag_type tag,
107                           gchar *filter_utf8);
109 /* add all songs in filelist to the playlist */
110 int
111 mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl);
113 /* sort by list-format */
114 gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);
116 #endif