From 3640900cf64f00591526444a80d9c412ba302a0a Mon Sep 17 00:00:00 2001 From: Stefan Kropp Date: Fri, 3 Jul 2020 12:02:41 +0200 Subject: [PATCH] Handle headline stanza Authored by DebXWoody in: https://github.com/profanity-im/profanity/pull/1369 Regards: https://github.com/profanity-im/profanity/issues/1366 Since I'm in the process of cleaning up message.c I take this now so he doesn't have to rebase. I also omitted the _handle_normal() case since I'm not sure that would be correct. Probably will be addressed again when continuing the cleanup. --- src/xmpp/message.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index cc9edaa7..2464898d 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -109,6 +109,19 @@ _handled_by_plugin(xmpp_stanza_t *const stanza) return !cont; } +static void +_handle_headline(xmpp_stanza_t *const stanza) +{ + char* text = NULL; + xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); + if (body) { + text = xmpp_stanza_get_text(body); + if (text) { + cons_show("Headline: %s", text); + } + } +} + static int _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) { @@ -127,7 +140,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con // XEP-0045: Multi-User Chat _handle_groupchat(stanza); } else if (g_strcmp0(type, STANZA_TYPE_HEADLINE) == 0) { - //TODO: implement headline + _handle_headline(stanza); } else if (type == NULL || g_strcmp0(type, STANZA_TYPE_CHAT) != 0 || g_strcmp0(type, STANZA_TYPE_NORMAL) != 0 ) { // type: chat, normal (==NULL)