annotate src/stdui/ui_profile_manager.py @ 1723:5632c5350296

core: avoid initialisation blocking when a long callback is added to backend.initialised (could prevent sessions starting)
author Goffi <goffi@goffi.org>
date Mon, 07 Dec 2015 13:10:44 +0100
parents 52af44e745b5
children d17772b0fe22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
069ad98b360d 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org)
069ad98b360d 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 1313
diff changeset
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
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
23 from sat.core.log import getLogger
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
24 log = getLogger(__name__)
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
25 from sat.core import exceptions
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 sat.tools import xml_tools
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
27 from sat.memory.memory import ProfileSessions
1089
8e0072754413 core, plugins, stdui, frontends: fixes handling of "Force server" and "Force port" parameters:
souliane <souliane@mailoo.org>
parents: 1088
diff changeset
28 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
29
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
30
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
31 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
32 """Manage profiles."""
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
33
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
42 def _startSessionEb(self, fail, first, profile):
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
43 """Errback method for startSession during profile authentication
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
44
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
45 @param first(bool): if True, this is the first try and we have tryied empty password
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
46 in this case we ask for a password to the user.
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
47 @param profile(unicode, None): %(doc_profile)s
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
48 must only be used if first is True
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
49 """
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
50 if first:
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
51 # first call, we ask for the password
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
52 form_ui = xml_tools.XMLUI("form", title=D_('Profile password for {}').format(profile), submit_id='')
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
53 form_ui.addPassword('profile_password', value='')
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
54 d = xml_tools.deferredUI(self.host, form_ui, chained=True)
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
55 d.addCallback(self._authenticateProfile, profile)
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
56 return {'xmlui': form_ui.toXml()}
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
57
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
58 assert profile is None
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
59
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
60 if fail.check(exceptions.PasswordError):
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
61 dialog = xml_tools.XMLUI('popup', title=D_('Connection error'))
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
62 dialog.addText(D_("The provided profile password doesn't match."))
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
63 else:
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
64 log.error(u"Unexpected exceptions: {}".format(fail))
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
65 dialog = xml_tools.XMLUI('popup', title=D_('Internal error'))
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
66 dialog.addText(D_(u"Internal error: {}".format(fail)))
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
67 return {'xmlui': dialog.toXml(), 'validated': C.BOOL_FALSE}
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
68
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
69 def _authenticateProfile(self, data, profile):
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
70 if self.host.memory.isSessionStarted(profile):
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
71 return {'validated': C.BOOL_TRUE}
1032
b262ae6d53af stdui: add ui_profile_manager to interact with frontends when profile authentication is needed
souliane <souliane@mailoo.org>
parents:
diff changeset
72 try:
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
73 password = data[xml_tools.formEscape('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
74 except KeyError:
1697
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
75 # first request, we try empty password
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
76 password = ''
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
77 first = True
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
78 eb_profile = profile
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
79 else:
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
80 first = False
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
81 eb_profile = None
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
82 d = self.host.memory.startSession(password, profile)
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
83 d.addCallback(lambda dummy: {'validated': C.BOOL_TRUE})
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
84 d.addErrback(self._startSessionEb, first, eb_profile)
52af44e745b5 core (stdui[ui_profile_manager]): refactored profile authentication: the workflow is greatly simplified by the use of the new startSession mechanisme and deferedUI
Goffi <goffi@goffi.org>
parents: 1608
diff changeset
85 return d
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
86
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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 _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
97 _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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106
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
107 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
108 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
109 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
110 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
111 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
112 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
113 return d