diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-07-02 17:53:28 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-07-02 17:53:28 +0200 |
commit | 83ed9ba24b85bd47ef3b2e90d4634a19b258d3a0 (patch) | |
tree | d31511562632df787b2aa36cd7ed0b7fea02d37f /src | |
parent | 6be5b51a46d1598ac12ddda88b36a2487bf523e0 (diff) | |
download | profani-tty-83ed9ba24b85bd47ef3b2e90d4634a19b258d3a0.tar.gz |
message.c: Put plugin handler code in helper function
Diffstat (limited to 'src')
-rw-r--r-- | src/xmpp/message.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 42507b91..4419f4ba 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -96,20 +96,27 @@ static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, static GHashTable *pubsub_event_handlers; -static int -_message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata) +static gboolean +_handled_by_plugin(xmpp_stanza_t *const stanza) { - 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); + 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"); + + 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); |