Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjs <js-gajim@webkeks.org>2008-07-23 22:28:55 +0400
committerjs <js-gajim@webkeks.org>2008-07-23 22:28:55 +0400
commit40112aa1280604bae4f725da8eed363316931384 (patch)
treebbe1fa5c5bb33f5670cd72c299e398d34438910b
parent0d9a73cde9b36b381aadefcd81d0c9663a4f12d9 (diff)
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!
-rw-r--r--src/common/caps.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/common/caps.py b/src/common/caps.py
index 3dc278602..c41caf8db 100644
--- a/src/common/caps.py
+++ b/src/common/caps.py
@@ -202,32 +202,42 @@ class ConnectionCaps(object):
''' Handle incoming presence stanzas... This is a callback
for xmpp registered in connection_handlers.py'''
+ # we will put these into proper Contact object and ask
+ # for disco... so that disco will learn how to interpret
+ # these caps
+ jid = helpers.get_full_jid_from_iq(presence)
+ contact = gajim.contacts.get_contact_from_full_jid(
+ self.name, jid)
+ if contact is None:
+ room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
+ contact = gajim.contacts.get_gc_contact(
+ self.name, room_jid, nick)
+ if contact is None:
+ # TODO: a way to put contact not-in-roster
+ # into Contacts
+ return
+
# get the caps element
caps = presence.getTag('c')
if not caps:
+ contact.caps_node = None
+ contact.caps_hash = None
+ contact.hash_method = None
return
- hash_method, node, hash = caps['hash'], caps['node'], caps['ver']
+ hash_method, node, hash = \
+ caps['hash'], caps['node'], caps['ver']
+
if hash_method is None or node is None or hash is None:
# improper caps in stanza, ignoring
+ contact.caps_node = None
+ contact.caps_hash = None
+ contact.hash_method = None
return
- # we will put these into proper Contact object and ask
- # for disco... so that disco will learn how to interpret
- # these caps
-
- jid = helpers.get_full_jid_from_iq(presence)
-
# start disco query...
gajim.capscache.preload(self, jid, node, hash_method, hash)
- contact = gajim.contacts.get_contact_from_full_jid(self.name, jid)
- if contact is None:
- room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
- contact = gajim.contacts.get_gc_contact(self.name, room_jid, nick)
- if contact is None:
- return # TODO: a way to put contact not-in-roster into Contacts
-
# overwriting old data
contact.caps_node = node
contact.caps_hash_method = hash_method