diff src/plugins/plugin_xep_0100.py @ 544:899bd6fc7580

plugin XEP-0100: fixed lackings profile arguments in some methods
author Goffi <goffi@goffi.org>
date Wed, 14 Nov 2012 21:29:38 +0100
parents 2a072735e459
children ca13633d3b6b
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0100.py	Wed Nov 14 20:56:04 2012 +0100
+++ b/src/plugins/plugin_xep_0100.py	Wed Nov 14 21:29:38 2012 +0100
@@ -20,13 +20,9 @@
 """
 
 from logging import debug, info, error
-from twisted.internet import protocol
-from twisted.words.protocols.jabber import client, jid
+from twisted.words.protocols.jabber import client as jabber_client, jid
 from twisted.words.protocols.jabber import error as jab_error
 import twisted.internet.error
-import pdb
-
-from wokkel import disco, iwokkel
 
 PLUGIN_INFO = {
 "name": "Gateways Plugin",
@@ -47,7 +43,7 @@
         host.bridge.addMethod("findGateways", ".plugin", in_sign='ss', out_sign='s', method=self.findGateways)
         host.bridge.addMethod("gatewayRegister", ".plugin", in_sign='ssa(ss)s', out_sign='s', method=self.gatewayRegister)
 
-    def __inc_handled_items(self, request_id):
+    def __inc_handled_items(self, request_id, profile):
         self.__gateways[request_id]['__handled_items']+=1
 
         if self.__gateways[request_id]['__total_items'] == self.__gateways[request_id]['__handled_items']:
@@ -55,9 +51,9 @@
             
             del self.__gateways[request_id]['__total_items']
             del self.__gateways[request_id]['__handled_items']
-            self.host.actionResultExt(request_id,"DICT_DICT",self.__gateways[request_id])
+            self.host.actionResultExt(request_id,"DICT_DICT",self.__gateways[request_id], profile)
 
-    def discoInfo(self, disco, entity, request_id):
+    def discoInfo(self, disco, entity, request_id, profile):
         """Find disco infos about entity, to check if it is a gateway"""
 
         for identity in disco.identities:
@@ -68,13 +64,13 @@
                     'type':identity[1]
                 }
 
-        self.__inc_handled_items(request_id)
+        self.__inc_handled_items(request_id, profile)
     
-    def discoInfoErr(self, failure, entity, request_id):
+    def discoInfoErr(self, failure, entity, request_id, profile):
         """Something is going wrong with disco"""
         failure.trap(jab_error.StanzaError,twisted.internet.error.ConnectionLost)
         error(_("Error when discovering [%(jid)s]: %(error)s") % {'jid':entity.full(), 'error':failure.getErrorMessage()})
-        self.__inc_handled_items(request_id)
+        self.__inc_handled_items(request_id, profile)
         
     
     def discoItems(self, disco, request_id, target, client):
@@ -90,7 +86,7 @@
         for item in disco._items:
             #TODO: need to set a timeout for theses requests
             debug (_("item found: %s"), item.name)
-            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)
+            client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id, profile=client.profile).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id, profile=client.profile)
 
     def discoItemsErr(self, failure, request_id, target, client):
         """Something is going wrong with disco"""
@@ -113,7 +109,7 @@
             self.host.plugins["XEP-0077"].addTrigger(target, self.registrationSuccessful, profile)
         return self.host.plugins["XEP-0077"].in_band_submit(action, target, fields, profile)
 
-    def findGateways(self, target, profile_key='@DEFAULT@'):
+    def findGateways(self, target, profile_key):
         """Find gateways in the target JID, using discovery protocol
         Return an id used for retrieving the list of gateways
         """