Code

mpdclient: removed the "need_update" flag
[ncmpc.git] / src / mpdclient.h
1 #ifndef MPDCLIENT_H
2 #define MPDCLIENT_H
4 #include "playlist.h"
6 #include <mpd/tag.h>
8 struct filelist;
10 struct mpdclient {
11         /* playlist */
12         struct mpdclient_playlist playlist;
14         /* Callbacks */
15         GList *error_callbacks;
16         GList *playlist_callbacks;
17         GList *browse_callbacks;
19         struct mpd_connection *connection;
20         struct mpd_status *status;
21         struct mpd_song *song;
23         int volume;
24         unsigned updatingdb;
25 };
27 /** functions ***************************************************************/
29 gint
30 mpdclient_finish_command(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 gint mpdclient_connect(struct mpdclient *c, const gchar *host, gint port,
44                        gfloat timeout_, const gchar *password);
45 gint mpdclient_disconnect(struct mpdclient *c);
46 gint mpdclient_update(struct mpdclient *c);
49 /*** MPD Commands  **********************************************************/
50 gint mpdclient_cmd_play(struct mpdclient *c, gint index);
51 gint mpdclient_cmd_pause(struct mpdclient *c, gint value);
52 gint
53 mpdclient_cmd_crop(struct mpdclient *c);
54 gint mpdclient_cmd_stop(struct mpdclient *c);
55 gint mpdclient_cmd_next(struct mpdclient *c);
56 gint mpdclient_cmd_prev(struct mpdclient *c);
57 gint mpdclient_cmd_seek(struct mpdclient *c, gint id, gint pos);
58 gint mpdclient_cmd_shuffle(struct mpdclient *c);
59 gint mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end);
60 gint mpdclient_cmd_clear(struct mpdclient *c);
61 gint mpdclient_cmd_repeat(struct mpdclient *c, gint value);
62 gint mpdclient_cmd_random(struct mpdclient *c, gint value);
63 gint mpdclient_cmd_single(struct mpdclient *c, gint value);
64 gint mpdclient_cmd_consume(struct mpdclient *c, gint value);
65 gint mpdclient_cmd_crossfade(struct mpdclient *c, gint value);
66 gint mpdclient_cmd_db_update(struct mpdclient *c, const gchar *path);
67 gint mpdclient_cmd_volume(struct mpdclient *c, gint value);
68 gint mpdclient_cmd_volume_up(struct mpdclient *c);
69 gint mpdclient_cmd_volume_down(struct mpdclient *c);
70 gint mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path);
72 gint mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song);
73 gint mpdclient_cmd_delete(struct mpdclient *c, gint index);
74 gint mpdclient_cmd_move(struct mpdclient *c, gint old_index, gint new_index);
76 gint mpdclient_cmd_save_playlist(struct mpdclient *c, const gchar *filename);
77 gint mpdclient_cmd_load_playlist(struct mpdclient *c, const gchar *filename_utf8);
78 gint mpdclient_cmd_delete_playlist(struct mpdclient *c, const gchar *filename_utf8);
80 /* list functions */
81 GList *mpdclient_get_artists(struct mpdclient *c);
82 GList *mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8);
85 /*** error callbacks *****************************************************/
87 #define IS_ACK_ERROR(n)       (n & MPD_ERROR_ACK)
88 #define GET_ACK_ERROR_CODE(n) ((n & 0xFF00) >> 8)
90 typedef void (*mpdc_error_cb_t) (struct mpdclient *c, gint error, const gchar *msg);
92 void mpdclient_install_error_callback(struct mpdclient *c, mpdc_error_cb_t cb);
93 void mpdclient_remove_error_callback(struct mpdclient *c, mpdc_error_cb_t cb);
95 /*** playlist functions  **************************************************/
97 /* update the complete playlist */
98 gint mpdclient_playlist_update(struct mpdclient *c);
100 /* get playlist changes */
101 gint mpdclient_playlist_update_changes(struct mpdclient *c);
104 /*** mpdclient playlist callbacks *****************************************/
106 #define PLAYLIST_EVENT_UPDATED     0x01
107 #define PLAYLIST_EVENT_CLEAR       0x02
108 #define PLAYLIST_EVENT_DELETE      0x03
109 #define PLAYLIST_EVENT_ADD         0x04
110 #define PLAYLIST_EVENT_MOVE        0x05
113 typedef void (*mpdc_list_cb_t) (struct mpdclient *c, int event, gpointer data);
115 /* install a playlist callback function */
116 void mpdclient_install_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb);
118 /* remove a playlist callback function */
119 void mpdclient_remove_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb);
122 /* issue a playlist callback */
123 void mpdclient_playlist_callback(struct mpdclient *c, int event, gpointer data);
126 /*** filelist functions  ***************************************************/
128 struct filelist *
129 mpdclient_filelist_get(struct mpdclient *c, const gchar *path);
131 struct filelist *
132 mpdclient_filelist_search(struct mpdclient *c, int exact_match,
133                           enum mpd_tag_type tag,
134                           gchar *filter_utf8);
136 /* add all songs in filelist to the playlist */
137 int
138 mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl);
140 /*** mpdclient browse callbacks ********************************************/
142 #define BROWSE_DB_UPDATED          0x01
143 #define BROWSE_PLAYLIST_SAVED      0x02
144 #define BROWSE_PLAYLIST_DELETED    0x03
147 /* install a playlist callback function */
148 void mpdclient_install_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb);
150 /* remove a playlist callback function */
151 void mpdclient_remove_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb);
154 /* issue a playlist callback */
155 void mpdclient_browse_callback(struct mpdclient *c, int event, gpointer data);
157 /* sort by list-format */
158 gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);
160 #endif