diff --git a/src/common/connection.py b/src/common/connection.py index 6821551ad..7a80a5249 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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,