From 4adf2c4f6d63cafcccc45361a0511230c462378b Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 31 Jul 2006 20:27:06 +0000 Subject: [PATCH] when we get an error (when we asked meta contact) don't except the server to include the sent request as it's only a SHOULD in RFC3390 9.2.3.7. detect the answer by iq id instead. --- src/common/connection.py | 3 ++ src/common/connection_handlers.py | 46 ++++++++++++++++--------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 19f1070a1..3c2c4bac5 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -936,6 +936,9 @@ class Connection(ConnectionHandlers): iq = common.xmpp.Iq(typ='get') iq2 = iq.addChild(name='query', namespace='jabber:iq:private') iq2.addChild(name='storage', namespace='storage:metacontacts') + id = self.connection.getAnID() + iq.setID(id) + self.awaiting_answers[id] = (METACONTACTS_ARRIVED, ) self.connection.send(iq) def store_metacontacts(self, tags_list): diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index a976c608b..7b9538b78 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -39,6 +39,7 @@ STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', VCARD_PUBLISHED = 'vcard_published' VCARD_ARRIVED = 'vcard_arrived' AGENT_REMOVED = 'agent_removed' +METACONTACTS_ARRIVED = 'metacontacts_arrived' HAS_IDLE = True try: import common.idle as idle # when we launch gajim from sources @@ -970,6 +971,29 @@ class ConnectionVcard: elif self.awaiting_answers[id][0] == AGENT_REMOVED: jid = self.awaiting_answers[id][1] self.dispatch('AGENT_REMOVED', jid) + elif self.awaiting_answers[id][0] == METACONTACTS_ARRIVED: + if iq_obj.getType() == 'result': + # Metacontact tags + # http://www.jabber.org/jeps/jep-XXXX.html + meta_list = {} + query = iq_obj.getTag('query') + storage = query.getTag('storage') + metas = storage.getTags('meta') + for meta in metas: + jid = meta.getAttr('jid') + tag = meta.getAttr('tag') + data = {'jid': jid} + order = meta.getAttr('order') + if order != None: + data['order'] = order + if meta_list.has_key(tag): + meta_list[tag].append(data) + else: + meta_list[tag] = [data] + self.dispatch('METACONTACTS', meta_list) + # We can now continue connection by requesting the roster + self.connection.initRoster() + del self.awaiting_answers[id] def _vCardCB(self, con, vc): @@ -1135,26 +1159,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) self.bookmarks.append(bm) self.dispatch('BOOKMARKS', self.bookmarks) - elif ns == 'storage:metacontacts': - # Metacontact tags - # http://www.jabber.org/jeps/jep-XXXX.html - meta_list = {} - metas = storage.getTags('meta') - for meta in metas: - jid = meta.getAttr('jid') - tag = meta.getAttr('tag') - data = {'jid': jid} - order = meta.getAttr('order') - if order != None: - data['order'] = order - if meta_list.has_key(tag): - meta_list[tag].append(data) - else: - meta_list[tag] = [data] - self.dispatch('METACONTACTS', meta_list) - # We can now continue connection by requesting the roster - self.connection.initRoster() - elif ns == 'gajim:prefs': # Preferences data # http://www.jabber.org/jeps/jep-0049.html @@ -1847,8 +1851,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco) common.xmpp.NS_ROSTER) con.RegisterHandler('iq', self._PrivateCB, 'result', common.xmpp.NS_PRIVATE) - con.RegisterHandler('iq', self._PrivateErrorCB, 'error', - common.xmpp.NS_PRIVATE) con.RegisterHandler('iq', self._HttpAuthCB, 'get', common.xmpp.NS_HTTP_AUTH) con.RegisterHandler('iq', self._gMailNewMailCB, 'set',