Mercurial > libervia-backend
annotate frontends/src/wix/chat.py @ 1249:3be9d8ab2e15
plugin sec_otr: a trigger was not returning True
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 20 Oct 2014 12:57:27 +0200 |
parents | 802b7e6bf098 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
811 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
20 | |
771 | 21 from sat.core.i18n import _ |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1011
diff
changeset
|
22 from sat_frontends.wix.constants import Const as C |
0 | 23 import wx |
24 import os.path | |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
25 import time |
1011 | 26 from sat.core.log import getLogger |
27 log = getLogger(__name__) | |
1139
75025461141f
move sat.tools.jid to sat_frontends.tools.jid
souliane <souliane@mailoo.org>
parents:
1093
diff
changeset
|
28 from sat_frontends.tools.jid import JID |
227 | 29 from sat_frontends.quick_frontend.quick_chat import QuickChat |
30 from sat_frontends.wix.contact_list import ContactList | |
31 from sat_frontends.wix.card_game import CardPanel | |
361 | 32 from sat_frontends.wix.quiz_game import QuizPanel |
0 | 33 |
34 idSEND = 1 | |
85 | 35 idTAROT = 2 |
0 | 36 |
1011 | 37 |
0 | 38 class Chat(wx.Frame, QuickChat): |
39 """The chat Window for one to one conversations""" | |
40 | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
41 def __init__(self, target, host, type_='one2one'): |
72 | 42 wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200)) |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
43 QuickChat.__init__(self, target, host, type_) |
0 | 44 |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
45 self.sizer = wx.BoxSizer(wx.VERTICAL) |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
46 self.SetSizer(self.sizer) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
47 |
72 | 48 self.splitter = wx.SplitterWindow(self, -1) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
49 self.sizer.Add(self.splitter, 1, flag = wx.EXPAND) |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
50 |
72 | 51 self.conv_panel = wx.Panel(self.splitter) |
52 self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL) | |
76 | 53 self.subjectBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_READONLY) |
72 | 54 self.chatWindow = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_MULTILINE | wx.TE_RICH | wx.TE_READONLY) |
55 self.textBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_PROCESS_ENTER) | |
76 | 56 self.conv_panel.sizer.Add(self.subjectBox, flag=wx.EXPAND) |
72 | 57 self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
58 self.conv_panel.sizer.Add(self.textBox, 0, flag=wx.EXPAND) |
72 | 59 self.conv_panel.SetSizer(self.conv_panel.sizer) |
60 self.splitter.Initialize(self.conv_panel) | |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
61 self.SetMenuBar(wx.MenuBar()) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
62 |
0 | 63 #events |
64 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
65 self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox) | |
66 | |
67 #fonts | |
68 self.font={} | |
69 self.font["points"] = self.chatWindow.GetFont().GetPointSize() | |
70 self.font["family"] = self.chatWindow.GetFont().GetFamily() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
71 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
72 |
0 | 73 #misc |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
74 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
75 self.setType(self.type) |
0 | 76 self.textBox.SetFocus() |
77 self.Hide() #We hide because of the show toggle | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
78 |
72 | 79 def __createPresents(self): |
80 """Create a list of present people in a group chat""" | |
81 self.present_panel = wx.Panel(self.splitter) | |
82 self.present_panel.sizer = wx.BoxSizer(wx.VERTICAL) | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
83 self.present_panel.presents = ContactList(self.present_panel, self.host, type_='nicks') |
72 | 84 self.present_panel.presents.SetMinSize(wx.Size(80,20)) |
85 self.present_panel.sizer.Add(self.present_panel.presents, 1, wx.EXPAND) | |
86 self.present_panel.SetSizer(self.present_panel.sizer) | |
87 self.splitter.SplitVertically(self.present_panel, self.conv_panel, 80) | |
88 | |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
89 def setType(self, type_): |
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
90 QuickChat.setType(self, type_) |
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
91 if type_ is 'group' and not self.splitter.IsSplit(): |
72 | 92 self.__createPresents() |
76 | 93 self.subjectBox.Show() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
94 self.__eraseMenus() |
85 | 95 self.__createMenus_group() |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
96 self.sizer.Layout() |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
97 elif type_ is 'one2one' and self.splitter.IsSplit(): |
72 | 98 self.splitter.Unsplit(self.present_panel) |
99 del self.present_panel | |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
100 self.GetMenuBar().Show() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
101 self.subjectBox.Hide() |
85 | 102 self.__eraseMenus() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
103 self.__createMenus_O2O() |
79 | 104 self.nick = None |
76 | 105 else: |
106 self.subjectBox.Hide() | |
85 | 107 self.__eraseMenus() |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
108 self.__createMenus_O2O() |
79 | 109 self.historyPrint(profile=self.host.profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
110 |
90 | 111 def startGame(self, game_type, referee, players): |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
112 """Configure the chat window to start a game""" |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
113 if game_type=="Tarot": |
1011 | 114 log.debug (_("configure chat window for Tarot game")) |
90 | 115 self.tarot_panel = CardPanel(self, referee, players, self.nick) |
87 | 116 self.sizer.Prepend(self.tarot_panel, 0, flag=wx.EXPAND) |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
117 self.sizer.Layout() |
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
118 self.Fit() |
321
1a990a88bff2
wix: force updating of splitterWindow in ChatWindow (needed when Tarot game is launched)
Goffi <goffi@goffi.org>
parents:
276
diff
changeset
|
119 self.splitter.UpdateSize() |
361 | 120 elif game_type=="Quiz": |
1011 | 121 log.debug (_("configure chat window for Quiz game")) |
361 | 122 self.quiz_panel = QuizPanel(self, referee, players, self.nick) |
123 self.sizer.Prepend(self.quiz_panel, 0, flag=wx.EXPAND) | |
124 self.sizer.Layout() | |
125 self.Fit() | |
126 self.splitter.UpdateSize() | |
86
4b5f2d55b6ac
wix: Tarot panel now appear on top of groupchat window when a Tarot game is started
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
127 |
87 | 128 def getGame(self, game_type): |
129 """Return class managing the game type""" | |
130 #TODO: check that the game is launched, and manage errors | |
131 if game_type=="Tarot": | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
132 return self.tarot_panel |
361 | 133 elif game_type=="Quiz": |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
134 return self.quiz_panel |
85 | 135 |
72 | 136 def setPresents(self, nicks): |
137 """Set the users presents in the contact list for a group chat | |
138 @param nicks: list of nicknames | |
139 """ | |
120 | 140 QuickChat.setPresents(self, nicks) |
72 | 141 for nick in nicks: |
85 | 142 self.present_panel.presents.replace(nick) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
143 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
144 def replaceUser(self, nick, show_info=True): |
75 | 145 """Add user if it is not in the group list""" |
1011 | 146 log.debug (_("Replacing user %s") % nick) |
75 | 147 if self.type != "group": |
1011 | 148 log.error (_("[INTERNAL] trying to replace user for a non group chat window")) |
75 | 149 return |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
150 QuickChat.replaceUser(self, nick, show_info) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
151 self.present_panel.presents.replace(nick) |
120 | 152 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
153 def removeUser(self, nick, show_info=True): |
75 | 154 """Remove a user from the group list""" |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
155 QuickChat.removeUser(self, nick, show_info) |
75 | 156 self.present_panel.presents.remove(nick) |
157 | |
76 | 158 def setSubject(self, subject): |
159 """Set title for a group chat""" | |
120 | 160 QuickChat.setSubject(self, subject) |
76 | 161 self.subjectBox.SetValue(subject) |
75 | 162 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
163 def __eraseMenus(self): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
164 """erase all menus""" |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
165 menuBar = self.GetMenuBar() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
166 for i in range(menuBar.GetMenuCount()): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
167 menuBar.Remove(i) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
168 |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
169 def __createMenus_O2O(self): |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
170 """create menu bar for one 2 one chat""" |
1011 | 171 log.info("Creating menus") |
78
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
172 self.__eraseMenus() |
ace2af8abc5a
Added method to know which MUC are joined, and which subjects were received.
Goffi <goffi@goffi.org>
parents:
77
diff
changeset
|
173 menuBar = self.GetMenuBar() |
0 | 174 actionMenu = wx.Menu() |
70 | 175 actionMenu.Append(idSEND, _("&SendFile CTRL-s"),_(" Send a file to contact")) |
176 menuBar.Append(actionMenu,_("&Action")) | |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1011
diff
changeset
|
177 self.host.addMenus(menuBar, C.MENU_SINGLE, {'jid': self.target}) |
0 | 178 |
179 #events | |
180 wx.EVT_MENU(self, idSEND, self.onSendFile) | |
181 | |
85 | 182 def __createMenus_group(self): |
183 """create menu bar for group chat""" | |
1011 | 184 log.info("Creating menus") |
85 | 185 self.__eraseMenus() |
186 menuBar = self.GetMenuBar() | |
187 actionMenu = wx.Menu() | |
188 actionMenu.Append(idTAROT, _("Start &Tarot game CTRL-t"),_(" Start a Tarot card game")) #tmp | |
189 menuBar.Append(actionMenu,_("&Games")) | |
1093
11e2bb20e896
core, frontends (menus): MENU_ROOM and MENU_SINGLE are now managed
Goffi <goffi@goffi.org>
parents:
1011
diff
changeset
|
190 self.host.addMenus(menuBar, C.MENU_ROOM, {'room_jid': self.target.bare}) |
85 | 191 |
192 #events | |
193 wx.EVT_MENU(self, idTAROT, self.onStartTarot) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
194 |
0 | 195 def __del__(self): |
196 wx.Frame.__del__(self) | |
197 | |
198 def onClose(self, event): | |
199 """Close event: we only hide the frame.""" | |
200 event.Veto() | |
201 self.Hide() | |
202 | |
203 def onEnterPressed(self, event): | |
204 """Behaviour when enter pressed in send line.""" | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
638
diff
changeset
|
205 self.host.sendMessage(self.target.bare if self.type == 'group' else self.target, |
638
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
206 event.GetString(), |
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
207 mess_type="groupchat" if self.type == 'group' else "chat", |
6821fc06a324
misc: a few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
609
diff
changeset
|
208 profile_key=self.host.profile) |
0 | 209 self.textBox.Clear() |
210 | |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
211 def __blink(self): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
212 """Do wizzz and buzzz to show window to user or |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
213 at least inform him of something new""" |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
214 #TODO: use notification system |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
215 if not self.IsActive(): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
216 self.RequestUserAttention() |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
217 if not self.IsShown(): |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
218 self.Show() |
0 | 219 |
1223
802b7e6bf098
frontends: printInfo and printMessage timestamp attribute defaults to None instead of ''
souliane <souliane@mailoo.org>
parents:
1172
diff
changeset
|
220 def printMessage(self, from_jid, msg, profile, timestamp=None): |
0 | 221 """Print the message with differents colors depending on where it comes from.""" |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
222 try: |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
223 jid,nick,mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
224 except TypeError: |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
225 return |
1011 | 226 log.debug("printMessage, jid = %s type = %s" % (jid, self.type)) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
227 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
228 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
229 _font_italic = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL) |
123
34766e0cf970
wix: chat: date is now printed in grey
Goffi <goffi@goffi.org>
parents:
122
diff
changeset
|
230 self.chatWindow.SetDefaultStyle(wx.TextAttr("GREY", font=_font_normal)) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
231 msg_time = time.localtime(timestamp or None) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
232 time_format = "%c" if msg_time < self.day_change else "%H:%M" #if the message was sent before today, we print the full date |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
233 self.chatWindow.AppendText("[%s]" % time.strftime(time_format, msg_time )) |
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
234 self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font_bold)) |
77
1ae680f9682e
wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
Goffi <goffi@goffi.org>
parents:
76
diff
changeset
|
235 self.chatWindow.AppendText("[%s] " % nick) |
122
29998cd0ed8d
wix: time is now printed in chat window
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
236 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_italic)) |
0 | 237 self.chatWindow.AppendText("%s\n" % msg) |
238 if not mymess: | |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
239 self.__blink() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
240 |
1223
802b7e6bf098
frontends: printInfo and printMessage timestamp attribute defaults to None instead of ''
souliane <souliane@mailoo.org>
parents:
1172
diff
changeset
|
241 def printInfo(self, msg, type_='normal', timestamp=None): |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
242 """Print general info |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
243 @param msg: message to print |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
244 @type_: one of: |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
245 normal: general info like "toto has joined the room" |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
246 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" |
1223
802b7e6bf098
frontends: printInfo and printMessage timestamp attribute defaults to None instead of ''
souliane <souliane@mailoo.org>
parents:
1172
diff
changeset
|
247 @param timestamp (float): number of seconds since epoch |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
248 """ |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
249 _font_bold = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD) |
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
250 _font_normal = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.NORMAL) |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
251 self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font_bold if type_ == 'normal' else _font_normal)) |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
252 self.chatWindow.AppendText("%s\n" % msg) |
812
084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
Goffi <goffi@goffi.org>
parents:
811
diff
changeset
|
253 if type_=="me": |
190
31632472e857
quick_frontend, wix, primitivus: informations in chat window
Goffi <goffi@goffi.org>
parents:
183
diff
changeset
|
254 self.__blink() |
0 | 255 |
256 ### events ### | |
257 | |
258 def onSendFile(self, e): | |
1011 | 259 log.debug(_("Send File")) |
70 | 260 filename = wx.FileSelector(_("Choose a file to send"), flags = wx.FD_FILE_MUST_EXIST) |
0 | 261 if filename: |
1011 | 262 log.debug(_("filename: %s"),filename) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
263 #FIXME: check last_resource: what if self.target.resource exists ? |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
638
diff
changeset
|
264 last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
265 if last_resource: |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
638
diff
changeset
|
266 full_jid = JID("%s/%s" % (self.target.bare, last_resource)) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
267 else: |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
268 full_jid = self.target |
387
e66d300c5d42
frontends, bridge: sendFile method signature change + jid parameters in bridge now use _jid suffix
Goffi <goffi@goffi.org>
parents:
361
diff
changeset
|
269 id = self.host.bridge.sendFile(full_jid, filename, {}, self.host.profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
270 self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile) |
0 | 271 |
85 | 272 def onStartTarot(self, e): |
1011 | 273 log.debug(_("Starting Tarot game")) |
274 log.warning(_("FIXME: temporary menu, must be changed")) | |
87 | 275 if len(self.occupants) != 4: |
276 err_dlg = wx.MessageDialog(self, _("You need to be exactly 4 peoples in the room to start a Tarot game"), _("Can't start game"), style = wx.OK | wx.ICON_ERROR) #FIXME: gof: temporary only, need to choose the people with who the game has to be started | |
277 err_dlg.ShowModal() | |
278 else: | |
90 | 279 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile) |
907
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
280 |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
281 def updateChatState(self, state, nick=None): |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
282 """Set the chat state (XEP-0085) of the contact. Leave nick to None |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
283 to set the state for a one2one conversation, or give a nickname or |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
284 Const.ALL_OCCUPANTS to set the state of a participant within a MUC. |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
285 @param state: the new chat state |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
286 @param nick: None for one2one, the MUC user nick or Const.ALL_OCCUPANTS |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
287 """ |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
288 #TODO: chat states not implemented yet |
cd02f5ef30df
primitivus: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
812
diff
changeset
|
289 pass |