Author: asterix
Date: 2006-05-01 20:29:12 +0200 (Mon, 01 May 2006)
New Revision: 6261
Modified:
trunk/src/common/connection.py
trunk/src/common/connection_handlers.py
trunk/src/gajim.py
trunk/src/roster_window.py
Log:
be sure that transport is really removed before we start to remove its contacts.
Modified: trunk/src/common/connection.py
===================================================================
--- trunk/src/common/connection.py 2006-05-01 17:42:12 UTC (rev 6260)
+++ trunk/src/common/connection.py 2006-05-01 18:29:12 UTC (rev 6261)
@@ -744,6 +744,9 @@
return
iq = common.xmpp.Iq('set', common.xmpp.NS_REGISTER, to = agent)
iq.getTag('query').setTag('remove')
+ id = self.connection.getAnID()
+ iq.setID(id)
+ self.awaiting_answers[id] = (AGENT_REMOVED, agent)
self.connection.send(iq)
self.connection.getRoster().delItem(agent)
Modified: trunk/src/common/connection_handlers.py
===================================================================
--- trunk/src/common/connection_handlers.py 2006-05-01 17:42:12 UTC (rev 6260)
+++ trunk/src/common/connection_handlers.py 2006-05-01 18:29:12 UTC (rev 6261)
@@ -40,6 +40,7 @@
# kind of events we can wait for an answer
VCARD_PUBLISHED = 'vcard_published'
VCARD_ARRIVED = 'vcard_arrived'
+AGENT_REMOVED = 'agent_removed'
HAS_IDLE = True
try:
import common.idle as idle # when we launch gajim from sources
@@ -947,6 +948,9 @@
self.dispatch('VCARD', {'jid': jid})
elif jid == our_jid:
self.dispatch('MYVCARD', {'jid': jid})
+ elif self.awaiting_answers[id][0] == AGENT_REMOVED:
+ jid = self.awaiting_answers[id][1]
+ self.dispatch('AGENT_REMOVED', jid)
del self.awaiting_answers[id]
def _vCardCB(self, con, vc):
Modified: trunk/src/gajim.py
===================================================================
--- trunk/src/gajim.py 2006-05-01 17:42:12 UTC (rev 6260)
+++ trunk/src/gajim.py 2006-05-01 18:29:12 UTC (rev 6261)
@@ -729,6 +729,23 @@
except AttributeError:
return
+ def handle_event_agent_removed(self, account, agent):
+ # remove transport's contacts from treeview
+ jid_list = gajim.contacts.get_jid_list(account)
+ for jid in jid_list:
+ if jid.endswith('@' + agent):
+ c = gajim.contacts.get_first_contact_from_jid(account, jid)
+ gajim.log.debug(
+ 'Removing contact %s due to unregistered transport %s'\
+ % (jid, agent))
+ gajim.connections[account].unsubscribe(c.jid)
+ # Transport contacts can't have 2 resources
+ if c.jid in gajim.to_be_removed[account]:
+ # This way we'll really remove it
+ gajim.to_be_removed[account].remove(c.jid)
+ gajim.contacts.remove_jid(account, c.jid)
+ self.roster.remove_contact(c, account)
+
def handle_event_register_agent_info(self, account, array):
#('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
if array[1].has_key('instructions'):
@@ -1623,6 +1640,7 @@
'SUBSCRIBE': self.handle_event_subscribe,
'AGENT_ERROR_INFO': self.handle_event_agent_info_error,
'AGENT_ERROR_ITEMS': self.handle_event_agent_items_error,
+ 'AGENT_REMOVED': self.handle_event_agent_removed,
'REGISTER_AGENT_INFO': self.handle_event_register_agent_info,
'AGENT_INFO_ITEMS': self.handle_event_agent_info_items,
'AGENT_INFO_INFO': self.handle_event_agent_info_info,
Modified: trunk/src/roster_window.py
===================================================================
--- trunk/src/roster_window.py 2006-05-01 17:42:12 UTC (rev 6260)
+++ trunk/src/roster_window.py 2006-05-01 18:29:12 UTC (rev 6261)
@@ -1142,18 +1142,6 @@
gajim.connections[account].unsubscribe_agent(full_jid)
# remove transport from treeview
self.remove_contact(contact, account)
- # remove transport's contacts from treeview
- jid_list = gajim.contacts.get_jid_list(account)
- for jid in jid_list:
- if jid.endswith('@' + contact.jid):
- c = gajim.contacts.get_first_contact_from_jid(account, jid)
- gajim.log.debug(
- 'Removing contact %s due to unregistered transport %s'\
- % (jid, contact.jid))
- gajim.connections[account].unsubscribe(c.jid)
- # Transport contacts can't have 2 resources
- gajim.contacts.remove_jid(account, c.jid)
- self.remove_contact(c, account)
gajim.contacts.remove_jid(account, contact.jid)
gajim.contacts.remove_contact(account, contact)