comparison frontends/src/primitivus/chat.py @ 1058:0a9986452bba

frontends: fixes bug with private message introduced with revision 1000 (6f1e03068b5f) + display messages from contacts not in roster
author souliane <souliane@mailoo.org>
date Thu, 29 May 2014 14:34:01 +0200
parents b12706d164d7
children 6ec513ad92c2
comparison
equal deleted inserted replaced
1057:7ea0215e7092 1058:0a9986452bba
23 from urwid_satext.files_management import FileDialog 23 from urwid_satext.files_management import FileDialog
24 from sat_frontends.quick_frontend.quick_chat import QuickChat 24 from sat_frontends.quick_frontend.quick_chat import QuickChat
25 from sat_frontends.primitivus.card_game import CardGame 25 from sat_frontends.primitivus.card_game import CardGame
26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate 26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
27 from sat_frontends.primitivus.xmlui import XMLUI 27 from sat_frontends.primitivus.xmlui import XMLUI
28 from sat_frontends.primitivus.constants import Const 28 from sat_frontends.primitivus.constants import Const as C
29 import time 29 import time
30 from sat.tools.jid import JID 30 from sat.tools.jid import JID
31 31
32 32
33 class ChatText(urwid.FlowWidget): 33 class ChatText(urwid.FlowWidget):
177 self._w = main_widget 177 self._w = main_widget
178 178
179 def updateChatState(self, state, nick=None): 179 def updateChatState(self, state, nick=None):
180 """Set the chat state (XEP-0085) of the contact. Leave nick to None 180 """Set the chat state (XEP-0085) of the contact. Leave nick to None
181 to set the state for a one2one conversation, or give a nickname or 181 to set the state for a one2one conversation, or give a nickname or
182 Const.ALL_OCCUPANTS to set the state of a participant within a MUC. 182 C.ALL_OCCUPANTS to set the state of a participant within a MUC.
183 @param state: the new chat state 183 @param state: the new chat state
184 @param nick: None for one2one, the MUC user nick or Const.ALL_OCCUPANTS 184 @param nick: None for one2one, the MUC user nick or C.ALL_OCCUPANTS
185 """ 185 """
186 if nick: 186 if nick:
187 assert(self.type == 'group') 187 assert(self.type == 'group')
188 occupants = self.occupants if nick == Const.ALL_OCCUPANTS else [nick] 188 occupants = self.occupants if nick == C.ALL_OCCUPANTS else [nick]
189 options = self.present_wid.getAllValues() 189 options = self.present_wid.getAllValues()
190 for index in xrange(0, len(options)): 190 for index in xrange(0, len(options)):
191 nick = options[index].value 191 nick = options[index].value
192 if nick in occupants: 192 if nick in occupants:
193 options[index] = (nick, '%s %s' % (Const.MUC_USER_STATES[state], nick)) 193 options[index] = (nick, '%s %s' % (C.MUC_USER_STATES[state], nick))
194 self.present_wid.changeValues(options) 194 self.present_wid.changeValues(options)
195 self.host.redraw() 195 self.host.redraw()
196 else: 196 else:
197 assert(self.type == 'one2one') 197 assert(self.type == 'one2one')
198 self.__setSurrendedText(state) 198 self.__setSurrendedText(state)
207 return 207 return
208 #we have a click on a nick, we add the private conversation to the contact_list 208 #we have a click on a nick, we add the private conversation to the contact_list
209 full_jid = JID("%s/%s" % (self.target.bare, nick)) 209 full_jid = JID("%s/%s" % (self.target.bare, nick))
210 new_jid = escapePrivate(full_jid) 210 new_jid = escapePrivate(full_jid)
211 if new_jid not in self.host.contact_list: 211 if new_jid not in self.host.contact_list:
212 self.host.contact_list.add(new_jid) 212 self.host.contact_list.add(new_jid, [C.GROUP_NOT_IN_ROSTER])
213 213
214 #now we select the new window 214 #now we select the new window
215 self.host.contact_list.setFocus(full_jid, True) 215 self.host.contact_list.setFocus(full_jid, True)
216 216
217 def __buildPresentList(self): 217 def __buildPresentList(self):