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

Commits:

2 changed files:

Changes:

  • gajim/common/connection.py
    ... ... @@ -671,6 +671,8 @@ class Connection(CommonConnection, ConnectionHandlers):
    671 671
             self.try_connecting_for_foo_secs = 45
    
    672 672
             # holds the actual hostname to which we are connected
    
    673 673
             self.connected_hostname = None
    
    674
    +        # Holds the full jid we received on the bind event
    
    675
    +        self.registered_name = None
    
    674 676
             self.redirected = None
    
    675 677
             self.last_time_to_reconnect = None
    
    676 678
             self.new_account_info = None
    
    ... ... @@ -754,19 +756,16 @@ class Connection(CommonConnection, ConnectionHandlers):
    754 756
         def check_jid(self, jid):
    
    755 757
             return helpers.parse_jid(jid)
    
    756 758
     
    
    757
    -    def get_own_jid(self, full=False):
    
    759
    +    def get_own_jid(self):
    
    758 760
             """
    
    759
    -        Return our own jid as JID
    
    760
    -        If full = True, this raises an exception if we cant provide
    
    761
    -        the full JID
    
    761
    +        Return the last full JID we received on a bind event.
    
    762
    +        In case we were never connected it returns the bare JID from config.
    
    762 763
             """
    
    763
    -        if self.connection:
    
    764
    -            full_jid = self.connection._registered_name
    
    765
    -            return nbxmpp.JID(full_jid)
    
    764
    +        if self.registered_name:
    
    765
    +            # This returns the full jid we received on the bind event
    
    766
    +            return self.registered_name
    
    766 767
             else:
    
    767
    -            if full:
    
    768
    -                raise exceptions.GajimGeneralException(
    
    769
    -                    'We are not connected, full JID unknown.')
    
    768
    +            # This returns the bare jid 
    
    770 769
                 return nbxmpp.JID(gajim.get_jid_from_account(self.name))
    
    771 770
     
    
    772 771
         def reconnect(self):
    
    ... ... @@ -1465,6 +1464,7 @@ class Connection(CommonConnection, ConnectionHandlers):
    1465 1464
                     return
    
    1466 1465
             if hasattr(con, 'Resource'):
    
    1467 1466
                 self.server_resource = con.Resource
    
    1467
    +        self.registered_name = con._registered_name
    
    1468 1468
             if gajim.config.get_per('accounts', self.name, 'anonymous_auth'):
    
    1469 1469
                 # Get jid given by server
    
    1470 1470
                 old_jid = gajim.get_jid_from_account(self.name)
    

  • gajim/common/connection_handlers_events.py
    ... ... @@ -1146,7 +1146,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
    1146 1146
             self.encrypted = False
    
    1147 1147
             account = self.conn.name
    
    1148 1148
     
    
    1149
    -        if self.stanza.getFrom() == self.conn.get_own_jid(full=True):
    
    1149
    +        if self.stanza.getFrom() == self.conn.get_own_jid():
    
    1150 1150
                 # Drop messages sent from our own full jid
    
    1151 1151
                 # It can happen that when we sent message to our own bare jid
    
    1152 1152
                 # that the server routes that message back to us