From b14b7114922766ee30721902cd4248a856834d68 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 2 Jul 2020 17:15:42 +0200 Subject: message.c: Parse incoming message stanzas according to type --- src/xmpp/message.c | 65 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 31f441de..0bb1d4f6 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -110,6 +110,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con return 1; } + // type according to RFC 6121 const char *type = xmpp_stanza_get_type(stanza); if (type == NULL) { @@ -127,44 +128,46 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { _handle_error(stanza); - } - - // XEP-0045: Multi-User Chat - if (g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0) { + } else if (g_strcmp0(type, STANZA_TYPE_GROUPCHAT) == 0) { + // XEP-0045: Multi-User Chat _handle_groupchat(stanza); - } + } else if (g_strcmp0(type, STANZA_TYPE_HEADLINE) == 0) { + //TODO: implement headline + } else { + // type: chat, normal (default if none is set) - // XEP-0045: Multi-User Chat - xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); - if (mucuser) { - _handle_muc_user(stanza); - } + // XEP-0045: Multi-User Chat - invites - presence + xmpp_stanza_t *mucuser = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER); + if (mucuser) { + _handle_muc_user(stanza); + } - // XEP-0249: Direct MUC Invitations - xmpp_stanza_t *conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); - if (conference) { - _handle_conference(stanza); - } + // XEP-0249: Direct MUC Invitations + xmpp_stanza_t *conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE); + if (conference) { + _handle_conference(stanza); + } - // XEP-0158: CAPTCHA Forms - xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA); - if (captcha) { - _handle_captcha(stanza); - } + // XEP-0158: CAPTCHA Forms + xmpp_stanza_t *captcha = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CAPTCHA); + if (captcha) { + _handle_captcha(stanza); + } - // XEP-0184: Message Delivery Receipts - xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); - if (receipts) { - _handle_receipt_received(stanza); - } + // XEP-0184: Message Delivery Receipts + xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS); + if (receipts) { + _handle_receipt_received(stanza); + } - // XEP-0060: Publish-Subscribe - xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); - if (event) { - _handle_pubsub(stanza, event); - } + // XEP-0060: Publish-Subscribe + xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); + if (event) { + _handle_pubsub(stanza, event); + } - _handle_chat(stanza, FALSE); + _handle_chat(stanza, FALSE); + } return 1; } -- cgit 1.4.1-2-gfad0 ef='#n17'>17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
n39'>39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108