Mercurial > libervia-backend
annotate frontends/src/quick_frontend/quick_app.py @ 1318:6c7d89843f1b frontends_multi_profiles
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 09 Feb 2015 21:39:51 +0100 |
parents | faa1129559b8 |
children | 781ee3539252 |
rev | line source |
---|---|
0 | 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 # helper class for making a SAT frontend |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
0 | 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. |
0 | 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. |
0 | 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/>. |
0 | 19 |
771 | 20 from sat.core.i18n import _ |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
613
diff
changeset
|
21 import sys |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
22 from sat.core.log import getLogger |
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
23 log = getLogger(__name__) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
24 from sat.core import exceptions |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
25 from sat_frontends.tools import jid |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
26 from sat_frontends.quick_frontend.quick_widgets import QuickWidgetsManager |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
27 from sat_frontends.quick_frontend import quick_chat |
0 | 28 |
1019 | 29 from sat_frontends.quick_frontend.constants import Const as C |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
30 |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
31 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
32 class ProfileManager(object): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
33 """Class managing all data relative to one profile, and plugging in mechanism""" |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
34 host = None |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
35 bridge = None |
1318
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
36 cache_keys_to_get = ['avatar'] |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
37 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
38 def __init__(self, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
39 self.profile = profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
40 self.whoami = None |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
41 self.data = {} |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
42 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
43 def __getitem__(self, key): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
44 return self.data[key] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
45 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
46 def __setitem__(self, key, value): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
47 self.data[key] = value |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
48 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
49 def plug(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
50 """Plug the profile to the host""" |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
51 # we get the essential params |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
52 self.bridge.asyncGetParamA("JabberID", "Connection", profile_key=self.profile, |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
53 callback=self._plug_profile_jid, errback=self._getParamError) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
54 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
55 def _plug_profile_jid(self, _jid): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
56 self.whoami = jid.JID(_jid) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
57 self.bridge.asyncGetParamA("autoconnect", "Connection", profile_key=self.profile, |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
58 callback=self._plug_profile_autoconnect, errback=self._getParamError) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
59 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
60 def _plug_profile_autoconnect(self, value_str): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
61 autoconnect = C.bool(value_str) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
62 if autoconnect and not self.bridge.isConnected(self.profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
63 self.host.asyncConnect(self.profile, callback=lambda dummy: self._plug_profile_afterconnect()) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
64 else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
65 self._plug_profile_afterconnect() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
66 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
67 def _plug_profile_afterconnect(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
68 # Profile can be connected or not |
1318
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
69 # we get cached data |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
70 self.host.bridge.getEntitiesData([], ProfileManager.cache_keys_to_get, profile=self.profile, callback=self._plug_profile_gotCachedValues, errback=self._plug_profile_failedCachedValues) |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
71 |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
72 def _plug_profile_failedCachedValues(self, failure): |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
73 log.error("Couldn't get cached values: {}".format(failure)) |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
74 self._plug_profile_gotCachedValues({}) |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
75 |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
76 def _plug_profile_gotCachedValues(self, cached_values): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
77 # TODO: watched plugin |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
78 contact_list = self.host.addContactList(self.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
79 |
1318
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
80 for entity, data in cached_values.iteritems(): |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
81 for key, value in data.iteritems(): |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
82 self.host.contact_lists[self.profile].setCache(jid.JID(entity), key, value) |
6c7d89843f1b
frontends (quick frontend): use of new getEntitiesData to get cached values for avatars on profile connection.
Goffi <goffi@goffi.org>
parents:
1290
diff
changeset
|
83 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
84 if not self.bridge.isConnected(self.profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
85 self.host.setStatusOnline(False, profile=self.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
86 else: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
87 self.host.setStatusOnline(True, profile=self.profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
88 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
89 contact_list.fill() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
90 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
91 #The waiting subscription requests |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
92 self.bridge.getWaitingSub(self.profile, callback=self._plug_profile_gotWaitingSub) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
93 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
94 def _plug_profile_gotWaitingSub(self, waiting_sub): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
95 for sub in waiting_sub: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
96 self.host.subscribeHandler(waiting_sub[sub], sub, self.profile) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
97 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
98 self.bridge.getRoomsJoined(self.profile, callback=self._plug_profile_gotRoomsJoined) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
99 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
100 def _plug_profile_gotRoomsJoined(self, rooms_args): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
101 #Now we open the MUC window where we already are: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
102 for room_args in rooms_args: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
103 self.host.roomJoinedHandler(*room_args, profile=self.profile) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
104 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
105 self.bridge.getRoomsSubjects(self.profile, callback=self._plug_profile_gotRoomsSubjects) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
106 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
107 def _plug_profile_gotRoomsSubjects(self, subjects_args): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
108 for subject_args in subjects_args: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
109 self.host.roomNewSubjectHandler(*subject_args, profile=self.profile) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
110 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
111 #Presence must be requested after rooms are filled |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
112 self.host.bridge.getPresenceStatuses(self.profile, callback=self._plug_profile_gotPresences) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
113 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
114 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
115 def _plug_profile_gotPresences(self, presences): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
116 def gotEntityData(data, contact): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
117 for key in ('avatar', 'nick'): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
118 if key in data: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
119 self.host.entityDataUpdatedHandler(contact, key, data[key], self.profile) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
120 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
121 for contact in presences: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
122 for res in presences[contact]: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
123 jabber_id = ('%s/%s' % (jid.JID(contact).bare, res)) if res else contact |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
124 show = presences[contact][res][0] |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
125 priority = presences[contact][res][1] |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
126 statuses = presences[contact][res][2] |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
127 self.host.presenceUpdateHandler(jabber_id, show, priority, statuses, self.profile) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
128 self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug("No cache data for {}".format(contact))) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
129 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
130 #Finaly, we get the waiting confirmation requests |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
131 self.bridge.getWaitingConf(self.profile, callback=self._plug_profile_gotWaitingConf) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
132 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
133 def _plug_profile_gotWaitingConf(self, waiting_confs): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
134 for confirm_id, confirm_type, data in waiting_confs: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
135 self.host.askConfirmationHandler(confirm_id, confirm_type, data, self.profile) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
136 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
137 # At this point, profile should be fully plugged |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
138 # and we launch frontend specific method |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
139 self.host.profilePlugged(self.profile) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
140 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
141 def _getParamError(self, ignore): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
142 log.error(_("Can't get profile parameter")) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
143 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
144 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
145 class ProfilesManager(object): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
146 """Class managing collection of profiles""" |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
147 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
148 def __init__(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
149 self._profiles = {} |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
150 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
151 def __contains__(self, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
152 return profile in self._profiles |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
153 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
154 def __iter__(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
155 return self._profiles.iterkeys() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
156 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
157 def __getitem__(self, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
158 return self._profiles[profile] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
159 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
160 def __len__(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
161 return len(self._profiles) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
162 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
163 def plug(self, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
164 if profile in self._profiles: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
165 raise exceptions.ConflictError('A profile of the name [{}] is already plugged'.format(profile)) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
166 self._profiles[profile] = ProfileManager(profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
167 self._profiles[profile].plug() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
168 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
169 def unplug(self, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
170 if profile not in self._profiles: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
171 raise ValueError('The profile [{}] is not plugged'.format(profile)) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
172 del self._profiles[profile] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
173 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
174 def chooseOneProfile(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
175 return self._profiles.keys()[0] |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
176 |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
177 class QuickApp(object): |
0 | 178 """This class contain the main methods needed for the frontend""" |
179 | |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
180 def __init__(self, create_bridge, check_options=None): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
181 """Create a frontend application |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
182 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
183 @param create_bridge: method to use to create the Bridge |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
184 @param check_options: method to call to check options (usually command line arguments) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
185 """ |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
186 ProfileManager.host = self |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
187 self.profiles = ProfilesManager() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
188 self.contact_lists = {} |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
189 self.widgets = QuickWidgetsManager(self) |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
190 if check_options is not None: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
191 self.options = check_options() |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
192 else: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
193 self.options = None |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
194 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
195 # widgets |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
196 self.selected_widget = None # widget currently selected (must be filled by frontend) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
197 |
0 | 198 ## bridge ## |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
199 try: |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
200 self.bridge = create_bridge() |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
201 except exceptions.BridgeExceptionNoService: |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
202 print(_(u"Can't connect to SàT backend, are you sure it's launched ?")) |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
613
diff
changeset
|
203 sys.exit(1) |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
204 except exceptions.BridgeInitError: |
627
d207c2186519
core, bridge, jp, quick_frontend: SàT stop more gracefully if bridge can't be initialised:
Goffi <goffi@goffi.org>
parents:
613
diff
changeset
|
205 print(_(u"Can't init bridge")) |
165
8a2053de6f8c
Frontends: management of unlaunched SàT Backend (information message and exit)
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
206 sys.exit(1) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
207 ProfileManager.bridge = self.bridge |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
208 self.registerSignal("connected") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
209 self.registerSignal("disconnected") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
210 self.registerSignal("newContact") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
211 self.registerSignal("newMessage", self._newMessage) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
212 self.registerSignal("newAlert") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
213 self.registerSignal("presenceUpdate") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
214 self.registerSignal("subscribe") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
215 self.registerSignal("paramUpdate") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
216 self.registerSignal("contactDeleted") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
217 self.registerSignal("entityDataUpdated") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
218 self.registerSignal("askConfirmation") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
219 self.registerSignal("actionResult") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
220 self.registerSignal("actionResultExt", self.actionResultHandler) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
221 self.registerSignal("roomJoined", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
222 self.registerSignal("roomLeft", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
223 self.registerSignal("roomUserJoined", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
224 self.registerSignal("roomUserLeft", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
225 self.registerSignal("roomUserChangedNick", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
226 self.registerSignal("roomNewSubject", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
227 self.registerSignal("tarotGameStarted", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
228 self.registerSignal("tarotGameNew", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
229 self.registerSignal("tarotGameChooseContrat", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
230 self.registerSignal("tarotGameShowCards", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
231 self.registerSignal("tarotGameYourTurn", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
232 self.registerSignal("tarotGameScore", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
233 self.registerSignal("tarotGameCardsPlayed", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
234 self.registerSignal("tarotGameInvalidCards", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
235 self.registerSignal("quizGameStarted", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
236 self.registerSignal("quizGameNew", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
237 self.registerSignal("quizGameQuestion", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
238 self.registerSignal("quizGamePlayerBuzzed", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
239 self.registerSignal("quizGamePlayerSays", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
240 self.registerSignal("quizGameAnswerResult", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
241 self.registerSignal("quizGameTimerExpired", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
242 self.registerSignal("quizGameTimerRestarted", iface="plugin") |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
243 self.registerSignal("chatStateReceived", iface="plugin") |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
244 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
245 self.current_action_ids = set() # FIXME: to be removed |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
246 self.current_action_ids_cb = {} # FIXME: to be removed |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
247 self.media_dir = self.bridge.getConfig('', 'media_dir') |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
248 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
249 @property |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
250 def current_profile(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
251 """Profile that a user would expect to use""" |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
252 try: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
253 return self.selected_widget.profile |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
254 except (TypeError, AttributeError): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
255 return self.profiles.chooseOneProfile() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
256 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
257 @property |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
258 def visible_widgets(self): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
259 """widgets currently visible (must be implemented by frontend)""" |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
260 raise NotImplementedError |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
261 |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
262 def registerSignal(self, functionName, handler=None, iface="core", with_profile=True): |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
263 """Register a handler for a signal |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
264 |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
265 @param functionName (str): name of the signal to handle |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
266 @param handler (instancemethod): method to call when the signal arrive, None for calling an automatically named handler (functionName + 'Handler') |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
267 @param iface (str): interface of the bridge to use ('core' or 'plugin') |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
268 @param with_profile (boolean): True if the signal concerns a specific profile, in that case the profile name has to be passed by the caller |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
269 """ |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
270 if handler is None: |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
271 handler = getattr(self, "{}{}".format(functionName, 'Handler')) |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
272 if not with_profile: |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
273 self.bridge.register(functionName, handler, iface) |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
274 return |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
275 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
276 def signalReceived(*args, **kwargs): |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
277 profile = kwargs.get('profile') |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
278 if profile is None: |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
279 if not args: |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
280 raise exceptions.ProfileNotSetError |
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
281 profile = args[-1] |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
282 if profile is not None and not self.check_profile(profile): |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
283 return # we ignore signal for profiles we don't manage |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
284 handler(*args, **kwargs) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
285 self.bridge.register(functionName, signalReceived, iface) |
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
286 |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
287 def check_profile(self, profile): |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
288 """Tell if the profile is currently followed by the application""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
289 return profile in self.profiles |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
290 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
291 def postInit(self, profile_manager): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
292 """Must be called after initialization is done, do all automatic task (auto plug profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
293 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
294 @param profile_manager: instance of a subclass of Quick_frontend.QuickProfileManager |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
295 """ |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
296 if self.options and self.options.profile: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
297 profile_manager.autoconnect([self.options.profile]) |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
298 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
299 def profilePlugged(self, profile): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
300 """Method called when the profile is fully plugged, to launch frontend specific workflow |
91 | 301 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
302 @param profile(unicode): %(doc_profile)s |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
303 """ |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
304 pass |
91 | 305 |
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:
1058
diff
changeset
|
306 def asyncConnect(self, profile, callback=None, errback=None): |
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:
1058
diff
changeset
|
307 if not callback: |
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:
1058
diff
changeset
|
308 callback = lambda dummy: None |
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:
1058
diff
changeset
|
309 if not errback: |
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:
1058
diff
changeset
|
310 def errback(failure): |
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:
1058
diff
changeset
|
311 log.error(_(u"Can't connect profile [%s]") % failure) |
1074
a47995155e55
frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents:
1063
diff
changeset
|
312 if failure.module.startswith('twisted.words.protocols.jabber') and failure.condition == "not-authorized": |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
313 self.launchAction(C.CHANGE_XMPP_PASSWD_ID, {}, profile=profile) |
1074
a47995155e55
frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents:
1063
diff
changeset
|
314 else: |
a47995155e55
frontends (quick_frontend): fixes the handling of asyncConnect failure
souliane <souliane@mailoo.org>
parents:
1063
diff
changeset
|
315 self.showDialog(failure.message, failure.fullname, 'error') |
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:
1058
diff
changeset
|
316 self.bridge.asyncConnect(profile, callback=callback, errback=errback) |
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:
1058
diff
changeset
|
317 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
318 def plug_profiles(self, profiles): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
319 """Tell application which profiles must be used |
0 | 320 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
321 @param profiles: list of valid profile names |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
322 """ |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
323 self.plugging_profiles() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
324 for profile in profiles: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
325 self.profiles.plug(profile) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
326 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
327 def plugging_profiles(self): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
328 """Method to subclass to manage frontend specific things to do |
0 | 329 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
330 will be called when profiles are choosen and are to be plugged soon |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
331 """ |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
332 pass |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
333 |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
334 def unplug_profile(self, profile): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
335 """Tell the application to not follow anymore the profile""" |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
336 if not profile in self.profiles: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
337 raise ValueError("The profile [{}] is not plugged".format(profile)) |
66
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
338 self.profiles.remove(profile) |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
339 |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
340 def clear_profile(self): |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
341 self.profiles.clear() |
8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents:
64
diff
changeset
|
342 |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
343 def addContactList(self, profile): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
344 """Method to subclass to add a contact list widget |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
345 |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
346 will be called on each profile session build |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
347 @return: a ContactList widget |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
348 """ |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
349 return NotImplementedError |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
350 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
351 def newWidget(self, widget): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
352 raise NotImplementedError |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
353 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
354 def connectedHandler(self, profile): |
52 | 355 """called when the connection is made""" |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
356 log.debug(_("Connected")) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
357 self.setStatusOnline(True, profile=profile) |
52 | 358 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
359 def disconnectedHandler(self, profile): |
52 | 360 """called when the connection is closed""" |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
361 log.debug(_("Disconnected")) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
362 self.contact_lists[profile].clearContacts() |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
363 self.setStatusOnline(False, profile=profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
364 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
365 def newContactHandler(self, JabberId, attributes, groups, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
366 entity = jid.JID(JabberId) |
347
ea3e1b82dd79
core: contact deletion from roster if we have no subscription to it (behaviour may change in futur)
Goffi <goffi@goffi.org>
parents:
344
diff
changeset
|
367 _groups = list(groups) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
368 self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
369 |
1172
e15d8a01cf6a
frontends: use of new "info" type in newMessage
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
370 def _newMessage(self, from_jid_s, msg, type_, to_jid_s, extra, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
371 from_jid = jid.JID(from_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
372 to_jid = jid.JID(to_jid_s) |
1172
e15d8a01cf6a
frontends: use of new "info" type in newMessage
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
373 self.newMessageHandler(from_jid, to_jid, msg, type_, extra, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
374 |
1172
e15d8a01cf6a
frontends: use of new "info" type in newMessage
Goffi <goffi@goffi.org>
parents:
1139
diff
changeset
|
375 def newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
376 from_me = from_jid.bare == self.profiles[profile].whoami.bare |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
377 target = to_jid if from_me else from_jid |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
378 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
379 chat_type = C.CHAT_GROUP if type_ == C.MESS_TYPE_GROUPCHAT else C.CHAT_ONE2ONE |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
380 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
381 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=chat_type, profile=profile) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
382 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
383 self.current_action_ids = set() # FIXME: to be removed |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
384 self.current_action_ids_cb = {} # FIXME: to be removed |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
385 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
386 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
387 |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
388 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key=C.PROF_KEY_NONE): |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
771
diff
changeset
|
389 if callback is None: |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
390 callback = lambda dummy=None: None # FIXME: optional argument is here because pyjamas doesn't support callback without arg with json proxy |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
771
diff
changeset
|
391 if errback is None: |
1063
6ec513ad92c2
frontends: async failures are more detailed (full class name + error message)
souliane <souliane@mailoo.org>
parents:
1060
diff
changeset
|
392 errback = lambda failure: self.showDialog(failure.fullname, failure.message, "error") |
776
f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
Goffi <goffi@goffi.org>
parents:
771
diff
changeset
|
393 self.bridge.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, callback=callback, errback=errback) |
0 | 394 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
395 def newAlertHandler(self, msg, title, alert_type, profile): |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
396 assert alert_type in ['INFO', 'ERROR'] |
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
397 self.showDialog(unicode(msg), unicode(title), alert_type.lower()) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
398 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
399 def setStatusOnline(self, online=True, show="", statuses={}, profile=C.PROF_KEY_NONE): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
400 raise NotImplementedError |
0 | 401 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
402 def presenceUpdateHandler(self, entity_s, show, priority, statuses, profile): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
403 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
404 log.debug(_("presence update for %(entity)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
405 % {'entity': entity_s, C.PRESENCE_SHOW: show, C.PRESENCE_PRIORITY: priority, C.PRESENCE_STATUSES: statuses, 'profile': profile}) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
406 entity = jid.JID(entity_s) |
0 | 407 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
408 if entity == self.profiles[profile].whoami: |
735
682933ca304c
frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents:
698
diff
changeset
|
409 if show == "unavailable": |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
410 self.setStatusOnline(False, profile=profile) |
735
682933ca304c
frontends: presence update in quick app:
souliane <souliane@mailoo.org>
parents:
698
diff
changeset
|
411 else: |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
412 self.setStatusOnline(True, show, statuses, profile=profile) |
0 | 413 return |
414 | |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
415 # #FIXME: must be moved in a plugin |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
416 # if entity.bare in self.profiles[profile].data.get('watched',[]) and not entity.bare in self.profiles[profile]['onlineContact']: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
417 # self.showAlert(_("Watched jid [%s] is connected !") % entity.bare) |
0 | 418 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
419 self.contact_lists[profile].updatePresence(entity, show, priority, statuses) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
420 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
421 def roomJoinedHandler(self, room_jid_s, room_nicks, user_nick, profile): |
72 | 422 """Called when a MUC room is joined""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
423 log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks}) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
424 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
425 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
426 chat_widget.setUserNick(user_nick) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
427 chat_widget.id = room_jid # FIXME: to be removed |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
428 chat_widget.setPresents(list(set([user_nick] + room_nicks))) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
429 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP) |
72 | 430 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
431 def roomLeftHandler(self, room_jid_s, profile): |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
432 """Called when a MUC room is left""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
433 log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile}) |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
434 del self.chat_wins[room_jid_s] |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
435 self.contact_lists[profile].remove(jid.JID(room_jid_s)) |
72 | 436 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
437 def roomUserJoinedHandler(self, room_jid_s, user_nick, user_data, profile): |
75 | 438 """Called when an user joined a MUC room""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
439 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
440 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
441 chat_widget.replaceUser(user_nick) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
442 log.debug("user [%(user_nick)s] joined room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid}) |
75 | 443 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
444 def roomUserLeftHandler(self, room_jid_s, user_nick, user_data, profile): |
75 | 445 """Called when an user joined a MUC room""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
446 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
447 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
448 chat_widget.removeUser(user_nick) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
449 log.debug("user [%(user_nick)s] left room [%(room_jid)s]" % {'user_nick': user_nick, 'room_jid': room_jid}) |
76 | 450 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
451 def roomUserChangedNickHandler(self, room_jid_s, old_nick, new_nick, profile): |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
452 """Called when an user joined a MUC room""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
453 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
454 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
455 chat_widget.changeUserNick(old_nick, new_nick) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
456 log.debug("user [%(old_nick)s] is now known as [%(new_nick)s] in room [%(room_jid)s]" % {'old_nick': old_nick, 'new_nick': new_nick, 'room_jid': room_jid}) |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
504
diff
changeset
|
457 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
458 def roomNewSubjectHandler(self, room_jid_s, subject, profile): |
76 | 459 """Called when subject of MUC room change""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
460 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
461 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
462 chat_widget.setSubject(subject) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
463 log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject}) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
464 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
465 def tarotGameStartedHandler(self, room_jid_s, referee, players, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
466 log.debug(_("Tarot Game Started \o/")) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
467 room_jid = jid.JID(room_jid_s) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
468 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_='group', profile=profile) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
469 chat_widget.startGame("Tarot", referee, players) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
470 log.debug("new Tarot game started by [%(referee)s] in room [%(room_jid)s] with %(players)s" % {'referee': referee, 'room_jid': room_jid, 'players': [str(player) for player in players]}) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
471 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
472 def tarotGameNewHandler(self, room_jid, hand, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
473 log.debug(_("New Tarot Game")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
474 if room_jid in self.chat_wins: |
87 | 475 self.chat_wins[room_jid].getGame("Tarot").newGame(hand) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
476 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
477 def tarotGameChooseContratHandler(self, room_jid, xml_data, profile): |
144
80661755ea8d
Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
132
diff
changeset
|
478 """Called when the player has to select his contrat""" |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
479 log.debug(_("Tarot: need to select a contrat")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
480 if room_jid in self.chat_wins: |
91 | 481 self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data) |
482 | |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
483 def tarotGameShowCardsHandler(self, room_jid, game_stage, cards, data, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
484 log.debug(_("Show cards")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
485 if room_jid in self.chat_wins: |
92 | 486 self.chat_wins[room_jid].getGame("Tarot").showCards(game_stage, cards, data) |
87 | 487 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
488 def tarotGameYourTurnHandler(self, room_jid, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
489 log.debug(_("My turn to play")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
490 if room_jid in self.chat_wins: |
150 | 491 self.chat_wins[room_jid].getGame("Tarot").myTurn() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
492 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
493 def tarotGameScoreHandler(self, room_jid, xml_data, winners, loosers, profile): |
95 | 494 """Called when the game is finished and the score are updated""" |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
495 log.debug(_("Tarot: score received")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
496 if room_jid in self.chat_wins: |
95 | 497 self.chat_wins[room_jid].getGame("Tarot").showScores(xml_data, winners, loosers) |
498 | |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
499 def tarotGameCardsPlayedHandler(self, room_jid, player, cards, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
500 log.debug(_("Card(s) played (%(player)s): %(cards)s") % {"player": player, "cards": cards}) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
501 if room_jid in self.chat_wins: |
93 | 502 self.chat_wins[room_jid].getGame("Tarot").cardsPlayed(player, cards) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
503 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
504 def tarotGameInvalidCardsHandler(self, room_jid, phase, played_cards, invalid_cards, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
505 log.debug(_("Cards played are not valid: %s") % invalid_cards) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
506 if room_jid in self.chat_wins: |
99
63c9067a1499
Tarot game: invalid cards management
Goffi <goffi@goffi.org>
parents:
95
diff
changeset
|
507 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
508 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
509 def quizGameStartedHandler(self, room_jid, referee, players, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
510 log.debug(_("Quiz Game Started \o/")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
511 if room_jid in self.chat_wins: |
361 | 512 self.chat_wins[room_jid].startGame("Quiz", referee, players) |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
513 log.debug(_("new Quiz game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee': referee, 'room_jid': room_jid, 'players': [str(player) for player in players]}) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
514 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
515 def quizGameNewHandler(self, room_jid, data, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
516 log.debug(_("New Quiz Game")) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
517 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
518 self.chat_wins[room_jid].getGame("Quiz").quizGameNewHandler(data) |
361 | 519 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
520 def quizGameQuestionHandler(self, room_jid, question_id, question, timer, profile): |
361 | 521 """Called when a new question is asked""" |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
522 log.debug(_(u"Quiz: new question: %s") % question) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
523 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
524 self.chat_wins[room_jid].getGame("Quiz").quizGameQuestionHandler(question_id, question, timer) |
361 | 525 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
526 def quizGamePlayerBuzzedHandler(self, room_jid, player, pause, profile): |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
527 """Called when a player pushed the buzzer""" |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
528 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
529 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerBuzzedHandler(player, pause) |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
530 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
531 def quizGamePlayerSaysHandler(self, room_jid, player, text, delay, profile): |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
532 """Called when a player say something""" |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
533 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
534 self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerSaysHandler(player, text, delay) |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
535 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
536 def quizGameAnswerResultHandler(self, room_jid, player, good_answer, score, profile): |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
537 """Called when a player say something""" |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
538 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
539 self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResultHandler(player, good_answer, score) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
540 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
541 def quizGameTimerExpiredHandler(self, room_jid, profile): |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
542 """Called when nobody answered the question in time""" |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
543 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
544 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerExpiredHandler() |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
545 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
546 def quizGameTimerRestartedHandler(self, room_jid, time_left, profile): |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
547 """Called when the question is not answered, and we still have time""" |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
548 if room_jid in self.chat_wins: |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
549 self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestartedHandler(time_left) |
362
208107419b17
Quiz game: buzzer, timer, answer management
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
550 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
551 def chatStateReceivedHandler(self, from_jid_s, state, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
552 """Called when a new chat state is received. |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
553 |
907
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
906
diff
changeset
|
554 @param from_jid_s: JID of the contact who sent his state, or '@ALL@' |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
906
diff
changeset
|
555 @param state: new state (string) |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
906
diff
changeset
|
556 @profile: current profile |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
906
diff
changeset
|
557 """ |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
558 from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
559 for widget in self.widgets.getWidgets(quick_chat.QuickChat): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
560 if from_jid == C.ENTITY_ALL or from_jid.bare == widget.target.bare: |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
561 widget.updateChatState(from_jid, state) |
907
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
906
diff
changeset
|
562 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
563 def _subscribe_cb(self, answer, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
564 entity, profile = data |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
565 if answer: |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
566 self.bridge.subscription("subscribed", entity.bare, profile_key=profile) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
567 else: |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
568 self.bridge.subscription("unsubscribed", entity.bare, profile_key=profile) |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
569 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
570 def subscribeHandler(self, type, raw_jid, profile): |
87 | 571 """Called when a subsciption management signal is received""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
572 entity = jid.JID(raw_jid) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
573 if type == "subscribed": |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
574 # this is a subscription confirmation, we just have to inform user |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
575 self.showDialog(_("The contact %s has accepted your subscription") % entity.bare, _('Subscription confirmation')) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
576 elif type == "unsubscribed": |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
577 # this is a subscription refusal, we just have to inform user |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
578 self.showDialog(_("The contact %s has refused your subscription") % entity.bare, _('Subscription refusal'), 'error') |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
579 elif type == "subscribe": |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
580 # this is a subscriptionn request, we have to ask for user confirmation |
943
71926ec2114d
core (memory): entities cache improvments:
Goffi <goffi@goffi.org>
parents:
917
diff
changeset
|
581 self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.bare, _('Subscription confirmation'), 'yes/no', answer_cb=self._subscribe_cb, answer_data=(entity, profile)) |
0 | 582 |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
583 def showDialog(self, message, title, type="info", answer_cb=None): |
0 | 584 raise NotImplementedError |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
585 |
0 | 586 def showAlert(self, message): |
587 pass #FIXME | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
588 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
589 def paramUpdateHandler(self, name, value, namespace, profile): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
590 log.debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace': namespace, 'name': name, 'value': value}) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
591 if (namespace, name) == ("Connection", "JabberID"): |
1009
d1084f7e56a5
quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents:
955
diff
changeset
|
592 log.debug(_("Changing JID to %s") % value) |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
593 self.profiles[profile].whoami = jid.JID(value) |
906
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
594 elif (namespace, name) == ("Misc", "Watched"): |
1cbae66fa725
quick_app: better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
595 self.profiles[profile]['watched'] = value.split() |
1229
03661d1b216a
primitivus: implement "Show offline contacts" parameter (sync with "DISCONNECTED_HIDE" action key)
souliane <souliane@mailoo.org>
parents:
1223
diff
changeset
|
596 elif (namespace, name) == ('General', C.SHOW_OFFLINE_CONTACTS): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
597 self.contact_lists[profile].showOfflineContacts(C.bool(value)) |
1230
3abc6563a0d2
primitivus: implement parameter "Show empty groups"
souliane <souliane@mailoo.org>
parents:
1229
diff
changeset
|
598 elif (namespace, name) == ('General', C.SHOW_EMPTY_GROUPS): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
599 self.contact_lists[profile].showEmptyGroups(C.bool(value)) |
0 | 600 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
601 def contactDeletedHandler(self, jid, profile): |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
602 target = jid.JID(jid) |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
603 self.contact_lists[profile].remove(target) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
604 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
605 def entityDataUpdatedHandler(self, entity_s, key, value, profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
606 entity = jid.JID(entity_s) |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
607 if key == "nick": |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
608 if entity in self.contact_lists[profile]: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
609 self.contact_lists[profile].setCache(entity, 'nick', value) |
504
65ecbb473cbb
core, quick frontend, plugin xep-0054, bridge: use of memory's entities data for vcard:
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
610 elif key == "avatar": |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
611 if entity in self.contact_lists[profile]: |
1290
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
612 def gotFilename(filename): |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
613 self.contact_lists[profile].setCache(entity, 'avatar', filename) |
faa1129559b8
core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents:
1265
diff
changeset
|
614 self.bridge.getAvatarFile(value, callback=gotFilename) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
615 |
1103
a096b8579a3c
frontends: signals are managed in a more generic way
Goffi <goffi@goffi.org>
parents:
1093
diff
changeset
|
616 def askConfirmationHandler(self, confirm_id, confirm_type, data, profile): |
0 | 617 raise NotImplementedError |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
618 |
1117
6053fb8a6466
quick_frontend: fixes an issue with the profile in the signal handler
souliane <souliane@mailoo.org>
parents:
1103
diff
changeset
|
619 def actionResultHandler(self, type, id, data, profile): |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
620 raise NotImplementedError |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
621 |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
622 def launchAction(self, callback_id, data=None, callback=None, profile="@NONE@"): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
623 """Launch a dynamic action |
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:
1058
diff
changeset
|
624 @param callback_id: id of the action to launch |
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:
1058
diff
changeset
|
625 @param data: data needed only for certain actions |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
626 @param callback: if not None and 'validated' key is present, it will be called with the following parameters: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
627 - callback_id |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
628 - data |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
629 - profile_key |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
630 @param profile_key: %(doc_profile)s |
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:
1058
diff
changeset
|
631 |
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:
1058
diff
changeset
|
632 """ |
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:
1058
diff
changeset
|
633 raise NotImplementedError |
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:
1058
diff
changeset
|
634 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
635 def onExit(self): |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
636 """Must be called when the frontend is terminating""" |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
637 for profile in self.profiles: |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
638 if self.bridge.isConnected(profile): |
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
639 if C.bool(self.bridge.getParamA("autodisconnect", "Connection", profile_key=profile)): |
414
f6f94e21c642
Quick frontend: use of asyncGetParamA when pluging profile
Goffi <goffi@goffi.org>
parents:
405
diff
changeset
|
640 #The user wants autodisconnection |
1265
e3a9ea76de35
quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents:
1241
diff
changeset
|
641 self.bridge.disconnect(profile) |