Remove trailing whitespaces.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:34 +01:00
commit 27b3592e16

View file

@ -39,18 +39,18 @@ PLUGIN_INFO = {
}
class XEP_0077():
def __init__(self, host):
info(_("Plugin XEP_0077 initialization"))
self.host = host
self.triggers = {} #used by other protocol (e.g. XEP-0100) to finish registration. key = target_jid
host.bridge.addMethod("in_band_register", ".plugin", in_sign='ss', out_sign='s', method=self.in_band_register)
host.bridge.addMethod("in_band_submit", ".plugin", in_sign='ssa(ss)s', out_sign='s', method=self.in_band_submit)
def addTrigger(self, target, cb, profile):
"""Add a callback which is called when registration to target is successful"""
self.triggers[target] = (cb, profile)
def reg_ok(self, answer, profile):
"""Called after the first get IQ"""
try:
@ -62,7 +62,7 @@ class XEP_0077():
answer_type = "ERROR"
self.host.bridge.actionResult(answer_type, answer['id'], answer_data, profile)
return
form = data_form.Form.fromElement(x_elem)
xml_data = dataForm2xml(form)
self.host.bridge.actionResult("XMLUI", answer['id'], {"target":answer["from"], "type":"registration", "xml":xml_data}, profile)
@ -75,13 +75,13 @@ class XEP_0077():
answer_data={"message":"%s [code: %s]" % (failure.value.condition, unicode(failure.value))}
answer_type = "ERROR"
self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile)
def unregistrationAnswer(self, answer, profile):
debug (_("registration answer: %s") % answer.toXml())
answer_type = "SUCCESS"
answer_data={"message":_("Your are now unregistred")}
self.host.bridge.actionResult(answer_type, answer['id'], answer_data, profile)
def unregistrationFailure(self, failure, profile):
info (_("Unregistration failure: %s") % str(failure.value))
answer_type = "ERROR"
@ -89,7 +89,7 @@ class XEP_0077():
answer_data['reason'] = 'unknown'
answer_data={"message":_("Unregistration failed: %s") % failure.value.condition}
self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile)
def registrationAnswer(self, answer, profile):
debug (_("registration answer: %s") % answer.toXml())
answer_type = "SUCCESS"
@ -99,7 +99,7 @@ class XEP_0077():
callback,profile = self.triggers[answer["from"]]
callback(answer["from"], profile)
del self.triggers[answer["from"]]
def registrationFailure(self, failure, profile):
info (_("Registration failure: %s") % str(failure.value))
print failure.value.stanza.toXml()
@ -120,10 +120,10 @@ class XEP_0077():
id, deferred = self.host.submitForm(action, target, fields, profile)
if action == 'CANCEL':
deferred.addCallbacks(self.unregistrationAnswer, self.unregistrationFailure, callbackArgs=[profile], errbackArgs=[profile])
else:
else:
deferred.addCallbacks(self.registrationAnswer, self.registrationFailure, callbackArgs=[profile], errbackArgs=[profile])
return id
def in_band_register(self, target, profile_key='@DEFAULT@'):
"""register to a target JID"""
client = self.host.getClient(profile_key)
@ -137,4 +137,4 @@ class XEP_0077():
reg_request["to"] = to_jid.full()
reg_request.addElement('query', NS_REG)
reg_request.send(to_jid.full()).addCallbacks(self.reg_ok, self.reg_err, callbackArgs=[client.profile], errbackArgs=[client.profile])
return reg_request["id"]
return reg_request["id"]