1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

message.c: Parse incoming message stanzas according to type

This commit is contained in:
Michael Vetter 2020-07-02 17:15:42 +02:00
parent 728cb55b68
commit b14b711492

View File

@ -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;
}