Mercurial > libervia-web
comparison src/browser/sat_browser/chat.py @ 673:e489218886d7 frontends_multi_profiles
browser_side: add attribute "merge_resources" to ContactsPanel to display the MUC occupants + override Chat.replaceUser and Chat.removeUser
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 11 Mar 2015 19:01:27 +0100 |
parents | b39a9eddfe56 |
children | 849ffb24d5bf |
comparison
equal
deleted
inserted
replaced
672:b39a9eddfe56 | 673:e489218886d7 |
---|---|
32 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 32 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
33 from pyjamas.ui.Label import Label | 33 from pyjamas.ui.Label import Label |
34 from pyjamas.ui.HTML import HTML | 34 from pyjamas.ui.HTML import HTML |
35 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler | 35 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler |
36 from pyjamas.ui.HTMLPanel import HTMLPanel | 36 from pyjamas.ui.HTMLPanel import HTMLPanel |
37 from pyjamas import DOM | |
37 | 38 |
38 from datetime import datetime | 39 from datetime import datetime |
39 from time import time | 40 from time import time |
40 | 41 |
41 import html_tools | 42 import html_tools |
94 self._body = AbsolutePanel() | 95 self._body = AbsolutePanel() |
95 self._body.setStyleName('chatPanel_body') | 96 self._body.setStyleName('chatPanel_body') |
96 chat_area = HorizontalPanel() | 97 chat_area = HorizontalPanel() |
97 chat_area.setStyleName('chatArea') | 98 chat_area.setStyleName('chatArea') |
98 if type_ == C.CHAT_GROUP: | 99 if type_ == C.CHAT_GROUP: |
99 self.occupants_panel = contact_panel.ContactsPanel(host, | 100 self.occupants_panel = contact_panel.ContactsPanel(host, merge_resources=False, |
100 contacts_style="muc_contact", | 101 contacts_style="muc_contact", |
101 contacts_menus=(C.MENU_JID_CONTEXT), | 102 contacts_menus=(C.MENU_JID_CONTEXT), |
102 contacts_display=('resource',)) | 103 contacts_display=('resource',)) |
103 self.occupants_panel.setStyleName("occupantsPanel") | |
104 chat_area.add(self.occupants_panel) | 104 chat_area.add(self.occupants_panel) |
105 DOM.setAttribute(chat_area.getWidgetTd(self.occupants_panel), "className", "occupantsPanelCell") | |
105 self._body.add(chat_area) | 106 self._body.add(chat_area) |
106 self.content = AbsolutePanel() | 107 self.content = AbsolutePanel() |
107 self.content.setStyleName('chatContent') | 108 self.content.setStyleName('chatContent') |
108 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) | 109 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) |
109 chat_area.add(self.content_scroll) | 110 chat_area.add(self.content_scroll) |
202 def setUserNick(self, nick): | 203 def setUserNick(self, nick): |
203 """Set the nick of the user, usefull for e.g. change the color of the user""" | 204 """Set the nick of the user, usefull for e.g. change the color of the user""" |
204 self.nick = nick | 205 self.nick = nick |
205 | 206 |
206 def setPresents(self, nicks): | 207 def setPresents(self, nicks): |
207 """Set the users presents in this room | 208 """Set the occupants of a group chat. |
208 @param occupants (list[unicode]): list of nicks | 209 |
209 """ | 210 @param nicks (list[unicode]): sorted list of nicknames |
210 self.occupants_panel.setList([jid.JID(u"%s/%s" % (self.target,nick)) for nick in nicks]) | 211 """ |
211 | 212 QuickChat.setPresents(self, nicks) |
212 # def userJoined(self, nick, data): | 213 self.occupants_panel.setList([jid.JID(u"%s/%s" % (self.target, nick)) for nick in nicks]) |
213 # if self.occupants_panel.getOccupantBox(nick): | 214 |
214 # return # user is already displayed | 215 def replaceUser(self, nick, show_info=True): |
215 # self.occupants_panel.addOccupant(nick) | 216 """Add user if it is not in the group list""" |
216 # if self.occupants_initialised: | 217 QuickChat.replaceUser(self, nick, show_info) |
217 # self.printInfo("=> %s has joined the room" % nick) | 218 occupant_jid = jid.JID("%s/%s" % (unicode(self.target), nick)) |
218 | 219 self.occupants_panel.addContact(occupant_jid) |
219 # def userLeft(self, nick, data): | 220 |
220 # self.occupants_panel.removeOccupant(nick) | 221 def removeUser(self, nick, show_info=True): |
221 # self.printInfo("<= %s has left the room" % nick) | 222 """Remove a user from the group list""" |
223 QuickChat.removeUser(self, nick, show_info) | |
224 occupant_jid = jid.JID("%s/%s" % (unicode(self.target), nick)) | |
225 self.occupants_panel.removeContact(occupant_jid) | |
222 | 226 |
223 def changeUserNick(self, old_nick, new_nick): | 227 def changeUserNick(self, old_nick, new_nick): |
224 assert self.type == C.CHAT_GROUP | 228 assert self.type == C.CHAT_GROUP |
225 # FIXME | 229 # FIXME |
226 # self.occupants_panel.removeOccupant(old_nick) | 230 # self.occupants_panel.removeOccupant(old_nick) |