the removal of an agent is now async

This commit is contained in:
Yann Leboulanger 2005-05-08 17:33:08 +00:00
parent 2171def073
commit 1753a316e4

View file

@ -693,15 +693,10 @@ class Connection:
if delroster:
self.connection.getRoster().delItem(jid)
def unsubscribe_agent(self, agent):
if not self.connection:
def _receive_agent_info(self, con, iq_obj, agent):
if not iq_obj:
return
self.connection.getRoster().delItem(agent)
iq = common.xmpp.Iq('get', common.xmpp.NS_REGISTER, to = agent)
agent_info = self.connection.SendAndWaitForResponse(iq) # FIXME: This blocks!
if not agent_info:
return
key = agent_info.getTag('query').getTagData('key')
key = iq_obj.getTag('query').getTagData('key')
iq = common.xmpp.Iq(to = agent, typ = 'set', queryNS =\
common.xmpp.NS_REGISTER)
iq.getTag('query').setTag('remove')
@ -709,6 +704,16 @@ class Connection:
self.connection.send(iq)
self.dispatch('AGENT_REMOVED', agent)
def unsubscribe_agent(self, agent):
if not self.connection:
return
self.connection.getRoster().delItem(agent)
iq = common.xmpp.Iq('get', common.xmpp.NS_REGISTER, to = agent)
self.connection.SendAndCallForResponse(iq, self._receive_agent_info,
{'agent': agent})
return
agent_info = self.connection.SendAndWaitForResponse(iq) # FIXME: This blocks!
def update_user(self, jid, name, groups):
if self.connection:
self.connection.getRoster().setItem(jid = jid, name = name,