plugin XEP-0100: fixed lackings profile arguments in some methods
This commit is contained in:
parent
a60c48d91d
commit
93777afc48
1 changed files with 9 additions and 13 deletions
|
|
@ -20,13 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
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 @@ class XEP_0100():
|
|||
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 @@ class XEP_0100():
|
|||
|
||||
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 @@ class XEP_0100():
|
|||
'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 @@ class XEP_0100():
|
|||
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 @@ class XEP_0100():
|
|||
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
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue