about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStefan Kropp <stefan@debxwoody.de>2020-07-03 12:02:41 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-07-03 12:02:41 +0200
commit3640900cf64f00591526444a80d9c412ba302a0a (patch)
tree292feff02626717be571fe7930d65c9ffca18be6
parent83c6aa68f17f0b90152c6608856c82ccd473773f (diff)
downloadprofani-tty-3640900cf64f00591526444a80d9c412ba302a0a.tar.gz
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.
-rw-r--r--src/xmpp/message.c15
1 files changed, 14 insertions, 1 deletions
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)