comparison src/browser/sat_browser/chat.py @ 660:267761bf7f08 frontends_multi_profiles

browser side (contact list): ContactPanels is used instead of OccupantsList in MUC: - ContactPanels become the generic class for all lists of contacts - OccupantsList will be removed - need to implements specials icons (e.g. for games) in ContactBox - ContactBox now manage a display arguments to set which data we want to display - ContactsPanel.display renamed to setList - ContactBox style can be changed when instaciating parent ContactsPanel - muc_contact CSS class is used for list of MUC occupants Not fully functionnal yet
author Goffi <goffi@goffi.org>
date Fri, 27 Feb 2015 22:53:27 +0100
parents 0262fee86375
children ebb602d8b3f2
comparison
equal deleted inserted replaced
659:8e7d4de56e75 660:267761bf7f08
96 self._body = AbsolutePanel() 96 self._body = AbsolutePanel()
97 self._body.setStyleName('chatPanel_body') 97 self._body.setStyleName('chatPanel_body')
98 chat_area = HorizontalPanel() 98 chat_area = HorizontalPanel()
99 chat_area.setStyleName('chatArea') 99 chat_area.setStyleName('chatArea')
100 if type_ == C.CHAT_GROUP: 100 if type_ == C.CHAT_GROUP:
101 self.occupants_list = contact_panel.OccupantsList() 101 self.occupants_panel = contact_panel.ContactsPanel(self, contacts_style="muc_contact", contacts_display=('resource',))
102 self.occupants_initialised = False 102 self.occupants_panel.setStyleName("occupantsPanel")
103 chat_area.add(self.occupants_list) 103 chat_area.add(self.occupants_panel)
104 self._body.add(chat_area) 104 self._body.add(chat_area)
105 self.content = AbsolutePanel() 105 self.content = AbsolutePanel()
106 self.content.setStyleName('chatContent') 106 self.content.setStyleName('chatContent')
107 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) 107 self.content_scroll = base_panel.ScrollPanelWrapper(self.content)
108 chat_area.add(self.content_scroll) 108 chat_area.add(self.content_scroll)
203 self.nick = nick 203 self.nick = nick
204 204
205 def setPresents(self, nicks): 205 def setPresents(self, nicks):
206 """Set the users presents in this room 206 """Set the users presents in this room
207 @param occupants: list of nicks (string)""" 207 @param occupants: list of nicks (string)"""
208 for nick in nicks: 208 self.occupants_panel.setList([jid.JID(u"%s/%s" % (self.target,nick)) for nick in nicks])
209 self.occupants_list.addOccupant(nick)
210 self.occupants_initialised = True
211 209
212 # def userJoined(self, nick, data): 210 # def userJoined(self, nick, data):
213 # if self.occupants_list.getOccupantBox(nick): 211 # if self.occupants_panel.getOccupantBox(nick):
214 # return # user is already displayed 212 # return # user is already displayed
215 # self.occupants_list.addOccupant(nick) 213 # self.occupants_panel.addOccupant(nick)
216 # if self.occupants_initialised: 214 # if self.occupants_initialised:
217 # self.printInfo("=> %s has joined the room" % nick) 215 # self.printInfo("=> %s has joined the room" % nick)
218 216
219 # def userLeft(self, nick, data): 217 # def userLeft(self, nick, data):
220 # self.occupants_list.removeOccupant(nick) 218 # self.occupants_panel.removeOccupant(nick)
221 # self.printInfo("<= %s has left the room" % nick) 219 # self.printInfo("<= %s has left the room" % nick)
222 220
223 def changeUserNick(self, old_nick, new_nick): 221 def changeUserNick(self, old_nick, new_nick):
224 assert(self.type == C.CHAT_GROUP) 222 assert self.type == C.CHAT_GROUP
225 self.occupants_list.removeOccupant(old_nick) 223 # FIXME
226 self.occupants_list.addOccupant(new_nick) 224 # self.occupants_panel.removeOccupant(old_nick)
225 # self.occupants_panel.addOccupant(new_nick)
227 self.printInfo(_("%(old_nick)s is now known as %(new_nick)s") % {'old_nick': old_nick, 'new_nick': new_nick}) 226 self.printInfo(_("%(old_nick)s is now known as %(new_nick)s") % {'old_nick': old_nick, 'new_nick': new_nick})
228 227
229 # def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT): 228 # def historyPrint(self, size=C.HISTORY_LIMIT_DEFAULT):
230 # """Print the initial history""" 229 # """Print the initial history"""
231 # def getHistoryCB(history): 230 # def getHistoryCB(history):
284 """Configure the chat window to start a game""" 283 """Configure the chat window to start a game"""
285 classes = {"Tarot": card_game.CardPanel, "RadioCol": radiocol.RadioColPanel} 284 classes = {"Tarot": card_game.CardPanel, "RadioCol": radiocol.RadioColPanel}
286 if game_type not in classes.keys(): 285 if game_type not in classes.keys():
287 return # unknown game 286 return # unknown game
288 attr = game_type.lower() 287 attr = game_type.lower()
289 self.occupants_list.updateSpecials(players, SYMBOLS[attr]) 288 # self.occupants_panel.updateSpecials(players, SYMBOLS[attr]) # FIXME
290 if waiting or not self.nick in players: 289 if waiting or not self.nick in players:
291 return # waiting for player or not playing 290 return # waiting for player or not playing
292 attr = "%s_panel" % attr 291 attr = "%s_panel" % attr
293 if hasattr(self, attr): 292 if hasattr(self, attr):
294 return 293 return
311 to set the state for a one2one conversation, or give a nickname or 310 to set the state for a one2one conversation, or give a nickname or
312 C.ALL_OCCUPANTS to set the state of a participant within a MUC. 311 C.ALL_OCCUPANTS to set the state of a participant within a MUC.
313 @param state: the new chat state 312 @param state: the new chat state
314 @param nick: ignored for one2one, otherwise the MUC user nick or C.ALL_OCCUPANTS 313 @param nick: ignored for one2one, otherwise the MUC user nick or C.ALL_OCCUPANTS
315 """ 314 """
315 return # FIXME
316 if self.type == C.CHAT_GROUP: 316 if self.type == C.CHAT_GROUP:
317 assert(nick) 317 assert(nick)
318 if nick == C.ALL_OCCUPANTS: 318 if nick == C.ALL_OCCUPANTS:
319 occupants = self.occupants_list.occupants_list.keys() 319 occupants = self.occupants_panel.occupants_panel.keys()
320 else: 320 else:
321 occupants = [nick] if nick in self.occupants_list.occupants_list else [] 321 occupants = [nick] if nick in self.occupants_panel.occupants_panel else []
322 for occupant in occupants: 322 for occupant in occupants:
323 self.occupants_list.occupants_list[occupant].setState(state) 323 self.occupants_panel.occupants_panel[occupant].setState(state)
324 else: 324 else:
325 self._state = state 325 self._state = state
326 self.refreshTitle() 326 self.refreshTitle()
327 self.state_machine.started = not not state # start to send "composing" state from now 327 self.state_machine.started = not not state # start to send "composing" state from now
328 328
335 335
336 def setConnected(self, jid_s, resource, availability, priority, statuses): 336 def setConnected(self, jid_s, resource, availability, priority, statuses):
337 """Set connection status 337 """Set connection status
338 @param jid_s (str): JID userhost as unicode 338 @param jid_s (str): JID userhost as unicode
339 """ 339 """
340 raise Exception("should not be there") # FIXME
340 assert(jid_s == self.target.bare) 341 assert(jid_s == self.target.bare)
341 if self.type != C.CHAT_GROUP: 342 if self.type != C.CHAT_GROUP:
342 return 343 return
343 box = self.occupants_list.getOccupantBox(resource) 344 box = self.occupants_panel.getOccupantBox(resource)
344 if box: 345 if box:
345 contact_list.setPresenceStyle(box, availability) 346 contact_list.setPresenceStyle(box, availability)
346 347
347 def updateChatState(self, from_jid, state): 348 def updateChatState(self, from_jid, state):
348 #TODO 349 #TODO