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

message.c: Put plugin handler code in helper function

This commit is contained in:
Michael Vetter 2020-07-02 17:53:28 +02:00
parent 6be5b51a46
commit 83ed9ba24b

View File

@ -96,20 +96,27 @@ static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to,
static GHashTable *pubsub_event_handlers;
static gboolean
_handled_by_plugin(xmpp_stanza_t *const stanza)
{
char *text;
size_t text_size;
xmpp_stanza_to_text(stanza, &text, &text_size);
gboolean cont = plugins_on_message_stanza_receive(text);
xmpp_free(connection_get_ctx(), text);
return !cont;
}
static int
_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata)
{
log_debug("Message stanza handler fired");
char *text;
size_t text_size;
xmpp_stanza_to_text(stanza, &text, &text_size);
gboolean cont = plugins_on_message_stanza_receive(text);
if (!cont) {
xmpp_free(connection_get_ctx(), text);
if (_handled_by_plugin(stanza)) {
return 1;
}
xmpp_free(connection_get_ctx(), text);
// type according to RFC 6121
const char *type = xmpp_stanza_get_type(stanza);