infor user about success or failure of registration with an agent. Fixes #3474
This commit is contained in:
		
							parent
							
								
									2087fcb016
								
							
						
					
					
						commit
						2804251df6
					
				
					 1 changed files with 15 additions and 4 deletions
				
			
		| 
						 | 
					@ -661,16 +661,26 @@ class ConnectionDisco:
 | 
				
			||||||
	def request_register_agent_info(self, agent):
 | 
						def request_register_agent_info(self, agent):
 | 
				
			||||||
		if not self.connection or self.connected < 2:
 | 
							if not self.connection or self.connected < 2:
 | 
				
			||||||
			return None
 | 
								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()
 | 
							id_ = self.connection.getAnID()
 | 
				
			||||||
		iq.setID(id_)
 | 
							iq.setID(id_)
 | 
				
			||||||
		# Wait the answer during 30 secondes
 | 
							# Wait the answer during 30 secondes
 | 
				
			||||||
		self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_,
 | 
							self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_,
 | 
				
			||||||
			_('Registration information for transport %s has not arrived in time') % \
 | 
								_('Registration information for transport %s has not arrived in time')\
 | 
				
			||||||
			agent)
 | 
								% agent)
 | 
				
			||||||
		self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo,
 | 
							self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo,
 | 
				
			||||||
			{'agent': agent})
 | 
								{'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):
 | 
						def register_agent(self, agent, info, is_form = False):
 | 
				
			||||||
		if not self.connection or self.connected < 2:
 | 
							if not self.connection or self.connected < 2:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
| 
						 | 
					@ -679,7 +689,8 @@ class ConnectionDisco:
 | 
				
			||||||
			query = iq.getTag('query')
 | 
								query = iq.getTag('query')
 | 
				
			||||||
			info.setAttr('type', 'submit')
 | 
								info.setAttr('type', 'submit')
 | 
				
			||||||
			query.addChild(node = info)
 | 
								query.addChild(node = info)
 | 
				
			||||||
			self.connection.send(iq)
 | 
								self.connection.SendAndCallForResponse(iq, self._agent_registered_cb,
 | 
				
			||||||
 | 
									{'agent': agent})
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			# fixed: blocking
 | 
								# fixed: blocking
 | 
				
			||||||
			common.xmpp.features_nb.register(self.connection, agent, info, None)
 | 
								common.xmpp.features_nb.register(self.connection, agent, info, None)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue