annotate frontends/src/quick_frontend/quick_chat.py @ 1816:2a030a830ebd

test (RSM): fix according to modification in sat.tmp.wokkel.rsm in rev 1771 (b77dc676a4df)
author souliane <souliane@mailoo.org>
date Tue, 19 Jan 2016 14:59:13 +0100
parents 104874018ab0
children 2daf7b4c6756
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
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1764
diff changeset
5 # Copyright (C) 2009-2016 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
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
58 # FIXME: has been introduced to temporarily fix http://bugs.goffi.org/show_bug.cgi?id=12
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
59 self.initialised = False
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
60
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
61 def __str__(self):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
62 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
63
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
64 @staticmethod
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
65 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
66 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
67
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
68 @staticmethod
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
69 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
70 """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
71
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
72 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
73 """
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
74 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
75
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
76 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
77 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
78 if target.resource:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
79 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
80
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
81 @property
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
82 def target(self):
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
83 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
84 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
85 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
86
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
87 @property
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
88 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
89 """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
90
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(unicode)
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
92 """
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
93 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
94 return set()
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
95 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
96 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
97
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
98 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
99 """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
100
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
101 @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
102 @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
103 @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
104 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
105 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
106 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
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 else:
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
109 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
110 return True
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
111 return False
0
goffi@necton2
parents:
diff changeset
112
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
113 def addUser(self, nick):
120
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
114 """Add user if it is not in the group list"""
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
115 if not self.initialised:
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
116 return # FIXME: tmp fix for bug 12, do not flood the room with the messages when we've just entered it
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
117 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
118
1377
017270e6eea4 quick_frontends, primitivus: know who are the MUC occupants from the presence informations:
souliane <souliane@mailoo.org>
parents: 1365
diff changeset
119 def removeUser(self, nick):
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
120 """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
121 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
122
79
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
123 def setUserNick(self, nick):
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
124 """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
125 self.nick = nick
db0a0f000e37 Chat presentation enhancement
Goffi <goffi@goffi.org>
parents: 72
diff changeset
126
507
f98bef71a918 frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents: 501
diff changeset
127 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
128 """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
129 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
130
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
131 def setSubject(self, subject):
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
132 """Set title for a group chat"""
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
133 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
134 if self.type != C.CHAT_GROUP:
1009
d1084f7e56a5 quick_frontend: use of new logging system
Goffi <goffi@goffi.org>
parents: 907
diff changeset
135 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
136 raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
1ca5f254ce41 primitivus group chat & misc
Goffi <goffi@goffi.org>
parents: 85
diff changeset
137
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 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
139 """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
140 pass
d6c3fea5ecfe quick_frontend, primitivus: add primitivus command ":history [limit]" (default value for limit is 50)
souliane <souliane@mailoo.org>
parents: 1009
diff changeset
141
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
142 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
143 """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
144 @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
145 @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
146 @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
147 """
1296
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
148 log_msg = _(u"now we print the history")
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
149 if size != C.HISTORY_LIMIT_DEFAULT:
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
150 log_msg += _(u" (%d messages)" % size)
ebf72fe68d1c quick_frontend: fix the history log message
souliane <souliane@mailoo.org>
parents: 1290
diff changeset
151 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
152
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
153 target = self.target.bare
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
154
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
155 def onHistory(history):
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
156 self.initialised = True # FIXME: tmp fix for bug 12
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
157 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
158 previous_day = datetime.now().strftime(day_format)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
159 for line in history:
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
160 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
161 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
162 (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
163 continue
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
164 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
165 if previous_day != message_day:
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
166 self.printDayChange(message_day)
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
167 previous_day = message_day
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
168 extra["timestamp"] = timestamp
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
169 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
170 self.afterHistoryPrint()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
171
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
172 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
173 log.error(_("Can't get history"))
425
e4e9187e3b5b backend, bridge: asynchronous history
Goffi <goffi@goffi.org>
parents: 380
diff changeset
174
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
175 self.initialised = False # FIXME: tmp fix for bug 12, here needed for :history and :search commands
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
176 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
177
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
178 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
179 """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
180 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
181 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
182 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
183 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
184 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
185 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
186
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
187 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
188 """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
189 raise NotImplementedError
0
goffi@necton2
parents:
diff changeset
190
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
191 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
192 """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
193
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
194 @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
195 """
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
196 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
197
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
198 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
199 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
200 # 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
201 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
202 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile)
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
203 return
1763
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
204 try:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
205 timestamp = float(extra['timestamp'])
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
206 except KeyError:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
207 timestamp = None
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
208
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
209 if not self.initialised and self.type == C.CHAT_ONE2ONE:
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
210 return # FIXME: tmp fix for bug 12, do not display the first one2one message which is already in the local history
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
211
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
212 if type_ == C.MESS_TYPE_INFO:
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
213 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
214 else:
1764
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
215 self.initialised = True # FIXME: tmp fix for bug 12, do not discard any message from now
33c815c17fe6 quick_frontend (chat): temporary fix for bug 12:
souliane <souliane@mailoo.org>
parents: 1763
diff changeset
216
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
217 nick = self._get_nick(from_jid)
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
218 if msg.startswith('/me '):
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
219 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
220 else:
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
221 # my_message is True if message comes from local user
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
222 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
223 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
224 if timestamp:
9b557e76a5a8 quick_frontend (chat): scroll down after having printed the history
souliane <souliane@mailoo.org>
parents: 1762
diff changeset
225 self.afterHistoryPrint()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
226
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
227 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
228 """Print message in chat window.
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
229
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
230 @param nick (unicode): author nick
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
231 @param my_message (boolean): True if profile is the author
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
232 @param message (unicode): message content
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
233 @param extra (dict): extra data
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
234 """
1786
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
235 if not timestamp:
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
236 # XXX: do not send notifications for each line of the history being displayed
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
237 # FIXME: this must be changed in the future if the timestamp is passed with
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
238 # all messages and not only with the messages coming from the history.
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
239 self.notify(nick, message)
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
240
1290
faa1129559b8 core, frontends: refactoring to base Libervia on QuickFrontend (big mixed commit):
Goffi <goffi@goffi.org>
parents: 1265
diff changeset
241 def printInfo(self, msg, type_='normal', extra=None):
1748
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
242 """Print general info.
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
243
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
244 @param msg (unicode): message to print
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
245 @param type_ (unicode):
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
246 - 'normal': general info like "toto has joined the room"
3a6cd1c14974 frontends: small message refactorisation:
souliane <souliane@mailoo.org>
parents: 1462
diff changeset
247 - '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
248 @param extra (dict): message data
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
249 """
1786
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
250 self.notify(msg=msg)
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
251
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
252 def notify(self, contact="somebody", msg=""):
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
253 """Notify the user of a new message if the frontend doesn't have the focus.
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
254
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
255 @param contact (unicode): contact who wrote to the users
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
256 @param msg (unicode): the message that has been received
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
257 """
104874018ab0 quick_frontend, primitivus (chat): move notification command to quick_frontend
souliane <souliane@mailoo.org>
parents: 1766
diff changeset
258 raise NotImplemented
190
31632472e857 quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents: 144
diff changeset
259
1749
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
260 def printDayChange(self, day):
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
261 """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
262
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
263 @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
264 """
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
265 pass
d047535e3ed5 quick_frontend: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents: 1748
diff changeset
266
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
267 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
268 """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
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 @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
271 @return: OrderedDict{unicode: unicode}
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 812
diff changeset
272 """
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
273 states = OrderedDict()
1378
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
274 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
275 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
276 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
277 if value:
3dae6964c071 quick_frontends, primitivus: move the chat states logic to quick_frontend
souliane <souliane@mailoo.org>
parents: 1377
diff changeset
278 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
279 return states
907
cd02f5ef30df primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents: 812
diff changeset
280
1360
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
281 def addGamePanel(self, widget):
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
282 """Insert a game panel to this Chat dialog.
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
283
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
284 @param widget (Widget): the game panel
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
285 """
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
286 raise NotImplementedError
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
287
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
288 def removeGamePanel(self, widget):
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
289 """Remove the game panel from this Chat dialog.
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
290
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
291 @param widget (Widget): the game panel
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
292 """
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
293 raise NotImplementedError
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
294
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
295 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
296 """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
297
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
298 @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
299 """
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
300 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
301
1360
8ea8fa13c351 frontends (quick_frontend, primitivus): fixes room games:
souliane <souliane@mailoo.org>
parents: 1296
diff changeset
302
1265
e3a9ea76de35 quick_frontend, primitivus: multi-profiles refactoring part 1 (big commit, sorry :p):
Goffi <goffi@goffi.org>
parents: 1224
diff changeset
303 quick_widgets.register(QuickChat)