Mercurial > libervia-backend
annotate frontends/src/primitivus/profile_manager.py @ 1667:bf67dc424784
quick_frontend (quick_blog): remove tags2mbdata which is replaced by common.iter2dict
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 24 Nov 2015 23:42:49 +0100 |
parents | 66f0e877625b |
children | 7923dc51143e |
rev | line source |
---|---|
112 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # Primitivus: a SAT frontend |
1396 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org) |
112 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
112 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
112 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | 19 |
771 | 20 from sat.core.i18n import _ |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
21 from sat.core import log as logging |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
22 log = logging.getLogger(__name__) |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
23 from sat_frontends.quick_frontend.quick_profile_manager import QuickProfileManager |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
24 from sat_frontends.primitivus.constants import Const as C |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
25 from sat_frontends.primitivus.keys import action_key_map as a_key |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
26 from urwid_satext import sat_widgets |
112 | 27 import urwid |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
28 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
29 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
30 class ProfileManager(QuickProfileManager, urwid.WidgetWrap): |
112 | 31 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
32 def __init__(self, host, autoconnect=None): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
33 QuickProfileManager.__init__(self, host, autoconnect) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
34 |
113 | 35 #login & password box must be created before list because of onProfileChange |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
36 self.login_wid = sat_widgets.AdvancedEdit(_('Login:'), align='center') |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
37 self.pass_wid = sat_widgets.Password(_('Password:'), align='center') |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
38 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
39 style = ['no_first_select'] |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
40 profiles = host.bridge.getProfilesList() |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
41 profiles.sort() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
42 self.list_profile = sat_widgets.List(profiles, style=style, align='center', on_change=self.onProfileChange) |
113 | 43 |
44 #new & delete buttons | |
45 buttons = [urwid.Button(_("New"), self.onNewProfile), | |
46 urwid.Button(_("Delete"), self.onDeleteProfile)] | |
47 buttons_flow = urwid.GridFlow(buttons, max([len(button.get_label()) for button in buttons])+4, 1, 1, 'center') | |
48 | |
49 #second part: login information: | |
50 divider = urwid.Divider('-') | |
51 | |
52 #connect button | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
53 connect_button = sat_widgets.CustomButton(_("Connect"), self.onConnectProfiles, align='center') |
113 | 54 |
55 #we now build the widget | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
56 list_walker = urwid.SimpleFocusListWalker([buttons_flow,self.list_profile, divider, self.login_wid, self.pass_wid, connect_button]) |
1178
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
57 frame_body = urwid.ListBox(list_walker) |
115
eed4f77c942e
primitivus: Profile Manager should now be fully fonctionnal
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
58 frame = urwid.Frame(frame_body,urwid.AttrMap(urwid.Text(_("Profile Manager"),align='center'),'title')) |
113 | 59 self.main_widget = urwid.LineBox(frame) |
60 urwid.WidgetWrap.__init__(self, self.main_widget) | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
61 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
62 self.go(autoconnect) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
63 |
113 | 64 |
1161
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
65 def keypress(self, size, key): |
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
66 if key == a_key['APP_QUIT']: |
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
67 self.host.onExit() |
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
68 raise urwid.ExitMainLoop() |
1178
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
69 elif key in (a_key['FOCUS_UP'], a_key['FOCUS_DOWN']): |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
70 focus_diff = 1 if key==a_key['FOCUS_DOWN'] else -1 |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
71 list_box = self.main_widget.base_widget.body |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
72 current_focus = list_box.body.get_focus()[1] |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
73 if current_focus is None: |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
74 return |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
75 while True: |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
76 current_focus += focus_diff |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
77 if current_focus < 0 or current_focus >= len(list_box.body): |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
78 break |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
79 if list_box.body[current_focus].selectable(): |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
80 list_box.set_focus(current_focus, 'above' if focus_diff == 1 else 'below') |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
81 list_box._invalidate() |
49d39b619e5d
primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
Goffi <goffi@goffi.org>
parents:
1161
diff
changeset
|
82 return |
1161
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
83 return super(ProfileManager, self).keypress(size, key) |
344bbe6fd1de
primitivus: profile manager now handle APP_QUIT key
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
84 |
113 | 85 def cancelDialog(self, button): |
117 | 86 self.host.removePopUp() |
113 | 87 |
88 def newProfile(self, button, edit): | |
217 | 89 """Create the profile""" |
113 | 90 name = edit.get_edit_text() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
91 self.host.bridge.asyncCreateProfile(name, callback=lambda: self.newProfileCreated(name), errback=self.profileCreationFailure) |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
92 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
93 def newProfileCreated(self, profile): |
117 | 94 self.host.removePopUp() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
95 self.refillProfiles() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
96 self.list_profile.selectValue(profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
97 self.current.profile=profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
98 self.getConnectionParams(profile) |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
99 self.host.redraw() |
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
100 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
101 def profileCreationFailure(self, reason): |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
102 self.host.removePopUp() |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
103 message = self._getErrorMessage(reason) |
1609
66f0e877625b
primitivus: fixed alert case + alert in profileManager
Goffi <goffi@goffi.org>
parents:
1489
diff
changeset
|
104 self.host.alert(_("Can't create profile"), message) |
113 | 105 |
106 def deleteProfile(self, button): | |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
107 self._deleteProfile() |
117 | 108 self.host.removePopUp() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
109 |
113 | 110 def onNewProfile(self, e): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
111 pop_up_widget = sat_widgets.InputDialog(_("New profile"), _("Please enter a new profile name"), cancel_cb=self.cancelDialog, ok_cb=self.newProfile) |
117 | 112 self.host.showPopUp(pop_up_widget) |
113 | 113 |
114 def onDeleteProfile(self, e): | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
115 if self.current.profile: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
116 pop_up_widget = sat_widgets.ConfirmDialog(_("Are you sure you want to delete the profile {} ?").format(self.current.profile), no_cb=self.cancelDialog, yes_cb=self.deleteProfile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
117 self.host.showPopUp(pop_up_widget) |
113 | 118 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
119 def onConnectProfiles(self, button): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
120 """Connect the profiles and start the main widget |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
121 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
122 @param button: the connect button |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
123 """ |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
124 self._onConnectProfiles() |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
125 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
126 def resetFields(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
127 """Set profile to None, and reset fields""" |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
128 super(ProfileManager, self).resetFields() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
129 self.list_profile.unselectAll(invisible=True) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
130 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
131 def setProfiles(self, profiles): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
132 """Update the list of profiles""" |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
133 self.list_profile.changeValues(profiles) |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
134 self.host.redraw() |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
135 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
136 def getProfiles(self): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
137 return self.list_profile.getSelectedValues() |
1019 | 138 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
139 def getJID(self): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
140 return self.login_wid.get_edit_text() |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
141 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
142 def getPassword(self): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
143 return self.pass_wid.get_edit_text() |
413
dd4caab17008
core: - individual parameters managed through sqlite
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
144 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
145 def setJID(self, jid_): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
146 self.login_wid.set_edit_text(jid_) |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
147 self.current.login = jid_ |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
148 self.host.redraw() # FIXME: redraw should be avoided |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
149 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
150 def setPassword(self, password): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
151 self.pass_wid.set_edit_text(password) |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
152 self.current.password = password |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
153 self.host.redraw() |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
154 |
1488
66d01f29f886
primitivus (ProfileManager): fixed profile change event callback
Goffi <goffi@goffi.org>
parents:
1479
diff
changeset
|
155 def onProfileChange(self, list_wid, widget=None, selected=None): |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
156 """This is called when a profile is selected in the profile list. |
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
157 |
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
158 @param list_wid: the List widget who sent the event |
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
159 """ |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
160 self.updateConnectionParams() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
161 focused = list_wid.focus |
1479
057f0714f27e
primivitus: fixed profile manager exception when nothing is focused
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
162 selected = focused.getState() if focused is not None else False |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
163 if not selected: # profile was just unselected |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
164 return |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
165 focused.setState(False, invisible=True) # we don't want the widget to be selected until we are sure we can access it |
1489
039d96e131be
frontends: callback are now always used in QuickApp launchAction (before it was only used if validated is present):
Goffi <goffi@goffi.org>
parents:
1488
diff
changeset
|
166 def authenticate_cb(data, cb_id, profile): |
039d96e131be
frontends: callback are now always used in QuickApp launchAction (before it was only used if validated is present):
Goffi <goffi@goffi.org>
parents:
1488
diff
changeset
|
167 if C.bool(data.pop('validated', C.BOOL_FALSE)): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
168 self.current.profile = profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
169 focused.setState(True, invisible=True) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
170 self.getConnectionParams(profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
171 self.host.redraw() |
1489
039d96e131be
frontends: callback are now always used in QuickApp launchAction (before it was only used if validated is present):
Goffi <goffi@goffi.org>
parents:
1488
diff
changeset
|
172 self.host.actionManager(data, callback=authenticate_cb, profile=profile) |
039d96e131be
frontends: callback are now always used in QuickApp launchAction (before it was only used if validated is present):
Goffi <goffi@goffi.org>
parents:
1488
diff
changeset
|
173 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
174 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=focused.text) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
175 |