mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
message.c: Add pubsub helper function
This commit is contained in:
parent
f2b415079a
commit
728cb55b68
@ -88,6 +88,7 @@ static void _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam);
|
|||||||
static void _handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam);
|
static void _handle_ox_chat(xmpp_stanza_t *const stanza, ProfMessage *message, gboolean is_mam);
|
||||||
static void _send_message_stanza(xmpp_stanza_t *const stanza);
|
static void _send_message_stanza(xmpp_stanza_t *const stanza);
|
||||||
static gboolean _handle_mam(xmpp_stanza_t *const stanza);
|
static gboolean _handle_mam(xmpp_stanza_t *const stanza);
|
||||||
|
static void _handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPGME
|
#ifdef HAVE_LIBGPGME
|
||||||
static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text);
|
static xmpp_stanza_t* _openpgp_signcrypt(xmpp_ctx_t* ctx, const char* const to, const char* const text);
|
||||||
@ -160,19 +161,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con
|
|||||||
// XEP-0060: Publish-Subscribe
|
// XEP-0060: Publish-Subscribe
|
||||||
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
|
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
|
||||||
if (event) {
|
if (event) {
|
||||||
xmpp_stanza_t *child = xmpp_stanza_get_children(event);
|
_handle_pubsub(stanza, event);
|
||||||
if (child) {
|
|
||||||
const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
|
|
||||||
if (node) {
|
|
||||||
ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, node);
|
|
||||||
if (handler) {
|
|
||||||
int keep = handler->func(stanza, handler->userdata);
|
|
||||||
if (!keep) {
|
|
||||||
g_hash_table_remove(pubsub_event_handlers, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handle_chat(stanza, FALSE);
|
_handle_chat(stanza, FALSE);
|
||||||
@ -1429,6 +1418,23 @@ _handle_mam(xmpp_stanza_t *const stanza)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_pubsub(xmpp_stanza_t *const stanza, xmpp_stanza_t *const event) {
|
||||||
|
xmpp_stanza_t *child = xmpp_stanza_get_children(event);
|
||||||
|
if (child) {
|
||||||
|
const char *node = xmpp_stanza_get_attribute(child, STANZA_ATTR_NODE);
|
||||||
|
if (node) {
|
||||||
|
ProfMessageHandler *handler = g_hash_table_lookup(pubsub_event_handlers, node);
|
||||||
|
if (handler) {
|
||||||
|
int keep = handler->func(stanza, handler->userdata);
|
||||||
|
if (!keep) {
|
||||||
|
g_hash_table_remove(pubsub_event_handlers, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_send_message_stanza(xmpp_stanza_t *const stanza)
|
_send_message_stanza(xmpp_stanza_t *const stanza)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user