Changeset 10013

Show
Ignore:
Timestamp:
07/23/08 20:28:55 (6 weeks ago)
Author:
js
Message:

Handle it correctly if caps were removed.
YES, it CAN happen that we had caps and now got a presence without!
And that WILL happen very often, for example if the other end signs
off!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/caps.py

    r9899 r10013  
    203203                for xmpp registered in connection_handlers.py''' 
    204204 
     205                # we will put these into proper Contact object and ask 
     206                # for disco... so that disco will learn how to interpret 
     207                # these caps 
     208                jid = helpers.get_full_jid_from_iq(presence) 
     209                contact = gajim.contacts.get_contact_from_full_jid( 
     210                        self.name, jid) 
     211                if contact is None: 
     212                        room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
     213                        contact = gajim.contacts.get_gc_contact( 
     214                                self.name, room_jid, nick) 
     215                        if contact is None: 
     216                                # TODO: a way to put contact not-in-roster 
     217                                # into Contacts 
     218                                return   
     219 
    205220                # get the caps element 
    206221                caps = presence.getTag('c') 
    207222                if not caps: 
    208                         return 
    209  
    210                 hash_method, node, hash = caps['hash'], caps['node'], caps['ver'] 
     223                        contact.caps_node = None 
     224                        contact.caps_hash = None 
     225                        contact.hash_method = None 
     226                        return 
     227 
     228                hash_method, node, hash = \ 
     229                        caps['hash'], caps['node'], caps['ver'] 
     230 
    211231                if hash_method is None or node is None or hash is None: 
    212232                        # improper caps in stanza, ignoring 
    213                         return 
    214  
    215                 # we will put these into proper Contact object and ask 
    216                 # for disco... so that disco will learn how to interpret 
    217                 # these caps 
    218  
    219                 jid = helpers.get_full_jid_from_iq(presence) 
     233                        contact.caps_node = None 
     234                        contact.caps_hash = None 
     235                        contact.hash_method = None 
     236                        return 
    220237 
    221238                # start disco query... 
    222239                gajim.capscache.preload(self, jid, node, hash_method, hash) 
    223  
    224                 contact = gajim.contacts.get_contact_from_full_jid(self.name, jid) 
    225                 if contact is None: 
    226                         room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) 
    227                         contact = gajim.contacts.get_gc_contact(self.name, room_jid, nick) 
    228                         if contact is None: 
    229                                 return  # TODO: a way to put contact not-in-roster into Contacts 
    230240 
    231241                # overwriting old data