SàT: plugin 0077 & 0100: fixed profile management

This commit is contained in:
Goffi 2010-08-12 12:30:36 +08:00
commit 546a114cde

View file

@ -44,7 +44,7 @@ class XEP_0100():
self.host = host
self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid
host.bridge.addMethod("findGateways", ".communication", in_sign='ss', out_sign='s', method=self.findGateways)
host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)', out_sign='s', method=self.gatewayRegister)
host.bridge.addMethod("gatewayRegister", ".request", in_sign='ssa(ss)s', out_sign='s', method=self.gatewayRegister)
def __inc_handled_items(self, request_id):
self.__gateways[request_id]['__handled_items']+=1
@ -97,17 +97,19 @@ class XEP_0100():
self.host.bridge.actionResult("ERROR", request_id, message_data)
def registrationSuccessful(self, target):
def registrationSuccessful(self, target, profile):
"""Called when in_band registration is ok, we must now follow the rest of procedure"""
debug (_("Registration successful, doing the rest"))
self.host.addContact(target)
self.host.setPresence(target)
self.host.addContact(target, profile)
self.host.setPresence(target, profile)
def gatewayRegister(self, action, target, fields):
def gatewayRegister(self, action, target, fields, profile_key='@DEFAULT@'):
"""Register gateway using in-band registration, then log-in to gateway"""
profile = self.host.memory.getProfileName(profile_key)
assert(profile) #FIXME: return an error here
if action == 'SUBMIT':
self.host.plugins["XEP_0077"].addTrigger(target, self.registrationSuccessful)
return self.host.plugins["XEP_0077"].in_band_submit(action, target, fields)
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@'):
"""Find gateways in the target JID, using discovery protocol