Mercurial > libervia-backend
annotate src/stdui/ui_profile_manager.py @ 1644:98a2eb768bb0
core: fixed session cleaning after actionNew timeout
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 22 Nov 2015 21:23:14 +0100 |
parents | 05274b27e90e |
children | 52af44e745b5 |
rev | line source |
---|---|
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # SAT standard user interface for managing contacts |
1396 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org) |
6 # Copyright (C) 2013, 2014, 2015 Adrien Cossa (souliane@mailoo.org) | |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 # (at your option) any later version. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 # GNU Affero General Public License for more details. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
1131
90f82f4ee405
core (stdui): fixed forgotten parametter in getParamError
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
21 from sat.core.i18n import D_ |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 from sat.core.constants import Const as C |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 from sat.tools import xml_tools |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 from sat.memory.crypto import PasswordHasher |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
25 from sat.memory.memory import ProfileSessions |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 from twisted.internet import defer |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
27 from twisted.words.protocols.jabber import jid |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 class ProfileManager(object): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
31 """Manage profiles.""" |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 def __init__(self, host): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 self.host = host |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 self.profile_ciphers = {} |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
36 self._sessions = ProfileSessions() |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 host.registerCallback(self._authenticateProfile, force_id=C.AUTHENTICATE_PROFILE_ID, with_data=True) |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
38 host.registerCallback(self._changeXMPPPassword, force_id=C.CHANGE_XMPP_PASSWD_ID, with_data=True) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
39 self.__new_xmpp_passwd_id = host.registerCallback(self._changeXMPPPasswordCb, with_data=True) |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 def _authenticateProfile(self, data, profile): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 """Get the data/dialog for connecting a profile |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 @param data (dict) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 @param profile: %(doc_profile)s |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 @return: deferred dict |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 """ |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
48 def gotProfileCipher(profile_cipher): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 if self.host.memory.auth_sessions.profileGetUnique(profile): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 # case 1: profile already authenticated |
1313
a8d7500090f6
core: boolConst is used to convert a boolean value to its equivalent string constant
Goffi <goffi@goffi.org>
parents:
1263
diff
changeset
|
51 return {'validated': C.boolConst(True)} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 self.profile_ciphers[profile] = profile_cipher |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 if 'profile_password' in data: |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 # case 2: password is provided by the caller |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
55 return self._verifyPassword(data, profile) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
56 |
1263 | 57 def check_empty_password(verify_password_result): |
58 validated = C.bool(verify_password_result['validated']) | |
59 if validated: | |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
60 # case 3: there's no password for this profile |
1263 | 61 return verify_password_result |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
62 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
63 # case 4: prompt the user for a password |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
64 def xmlui_cb(data_, profile): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
65 return self._verifyPassword(data_, profile) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
66 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
67 callback_id = self.host.registerCallback(xmlui_cb, with_data=True, one_shot=True) |
1530 | 68 form_ui = xml_tools.XMLUI("form", title=D_('Profile password for {}').format(profile), submit_id=callback_id) |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
69 form_ui.addPassword('profile_password', value='') |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 return {'xmlui': form_ui.toXml()} |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
71 |
1263 | 72 check_empty_data = {'profile_password': ''} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 d = self._verifyPassword(check_empty_data, profile) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 return d.addCallback(check_empty_password) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 d = self.host.memory.asyncGetStringParamA(C.PROFILE_PASS_PATH[1], C.PROFILE_PASS_PATH[0], profile_key=profile) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
77 d.addCallback(gotProfileCipher) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
78 d.addErrback(self.getParamError) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
79 return d |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
80 |
1131
90f82f4ee405
core (stdui): fixed forgotten parametter in getParamError
Goffi <goffi@goffi.org>
parents:
1089
diff
changeset
|
81 def getParamError(self, failure): |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
82 _dialog = xml_tools.XMLUI('popup', title=D_('Error')) |
1063
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
83 _dialog.addText(D_("Can't get profile parameter.")) |
1313
a8d7500090f6
core: boolConst is used to convert a boolean value to its equivalent string constant
Goffi <goffi@goffi.org>
parents:
1263
diff
changeset
|
84 return {'xmlui': _dialog.toXml(), 'validated': C.boolConst(False)} |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
85 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
86 @defer.inlineCallbacks |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
87 def _verifyPassword(self, data, profile): |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
88 """Verify the given password |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
89 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
90 @param data (dict) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
91 @param profile: %(doc_profile)s |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
92 @return: deferred dict |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
93 """ |
1608
05274b27e90e
frontends (xmlui): fixed widget closing on submit
Goffi <goffi@goffi.org>
parents:
1530
diff
changeset
|
94 assert profile in self.profile_ciphers |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
95 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
96 try: |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
97 profile_password = data[xml_tools.formEscape('profile_password')] |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
98 except KeyError: |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
99 profile_password = data['profile_password'] # not received from a user input |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
100 verified = yield PasswordHasher.verify(profile_password, self.profile_ciphers[profile]) |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
101 if not verified: |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
102 _dialog = xml_tools.XMLUI('popup', title=D_('Connection error')) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
103 _dialog.addText(D_("The provided profile password doesn't match.")) |
1313
a8d7500090f6
core: boolConst is used to convert a boolean value to its equivalent string constant
Goffi <goffi@goffi.org>
parents:
1263
diff
changeset
|
104 defer.returnValue({'xmlui': _dialog.toXml(), 'validated': C.boolConst(False)}) |
1032
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
105 |
b262ae6d53af
stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
106 yield self.host.memory.newAuthSession(profile_password, profile) |
1313
a8d7500090f6
core: boolConst is used to convert a boolean value to its equivalent string constant
Goffi <goffi@goffi.org>
parents:
1263
diff
changeset
|
107 defer.returnValue({'validated': C.boolConst(True)}) |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
108 |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
109 def _changeXMPPPassword(self, data, profile): |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
110 session_data = self._sessions.profileGetUnique(profile) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
111 if not session_data: |
1088
b29452cab50b
core, memory, plugins, stdui, frontends: look for DNS SRV records when server is not specified:
souliane <souliane@mailoo.org>
parents:
1063
diff
changeset
|
112 server = self.host.memory.getParamA(C.FORCE_SERVER_PARAM, "Connection", profile_key=profile) |
1089
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
113 if not server: |
8e0072754413
core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents:
1088
diff
changeset
|
114 server = jid.parse(self.host.memory.getParamA('JabberID', "Connection", profile_key=profile))[1] |
1212
628e320eab1f
memory: Sessions.newSession can be called with a forced session ID
souliane <souliane@mailoo.org>
parents:
1131
diff
changeset
|
115 session_id, session_data = self._sessions.newSession({'count': 0, 'server': server}, profile=profile) |
1043
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
116 if session_data['count'] > 2: # 3 attempts with a new password after the initial try |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
117 self._sessions.profileDelUnique(profile) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
118 _dialog = xml_tools.XMLUI('popup', title=D_('Connection error')) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
119 _dialog.addText(D_("Can't connect to %s. Please check your connection details.") % session_data['server']) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
120 return {'xmlui': _dialog.toXml()} |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
121 session_data['count'] += 1 |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
122 counter = ' (%d)' % session_data['count'] if session_data['count'] > 1 else '' |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
123 title = D_('XMPP password for %(profile)s%(counter)s') % {'profile': profile, 'counter': counter} |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
124 form_ui = xml_tools.XMLUI("form", title=title, submit_id=self.__new_xmpp_passwd_id) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
125 form_ui.addText(D_("Can't connect to %s. Please check your connection details or try with another password.") % session_data['server']) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
126 form_ui.addPassword('xmpp_password', value='') |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
127 return {'xmlui': form_ui.toXml()} |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
128 |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
129 def _changeXMPPPasswordCb(self, data, profile): |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
130 xmpp_password = data[xml_tools.formEscape('xmpp_password')] |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
131 d = self.host.memory.setParam("Password", xmpp_password, "Connection", profile_key=profile) |
066308706dc6
core, stdui (profile manager), quick_app: ask for another XMPP password when profile authentication succeed but XMPP connection fails
souliane <souliane@mailoo.org>
parents:
1032
diff
changeset
|
132 d.addCallback(lambda dummy: self.host.asyncConnect(profile)) |
1060
aa15453ec54d
core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
133 d.addCallback(lambda dummy: {}) |
aa15453ec54d
core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
134 d.addErrback(lambda dummy: self._changeXMPPPassword({}, profile)) |
aa15453ec54d
core (xmpp), stdui (profile_manager), bridge, frontends: raise an exception if the XMPP connection failed instead of sending a signal
souliane <souliane@mailoo.org>
parents:
1043
diff
changeset
|
135 return d |