annotate frontends/src/quick_frontend/quick_chat.py @ 1763:9b557e76a5a8

quick_frontend (chat): scroll down after having printed the history
author souliane <souliane@mailoo.org>
date Tue, 22 Dec 2015 11:43:02 +0100
parents 2e2fb462729a
children 33c815c17fe6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
diff changeset
4 # helper class for making a SAT frontend
1396
069ad98b360d 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 1388
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org)
0
goffi@necton2
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
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: 588
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: 588
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: 588
diff changeset
10 # (at your option) any later version.
0
goffi@necton2
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
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: 588
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: 588
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: 588
diff changeset
15 # GNU Affero General Public License for more details.
0
goffi@necton2
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 588
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: 588
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
goffi@necton2
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 736
diff changeset
20 from sat.core.i18n import _
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
21 from sat.core.log import getLogger
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
22 log = getLogger(__name__)
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
23 from sat_frontends.tools import jid
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
24 from sat_frontends.quick_frontend import quick_widgets
1222
e6e0ea4dc835 memory: add Parameter "Chat history limit"
souliane <souliane@mailoo.org>
parents: 1139
diff changeset
25 from sat_frontends.quick_frontend.constants import Const as C
1378
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
26 from collections import OrderedDict
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
27 from datetime import datetime
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
28 from time import time
0
goffi@necton2
parents:
diff changeset
29
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
30 try:
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
31 # FIXME: to be removed when an acceptable solution is here
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
32 unicode('') # XXX: unicode doesn't exist in pyjamas
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
33 except (TypeError, AttributeError): # Error raised is not the same depending on pyjsbuild options
1462
c74015dc2785 quick_frontend: minor fixes
Goffi <goffi@goffi.org>
parents: 1441
diff changeset
34 unicode = str
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
35
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
36
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
37 class QuickChat(quick_widgets.QuickWidget):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
38
1378
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
39 visible_states = ['chat_state']
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
40
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
41 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
42 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
43 @param type_: can be C.CHAT_ONE2ONE for single conversation or C.CHAT_GROUP for chat à la IRC
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
44 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
45 quick_widgets.QuickWidget.__init__(self, host, target, profiles=profiles)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
46 assert type_ in (C.CHAT_ONE2ONE, C.CHAT_GROUP)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
47 if type_ == C.CHAT_GROUP and target.resource:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
48 raise ValueError("A group chat entity can't have a resource")
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
49 self.current_target = target
812
084b52afdceb frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents: 811
diff changeset
50 self.type = type_
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
51 self.id = "" # FIXME: to be removed
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
52 self.nick = None
1379
da2ea16fabc6 quick_frontend: display MUC games symbols
souliane <souliane@mailoo.org>
parents: 1378
diff changeset
53 self.games = {} # key=game name (unicode), value=instance of quick_games.RoomGame
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
54
1762
2e2fb462729a quick_frontend, primitivus (chat): printing the history is left to quick_frontend
souliane <souliane@mailoo.org>
parents: 1749
diff changeset
55 if type_ == C.CHAT_ONE2ONE:
2e2fb462729a quick_frontend, primitivus (chat): printing the history is left to quick_frontend
souliane <souliane@mailoo.org>
parents: 1749
diff changeset
56 self.historyPrint(profile=self.profile)
2e2fb462729a quick_frontend, primitivus (chat): printing the history is left to quick_frontend
souliane <souliane@mailoo.org>
parents: 1749
diff changeset
57
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
58 def __str__(self):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
59 return u"Chat Widget [target: {}, type: {}, profile: {}]".format(self.target, self.type, self.profile)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
60
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
61 @staticmethod
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
62 def getWidgetHash(target, profile):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
63 return (unicode(profile), target.bare)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
64
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
65 @staticmethod
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
66 def getPrivateHash(target, profile):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
67 """Get unique hash for private conversations
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
68
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
69 This method should be used with force_hash to get unique widget for private MUC conversations
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
70 """
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
71 return (unicode(profile), target)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
72
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
73 def addTarget(self, target):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
74 super(QuickChat, self).addTarget(target)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
75 if target.resource:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
76 self.current_target = target # FIXME: tmp, must use resource priority throught contactList instead
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
77
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
78 @property
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
79 def target(self):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
80 if self.type == C.CHAT_GROUP:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
81 return self.current_target.bare
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
82 return self.current_target
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
83
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
84 @property
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
85 def occupants(self):
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
86 """Return the occupants of a group chat (nicknames).
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
87
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
88 @return: set(unicode)
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
89 """
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
90 if self.type != C.CHAT_GROUP:
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
91 return set()
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
92 contact_list = self.host.contact_lists[self.profile]
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
93 return contact_list.getCache(self.target, C.CONTACT_RESOURCES).keys()
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
94
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
95 def manageMessage(self, entity, mess_type):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
96 """Tell if this chat widget manage an entity and message type couple
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
97
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
98 @param entity (jid.JID): (full) jid of the sending entity
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
99 @param mess_type (str): message type as given by newMessage
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
100 @return (bool): True if this Chat Widget manage this couple
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
101 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
102 if self.type == C.CHAT_GROUP:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
103 if mess_type == C.MESS_TYPE_GROUPCHAT and self.target == entity.bare:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
104 return True
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
105 else:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
106 if mess_type != C.MESS_TYPE_GROUPCHAT and entity in self.targets:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
107 return True
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
108 return False
0
goffi@necton2
parents:
diff changeset
109
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
110 def addUser(self, nick):
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
111 """Add user if it is not in the group list"""
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
112 self.printInfo("=> %s has joined the room" % nick)
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
113
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
114 def removeUser(self, nick):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
115 """Remove a user from the group list"""
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
116 self.printInfo("<= %s has left the room" % nick)
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
117
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
118 def setUserNick(self, nick):
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
119 """Set the nick of the user, usefull for e.g. change the color of the user"""
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
120 self.nick = nick
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
121
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
122 def changeUserNick(self, old_nick, new_nick):
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
123 """Change nick of a user in group list"""
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
124 self.printInfo("%s is now known as %s" % (old_nick, new_nick))
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
125
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
126 def setSubject(self, subject):
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
127 """Set title for a group chat"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
128 log.debug(_("Setting subject to %s") % subject)
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
129 if self.type != C.CHAT_GROUP:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
130 log.error (_("[INTERNAL] trying to set subject for a non group chat window"))
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
131 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
132
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
133 def afterHistoryPrint(self):
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
134 """Refresh or scroll down the focus after the history is printed"""
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
135 pass
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
136
1224
f0c9b149ed99 bridge, memory: add "search" attribute to getHistory (filter the results with a unix globbing pattern)
souliane <souliane@mailoo.org>
parents: 1223
diff changeset
137 def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT, search='', profile='@NONE@'):
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
138 """Print the current history
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
139 @param size (int): number of messages
1224
f0c9b149ed99 bridge, memory: add "search" attribute to getHistory (filter the results with a unix globbing pattern)
souliane <souliane@mailoo.org>
parents: 1223
diff changeset
140 @param search (str): pattern to filter the history results
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
141 @param profile (str): %(doc_profile)s
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
142 """
1296
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
143 log_msg = _(u"now we print the history")
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
144 if size != C.HISTORY_LIMIT_DEFAULT:
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
145 log_msg += _(u" (%d messages)" % size)
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
146 log.debug(log_msg)
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
147
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
148 target = self.target.bare
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
149
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
150 def onHistory(history):
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
151 day_format = "%A, %d %b %Y" # to display the day change
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
152 previous_day = datetime.now().strftime(day_format)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
153 for line in history:
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
154 timestamp, from_jid, to_jid, message, type_, extra = line # FIXME: extra is unused !
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
155 if ((self.type == C.CHAT_GROUP and type_ != C.MESS_TYPE_GROUPCHAT) or
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
156 (self.type == C.CHAT_ONE2ONE and type_ == C.MESS_TYPE_GROUPCHAT)):
512
862c0d6ab974 core, bridge, quick_frontend: MUC private messages history management:
Goffi <goffi@goffi.org>
parents: 510
diff changeset
157 continue
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
158 message_day = datetime.fromtimestamp(float(timestamp or time())).strftime(day_format)
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
159 if previous_day != message_day:
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
160 self.printDayChange(message_day)
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
161 previous_day = message_day
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
162 extra["timestamp"] = timestamp
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
163 self.newMessage(jid.JID(from_jid), target, message, type_, extra, profile)
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
164 self.afterHistoryPrint()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
165
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
166 def onHistoryError(err):
1125
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
167 log.error(_("Can't get history"))
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
168
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
169 self.host.bridge.getHistory(unicode(self.host.profiles[profile].whoami.bare), unicode(target), size, True, search, profile, callback=onHistory, errback=onHistoryError)
512
862c0d6ab974 core, bridge, quick_frontend: MUC private messages history management:
Goffi <goffi@goffi.org>
parents: 510
diff changeset
170
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
171 def _get_nick(self, entity):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
172 """Return nick of this entity when possible"""
1428
0e518415d03a display the resource in the chat dialog when printing a private MUC message
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
173 contact_list = self.host.contact_lists[self.profile]
0e518415d03a display the resource in the chat dialog when printing a private MUC message
souliane <souliane@mailoo.org>
parents: 1396
diff changeset
174 if self.type == C.CHAT_GROUP or entity in contact_list.getSpecialExtras(C.CONTACT_SPECIAL_GROUP):
1441
b4c49c234c6b quick_frontend (quick_chat): QuickChat._get_nick returns "" instead of None for message from the MUC
souliane <souliane@mailoo.org>
parents: 1428
diff changeset
175 return entity.resource or ""
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
176 if entity.bare in contact_list:
1441
b4c49c234c6b quick_frontend (quick_chat): QuickChat._get_nick returns "" instead of None for message from the MUC
souliane <souliane@mailoo.org>
parents: 1428
diff changeset
177 return contact_list.getCache(entity, 'nick') or contact_list.getCache(entity, 'name') or entity.node or entity
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
178 return entity.node or entity
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
179
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
180 def onPrivateCreated(self, widget):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
181 """Method called when a new widget for private conversation (MUC) is created"""
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
182 raise NotImplementedError
0
goffi@necton2
parents:
diff changeset
183
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
184 def getOrCreatePrivateWidget(self, entity):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
185 """Create a widget for private conversation, or get it if it already exists
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
186
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
187 @param entity: full jid of the target
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
188 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
189 return self.host.widgets.getOrCreateWidget(QuickChat, entity, type_=C.CHAT_ONE2ONE, force_hash=self.getPrivateHash(self.profile, entity), on_new_widget=self.onPrivateCreated, profile=self.profile) # we force hash to have a new widget, not this one again
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
190
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
191 def newMessage(self, 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: 1224
diff changeset
192 if self.type == C.CHAT_GROUP and target.resource and type_ != C.MESS_TYPE_GROUPCHAT:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
193 # we have a private message, we forward it to a private conversation widget
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
194 chat_widget = self.getOrCreatePrivateWidget(target)
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
195 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile)
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
196 return
1763
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
197 try:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
198 timestamp = float(extra['timestamp'])
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
199 except KeyError:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
200 timestamp = None
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
201 if type_ == C.MESS_TYPE_INFO:
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
202 self.printInfo(msg, extra=extra)
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
203 else:
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
204 nick = self._get_nick(from_jid)
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
205 if msg.startswith('/me '):
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
206 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', extra=extra)
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
207 else:
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
208 # my_message is True if message comes from local user
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
209 my_message = (from_jid.resource == self.nick) if self.type == C.CHAT_GROUP else (from_jid.bare == self.host.profiles[profile].whoami.bare)
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
210 self.printMessage(nick, my_message, msg, timestamp, extra, profile)
1763
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
211 if timestamp:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
212 self.afterHistoryPrint()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
213
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
214 def printMessage(self, nick, my_message, message, timestamp, extra=None, profile=C.PROF_KEY_NONE):
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
215 """Print message in chat window.
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
216
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
217 @param nick (unicode): author nick
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
218 @param my_message (boolean): True if profile is the author
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
219 @param message (unicode): message content
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
220 @param extra (dict): extra data
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
221 """
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
222 raise NotImplementedError
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
223
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
224 def printInfo(self, msg, type_='normal', extra=None):
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
225 """Print general info.
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
226
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
227 @param msg (unicode): message to print
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
228 @param type_ (unicode):
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
229 - 'normal': general info like "toto has joined the room"
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
230 - 'me': "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
231 @param extra (dict): message data
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
232 """
0
goffi@necton2
parents:
diff changeset
233 raise NotImplementedError
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
234
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
235 def printDayChange(self, day):
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
236 """Display the day on a new line.
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
237
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
238 @param day(unicode): day to display (or not if this method is not overwritten)
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
239 """
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
240 pass
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
241
1388
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
242 def getEntityStates(self, entity):
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
243 """Retrieve states for an entity.
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
244
1388
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
245 @param entity (jid.JID): entity
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
246 @return: OrderedDict{unicode: unicode}
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 812
diff changeset
247 """
1388
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
248 states = OrderedDict()
1378
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
249 clist = self.host.contact_lists[self.profile]
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
250 for key in self.visible_states:
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
251 value = clist.getCache(entity, key)
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
252 if value:
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
253 states[key] = value
1388
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
254 return states
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 812
diff changeset
255
1360
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
256 def addGamePanel(self, widget):
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
257 """Insert a game panel to this Chat dialog.
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
258
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
259 @param widget (Widget): the game panel
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
260 """
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
261 raise NotImplementedError
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
262
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
263 def removeGamePanel(self, widget):
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
264 """Remove the game panel from this Chat dialog.
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
265
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
266 @param widget (Widget): the game panel
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
267 """
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
268 raise NotImplementedError
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
269
1388
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
270 def update(self, entity=None):
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
271 """Update one or all entities.
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
272
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
273 @param entity (jid.JID): entity to update
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
274 """
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
275 raise NotImplementedError
a025242bebe7 quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
souliane <souliane@mailoo.org>
parents: 1386
diff changeset
276
1360
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
277
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
278 quick_widgets.register(QuickChat)