Mercurial > libervia-backend
diff src/plugins/plugin_xep_0077.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | beaf6bec2fcd |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0077.py Fri Jan 18 17:55:27 2013 +0100 +++ b/src/plugins/plugin_xep_0077.py Fri Jan 18 17:55:34 2013 +0100 @@ -39,18 +39,18 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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"]