Author: asterix
Date: 2009-01-26 11:27:46 +0100 (Mon, 26 Jan 2009)
New Revision: 11030
Modified:
trunk/src/common/connection_handlers.py
Log:
infor user about success or failure of registration with an agent. Fixes #3474
Modified: trunk/src/common/connection_handlers.py
===================================================================
--- trunk/src/common/connection_handlers.py 2009-01-26 09:22:28 UTC (rev 11029)
+++ trunk/src/common/connection_handlers.py 2009-01-26 10:27:46 UTC (rev 11030)
@@ -661,16 +661,26 @@
def request_register_agent_info(self, agent):
if not self.connection or self.connected < 2:
return None
- iq=common.xmpp.Iq('get', common.xmpp.NS_REGISTER, to=agent)
+ iq = common.xmpp.Iq('get', common.xmpp.NS_REGISTER, to=agent)
id_ = self.connection.getAnID()
iq.setID(id_)
# Wait the answer during 30 secondes
self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_,
- _('Registration information for transport %s has not arrived in time') % \
- agent)
+ _('Registration information for transport %s has not arrived in time')\
+ % agent)
self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo,
{'agent': agent})
+ def _agent_registered_cb(self, con, resp, agent):
+ if resp.getType() == 'result':
+ self.dispatch('INFORMATION', (_('Registration succeeded'),
+ _('Resgitration with agent %s succeeded') % agent))
+ if resp.getType() == 'error':
+ self.dispatch('ERROR', (_('Registration failed'), _('Resgitration with'
+ ' agent %(agent)s failed with error %(error)s: %(error_msg)s') % {
+ 'agent': agent, 'error': resp.getError(),
+ 'error_msg': resp.getErrorMsg()}))
+
def register_agent(self, agent, info, is_form = False):
if not self.connection or self.connected < 2:
return
@@ -679,7 +689,8 @@
query = iq.getTag('query')
info.setAttr('type', 'submit')
query.addChild(node = info)
- self.connection.send(iq)
+ self.connection.SendAndCallForResponse(iq, self._agent_registered_cb,
+ {'agent': agent})
else:
# fixed: blocking
common.xmpp.features_nb.register(self.connection, agent, info, None)