Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0077.py @ 554:caad23285a38
plugin XEP-0077: misc fixes
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Dec 2012 23:24:53 +0100 |
parents | 2c4016921403 |
children | ca13633d3b6b |
comparison
equal
deleted
inserted
replaced
553:2b3e3349f6a4 | 554:caad23285a38 |
---|---|
18 You should have received a copy of the GNU Affero General Public License | 18 You should have received a copy of the GNU Affero General Public License |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | 20 """ |
21 | 21 |
22 from logging import debug, info, error | 22 from logging import debug, info, error |
23 from twisted.words.protocols.jabber import client, jid | 23 from twisted.words.protocols.jabber import jid |
24 from twisted.words.protocols.jabber import error as jab_error | |
25 from twisted.words.protocols.jabber.xmlstream import IQ | 24 from twisted.words.protocols.jabber.xmlstream import IQ |
26 from twisted.internet import reactor | |
27 from sat.tools.xml_tools import dataForm2xml | 25 from sat.tools.xml_tools import dataForm2xml |
28 import pdb | |
29 | 26 |
30 from wokkel import data_form | 27 from wokkel import data_form |
31 | 28 |
32 NS_REG = 'jabber:iq:register' | 29 NS_REG = 'jabber:iq:register' |
33 | 30 |
113 answer_data={"message":_("Username already exists, please choose an other one")} | 110 answer_data={"message":_("Username already exists, please choose an other one")} |
114 else: | 111 else: |
115 answer_data['reason'] = 'unknown' | 112 answer_data['reason'] = 'unknown' |
116 answer_data={"message":_("Registration failed")} | 113 answer_data={"message":_("Registration failed")} |
117 self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile) | 114 self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data, profile) |
118 if self.triggers.has_key(answer["from"]): | 115 if failure.value.stanza["from"] in self.triggers.has_key: |
119 del self.triggers[answer["from"]] | 116 del self.triggers[failure.value.stanza["from"]] |
120 | 117 |
121 def in_band_submit(self, action, target, fields, profile): | 118 def in_band_submit(self, action, target, fields, profile): |
122 """Submit a form for registration, using data_form""" | 119 """Submit a form for registration, using data_form""" |
123 id, deferred = self.host.submitForm(action, target, fields, profile) | 120 id, deferred = self.host.submitForm(action, target, fields, profile) |
124 if action == 'CANCEL': | 121 if action == 'CANCEL': |
136 to_jid = jid.JID(target) | 133 to_jid = jid.JID(target) |
137 debug(_("Asking registration for [%s]") % to_jid.full()) | 134 debug(_("Asking registration for [%s]") % to_jid.full()) |
138 reg_request=IQ(client.xmlstream,'get') | 135 reg_request=IQ(client.xmlstream,'get') |
139 reg_request["from"]=client.jid.full() | 136 reg_request["from"]=client.jid.full() |
140 reg_request["to"] = to_jid.full() | 137 reg_request["to"] = to_jid.full() |
141 query=reg_request.addElement('query', NS_REG) | 138 reg_request.addElement('query', NS_REG) |
142 reg_request.send(to_jid.full()).addCallbacks(self.reg_ok, self.reg_err, callbackArgs=[profile], errbackArgs=[profile]) | 139 reg_request.send(to_jid.full()).addCallbacks(self.reg_ok, self.reg_err, callbackArgs=[client.profile], errbackArgs=[client.profile]) |
143 return reg_request["id"] | 140 return reg_request["id"] |