diff 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
line wrap: on
line diff
--- a/plugins/plugin_xep_0100.py	Sat Jun 19 17:15:30 2010 +0800
+++ b/plugins/plugin_xep_0100.py	Tue Jun 22 13:58:53 2010 +0800
@@ -88,8 +88,14 @@
         self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}}
         for item in disco._items:
             debug (_("item found: %s"), item.name)
-            client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id)
-            client.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id)
+            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)
+
+    def discoItemsErr(self, failure, request_id, target, client):
+        """Something is going wrong with disco"""
+        error(_("Error when discovering [%(target)s]: %(condition)s") % {'target':target.full(), 'condition':unicode(failure.value)})
+        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)}}
+        self.host.bridge.actionResult("ERROR", request_id, message_data)
+
 
     def registrationSuccessful(self, target):
         """Called when in_band registration is ok, we must now follow the rest of procedure"""
@@ -107,10 +113,11 @@
         """Find gateways in the target JID, using discovery protocol
         Return an id used for retrieving the list of gateways
         """
+        profile = self.host.memory.getProfileName(profile_key)
         client = self.host.getClient(profile_key)
         assert(client)
         to_jid = jid.JID(target)
-        debug (_("find gateways (target = %s)") % to_jid.full())
+        debug (_("find gateways (target = %(target)s, profile = %(profile)s)") % {'target':to_jid.full(), 'profile':profile})
         request_id = self.host.get_next_id()
-        client.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid, client = client)
+        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)
         return request_id