Mercurial > libervia-backend
annotate libervia/frontends/quick_frontend/quick_profile_manager.py @ 4216:1a7a3e4b52a4
core (memory/migration):
Update XEP-0384 and `fe3a02cb4bec_convert_legacypickle_columns_to_json.py` migration to
properly handle (de)serialisation of `TrustMessageCacheEntry`.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 05 Mar 2024 17:31:12 +0100 |
parents | b620a8e882e1 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3137 | 1 #!/usr/bin/env python3 |
2 | |
112 | 3 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
4 # helper class for making a SAT frontend |
3479 | 5 # Copyright (C) 2009-2021 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 |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
20 from libervia.backend.core.i18n import _ |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
21 from libervia.backend.core import log as logging |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
22 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
23 log = logging.getLogger(__name__) |
4076
b620a8e882e1
refactoring: rename `libervia.frontends.primitivus` to `libervia.tui`
Goffi <goffi@goffi.org>
parents:
4074
diff
changeset
|
24 from libervia.tui.constants import Const as C |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
25 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
26 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
27 class ProfileRecord(object): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
28 """Class which manage data for one profile""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
29 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
30 def __init__(self, profile=None, login=None, password=None): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
31 self._profile = profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
32 self._login = login |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
33 self._password = password |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
34 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
35 @property |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
36 def profile(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
37 return self._profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
38 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
39 @profile.setter |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
40 def profile(self, value): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
41 self._profile = value |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
42 # if we change the profile, |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
43 # we must have no login/password until backend give them |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
44 self._login = self._password = None |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
45 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
46 @property |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
47 def login(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
48 return self._login |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
49 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
50 @login.setter |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
51 def login(self, value): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
52 self._login = value |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
53 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
54 @property |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
55 def password(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
56 return self._password |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
57 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
58 @password.setter |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
59 def password(self, value): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
60 self._password = value |
112 | 61 |
62 | |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
63 class QuickProfileManager(object): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
64 """Class with manage profiles creation/deletion/connection""" |
112 | 65 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
66 def __init__(self, host, autoconnect=None): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
67 """Create the manager |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
68 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
69 @param host: %(doc_host)s |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
70 @param autoconnect(iterable): list of profiles to connect automatically |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
71 """ |
112 | 72 self.host = host |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
73 self._autoconnect = bool(autoconnect) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
74 self.current = ProfileRecord() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
75 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
76 def go(self, autoconnect): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
77 if self._autoconnect: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
78 self.autoconnect(autoconnect) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
79 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
80 def autoconnect(self, profile_keys): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
81 """Automatically connect profiles |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
82 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
83 @param profile_keys(iterable): list of profile keys to connect |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
84 """ |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
85 if not profile_keys: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
86 log.warning("No profile given to autoconnect") |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
87 return |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
88 self._autoconnect = True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
89 self._autoconnect_profiles = [] |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
90 self._do_autoconnect(profile_keys) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
91 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
92 def _do_autoconnect(self, profile_keys): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
93 """Connect automatically given profiles |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
94 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
95 @param profile_kes(iterable): profiles to connect |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
96 """ |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
97 assert self._autoconnect |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
98 |
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:
1409
diff
changeset
|
99 def authenticate_cb(data, cb_id, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
100 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
101 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
|
102 self._autoconnect_profiles.append(profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
103 if len(self._autoconnect_profiles) == len(profile_keys): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
104 # all the profiles have been validated |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
105 self.host.plug_profiles(self._autoconnect_profiles) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
106 else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
107 # a profile is not validated, we go to manual mode |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
108 self._autoconnect = False |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
109 self.host.action_manager(data, callback=authenticate_cb, profile=profile) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
110 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
111 def get_profile_name_cb(profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
112 if not profile: |
2091
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
113 # FIXME: this method is not handling manual mode correclty anymore |
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
114 # must be thought to be handled asynchronously |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
115 self._autoconnect = False # manual mode |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
116 msg = _("Trying to plug an unknown profile key ({})".format(profile_key)) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
117 log.warning(msg) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
118 self.host.show_dialog(_("Profile plugging in error"), msg, "error") |
2091
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
119 else: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
120 self.host.action_launch( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
121 C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
122 ) |
2091
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
123 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
124 def get_profile_name_eb(failure): |
3028 | 125 log.error("Can't retrieve profile name: {}".format(failure)) |
2091
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
126 |
f413bfc24458
bridge, quick_frontend: preparation for async bridge
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
127 for profile_key in profile_keys: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
128 self.host.bridge.profile_name_get( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
129 profile_key, callback=get_profile_name_cb, errback=get_profile_name_eb |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
130 ) |
112 | 131 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
132 def get_param_error(self, __): |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
133 self.host.show_dialog(_("Error"), _("Can't get profile parameter"), "error") |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
134 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
135 ## Helping methods ## |
113 | 136 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
137 def _get_error_message(self, reason): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
138 """Return an error message corresponding to profile creation error |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
139 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
140 @param reason (str): reason as returned by profile_create |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
141 @return (unicode): human readable error message |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
142 """ |
1063
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1034
diff
changeset
|
143 if reason == "ConflictError": |
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1034
diff
changeset
|
144 message = _("A profile with this name already exists") |
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1034
diff
changeset
|
145 elif reason == "CancelError": |
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1034
diff
changeset
|
146 message = _("Profile creation cancelled by backend") |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
147 elif reason == "ValueError": |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
148 message = _( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
149 "You profile name is not valid" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
150 ) # TODO: print a more informative message (empty name, name starting with '@') |
421
28e4299d4553
primitivus: profile manager updated to use new asynchronous profile creation
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
151 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
152 message = _("Can't create profile ({})").format(reason) |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
153 return message |
113 | 154 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
155 def _delete_profile(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
156 """Delete the currently selected profile""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
157 if self.current.profile: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
158 self.host.bridge.profile_delete_async( |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
159 self.current.profile, callback=self.refill_profiles |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
160 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
161 self.reset_fields() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
162 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
163 ## workflow methods (events occuring during the profiles selection) ## |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
164 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
165 # These methods must be called by the frontend at some point |
113 | 166 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
167 def _on_connect_profiles(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
168 """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
|
169 if self._autoconnect: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
170 self.host.show_dialog( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
171 _("Internal error"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
172 _("You can't connect manually and automatically at the same time"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
173 "error", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
174 ) |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
175 return |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
176 self.update_connection_params() |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
177 profiles = self.get_profiles() |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
178 if not profiles: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
179 self.host.show_dialog( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
180 _("No profile selected"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
181 _("You need to create and select at least one profile before connecting"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
182 "error", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
183 ) |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
184 else: |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
185 # All profiles in the list are already validated, so we can plug them directly |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
186 self.host.plug_profiles(profiles) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
187 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
188 def get_connection_params(self, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
189 """Get login and password and display them |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
190 |
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
191 @param profile: %(doc_profile)s |
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
192 """ |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
193 self.host.bridge.param_get_a_async( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
194 "JabberID", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
195 "Connection", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
196 profile_key=profile, |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
197 callback=self.set_jid, |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
198 errback=self.get_param_error, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
199 ) |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
200 self.host.bridge.param_get_a_async( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
201 "Password", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
202 "Connection", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
203 profile_key=profile, |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
204 callback=self.set_password, |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
205 errback=self.get_param_error, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
206 ) |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
207 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
208 def update_connection_params(self): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
209 """Check if connection parameters have changed, and update them if so""" |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
210 if self.current.profile: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
211 login = self.get_jid() |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
212 password = self.getPassword() |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
213 if login != self.current.login and self.current.login is not None: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
214 self.current.login = login |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
215 self.host.bridge.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
216 "JabberID", login, "Connection", profile_key=self.current.profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
217 ) |
3028 | 218 log.info("login updated for profile [{}]".format(self.current.profile)) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
219 if password != self.current.password and self.current.password is not None: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
220 self.current.password = password |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
221 self.host.bridge.param_set( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
222 "Password", password, "Connection", profile_key=self.current.profile |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
223 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
224 log.info( |
3028 | 225 "password updated for profile [{}]".format(self.current.profile) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
226 ) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
227 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
228 ## graphic updates (should probably be overriden in frontends) ## |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
229 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
230 def reset_fields(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
231 """Set profile to None, and reset fields""" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
232 self.current.profile = None |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
233 self.set_jid("") |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
234 self.set_password("") |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
235 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
236 def refill_profiles(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
237 """Rebuild the list of profiles""" |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
238 profiles = self.host.bridge.profiles_list_get() |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
239 profiles.sort() |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
240 self.set_profiles(profiles) |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
241 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
242 ## Method which must be implemented by frontends ## |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
243 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
244 # get/set data |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
245 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
246 def get_profiles(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
247 """Return list of selected profiles |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
248 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
249 Must be implemented by frontends |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
250 @return (list): list of profiles |
1034
5197600a1e13
quick_app, primitivus: update the connection mechanism to ask for non empty profile passwords
souliane <souliane@mailoo.org>
parents:
1019
diff
changeset
|
251 """ |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
252 raise NotImplementedError |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
253 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
254 def set_profiles(self, profiles): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
255 """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
|
256 raise NotImplementedError |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
257 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
258 def get_jid(self): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
259 """Get current jid |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
260 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
261 Must be implemented by frontends |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
262 @return (unicode): current jabber id |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
263 """ |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
264 raise NotImplementedError |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
265 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
266 def getPassword(self): |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
267 """Get current password |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
268 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
269 Must be implemented by frontends |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
270 @return (unicode): current password |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
271 """ |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
272 raise NotImplementedError |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
273 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
274 def set_jid(self, jid_): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
275 """Set current jid |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
276 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
277 Must be implemented by frontends |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
278 @param jid_(unicode): jabber id to set |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1178
diff
changeset
|
279 """ |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
280 raise NotImplementedError |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
281 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
282 def set_password(self, password): |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
283 """Set current password |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
284 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
285 Must be implemented by frontends |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
286 """ |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
287 raise NotImplementedError |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
288 |
1288
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
289 # dialogs |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
290 |
7cf32aeeebdb
quick_frontend, primitivus: moved parts of primitivus's profileManager to quick_frontend
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
291 # Note: a method which check profiles change must be implemented too |