From 03df717bf8e01754c730c3ab5e08ed6a920dcb40 Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 1 Dec 2015 01:38:30 -0300 Subject: Add 'log' UI function, to avoid direct calls to irc_rootmsg from nogaim Just a trivial wrapper over irc_rootmsg(), but will help me to slightly reduce the ugliness of an unavoidably ugly hack for libpurple. --- irc_im.c | 9 +++++++++ protocols/bee.h | 2 ++ protocols/nogaim.c | 9 ++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/irc_im.c b/irc_im.c index 0b0b0274..72a0d8ce 100644 --- a/irc_im.c +++ b/irc_im.c @@ -1108,6 +1108,13 @@ static void bee_irc_ft_finished(struct im_connection *ic, file_transfer_t *file) } } +static void bee_irc_log(bee_t *bee, const char *tag, const char *msg) +{ + irc_t *irc = (irc_t *) bee->ui_data; + + irc_rootmsg(irc, "%s - %s", tag, msg); +} + const struct bee_ui_funcs irc_ui_funcs = { bee_irc_imc_connected, bee_irc_imc_disconnected, @@ -1136,4 +1143,6 @@ const struct bee_ui_funcs irc_ui_funcs = { bee_irc_ft_out_start, bee_irc_ft_close, bee_irc_ft_finished, + + bee_irc_log, }; diff --git a/protocols/bee.h b/protocols/bee.h index a9678a6e..4a053845 100644 --- a/protocols/bee.h +++ b/protocols/bee.h @@ -128,6 +128,8 @@ typedef struct bee_ui_funcs { gboolean (*ft_out_start)(struct im_connection *ic, struct file_transfer *ft); void (*ft_close)(struct im_connection *ic, struct file_transfer *ft); void (*ft_finished)(struct im_connection *ic, struct file_transfer *ft); + + void (*log)(bee_t *bee, const char *tag, const char *msg); } bee_ui_funcs_t; diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 459a3913..21152e0f 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -206,6 +206,10 @@ static void serv_got_crap(struct im_connection *ic, char *format, ...) char *text; account_t *a; + if (!ic->bee->ui->log) { + return; + } + va_start(params, format); text = g_strdup_vprintf(format, params); va_end(params); @@ -224,10 +228,9 @@ static void serv_got_crap(struct im_connection *ic, char *format, ...) /* If we found one, include the screenname in the message. */ if (a) { - /* FIXME(wilmer): ui_log callback or so */ - irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->tag, text); + ic->bee->ui->log(ic->bee, ic->acc->tag, text); } else { - irc_rootmsg(ic->bee->ui_data, "%s - %s", ic->acc->prpl->name, text); + ic->bee->ui->log(ic->bee, ic->acc->prpl->name, text); } g_free(text); -- cgit v1.2.3