From 503ee35bd0bd1c263e4bc0115c31464f5d0f0016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Thu, 5 Jul 2018 21:09:55 +0200 Subject: [PATCH] Add message handlers for AUTH and ROSTERX --- gajim/common/connection_handlers.py | 13 ++++++++++++- gajim/common/connection_handlers_events.py | 12 ------------ gajim/common/modules/http_auth.py | 3 ++- gajim/common/modules/roster_item_exchange.py | 3 ++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gajim/common/connection_handlers.py b/gajim/common/connection_handlers.py index 8b0a5943e..865c7b205 100644 --- a/gajim/common/connection_handlers.py +++ b/gajim/common/connection_handlers.py @@ -302,6 +302,11 @@ class ConnectionHandlersBase: # We decrypt GPG messages one after the other. Keep queue in mem self.gpg_messages_to_decrypt = [] + # XEPs that are based on Message + self._message_namespaces = set([nbxmpp.NS_HTTP_AUTH, + nbxmpp.NS_PUBSUB_EVENT, + nbxmpp.NS_ROSTERX]) + app.ged.register_event_handler('iq-error-received', ged.CORE, self._nec_iq_error_received) app.ged.register_event_handler('presence-received', ged.CORE, @@ -1023,7 +1028,13 @@ ConnectionHTTPUpload): """ Called when we receive a message """ - if nbxmpp.NS_PUBSUB_EVENT in stanza.getProperties(): + + # Check if a child of the message contains any + # of these namespaces, so we dont execute the + # message handler for them. + # They have defined their own message handlers + # but nbxmpp executes less common handlers last + if self._message_namespaces & set(stanza.getProperties()): return log.debug('MessageCB') diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index 8554525b7..2443c4201 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -914,18 +914,6 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): self.stanza.getFrom()) return - # check if the message is a roster item exchange (XEP-0144) - if self.stanza.getTag('x', namespace=nbxmpp.NS_ROSTERX): - self.conn.get_module('RosterItemExchange').received_item( - self.conn, self.stanza) - return - - # check if the message is a XEP-0070 confirmation request - if self.stanza.getTag('confirm', namespace=nbxmpp.NS_HTTP_AUTH): - self.conn.get_module('HTTPAuth').answer_request( - self.conn, self.stanza) - return - try: self.get_jid_resource() except helpers.InvalidFormat: diff --git a/gajim/common/modules/http_auth.py b/gajim/common/modules/http_auth.py index 3cf8131a9..52b22e277 100644 --- a/gajim/common/modules/http_auth.py +++ b/gajim/common/modules/http_auth.py @@ -30,7 +30,8 @@ class HTTPAuth: self._account = con.name self.handlers = [ - ('iq', self.answer_request, 'get', nbxmpp.NS_HTTP_AUTH) + ('iq', self.answer_request, 'get', nbxmpp.NS_HTTP_AUTH), + ('message', self.answer_request, '', nbxmpp.NS_HTTP_AUTH) ] def answer_request(self, con, stanza): diff --git a/gajim/common/modules/roster_item_exchange.py b/gajim/common/modules/roster_item_exchange.py index 3ae5ca010..ab356fc5c 100644 --- a/gajim/common/modules/roster_item_exchange.py +++ b/gajim/common/modules/roster_item_exchange.py @@ -31,7 +31,8 @@ class RosterItemExchange: self._account = con.name self.handlers = [ - ('iq', self.received_item, 'set', nbxmpp.NS_ROSTERX) + ('iq', self.received_item, 'set', nbxmpp.NS_ROSTERX), + ('message', self.received_item, '', nbxmpp.NS_ROSTERX) ] def received_item(self, con, stanza):