comparison plugins/plugin_xep_0100.py @ 102:94011f553cd0

misc bugfixes - wix: added forgotten profile in gateways management - xml_tools: removed XMLClass to the 2 methods as a direct methods - plugin_xep_100 (gateways discovery): added error callback
author Goffi <goffi@goffi.org>
date Tue, 22 Jun 2010 13:58:53 +0800
parents 86f1f7f6d332
children 06985b6ad23a
comparison
equal deleted inserted replaced
101:783e9d6980ec 102:94011f553cd0
86 return 86 return
87 87
88 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}} 88 self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}}
89 for item in disco._items: 89 for item in disco._items:
90 debug (_("item found: %s"), item.name) 90 debug (_("item found: %s"), item.name)
91 client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id) 91 client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id)
92 client.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id) 92
93 def discoItemsErr(self, failure, request_id, target, client):
94 """Something is going wrong with disco"""
95 error(_("Error when discovering [%(target)s]: %(condition)s") % {'target':target.full(), 'condition':unicode(failure.value)})
96 message_data={"reason": "connection error", "message":_(u"Error while trying to discover %(target)s gateways: %(error_mess)s") % {'target':target.full(), 'error_mess':unicode(failure.value)}}
97 self.host.bridge.actionResult("ERROR", request_id, message_data)
98
93 99
94 def registrationSuccessful(self, target): 100 def registrationSuccessful(self, target):
95 """Called when in_band registration is ok, we must now follow the rest of procedure""" 101 """Called when in_band registration is ok, we must now follow the rest of procedure"""
96 debug (_("Registration successful, doing the rest")) 102 debug (_("Registration successful, doing the rest"))
97 self.host.addContact(target) 103 self.host.addContact(target)
105 111
106 def findGateways(self, target, profile_key='@DEFAULT@'): 112 def findGateways(self, target, profile_key='@DEFAULT@'):
107 """Find gateways in the target JID, using discovery protocol 113 """Find gateways in the target JID, using discovery protocol
108 Return an id used for retrieving the list of gateways 114 Return an id used for retrieving the list of gateways
109 """ 115 """
116 profile = self.host.memory.getProfileName(profile_key)
110 client = self.host.getClient(profile_key) 117 client = self.host.getClient(profile_key)
111 assert(client) 118 assert(client)
112 to_jid = jid.JID(target) 119 to_jid = jid.JID(target)
113 debug (_("find gateways (target = %s)") % to_jid.full()) 120 debug (_("find gateways (target = %(target)s, profile = %(profile)s)") % {'target':to_jid.full(), 'profile':profile})
114 request_id = self.host.get_next_id() 121 request_id = self.host.get_next_id()
115 client.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid, client = client) 122 client.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid, client = client).addErrback(self.discoItemsErr, request_id=request_id, target = to_jid, client = client)
116 return request_id 123 return request_id