From 05aba5534a8b2ea1374b43412a56b7ca00901fcc Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 1 Dec 2015 01:55:21 -0300 Subject: purple: Implement PurpleNotifyUiOps.notify_message Which has no connection context. Luckily local_bee exists, and libpurple only supports only one irc user per process. This sucks. And yesterday I was naively thinking (again) that local_bee might not be needed, that maybe we can do things properly. Of course it only took a look at that one reverted commit (56985aa) to remember that life is unfair, and that, under Moloch, everyone is irresistably incentivized to ignore the things that unite us in favor of forever picking at the things that divide us in exactly the way that is most likely to make them more divisive. That being said, I think all these hacks are going to look nicer once I sandbox the whole thing in a separate process with one IM account per process, as opposed to one irc use per process. Then we'll be able to rely on global state exclusively, which is saner. --- protocols/purple/purple.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/protocols/purple/purple.c b/protocols/purple/purple.c index 911edaea..a784cc9d 100644 --- a/protocols/purple/purple.c +++ b/protocols/purple/purple.c @@ -1287,6 +1287,27 @@ static PurpleEventLoopUiOps glib_eventloops = prplcb_ev_remove, }; +/* Absolutely no connection context at all. Thanks purple! brb crying */ +static void *prplcb_notify_message(PurpleNotifyMsgType type, const char *title, + const char *primary, const char *secondary) +{ + char *text = g_strdup_printf("%s%s - %s%s%s", + (type == PURPLE_NOTIFY_MSG_ERROR) ? "Error: " : "", + title, + primary ?: "", + (primary && secondary) ? " - " : "", + secondary ?: "" + ); + + if (local_bee->ui->log) { + local_bee->ui->log(local_bee, "purple", text); + } + + g_free(text); + + return NULL; +} + static void *prplcb_notify_email(PurpleConnection *gc, const char *subject, const char *from, const char *to, const char *url) { @@ -1347,7 +1368,7 @@ static void *prplcb_notify_userinfo(PurpleConnection *gc, const char *who, Purpl static PurpleNotifyUiOps bee_notify_uiops = { - NULL, + prplcb_notify_message, prplcb_notify_email, NULL, NULL, -- cgit v1.2.3