diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-03 19:43:51 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-03 19:43:51 +0200 |
commit | 1e39ae52c510609fd50adc6ba3d7440b79ac3e33 (patch) | |
tree | a03bc22120e0419bec71fdd9ea0d5efd256f9c02 /mpd.c | |
parent | 91b6a799c8242d31b3ef511f67f02b1f348b4645 (diff) | |
download | nncmpp-1e39ae52c510609fd50adc6ba3d7440b79ac3e33.tar.gz nncmpp-1e39ae52c510609fd50adc6ba3d7440b79ac3e33.tar.xz nncmpp-1e39ae52c510609fd50adc6ba3d7440b79ac3e33.zip |
Make the debug tab prettier
And the MPD code a little bit more generic.
Diffstat (limited to 'mpd.c')
-rw-r--r-- | mpd.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1,4 +1,5 @@ // Copied from desktop-tools, should go to liberty if it proves useful +// XXX: changed: added a debugging callback instead of hardcoded print_debug // --- MPD client interface ---------------------------------------------------- @@ -107,6 +108,9 @@ struct mpd_client /// Callback to receive "idle" updates. /// Remember to restart the idle if needed. void (*on_event) (unsigned subsystems, void *user_data); + + /// Callback to trace protocol I/O + void (*on_io_hook) (void *user_data, bool outgoing, const char *line); }; static void mpd_client_reset (struct mpd_client *self); @@ -258,7 +262,8 @@ mpd_client_parse_hello (struct mpd_client *self, const char *line) static bool mpd_client_parse_line (struct mpd_client *self, const char *line) { - print_debug ("MPD >> %s", line); + if (self->on_io_hook) + self->on_io_hook (self->user_data, false, line); if (!self->got_hello) return mpd_client_parse_hello (self, line); @@ -414,7 +419,9 @@ mpd_client_send_commandv (struct mpd_client *self, char **commands) str_append (&line, *commands); } - print_debug ("MPD << %s", line.str); + if (self->on_io_hook) + self->on_io_hook (self->user_data, true, line.str); + str_append_c (&line, '\n'); str_append_str (&self->write_buffer, &line); str_free (&line); |