Philipp Hörist pushed to branch master at gajim / gajim

Commits:
503ee35b by Philipp Hörist at 2018-07-05T21:09:55+02:00
Add message handlers for AUTH and ROSTERX

- - - - -
51e85f14 by Philipp Hörist at 2018-07-05T21:41:28+02:00
Remove unused code

- - - - -
a1e1e56d by Philipp Hörist at 2018-07-05T22:03:06+02:00
Fix logic error when printing status

- - - - -


6 changed files:

- gajim/common/connection.py
- gajim/common/connection_handlers.py
- gajim/common/connection_handlers_events.py
- gajim/common/modules/http_auth.py
- gajim/common/modules/roster_item_exchange.py
- gajim/groupchat_control.py


Changes:

=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -630,7 +630,6 @@ class Connection(CommonConnection, ConnectionHandlers):
         self.last_time_to_reconnect = None
         self.new_account_info = None
         self.new_account_form = None
-        self.last_io = app.idlequeue.current_time()
         self.last_sent = []
         self.password = passwords.get_password(name)
 
@@ -1512,7 +1511,6 @@ class Connection(CommonConnection, ConnectionHandlers):
             app.nec.push_incoming_event(AnonymousAuthEvent(None,
                 conn=self, old_jid=old_jid, new_jid=new_jid))
         if auth:
-            self.last_io = app.idlequeue.current_time()
             self.connected = 2
             self.retrycount = 0
             if self.on_connect_auth:


=====================================
gajim/common/connection_handlers.py
=====================================
--- 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')
 
@@ -1192,9 +1203,6 @@ ConnectionHTTPUpload):
                 # This way we'll really remove it
                 app.to_be_removed[self.name].remove(jid)
 
-    def _StanzaArrivedCB(self, con, obj):
-        self.last_io = app.idlequeue.current_time()
-
     def _MucOwnerCB(self, con, iq_obj):
         log.debug('MucOwnerCB')
         app.nec.push_incoming_event(MucOwnerReceivedEvent(None, conn=self,
@@ -1459,10 +1467,7 @@ ConnectionHTTPUpload):
         con.RegisterHandler('iq', self._JingleCB, 'set', nbxmpp.NS_JINGLE)
         con.RegisterHandler('iq', self._ErrorCB, 'error')
         con.RegisterHandler('iq', self._IqCB)
-        con.RegisterHandler('iq', self._StanzaArrivedCB)
         con.RegisterHandler('iq', self._ResultCB, 'result')
-        con.RegisterHandler('presence', self._StanzaArrivedCB)
-        con.RegisterHandler('message', self._StanzaArrivedCB)
         con.RegisterHandler('unknown', self._StreamCB,
             nbxmpp.NS_XMPP_STREAMS, xmlns=nbxmpp.NS_STREAMS)
         con.RegisterHandler('iq', self._PubkeyGetCB, 'get',


=====================================
gajim/common/connection_handlers_events.py
=====================================
--- 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:


=====================================
gajim/common/modules/http_auth.py
=====================================
--- 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):


=====================================
gajim/common/modules/roster_item_exchange.py
=====================================
--- 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):


=====================================
gajim/groupchat_control.py
=====================================
--- a/gajim/groupchat_control.py
+++ b/gajim/groupchat_control.py
@@ -1978,8 +1978,11 @@ class GroupchatControl(ChatControlBase):
             con = app.connections[self.account]
             bookmarks = con.get_module('Bookmarks').bookmarks
             bookmark = bookmarks.get(self.room_jid, None)
-            print_status = bookmark.get(
-                'print_status', app.config.get('print_status_in_muc'))
+            if bookmark is None or not bookmark['print_status']:
+                print_status = app.config.get('print_status_in_muc')
+            else:
+                print_status = bookmark['print_status']
+
             if obj.show == 'offline':
                 if obj.nick in self.attention_list:
                     self.attention_list.remove(obj.nick)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/fe3c1b4fbdb206c1d9fac096d37dffce0f394f9b...a1e1e56dda620ea01f86e2dd23b9f0d281bea9ee

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/fe3c1b4fbdb206c1d9fac096d37dffce0f394f9b...a1e1e56dda620ea01f86e2dd23b9f0d281bea9ee
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to