From: Max Kellermann Date: Mon, 28 Sep 2009 15:38:40 +0000 (+0200) Subject: mpdclient: removed the mpdclient_t typedef X-Git-Tag: release-0.16~324 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e87293c67c377130dcda2f5cb4b1ddd06026f551;p=ncmpc.git mpdclient: removed the mpdclient_t typedef Use forward-declared struct instead. This also removes the typedefs mpdclient_filelist_t, mpdclient_filelist_entry_t, mpdclient_playlist_t. --- diff --git a/src/filelist.h b/src/filelist.h index 7904016..0f1f0c0 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -24,15 +24,15 @@ struct mpd_song; -typedef struct filelist_entry { +struct filelist_entry { guint flags; struct mpd_entity *entity; -} filelist_entry_t; +}; -typedef struct filelist { +struct filelist { /* the list */ GPtrArray *entries; -} mpdclient_filelist_t; +}; struct filelist * filelist_new(void); diff --git a/src/main.c b/src/main.c index 9f68adb..8313d01 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,7 @@ static const guint update_interval = 500; static const guint idle_interval = 500; -static mpdclient_t *mpd = NULL; +static struct mpdclient *mpd = NULL; static gboolean connected = FALSE; static GMainLoop *main_loop; static guint reconnect_source_id, idle_source_id, update_source_id; @@ -84,7 +84,7 @@ error_msg(const gchar *msg) } static void -error_callback(G_GNUC_UNUSED mpdclient_t *c, gint error, const gchar *_msg) +error_callback(G_GNUC_UNUSED struct mpdclient *c, gint error, const gchar *_msg) { char *msg = utf8_to_locale(_msg); diff --git a/src/mpdclient.c b/src/mpdclient.c index 86f825f..14e13fc 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -18,6 +18,7 @@ */ #include "mpdclient.h" +#include "filelist.h" #include "screen_utils.h" #include "config.h" #include "options.h" @@ -54,8 +55,8 @@ compare_filelistentry(gconstpointer filelist_entry1, const struct mpd_entity *e1, *e2; int n = 0; - e1 = ((const filelist_entry_t *)filelist_entry1)->entity; - e2 = ((const filelist_entry_t *)filelist_entry2)->entity; + e1 = ((const struct filelist_entry *)filelist_entry1)->entity; + e2 = ((const struct filelist_entry *)filelist_entry2)->entity; if (e1 != NULL && e2 != NULL && mpd_entity_get_type(e1) == mpd_entity_get_type(e2)) { @@ -85,8 +86,8 @@ compare_filelistentry_format(gconstpointer filelist_entry1, char key1[BUFSIZE], key2[BUFSIZE]; int n = 0; - e1 = ((const filelist_entry_t *)filelist_entry1)->entity; - e2 = ((const filelist_entry_t *)filelist_entry2)->entity; + e1 = ((const struct filelist_entry *)filelist_entry1)->entity; + e2 = ((const struct filelist_entry *)filelist_entry2)->entity; if (e1 && e2 && mpd_entity_get_type(e1) == MPD_ENTITY_TYPE_SONG && @@ -102,7 +103,7 @@ compare_filelistentry_format(gconstpointer filelist_entry1, /* Error callbacks */ static gint -error_cb(mpdclient_t *c, gint error, const gchar *msg) +error_cb(struct mpdclient *c, gint error, const gchar *msg) { GList *list = c->error_callbacks; @@ -126,7 +127,7 @@ error_cb(mpdclient_t *c, gint error, const gchar *msg) /****************************************************************************/ static gint -mpdclient_handle_error(mpdclient_t *c) +mpdclient_handle_error(struct mpdclient *c) { enum mpd_error error = mpd_connection_get_error(c->connection); bool is_fatal = error != MPD_ERROR_SERVER; @@ -150,18 +151,18 @@ mpdclient_handle_error(mpdclient_t *c) } gint -mpdclient_finish_command(mpdclient_t *c) +mpdclient_finish_command(struct mpdclient *c) { return mpd_response_finish(c->connection) ? 0 : mpdclient_handle_error(c); } -mpdclient_t * +struct mpdclient * mpdclient_new(void) { - mpdclient_t *c; + struct mpdclient *c; - c = g_malloc0(sizeof(mpdclient_t)); + c = g_new0(struct mpdclient, 1); playlist_init(&c->playlist); c->volume = MPD_STATUS_NO_VOLUME; @@ -169,7 +170,7 @@ mpdclient_new(void) } void -mpdclient_free(mpdclient_t *c) +mpdclient_free(struct mpdclient *c) { mpdclient_disconnect(c); @@ -182,7 +183,7 @@ mpdclient_free(mpdclient_t *c) } gint -mpdclient_disconnect(mpdclient_t *c) +mpdclient_disconnect(struct mpdclient *c) { if (c->connection) mpd_connection_free(c->connection); @@ -201,7 +202,7 @@ mpdclient_disconnect(mpdclient_t *c) } gint -mpdclient_connect(mpdclient_t *c, +mpdclient_connect(struct mpdclient *c, const gchar *host, gint port, gfloat _timeout, @@ -240,7 +241,7 @@ mpdclient_connect(mpdclient_t *c, } gint -mpdclient_update(mpdclient_t *c) +mpdclient_update(struct mpdclient *c) { gint retval = 0; @@ -289,7 +290,7 @@ mpdclient_update(mpdclient_t *c) /****************************************************************************/ gint -mpdclient_cmd_play(mpdclient_t *c, gint idx) +mpdclient_cmd_play(struct mpdclient *c, gint idx) { #ifdef ENABLE_SONG_ID struct mpd_song *song = playlist_get_song(c, idx); @@ -312,7 +313,7 @@ mpdclient_cmd_play(mpdclient_t *c, gint idx) } gint -mpdclient_cmd_pause(mpdclient_t *c, gint value) +mpdclient_cmd_pause(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -322,7 +323,7 @@ mpdclient_cmd_pause(mpdclient_t *c, gint value) } gint -mpdclient_cmd_crop(mpdclient_t *c) +mpdclient_cmd_crop(struct mpdclient *c) { struct mpd_status *status; bool playing; @@ -357,7 +358,7 @@ mpdclient_cmd_crop(mpdclient_t *c) } gint -mpdclient_cmd_stop(mpdclient_t *c) +mpdclient_cmd_stop(struct mpdclient *c) { if (MPD_ERROR(c)) return -1; @@ -367,7 +368,7 @@ mpdclient_cmd_stop(mpdclient_t *c) } gint -mpdclient_cmd_next(mpdclient_t *c) +mpdclient_cmd_next(struct mpdclient *c) { if (MPD_ERROR(c)) return -1; @@ -378,7 +379,7 @@ mpdclient_cmd_next(mpdclient_t *c) } gint -mpdclient_cmd_prev(mpdclient_t *c) +mpdclient_cmd_prev(struct mpdclient *c) { if (MPD_ERROR(c)) return -1; @@ -389,7 +390,7 @@ mpdclient_cmd_prev(mpdclient_t *c) } gint -mpdclient_cmd_seek(mpdclient_t *c, gint id, gint pos) +mpdclient_cmd_seek(struct mpdclient *c, gint id, gint pos) { if (MPD_ERROR(c)) return -1; @@ -399,7 +400,7 @@ mpdclient_cmd_seek(mpdclient_t *c, gint id, gint pos) } gint -mpdclient_cmd_shuffle(mpdclient_t *c) +mpdclient_cmd_shuffle(struct mpdclient *c) { if (MPD_ERROR(c)) return -1; @@ -410,7 +411,7 @@ mpdclient_cmd_shuffle(mpdclient_t *c) } gint -mpdclient_cmd_shuffle_range(mpdclient_t *c, guint start, guint end) +mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end) { mpd_send_shuffle_range(c->connection, start, end); c->need_update = TRUE; @@ -418,7 +419,7 @@ mpdclient_cmd_shuffle_range(mpdclient_t *c, guint start, guint end) } gint -mpdclient_cmd_clear(mpdclient_t *c) +mpdclient_cmd_clear(struct mpdclient *c) { gint retval = 0; @@ -434,7 +435,7 @@ mpdclient_cmd_clear(mpdclient_t *c) } gint -mpdclient_cmd_repeat(mpdclient_t *c, gint value) +mpdclient_cmd_repeat(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -444,7 +445,7 @@ mpdclient_cmd_repeat(mpdclient_t *c, gint value) } gint -mpdclient_cmd_random(mpdclient_t *c, gint value) +mpdclient_cmd_random(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -454,7 +455,7 @@ mpdclient_cmd_random(mpdclient_t *c, gint value) } gint -mpdclient_cmd_single(mpdclient_t *c, gint value) +mpdclient_cmd_single(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -464,7 +465,7 @@ mpdclient_cmd_single(mpdclient_t *c, gint value) } gint -mpdclient_cmd_consume(mpdclient_t *c, gint value) +mpdclient_cmd_consume(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -474,7 +475,7 @@ mpdclient_cmd_consume(mpdclient_t *c, gint value) } gint -mpdclient_cmd_crossfade(mpdclient_t *c, gint value) +mpdclient_cmd_crossfade(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -484,7 +485,7 @@ mpdclient_cmd_crossfade(mpdclient_t *c, gint value) } gint -mpdclient_cmd_db_update(mpdclient_t *c, const gchar *path) +mpdclient_cmd_db_update(struct mpdclient *c, const gchar *path) { gint ret; @@ -504,7 +505,7 @@ mpdclient_cmd_db_update(mpdclient_t *c, const gchar *path) } gint -mpdclient_cmd_volume(mpdclient_t *c, gint value) +mpdclient_cmd_volume(struct mpdclient *c, gint value) { if (MPD_ERROR(c)) return -1; @@ -550,7 +551,7 @@ gint mpdclient_cmd_volume_down(struct mpdclient *c) } gint -mpdclient_cmd_add_path(mpdclient_t *c, const gchar *path_utf8) +mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path_utf8) { if (MPD_ERROR(c)) return -1; @@ -560,7 +561,7 @@ mpdclient_cmd_add_path(mpdclient_t *c, const gchar *path_utf8) } gint -mpdclient_cmd_add(mpdclient_t *c, const struct mpd_song *song) +mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song) { gint retval = 0; @@ -592,7 +593,7 @@ mpdclient_cmd_add(mpdclient_t *c, const struct mpd_song *song) } gint -mpdclient_cmd_delete(mpdclient_t *c, gint idx) +mpdclient_cmd_delete(struct mpdclient *c, gint idx) { gint retval = 0; struct mpd_song *song; @@ -640,7 +641,7 @@ mpdclient_cmd_delete(mpdclient_t *c, gint idx) } gint -mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index) +mpdclient_cmd_move(struct mpdclient *c, gint old_index, gint new_index) { gint n; struct mpd_song *song1, *song2; @@ -683,7 +684,7 @@ mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index) } gint -mpdclient_cmd_save_playlist(mpdclient_t *c, const gchar *filename_utf8) +mpdclient_cmd_save_playlist(struct mpdclient *c, const gchar *filename_utf8) { gint retval = 0; @@ -697,7 +698,7 @@ mpdclient_cmd_save_playlist(mpdclient_t *c, const gchar *filename_utf8) } gint -mpdclient_cmd_load_playlist(mpdclient_t *c, const gchar *filename_utf8) +mpdclient_cmd_load_playlist(struct mpdclient *c, const gchar *filename_utf8) { if (MPD_ERROR(c)) return -1; @@ -708,7 +709,7 @@ mpdclient_cmd_load_playlist(mpdclient_t *c, const gchar *filename_utf8) } gint -mpdclient_cmd_delete_playlist(mpdclient_t *c, const gchar *filename_utf8) +mpdclient_cmd_delete_playlist(struct mpdclient *c, const gchar *filename_utf8) { gint retval = 0; @@ -727,7 +728,7 @@ mpdclient_cmd_delete_playlist(mpdclient_t *c, const gchar *filename_utf8) /****************************************************************************/ static void -do_list_callbacks(mpdclient_t *c, GList *list, gint event, gpointer data) +do_list_callbacks(struct mpdclient *c, GList *list, gint event, gpointer data) { while (list) { mpdc_list_cb_t fn = list->data; @@ -738,50 +739,50 @@ do_list_callbacks(mpdclient_t *c, GList *list, gint event, gpointer data) } void -mpdclient_playlist_callback(mpdclient_t *c, int event, gpointer data) +mpdclient_playlist_callback(struct mpdclient *c, int event, gpointer data) { do_list_callbacks(c, c->playlist_callbacks, event, data); } void -mpdclient_install_playlist_callback(mpdclient_t *c,mpdc_list_cb_t cb) +mpdclient_install_playlist_callback(struct mpdclient *c,mpdc_list_cb_t cb) { c->playlist_callbacks = g_list_append(c->playlist_callbacks, cb); } void -mpdclient_remove_playlist_callback(mpdclient_t *c, mpdc_list_cb_t cb) +mpdclient_remove_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb) { c->playlist_callbacks = g_list_remove(c->playlist_callbacks, cb); } void -mpdclient_browse_callback(mpdclient_t *c, int event, gpointer data) +mpdclient_browse_callback(struct mpdclient *c, int event, gpointer data) { do_list_callbacks(c, c->browse_callbacks, event, data); } void -mpdclient_install_browse_callback(mpdclient_t *c,mpdc_list_cb_t cb) +mpdclient_install_browse_callback(struct mpdclient *c,mpdc_list_cb_t cb) { c->browse_callbacks = g_list_append(c->browse_callbacks, cb); } void -mpdclient_remove_browse_callback(mpdclient_t *c, mpdc_list_cb_t cb) +mpdclient_remove_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb) { c->browse_callbacks = g_list_remove(c->browse_callbacks, cb); } void -mpdclient_install_error_callback(mpdclient_t *c, mpdc_error_cb_t cb) +mpdclient_install_error_callback(struct mpdclient *c, mpdc_error_cb_t cb) { c->error_callbacks = g_list_append(c->error_callbacks, cb); } void -mpdclient_remove_error_callback(mpdclient_t *c, mpdc_error_cb_t cb) +mpdclient_remove_error_callback(struct mpdclient *c, mpdc_error_cb_t cb) { c->error_callbacks = g_list_remove(c->error_callbacks, cb); } @@ -793,7 +794,7 @@ mpdclient_remove_error_callback(mpdclient_t *c, mpdc_error_cb_t cb) /* update playlist */ gint -mpdclient_playlist_update(mpdclient_t *c) +mpdclient_playlist_update(struct mpdclient *c) { struct mpd_entity *entity; @@ -823,7 +824,7 @@ mpdclient_playlist_update(mpdclient_t *c) /* update playlist (plchanges) */ gint -mpdclient_playlist_update_changes(mpdclient_t *c) +mpdclient_playlist_update_changes(struct mpdclient *c) { struct mpd_song *song; guint length; @@ -867,7 +868,7 @@ mpdclient_playlist_update_changes(mpdclient_t *c) #else gint -mpdclient_playlist_update_changes(mpdclient_t *c) +mpdclient_playlist_update_changes(struct mpdclient *c) { return mpdclient_playlist_update(c); } @@ -878,10 +879,10 @@ mpdclient_playlist_update_changes(mpdclient_t *c) /*** Filelist functions *****************************************************/ /****************************************************************************/ -mpdclient_filelist_t * -mpdclient_filelist_get(mpdclient_t *c, const gchar *path) +struct filelist * +mpdclient_filelist_get(struct mpdclient *c, const gchar *path) { - mpdclient_filelist_t *filelist; + struct filelist *filelist; struct mpd_entity *entity; if (MPD_ERROR(c)) @@ -923,8 +924,8 @@ mpdclient_recv_filelist_response(struct mpdclient *c) return filelist; } -mpdclient_filelist_t * -mpdclient_filelist_search(mpdclient_t *c, +struct filelist * +mpdclient_filelist_search(struct mpdclient *c, int exact_match, enum mpd_tag_type tag, gchar *filter_utf8) @@ -941,7 +942,7 @@ mpdclient_filelist_search(mpdclient_t *c, } int -mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl) +mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl) { guint i; @@ -954,7 +955,7 @@ mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl) mpd_command_list_begin(c->connection, false); for (i = 0; i < filelist_length(fl); ++i) { - filelist_entry_t *entry = filelist_get(fl, i); + struct filelist_entry *entry = filelist_get(fl, i); struct mpd_entity *entity = entry->entity; if (entity != NULL && @@ -973,7 +974,7 @@ mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl) } GList * -mpdclient_get_artists(mpdclient_t *c) +mpdclient_get_artists(struct mpdclient *c) { GList *list = NULL; struct mpd_pair *pair; @@ -997,7 +998,7 @@ mpdclient_get_artists(mpdclient_t *c) } GList * -mpdclient_get_albums(mpdclient_t *c, const gchar *artist_utf8) +mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8) { GList *list = NULL; struct mpd_pair *pair; diff --git a/src/mpdclient.h b/src/mpdclient.h index 82940ab..e1b7476 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -2,13 +2,14 @@ #define MPDCLIENT_H #include "playlist.h" -#include "filelist.h" #include -typedef struct mpdclient { +struct filelist; + +struct mpdclient { /* playlist */ - mpdclient_playlist_t playlist; + struct mpdclient_playlist playlist; /* Callbacks */ GList *error_callbacks; @@ -23,55 +24,57 @@ typedef struct mpdclient { int volume; unsigned updatingdb; -} mpdclient_t; +}; /** functions ***************************************************************/ gint -mpdclient_finish_command(mpdclient_t *c); +mpdclient_finish_command(struct mpdclient *c); + +struct mpdclient * +mpdclient_new(void); -mpdclient_t *mpdclient_new(void); -void mpdclient_free(mpdclient_t *c); -gint mpdclient_connect(mpdclient_t *c, const gchar *host, gint port, +void mpdclient_free(struct mpdclient *c); +gint mpdclient_connect(struct mpdclient *c, const gchar *host, gint port, gfloat timeout_, const gchar *password); -gint mpdclient_disconnect(mpdclient_t *c); -gint mpdclient_update(mpdclient_t *c); +gint mpdclient_disconnect(struct mpdclient *c); +gint mpdclient_update(struct mpdclient *c); /*** MPD Commands **********************************************************/ -gint mpdclient_cmd_play(mpdclient_t *c, gint index); -gint mpdclient_cmd_pause(mpdclient_t *c, gint value); +gint mpdclient_cmd_play(struct mpdclient *c, gint index); +gint mpdclient_cmd_pause(struct mpdclient *c, gint value); gint -mpdclient_cmd_crop(mpdclient_t *c); -gint mpdclient_cmd_stop(mpdclient_t *c); -gint mpdclient_cmd_next(mpdclient_t *c); -gint mpdclient_cmd_prev(mpdclient_t *c); -gint mpdclient_cmd_seek(mpdclient_t *c, gint id, gint pos); -gint mpdclient_cmd_shuffle(mpdclient_t *c); -gint mpdclient_cmd_shuffle_range(mpdclient_t *c, guint start, guint end); -gint mpdclient_cmd_clear(mpdclient_t *c); -gint mpdclient_cmd_repeat(mpdclient_t *c, gint value); -gint mpdclient_cmd_random(mpdclient_t *c, gint value); -gint mpdclient_cmd_single(mpdclient_t *c, gint value); -gint mpdclient_cmd_consume(mpdclient_t *c, gint value); -gint mpdclient_cmd_crossfade(mpdclient_t *c, gint value); -gint mpdclient_cmd_db_update(mpdclient_t *c, const gchar *path); -gint mpdclient_cmd_volume(mpdclient_t *c, gint value); +mpdclient_cmd_crop(struct mpdclient *c); +gint mpdclient_cmd_stop(struct mpdclient *c); +gint mpdclient_cmd_next(struct mpdclient *c); +gint mpdclient_cmd_prev(struct mpdclient *c); +gint mpdclient_cmd_seek(struct mpdclient *c, gint id, gint pos); +gint mpdclient_cmd_shuffle(struct mpdclient *c); +gint mpdclient_cmd_shuffle_range(struct mpdclient *c, guint start, guint end); +gint mpdclient_cmd_clear(struct mpdclient *c); +gint mpdclient_cmd_repeat(struct mpdclient *c, gint value); +gint mpdclient_cmd_random(struct mpdclient *c, gint value); +gint mpdclient_cmd_single(struct mpdclient *c, gint value); +gint mpdclient_cmd_consume(struct mpdclient *c, gint value); +gint mpdclient_cmd_crossfade(struct mpdclient *c, gint value); +gint mpdclient_cmd_db_update(struct mpdclient *c, const gchar *path); +gint mpdclient_cmd_volume(struct mpdclient *c, gint value); gint mpdclient_cmd_volume_up(struct mpdclient *c); gint mpdclient_cmd_volume_down(struct mpdclient *c); -gint mpdclient_cmd_add_path(mpdclient_t *c, const gchar *path); +gint mpdclient_cmd_add_path(struct mpdclient *c, const gchar *path); -gint mpdclient_cmd_add(mpdclient_t *c, const struct mpd_song *song); -gint mpdclient_cmd_delete(mpdclient_t *c, gint index); -gint mpdclient_cmd_move(mpdclient_t *c, gint old_index, gint new_index); +gint mpdclient_cmd_add(struct mpdclient *c, const struct mpd_song *song); +gint mpdclient_cmd_delete(struct mpdclient *c, gint index); +gint mpdclient_cmd_move(struct mpdclient *c, gint old_index, gint new_index); -gint mpdclient_cmd_save_playlist(mpdclient_t *c, const gchar *filename); -gint mpdclient_cmd_load_playlist(mpdclient_t *c, const gchar *filename_utf8); -gint mpdclient_cmd_delete_playlist(mpdclient_t *c, const gchar *filename_utf8); +gint mpdclient_cmd_save_playlist(struct mpdclient *c, const gchar *filename); +gint mpdclient_cmd_load_playlist(struct mpdclient *c, const gchar *filename_utf8); +gint mpdclient_cmd_delete_playlist(struct mpdclient *c, const gchar *filename_utf8); /* list functions */ -GList *mpdclient_get_artists(mpdclient_t *c); -GList *mpdclient_get_albums(mpdclient_t *c, const gchar *artist_utf8); +GList *mpdclient_get_artists(struct mpdclient *c); +GList *mpdclient_get_albums(struct mpdclient *c, const gchar *artist_utf8); /*** error callbacks *****************************************************/ @@ -79,10 +82,10 @@ GList *mpdclient_get_albums(mpdclient_t *c, const gchar *artist_utf8); #define IS_ACK_ERROR(n) (n & MPD_ERROR_ACK) #define GET_ACK_ERROR_CODE(n) ((n & 0xFF00) >> 8) -typedef void (*mpdc_error_cb_t) (mpdclient_t *c, gint error, const gchar *msg); +typedef void (*mpdc_error_cb_t) (struct mpdclient *c, gint error, const gchar *msg); -void mpdclient_install_error_callback(mpdclient_t *c, mpdc_error_cb_t cb); -void mpdclient_remove_error_callback(mpdclient_t *c, mpdc_error_cb_t cb); +void mpdclient_install_error_callback(struct mpdclient *c, mpdc_error_cb_t cb); +void mpdclient_remove_error_callback(struct mpdclient *c, mpdc_error_cb_t cb); /*** playlist functions **************************************************/ @@ -102,29 +105,32 @@ gint mpdclient_playlist_update_changes(struct mpdclient *c); #define PLAYLIST_EVENT_MOVE 0x05 -typedef void (*mpdc_list_cb_t) (mpdclient_t *c, int event, gpointer data); +typedef void (*mpdc_list_cb_t) (struct mpdclient *c, int event, gpointer data); /* install a playlist callback function */ -void mpdclient_install_playlist_callback(mpdclient_t *c, mpdc_list_cb_t cb); +void mpdclient_install_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb); /* remove a playlist callback function */ -void mpdclient_remove_playlist_callback(mpdclient_t *c, mpdc_list_cb_t cb); +void mpdclient_remove_playlist_callback(struct mpdclient *c, mpdc_list_cb_t cb); /* issue a playlist callback */ -void mpdclient_playlist_callback(mpdclient_t *c, int event, gpointer data); +void mpdclient_playlist_callback(struct mpdclient *c, int event, gpointer data); /*** filelist functions ***************************************************/ -mpdclient_filelist_t *mpdclient_filelist_get(mpdclient_t *c, const gchar *path); -mpdclient_filelist_t *mpdclient_filelist_search(mpdclient_t *c, - int exact_match, - enum mpd_tag_type tag, - gchar *filter_utf8); +struct filelist * +mpdclient_filelist_get(struct mpdclient *c, const gchar *path); + +struct filelist * +mpdclient_filelist_search(struct mpdclient *c, int exact_match, + enum mpd_tag_type tag, + gchar *filter_utf8); /* add all songs in filelist to the playlist */ -int mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl); +int +mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl); /*** mpdclient browse callbacks ********************************************/ @@ -134,14 +140,14 @@ int mpdclient_filelist_add_all(mpdclient_t *c, mpdclient_filelist_t *fl); /* install a playlist callback function */ -void mpdclient_install_browse_callback(mpdclient_t *c, mpdc_list_cb_t cb); +void mpdclient_install_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb); /* remove a playlist callback function */ -void mpdclient_remove_browse_callback(mpdclient_t *c, mpdc_list_cb_t cb); +void mpdclient_remove_browse_callback(struct mpdclient *c, mpdc_list_cb_t cb); /* issue a playlist callback */ -void mpdclient_browse_callback(mpdclient_t *c, int event, gpointer data); +void mpdclient_browse_callback(struct mpdclient *c, int event, gpointer data); /* sort by list-format */ gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2); diff --git a/src/playlist.c b/src/playlist.c index 564cee6..38a39ab 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -50,19 +50,19 @@ playlist_clear(struct mpdclient_playlist *playlist) } gint -mpdclient_playlist_free(mpdclient_playlist_t *playlist) +mpdclient_playlist_free(struct mpdclient_playlist *playlist) { if (playlist->list != NULL) { playlist_clear(playlist); g_ptr_array_free(playlist->list, TRUE); } - memset(playlist, 0, sizeof(mpdclient_playlist_t)); + memset(playlist, 0, sizeof(*playlist)); return 0; } struct mpd_song * -playlist_get_song(mpdclient_t *c, gint idx) +playlist_get_song(struct mpdclient *c, gint idx) { if (idx < 0 || (guint)idx >= c->playlist.list->len) return NULL; @@ -71,7 +71,7 @@ playlist_get_song(mpdclient_t *c, gint idx) } struct mpd_song * -playlist_lookup_song(mpdclient_t *c, unsigned id) +playlist_lookup_song(struct mpdclient *c, unsigned id) { guint i; diff --git a/src/playlist.h b/src/playlist.h index f56daa3..b948936 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -27,13 +27,13 @@ struct mpdclient; -typedef struct mpdclient_playlist { +struct mpdclient_playlist { /* playlist id */ unsigned id; /* the list */ GPtrArray *list; -} mpdclient_playlist_t; +}; void playlist_init(struct mpdclient_playlist *playlist); @@ -43,7 +43,8 @@ void playlist_clear(struct mpdclient_playlist *playlist); /* free a playlist */ -gint mpdclient_playlist_free(mpdclient_playlist_t *playlist); +gint +mpdclient_playlist_free(struct mpdclient_playlist *playlist); static inline guint playlist_length(const struct mpdclient_playlist *playlist) diff --git a/src/screen.c b/src/screen.c index 255cacd..1e6d87b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -128,7 +128,7 @@ find_configured_screen(const char *name) } static void -screen_next_mode(mpdclient_t *c, int offset) +screen_next_mode(struct mpdclient *c, int offset) { int max = g_strv_length(options.screen_list); int current, next; @@ -170,7 +170,7 @@ get_volume(const struct mpd_status *status) } static void -paint_top_window2(const char *header, mpdclient_t *c) +paint_top_window2(const char *header, struct mpdclient *c) { int volume; char flags[5]; @@ -253,7 +253,7 @@ volume_length(int volume) } static void -paint_top_window(const char *header, mpdclient_t *c, int full_repaint) +paint_top_window(const char *header, struct mpdclient *c, int full_repaint) { static int prev_volume = -1; static unsigned prev_header_len = -1; @@ -281,7 +281,7 @@ paint_top_window(const char *header, mpdclient_t *c, int full_repaint) } static void -paint_progress_window(mpdclient_t *c) +paint_progress_window(struct mpdclient *c) { double p; int width; @@ -312,7 +312,7 @@ paint_progress_window(mpdclient_t *c) } static void -paint_status_window(mpdclient_t *c) +paint_status_window(struct mpdclient *c) { WINDOW *w = screen.status_window.w; const struct mpd_status *status = c->status; @@ -544,7 +544,7 @@ screen_status_printf(const char *format, ...) } void -screen_init(mpdclient_t *c) +screen_init(struct mpdclient *c) { if (COLS < SCREEN_MIN_COLS || LINES < SCREEN_MIN_ROWS) { fprintf(stderr, "%s\n", _("Error: Screen too small")); @@ -623,7 +623,7 @@ screen_init(mpdclient_t *c) } void -screen_paint(mpdclient_t *c) +screen_paint(struct mpdclient *c) { const char *title = NULL; @@ -659,7 +659,7 @@ screen_paint(mpdclient_t *c) } void -screen_update(mpdclient_t *c) +screen_update(struct mpdclient *c) { #ifndef NCMPC_MINI static bool initialized = false; @@ -765,7 +765,7 @@ screen_update(mpdclient_t *c) } void -screen_idle(mpdclient_t *c) +screen_idle(struct mpdclient *c) { if (c->song != NULL && seek_id == (int)mpd_song_get_id(c->song) && (screen.last_cmd == CMD_SEEK_FORWARD || @@ -778,7 +778,7 @@ screen_idle(mpdclient_t *c) #ifdef HAVE_GETMOUSE int -screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row) +screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row) { MEVENT event; @@ -799,7 +799,7 @@ screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row) #endif static int -screen_client_cmd(mpdclient_t *c, command_t cmd) +screen_client_cmd(struct mpdclient *c, command_t cmd) { if (c->connection == NULL || c->status == NULL) return 0; @@ -901,7 +901,7 @@ screen_client_cmd(mpdclient_t *c, command_t cmd) } void -screen_cmd(mpdclient_t *c, command_t cmd) +screen_cmd(struct mpdclient *c, command_t cmd) { screen.last_cmd = cmd; #ifndef NCMPC_MINI diff --git a/src/screen.h b/src/screen.h index fb2bc30..b22eae4 100644 --- a/src/screen.h +++ b/src/screen.h @@ -21,7 +21,6 @@ #define SCREEN_H #include "config.h" -#include "mpdclient.h" #include "command.h" #include @@ -40,6 +39,8 @@ #define MAX_SONGNAME_LENGTH 512 +struct mpdclient; + struct window { WINDOW *w; unsigned rows, cols; @@ -94,25 +95,25 @@ extern const struct screen_functions screen_outputs; typedef struct screen_functions { void (*init)(WINDOW *w, int cols, int rows); void (*exit)(void); - void (*open)(mpdclient_t *c); + void (*open)(struct mpdclient *c); void (*close)(void); void (*resize)(int cols, int rows); void (*paint)(void); - void (*update)(mpdclient_t *c); - bool (*cmd)(mpdclient_t *c, command_t cmd); + void (*update)(struct mpdclient *c); + bool (*cmd)(struct mpdclient *c, command_t cmd); const char *(*get_title)(char *s, size_t size); } screen_functions_t; -void screen_init(mpdclient_t *c); +void screen_init(struct mpdclient *c); void screen_exit(void); void screen_resize(struct mpdclient *c); void screen_status_message(const char *msg); void screen_status_printf(const char *format, ...); char *screen_error(void); -void screen_paint(mpdclient_t *c); -void screen_update(mpdclient_t *c); -void screen_idle(mpdclient_t *c); -void screen_cmd(mpdclient_t *c, command_t cmd); +void screen_paint(struct mpdclient *c); +void screen_update(struct mpdclient *c); +void screen_idle(struct mpdclient *c); +void screen_cmd(struct mpdclient *c, command_t cmd); gint screen_get_id(const char *name); void @@ -123,7 +124,8 @@ screen_swap(struct mpdclient *c, const struct mpd_song *song); gboolean screen_is_visible(const struct screen_functions *sf); -int screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row); +int +screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row); bool screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song); diff --git a/src/screen_artist.c b/src/screen_artist.c index f6de9dd..03d7155 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -27,6 +27,7 @@ #include "screen.h" #include "screen_utils.h" #include "screen_browser.h" +#include "filelist.h" #include #include @@ -113,7 +114,7 @@ artist_repaint_if_active(void) #ifndef NCMPC_MINI /* the playlist has been updated -> fix highlights */ static void -playlist_changed_callback(mpdclient_t *c, int event, gpointer data) +playlist_changed_callback(struct mpdclient *c, int event, gpointer data) { browser_playlist_changed(&browser, c, event, data); @@ -308,7 +309,7 @@ reload_lists(struct mpdclient *c) /* db updated */ static void -browse_callback(mpdclient_t *c, int event, G_GNUC_UNUSED gpointer data) +browse_callback(struct mpdclient *c, int event, G_GNUC_UNUSED gpointer data) { switch(event) { case BROWSE_DB_UPDATED: @@ -337,7 +338,7 @@ quit(void) } static void -open(mpdclient_t *c) +open(struct mpdclient *c) { static gboolean callback_installed = FALSE; @@ -407,10 +408,10 @@ get_title(char *str, size_t size) } static void -add_query(mpdclient_t *c, enum mpd_tag_type table, char *_filter) +add_query(struct mpdclient *c, enum mpd_tag_type table, char *_filter) { char *str; - mpdclient_filelist_t *addlist; + struct filelist *addlist; assert(filter != NULL); @@ -469,7 +470,7 @@ string_array_find(GPtrArray *array, const char *value) } static bool -artist_cmd(mpdclient_t *c, command_t cmd) +artist_cmd(struct mpdclient *c, command_t cmd) { char *selected; char *old; diff --git a/src/screen_browser.c b/src/screen_browser.c index c8f705b..efa2a38 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -23,6 +23,8 @@ #include "charset.h" #include "strfsong.h" #include "screen_utils.h" +#include "mpdclient.h" +#include "filelist.h" #include @@ -40,7 +42,7 @@ static const char playlist_format[] = "*%s*"; /* clear the highlight flag for all items in the filelist */ static void -clear_highlights(mpdclient_filelist_t *fl) +clear_highlights(struct filelist *fl) { guint i; @@ -53,7 +55,7 @@ clear_highlights(mpdclient_filelist_t *fl) /* change the highlight flag for a song */ static void -set_highlight(mpdclient_filelist_t *fl, struct mpd_song *song, int highlight) +set_highlight(struct filelist *fl, struct mpd_song *song, int highlight) { int i = filelist_find_song(fl, song); struct filelist_entry *entry; @@ -70,7 +72,7 @@ set_highlight(mpdclient_filelist_t *fl, struct mpd_song *song, int highlight) /* sync highlight flags with playlist */ void -sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl) +sync_highlights(struct mpdclient *c, struct filelist *fl) { guint i; @@ -92,7 +94,7 @@ sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl) /* the playlist has been updated -> fix highlights */ void -browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c, +browser_playlist_changed(struct screen_browser *browser, struct mpdclient *c, int event, gpointer data) { if (browser->filelist == NULL) @@ -122,9 +124,9 @@ browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c, const char * browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_column, void *data) { + struct filelist *fl = (struct filelist *) data; static char buf[BUFSIZE]; - mpdclient_filelist_t *fl = (mpdclient_filelist_t *) data; - filelist_entry_t *entry; + struct filelist_entry *entry; struct mpd_entity *entity; if (fl == NULL || idx >= filelist_length(fl)) @@ -170,7 +172,7 @@ browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_c } static bool -load_playlist(mpdclient_t *c, const struct mpd_playlist *playlist) +load_playlist(struct mpdclient *c, const struct mpd_playlist *playlist) { char *filename = utf8_to_locale(mpd_playlist_get_path(playlist)); @@ -182,7 +184,7 @@ load_playlist(mpdclient_t *c, const struct mpd_playlist *playlist) } static bool -enqueue_and_play(mpdclient_t *c, filelist_entry_t *entry) +enqueue_and_play(struct mpdclient *c, struct filelist_entry *entry) { int idx; const struct mpd_song *song = mpd_entity_get_song(entry->entity); @@ -253,7 +255,7 @@ browser_get_index(const struct screen_browser *browser, unsigned i) } static bool -browser_handle_enter(struct screen_browser *browser, mpdclient_t *c) +browser_handle_enter(struct screen_browser *browser, struct mpdclient *c) { struct filelist_entry *entry = browser_get_selected_entry(browser); struct mpd_entity *entity; @@ -273,7 +275,7 @@ browser_handle_enter(struct screen_browser *browser, mpdclient_t *c) } static bool -browser_select_entry(mpdclient_t *c, filelist_entry_t *entry, +browser_select_entry(struct mpdclient *c, struct filelist_entry *entry, G_GNUC_UNUSED gboolean toggle) { assert(entry != NULL); @@ -334,7 +336,7 @@ browser_select_entry(mpdclient_t *c, filelist_entry_t *entry, } static bool -browser_handle_select(struct screen_browser *browser, mpdclient_t *c) +browser_handle_select(struct screen_browser *browser, struct mpdclient *c) { struct filelist_entry *entry; @@ -358,7 +360,7 @@ browser_handle_select(struct screen_browser *browser, mpdclient_t *c) } static bool -browser_handle_add(struct screen_browser *browser, mpdclient_t *c) +browser_handle_add(struct screen_browser *browser, struct mpdclient *c) { struct filelist_entry *entry; @@ -382,7 +384,7 @@ browser_handle_add(struct screen_browser *browser, mpdclient_t *c) } static void -browser_handle_select_all(struct screen_browser *browser, mpdclient_t *c) +browser_handle_select_all(struct screen_browser *browser, struct mpdclient *c) { guint i; @@ -399,7 +401,7 @@ browser_handle_select_all(struct screen_browser *browser, mpdclient_t *c) #ifdef HAVE_GETMOUSE static int -browser_handle_mouse_event(struct screen_browser *browser, mpdclient_t *c) +browser_handle_mouse_event(struct screen_browser *browser, struct mpdclient *c) { int row; unsigned prev_selected = browser->lw->selected; diff --git a/src/screen_browser.h b/src/screen_browser.h index 093ece7..44d1d66 100644 --- a/src/screen_browser.h +++ b/src/screen_browser.h @@ -21,27 +21,28 @@ #define SCREEN_BROWSER_H #include "screen.h" -#include "mpdclient.h" #include "config.h" #include +struct mpdclient; +struct filelist; struct list_window; struct list_window_state; struct screen_browser { struct list_window *lw; - mpdclient_filelist_t *filelist; + struct filelist *filelist; }; #ifndef NCMPC_MINI void -sync_highlights(mpdclient_t *c, mpdclient_filelist_t *fl); +sync_highlights(struct mpdclient *c, struct filelist *fl); void -browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c, +browser_playlist_changed(struct screen_browser *browser, struct mpdclient *c, int event, gpointer data); #endif diff --git a/src/screen_file.c b/src/screen_file.c index c69b7d5..ed3d26a 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -16,11 +16,13 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include "config.h" #include "i18n.h" #include "options.h" #include "charset.h" #include "mpdclient.h" +#include "filelist.h" #include "command.h" #include "screen.h" #include "screen_utils.h" @@ -65,7 +67,7 @@ file_reload(struct mpdclient *c) /* the db has changed -> update the filelist */ static void -file_changed_callback(mpdclient_t *c, G_GNUC_UNUSED int event, +file_changed_callback(struct mpdclient *c, G_GNUC_UNUSED int event, G_GNUC_UNUSED gpointer data) { file_reload(c); @@ -81,7 +83,7 @@ file_changed_callback(mpdclient_t *c, G_GNUC_UNUSED int event, #ifndef NCMPC_MINI /* the playlist has been updated -> fix highlights */ static void -playlist_changed_callback(mpdclient_t *c, int event, gpointer data) +playlist_changed_callback(struct mpdclient *c, int event, gpointer data) { browser_playlist_changed(&browser, c, event, data); @@ -93,7 +95,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data) * Change to the specified absolute directory. */ static bool -file_change_directory(mpdclient_t *c, const char *new_path) +file_change_directory(struct mpdclient *c, const char *new_path) { g_free(current_path); current_path = g_strdup(new_path); @@ -113,7 +115,7 @@ file_change_directory(mpdclient_t *c, const char *new_path) * Change to the parent directory of the current directory. */ static bool -file_change_to_parent(mpdclient_t *c) +file_change_to_parent(struct mpdclient *c) { char *parent = g_path_get_dirname(current_path); char *old_path; @@ -145,11 +147,11 @@ file_change_to_parent(mpdclient_t *c) } /** - * Change to the directory referred by the specified filelist_entry_t + * Change to the directory referred by the specified #filelist_entry * object. */ static bool -file_change_to_entry(mpdclient_t *c, const filelist_entry_t *entry) +file_change_to_entry(struct mpdclient *c, const struct filelist_entry *entry) { assert(entry != NULL); @@ -173,9 +175,9 @@ file_handle_enter(struct mpdclient *c) } static int -handle_save(mpdclient_t *c) +handle_save(struct mpdclient *c) { - filelist_entry_t *entry; + struct filelist_entry *entry; const char *defaultname = NULL; char *defaultname_utf8 = NULL; int ret; @@ -206,9 +208,9 @@ handle_save(mpdclient_t *c) } static int -handle_delete(mpdclient_t *c) +handle_delete(struct mpdclient *c) { - filelist_entry_t *entry; + struct filelist_entry *entry; struct mpd_entity *entity; const struct mpd_playlist *playlist; char *str, *buf; @@ -283,7 +285,7 @@ browse_exit(void) } static void -browse_open(G_GNUC_UNUSED mpdclient_t *c) +browse_open(G_GNUC_UNUSED struct mpdclient *c) { if (browser.filelist == NULL) { browser.filelist = mpdclient_filelist_get(c, ""); @@ -325,7 +327,7 @@ browse_paint(void) } static bool -browse_cmd(mpdclient_t *c, command_t cmd) +browse_cmd(struct mpdclient *c, command_t cmd) { switch(cmd) { case CMD_PLAY: diff --git a/src/screen_help.c b/src/screen_help.c index 81b479f..59ea8a2 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -256,7 +256,7 @@ help_paint(void) } static bool -help_cmd(G_GNUC_UNUSED mpdclient_t *c, command_t cmd) +help_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd) { if (list_window_scroll_cmd(lw, help_text_rows, cmd)) { list_window_paint(lw, list_callback, NULL); diff --git a/src/screen_keydef.c b/src/screen_keydef.c index d1dce23..16cc957 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -246,7 +246,7 @@ keydef_exit(void) } static void -keydef_open(G_GNUC_UNUSED mpdclient_t *c) +keydef_open(G_GNUC_UNUSED struct mpdclient *c) { if (cmds == NULL) { command_definition_t *current_cmds = get_command_definitions(); @@ -293,7 +293,7 @@ keydef_paint(void) } static bool -keydef_cmd(G_GNUC_UNUSED mpdclient_t *c, command_t cmd) +keydef_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd) { int length = LIST_LENGTH(); diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 5714258..f9fdb81 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -200,7 +200,7 @@ lyrics_exit(void) } static void -lyrics_open(mpdclient_t *c) +lyrics_open(struct mpdclient *c) { if (next_song == NULL) next_song = c->song; @@ -217,7 +217,7 @@ lyrics_open(mpdclient_t *c) } static void -lyrics_update(mpdclient_t *c) +lyrics_update(struct mpdclient *c) { if (!follow) return; @@ -260,7 +260,7 @@ lyrics_paint(void) } static bool -lyrics_cmd(mpdclient_t *c, command_t cmd) +lyrics_cmd(struct mpdclient *c, command_t cmd) { if (screen_text_cmd(&text, c, cmd)) return true; diff --git a/src/screen_outputs.c b/src/screen_outputs.c index 43b95e3..ac41c09 100644 --- a/src/screen_outputs.c +++ b/src/screen_outputs.c @@ -20,10 +20,12 @@ #include "i18n.h" #include "screen.h" #include "list_window.h" +#include "mpdclient.h" #include #include +#include static list_window_t *lw = NULL; @@ -40,7 +42,7 @@ outputs_repaint(void) } static int -toggle_output(mpdclient_t *c, unsigned int output_index) +toggle_output(struct mpdclient *c, unsigned int output_index) { int return_value; struct mpd_output *output; @@ -96,7 +98,7 @@ clear_outputs_list(void) } static void -fill_outputs_list(mpdclient_t *c) +fill_outputs_list(struct mpdclient *c) { struct mpd_output *output; @@ -154,7 +156,7 @@ outputs_exit(void) } static void -outputs_open(mpdclient_t *c) +outputs_open(struct mpdclient *c) { fill_outputs_list(c); } @@ -178,7 +180,7 @@ outputs_paint(void) } static bool -outputs_cmd(mpdclient_t *c, command_t cmd) +outputs_cmd(struct mpdclient *c, command_t cmd) { assert(mpd_outputs != NULL); diff --git a/src/screen_play.c b/src/screen_play.c index 51835a1..fb5e82b 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -50,7 +50,7 @@ typedef struct { GList **list; GList **dir_list; - mpdclient_t *c; + struct mpdclient *c; } completion_callback_data_t; #endif @@ -77,7 +77,7 @@ playlist_repaint_if_active(void) } static void -playlist_changed_callback(mpdclient_t *c, int event, gpointer data) +playlist_changed_callback(struct mpdclient *c, int event, gpointer data) { switch (event) { case PLAYLIST_EVENT_DELETE: @@ -162,7 +162,7 @@ list_callback(unsigned idx, bool *highlight, char **second_column, G_GNUC_UNUSED } static void -center_playing_item(mpdclient_t *c, bool center_cursor) +center_playing_item(struct mpdclient *c, bool center_cursor) { unsigned length = c->playlist.list->len; int idx; @@ -221,7 +221,7 @@ save_pre_completion_cb(GCompletion *gcmp, G_GNUC_UNUSED gchar *line, { completion_callback_data_t *tmp = (completion_callback_data_t *)data; GList **list = tmp->list; - mpdclient_t *c = tmp->c; + struct mpdclient *c = tmp->c; if( *list == NULL ) { /* create completion list */ @@ -254,7 +254,7 @@ completion_strncmp(const gchar *s1, const gchar *s2, gsize n) #endif int -playlist_save(mpdclient_t *c, char *name, char *defaultname) +playlist_save(struct mpdclient *c, char *name, char *defaultname) { gchar *filename, *filename_utf8; gint error; @@ -352,7 +352,7 @@ playlist_save(mpdclient_t *c, char *name, char *defaultname) #ifndef NCMPC_MINI static void add_dir(GCompletion *gcmp, gchar *dir, GList **dir_list, - GList **list, mpdclient_t *c) + GList **list, struct mpdclient *c) { g_completion_remove_items(gcmp, *list); *list = string_list_remove(*list, dir); @@ -366,7 +366,7 @@ static void add_pre_completion_cb(GCompletion *gcmp, gchar *line, void *data) completion_callback_data_t *tmp = (completion_callback_data_t *)data; GList **dir_list = tmp->dir_list; GList **list = tmp->list; - mpdclient_t *c = tmp->c; + struct mpdclient *c = tmp->c; if (*list == NULL) { /* create initial list */ @@ -385,7 +385,7 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line, completion_callback_data_t *tmp = (completion_callback_data_t *)data; GList **dir_list = tmp->dir_list; GList **list = tmp->list; - mpdclient_t *c = tmp->c; + struct mpdclient *c = tmp->c; if (g_list_length(items) >= 1) screen_display_completion_list(items); @@ -399,7 +399,7 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line, #endif static int -handle_add_to_playlist(mpdclient_t *c) +handle_add_to_playlist(struct mpdclient *c) { gchar *path; #ifndef NCMPC_MINI @@ -482,7 +482,7 @@ timer_hide_cursor(gpointer data) } static void -play_open(mpdclient_t *c) +play_open(struct mpdclient *c) { static gboolean install_cb = TRUE; @@ -541,7 +541,7 @@ play_paint(void) } static void -play_update(mpdclient_t *c) +play_update(struct mpdclient *c) { static int prev_song_id = -1; @@ -607,7 +607,7 @@ handle_mouse_event(struct mpdclient *c) #endif static bool -play_cmd(mpdclient_t *c, command_t cmd) +play_cmd(struct mpdclient *c, command_t cmd) { static command_t cached_cmd = CMD_NONE; command_t prev_cmd = cached_cmd; diff --git a/src/screen_play.h b/src/screen_play.h index cf76509..3cccfb8 100644 --- a/src/screen_play.h +++ b/src/screen_play.h @@ -17,4 +17,5 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -int playlist_save(mpdclient_t *c, char *name, char *defaultname); +int +playlist_save(struct mpdclient *c, char *name, char *defaultname); diff --git a/src/screen_search.c b/src/screen_search.c index ff78082..9ab9a3f 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -16,6 +16,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include "i18n.h" #include "options.h" #include "charset.h" @@ -26,6 +27,7 @@ #include "utils.h" #include "screen_utils.h" #include "screen_browser.h" +#include "filelist.h" #include #include @@ -140,7 +142,7 @@ search_repaint_if_active(void) /* the playlist has been updated -> fix highlights */ static void -playlist_changed_callback(mpdclient_t *c, int event, gpointer data) +playlist_changed_callback(struct mpdclient *c, int event, gpointer data) { browser_playlist_changed(&browser, c, event, data); search_repaint_if_active(); @@ -161,7 +163,7 @@ search_check_mode(void) } static void -search_clear(mpdclient_t *c, +search_clear(struct mpdclient *c, gboolean clear_pattern) { if (browser.filelist) { @@ -175,11 +177,11 @@ search_clear(mpdclient_t *c, } } -static mpdclient_filelist_t * -filelist_search(mpdclient_t *c, G_GNUC_UNUSED int exact_match, int table, +static struct filelist * +filelist_search(struct mpdclient *c, G_GNUC_UNUSED int exact_match, int table, gchar *local_pattern) { - mpdclient_filelist_t *list, *list2; + struct filelist *list, *list2; gchar *filter_utf8 = locale_to_utf8(local_pattern); if (table == SEARCH_ARTIST_TITLE) { @@ -211,14 +213,14 @@ filelist_search(mpdclient_t *c, G_GNUC_UNUSED int exact_match, int table, * Its ugly and MUST be redesigned before the next release! *----------------------------------------------------------------------- */ -static mpdclient_filelist_t * -search_advanced_query(char *query, mpdclient_t *c) +static struct filelist * +search_advanced_query(char *query, struct mpdclient *c) { int i,j; char **strv; int table[10]; char *arg[10]; - mpdclient_filelist_t *fl = NULL; + struct filelist *fl = NULL; advanced_search_mode = FALSE; if( g_strrstr(query, ":") == NULL ) @@ -309,7 +311,7 @@ search_advanced_query(char *query, mpdclient_t *c) } static void -search_new(mpdclient_t *c) +search_new(struct mpdclient *c) { if (c->connection == NULL) return; @@ -373,7 +375,7 @@ quit(void) } static void -open(G_GNUC_UNUSED mpdclient_t *c) +open(G_GNUC_UNUSED struct mpdclient *c) { // if( pattern==NULL ) // search_new(screen, c); @@ -421,7 +423,7 @@ get_title(char *str, size_t size) } static bool -search_cmd(mpdclient_t *c, command_t cmd) +search_cmd(struct mpdclient *c, command_t cmd) { switch (cmd) { case CMD_SEARCH_MODE: diff --git a/src/screen_song.c b/src/screen_song.c index 8ded356..fc46648 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -22,10 +22,12 @@ #include "screen_utils.h" #include "charset.h" #include "utils.h" +#include "mpdclient.h" #include #include +#include #include static list_window_t *lw; @@ -193,7 +195,7 @@ screen_song_append_tag(const char *label, const struct mpd_song *song, } static void -screen_song_add_song(const struct mpd_song *song, const mpdclient_t *c) +screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c) { unsigned i, max_label_width; enum label { @@ -271,7 +273,7 @@ screen_song_add_song(const struct mpd_song *song, const mpdclient_t *c) } static void -screen_song_add_stats(const mpdclient_t *c) +screen_song_add_stats(const struct mpdclient *c) { unsigned i, max_label_width; char buf[64]; @@ -333,7 +335,7 @@ screen_song_add_stats(const mpdclient_t *c) } static void -screen_song_update(mpdclient_t *c) +screen_song_update(struct mpdclient *c) { /* Clear all lines */ for (guint i = 0; i < current.lines->len; ++i) @@ -379,7 +381,7 @@ screen_song_update(mpdclient_t *c) } static bool -screen_song_cmd(mpdclient_t *c, command_t cmd) +screen_song_cmd(struct mpdclient *c, command_t cmd) { if (list_window_scroll_cmd(lw, current.lines->len, cmd)) { screen_song_repaint(); @@ -449,7 +451,7 @@ const struct screen_functions screen_song = { }; void -screen_song_switch(mpdclient_t *c, const struct mpd_song *song) +screen_song_switch(struct mpdclient *c, const struct mpd_song *song) { assert(song != NULL); assert(current.selected_song == NULL); diff --git a/src/utils.c b/src/utils.c index 23408f2..41ba2a5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -21,6 +21,8 @@ #include "options.h" #include "charset.h" #include "i18n.h" +#include "mpdclient.h" +#include "filelist.h" #include #include @@ -72,10 +74,11 @@ string_list_remove(GList *string_list, const gchar *str) /* create a list suitable for GCompletion from path */ GList * -gcmp_list_from_path(mpdclient_t *c, const gchar *path, GList *list, gint types) +gcmp_list_from_path(struct mpdclient *c, const gchar *path, + GList *list, gint types) { guint i; - mpdclient_filelist_t *filelist; + struct filelist *filelist; if ((filelist = mpdclient_filelist_get(c, path)) == NULL) return list; diff --git a/src/utils.h b/src/utils.h index 20077f0..4085680 100644 --- a/src/utils.h +++ b/src/utils.h @@ -20,10 +20,10 @@ #ifndef UTILS_H #define UTILS_H -#include "mpdclient.h" - #include +struct mpdclient; + /* functions for lists containing strings */ GList *string_list_free(GList *string_list); GList *string_list_find(GList *string_list, const gchar *str); @@ -36,10 +36,9 @@ GList *string_list_remove(GList *string_list, const gchar *str); #define GCMP_TYPE_RFILE (GCMP_TYPE_DIR | GCMP_TYPE_FILE) #define GCMP_TYPE_RPLAYLIST (GCMP_TYPE_DIR | GCMP_TYPE_PLAYLIST) -GList *gcmp_list_from_path(mpdclient_t *c, - const gchar *path, - GList *list, - gint types); +GList * +gcmp_list_from_path(struct mpdclient *c, const gchar *path, + GList *list, gint types); char * time_seconds_to_durationstr(unsigned long time_seconds);