be sure that transport is really removed before we start to remove its contacts.
This commit is contained in:
parent
50c14f16a8
commit
d25d056677
|
@ -744,6 +744,9 @@ class Connection(ConnectionHandlers):
|
|||
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)
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
|||
# 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 @@ class ConnectionVcard:
|
|||
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):
|
||||
|
|
18
src/gajim.py
18
src/gajim.py
|
@ -729,6 +729,23 @@ class Interface:
|
|||
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 @@ class Interface:
|
|||
'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,
|
||||
|
|
|
@ -1142,18 +1142,6 @@ class RosterWindow:
|
|||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue