1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Use libstrophe xmpp_message_get_body convenience function

This commit is contained in:
James Booth 2016-08-20 19:23:32 +01:00
parent 39ff399626
commit d61abd3577

View File

@ -504,12 +504,7 @@ _handle_captcha(xmpp_stanza_t *const stanza)
} }
// XEP-0158 // XEP-0158
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); char *message = xmpp_message_get_body(stanza);
if (!body) {
return;
}
char *message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
return; return;
} }
@ -539,13 +534,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
// handle room broadcasts // handle room broadcasts
if (!jid->resourcepart) { if (!jid->resourcepart) {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); message = xmpp_message_get_body(stanza);
if (!body) {
jid_destroy(jid);
return;
}
message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
jid_destroy(jid); jid_destroy(jid);
return; return;
@ -571,15 +560,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
return; return;
} }
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); message = xmpp_message_get_body(stanza);
// check for and deal with message
if (!body) {
jid_destroy(jid);
return;
}
message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
jid_destroy(jid); jid_destroy(jid);
return; return;
@ -674,12 +655,7 @@ _receipt_request_handler(xmpp_stanza_t *const stanza)
void void
_private_chat_handler(xmpp_stanza_t *const stanza, const char *const fulljid) _private_chat_handler(xmpp_stanza_t *const stanza, const char *const fulljid)
{ {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); char *message = xmpp_message_get_body(stanza);
if (!body) {
return;
}
char *message = xmpp_stanza_get_text(body);
if (!message) { if (!message) {
return; return;
} }
@ -722,9 +698,7 @@ _handle_carbons(xmpp_stanza_t *const stanza)
Jid *my_jid = jid_create(connection_get_fulljid()); Jid *my_jid = jid_create(connection_get_fulljid());
// check for and deal with message // check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY); char *message_txt = xmpp_message_get_body(message);
if (body) {
char *message_txt = xmpp_stanza_get_text(body);
if (message_txt) { if (message_txt) {
// check for pgp encrypted message // check for pgp encrypted message
char *enc_message = NULL; char *enc_message = NULL;
@ -744,7 +718,6 @@ _handle_carbons(xmpp_stanza_t *const stanza)
xmpp_free(ctx, message_txt); xmpp_free(ctx, message_txt);
xmpp_free(ctx, enc_message); xmpp_free(ctx, enc_message);
} }
}
jid_destroy(jid_from); jid_destroy(jid_from);
jid_destroy(jid_to); jid_destroy(jid_to);