mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Tidy _handle_carbons
This commit is contained in:
parent
583fb2b8c6
commit
948d63d855
@ -681,11 +681,33 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *name = xmpp_stanza_get_name(carbons);
|
const char *name = xmpp_stanza_get_name(carbons);
|
||||||
if ((g_strcmp0(name, "received") == 0) || (g_strcmp0(name, "sent")) == 0) {
|
if (!name) {
|
||||||
xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(carbons, STANZA_NS_FORWARD);
|
log_error("Unable to retrieve stanza name for Carbon");
|
||||||
xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
xmpp_ctx_t *ctx = connection_get_ctx();
|
if ((g_strcmp0(name, "received") != 0) && (g_strcmp0(name, "sent") != 0)) {
|
||||||
|
log_warning("Carbon received with unrecognised stanza name: %s", name);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(carbons, STANZA_NS_FORWARD);
|
||||||
|
if (!forwarded) {
|
||||||
|
log_warning("Carbon received with no forwarded element");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
|
||||||
|
if (!message) {
|
||||||
|
log_warning("Carbon received with no message element");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *message_txt = xmpp_message_get_body(message);
|
||||||
|
if (!message_txt) {
|
||||||
|
log_warning("Carbon received with no message.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *to = xmpp_stanza_get_to(message);
|
const gchar *to = xmpp_stanza_get_to(message);
|
||||||
const gchar *from = xmpp_stanza_get_from(message);
|
const gchar *from = xmpp_stanza_get_from(message);
|
||||||
@ -697,9 +719,6 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
Jid *jid_to = jid_create(to);
|
Jid *jid_to = jid_create(to);
|
||||||
Jid *my_jid = jid_create(connection_get_fulljid());
|
Jid *my_jid = jid_create(connection_get_fulljid());
|
||||||
|
|
||||||
// check for and deal with message
|
|
||||||
char *message_txt = xmpp_message_get_body(message);
|
|
||||||
if (message_txt) {
|
|
||||||
// check for pgp encrypted message
|
// check for pgp encrypted message
|
||||||
char *enc_message = NULL;
|
char *enc_message = NULL;
|
||||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);
|
xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);
|
||||||
@ -715,9 +734,10 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
} else {
|
} else {
|
||||||
sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
|
sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||||
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);
|
||||||
@ -726,9 +746,6 @@ _handle_carbons(xmpp_stanza_t *const stanza)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_handle_chat(xmpp_stanza_t *const stanza)
|
_handle_chat(xmpp_stanza_t *const stanza)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user