Mercurial > libervia-backend
annotate src/plugins/plugin_misc_register_account.py @ 2104:4f189bd1d9ed
misc: README update
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Dec 2016 14:08:21 +0100 |
parents | 2daf7b4c6756 |
children | 33c8c4973743 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
1 #!/usr/bin/env python2 |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # SàT plugin for registering a new XMPP account |
1766 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) | |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 # (at your option) any later version. |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 # GNU Affero General Public License for more details. |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 from sat.core.i18n import _, D_ |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 from sat.core.log import getLogger |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 log = getLogger(__name__) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 from sat.core.constants import Const as C |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
25 from twisted.words.protocols.jabber import jid, xmlstream |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 from sat.core import xmpp |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 from sat.memory.memory import Sessions |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 from twisted.internet import reactor, defer |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 from sat.tools import xml_tools |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 from sat.tools.xml_tools import SAT_FORM_PREFIX, SAT_PARAM_SEPARATOR |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
31 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 PLUGIN_INFO = { |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 "name": "Register Account Plugin", |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 "import_name": "REGISTER-ACCOUNT", |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 "type": "MISC", |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 "protocols": [], |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 "dependencies": [], |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 "recommendations": [], |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 "main": "RegisterAccount", |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 "handler": "no", |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 "description": _(u"""Register XMPP account""") |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 } |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 class RegisterAccount(object): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
48 def __init__(self, host): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 log.info(_(u"Plugin Register Account initialization")) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 self.host = host |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
51 self._sessions = Sessions() |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 host.registerCallback(self.registerNewAccountCB, with_data=True, force_id="registerNewAccount") |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 self.__register_account_id = host.registerCallback(self._registerConfirmation, with_data=True) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
55 def registerNewAccountCB(self, data, profile): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
56 """Called when the use click on the "New account" button.""" |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
57 session_data = {} |
1088
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
58 for param in ('JabberID', 'Password', C.FORCE_PORT_PARAM, C.FORCE_SERVER_PARAM): |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
59 try: |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
60 session_data[param] = data["%s%s%s%s" % (SAT_FORM_PREFIX, "Connection", SAT_PARAM_SEPARATOR, param)] |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
61 except KeyError: |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
62 if param in (C.FORCE_PORT_PARAM, C.FORCE_SERVER_PARAM): |
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
63 session_data[param] = '' |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
64 |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
65 for param in ('JabberID', 'Password'): |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
66 if not session_data[param]: |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
67 form_ui = xml_tools.XMLUI("popup", title=D_("Missing values")) |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
68 form_ui.addText(D_("No user JID or password given: can't register new account.")) |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
69 return {'xmlui': form_ui.toXml()} |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
71 session_data['user'], host, resource = jid.parse(session_data['JabberID']) |
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
72 session_data['server'] = session_data[C.FORCE_SERVER_PARAM] or host |
1212
628e320eab1f
memory: Sessions.newSession can be called with a forced session ID
souliane <souliane@mailoo.org>
parents:
1089
diff
changeset
|
73 session_id, dummy = self._sessions.newSession(session_data, profile=profile) |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 form_ui = xml_tools.XMLUI("form", title=D_("Register new account"), submit_id=self.__register_account_id, session_id=session_id) |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
75 form_ui.addText(D_("Do you want to register a new XMPP account [%(user)s] on server %(server)s ?") % {'user': session_data['user'], 'server': session_data['server']}) |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 return {'xmlui': form_ui.toXml()} |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
77 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
78 def _registerConfirmation(self, data, profile): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
79 """Save the related parameters and proceed the registration.""" |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
80 session_data = self._sessions.profileGet(data['session_id'], profile) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
81 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
82 self.host.memory.setParam("JabberID", session_data["JabberID"], "Connection", profile_key=profile) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
83 self.host.memory.setParam("Password", session_data["Password"], "Connection", profile_key=profile) |
1088
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
84 self.host.memory.setParam(C.FORCE_SERVER_PARAM, session_data[C.FORCE_SERVER_PARAM], "Connection", profile_key=profile) |
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1044
diff
changeset
|
85 self.host.memory.setParam(C.FORCE_PORT_PARAM, session_data[C.FORCE_PORT_PARAM], "Connection", profile_key=profile) |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
86 |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
87 d = self._registerNewAccount(session_data['user'], session_data["Password"], None, session_data['server'], profile_key=profile) |
1044
85c110c0be86
plugins misc_account, misc_register_account: manually delete the sessions when not needed anymore
souliane <souliane@mailoo.org>
parents:
1037
diff
changeset
|
88 del self._sessions[data['session_id']] |
85c110c0be86
plugins misc_account, misc_register_account: manually delete the sessions when not needed anymore
souliane <souliane@mailoo.org>
parents:
1037
diff
changeset
|
89 return d |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
90 |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
91 def _registerNewAccount(self, user, password, email, host, port=C.XMPP_C2S_PORT, profile_key=C.PROF_KEY_NONE): |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
92 """Connect to a server and create a new account using in-band registration. |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
93 @param user: login of the account |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
94 @param password: password of the account |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
95 @param email: email of the account |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
96 @param host: host of the server to register to |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
97 @param port: port of the server to register to |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
98 @param profile_key: %(doc_profile_key)s |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
99 """ |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
100 profile = self.host.memory.getProfileName(profile_key) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
101 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
102 d = defer.Deferred() |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
103 serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, host, user, password, email, d, profile)) |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
104 connector = reactor.connectTCP(host, port or C.XMPP_C2S_PORT, serverRegistrer) |
1037
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
105 serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect() |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
106 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
107 def cb(dummy): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
108 xmlui = xml_tools.XMLUI("popup", title=D_("Confirmation")) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
109 xmlui.addText(D_("Registration successful.")) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
110 return ({'xmlui': xmlui.toXml()}) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
111 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
112 def eb(failure): |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
113 xmlui = xml_tools.XMLUI("popup", title=D_("Failure")) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
114 xmlui.addText(D_("Registration failed: %s") % failure.getErrorMessage()) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
115 try: |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
116 if failure.value.condition == 'conflict': |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
117 xmlui.addText(D_("Username already exists, please choose an other one.")) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
118 except AttributeError: |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
119 pass |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
120 return ({'xmlui': xmlui.toXml()}) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
121 |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
122 d.addCallbacks(cb, eb) |
6e975c6b0faf
core, memory, bridge, plugin misc_register_account: move registerNewAccount to a new plugin:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
123 return d |