comparison sat/stdui/ui_profile_manager.py @ 3120:0c29155ac68b

core: backend autoconnection: A new Connection/autoconnect_backend param can be set for a profile or component to be started automatically with backend. This is specially useful for components, but can be useful for client profile too (e.g. on Android we need to start profile with backend to get notifications, this part will come with following commits). The new Sqlite.getIndParamValues method allows to retrieve the same parameters for all profiles.
author Goffi <goffi@goffi.org>
date Sat, 25 Jan 2020 21:08:32 +0100
parents ab2696e34d29
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3119:790489521b15 3120:0c29155ac68b
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 from sat.core.i18n import D_ 21 from sat.core.i18n import D_
22 from sat.core.constants import Const as C 22 from sat.core.constants import Const as C
23 from sat.core.log import getLogger 23 from sat.core.log import getLogger
24
25 log = getLogger(__name__)
26 from sat.core import exceptions 24 from sat.core import exceptions
27 from sat.tools import xml_tools 25 from sat.tools import xml_tools
28 from sat.memory.memory import ProfileSessions 26 from sat.memory.memory import ProfileSessions
27 from twisted.internet import defer
29 from twisted.words.protocols.jabber import jid 28 from twisted.words.protocols.jabber import jid
29
30
31 log = getLogger(__name__)
30 32
31 33
32 class ProfileManager(object): 34 class ProfileManager(object):
33 """Manage profiles.""" 35 """Manage profiles."""
34 36
141 def _changeXMPPPasswordCb(self, data, profile): 143 def _changeXMPPPasswordCb(self, data, profile):
142 xmpp_password = data[xml_tools.formEscape("xmpp_password")] 144 xmpp_password = data[xml_tools.formEscape("xmpp_password")]
143 d = self.host.memory.setParam( 145 d = self.host.memory.setParam(
144 "Password", xmpp_password, "Connection", profile_key=profile 146 "Password", xmpp_password, "Connection", profile_key=profile
145 ) 147 )
146 d.addCallback(lambda __: self.host.connect(profile)) 148 d.addCallback(lambda __: defer.ensureDeferred(self.host.connect(profile)))
147 d.addCallback(lambda __: {}) 149 d.addCallback(lambda __: {})
148 d.addErrback(lambda __: self._changeXMPPPassword({}, profile)) 150 d.addErrback(lambda __: self._changeXMPPPassword({}, profile))
149 return d 151 return d