changeset 573:12823bcbd05b

browser_side: display MUC occupants presences
author souliane <souliane@mailoo.org>
date Fri, 17 Oct 2014 13:26:33 +0200
parents 7a823c6568e2
children b07f0fe2763a
files src/browser/libervia_main.py src/browser/sat_browser/base_panels.py src/browser/sat_browser/panels.py
diffstat 3 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Fri Oct 17 10:44:06 2014 +0200
+++ b/src/browser/libervia_main.py	Fri Oct 17 13:26:33 2014 +0200
@@ -766,11 +766,15 @@
             if statuses:
                 self.status_panel.setStatus(statuses.values()[0])  # pylint: disable=E1103
         else:
-            self.contact_panel.setConnected(entity_jid.bare, entity_jid.resource, show, priority, statuses)
-            if show == 'unavailable':  # XXX: save some resources as for now we only need 'unavailable'
-                for plugin in self.plugins.values():
-                    if hasattr(plugin, 'presenceReceivedTrigger'):
-                        plugin.presenceReceivedTrigger(entity_jid, show, priority, statuses)
+            if entity_jid.bare in self.room_list:
+                wid = self.getLiberviaWidget(panels.ChatPanel, entity_jid.bare, ignoreOtherTabs=False)
+            else:
+                wid = self.contact_panel
+                if show == 'unavailable':  # XXX: save some resources as for now we only need 'unavailable'
+                    for plugin in self.plugins.values():
+                        if hasattr(plugin, 'presenceReceivedTrigger'):
+                            plugin.presenceReceivedTrigger(entity_jid, show, priority, statuses)
+            wid.setConnected(entity_jid.bare, entity_jid.resource, show, priority, statuses)
 
     def _roomJoinedCb(self, room_jid, room_nicks, user_nick):
         _target = jid.JID(room_jid)
--- a/src/browser/sat_browser/base_panels.py	Fri Oct 17 10:44:06 2014 +0200
+++ b/src/browser/sat_browser/base_panels.py	Fri Oct 17 13:26:33 2014 +0200
@@ -71,7 +71,7 @@
         @param state: the user chate state (XEP-0085)
         @param special: a string of symbols (e.g: for activities)
         """
-        HTML.__init__(self)
+        HTML.__init__(self, StyleName="occupant")
         self.nick = nick
         self._state = state
         self.special = special
@@ -101,7 +101,7 @@
     def _refresh(self):
         state = (' %s' % C.MUC_USER_STATES[self._state]) if self._state else ''
         special = "" if len(self.special) == 0 else " %s" % self.special
-        self.setHTML("<div class='occupant'>%s%s%s</div>" % (html_tools.html_sanitize(self.nick), special, state))
+        self.setHTML("%s%s%s" % (html_tools.html_sanitize(self.nick), special, state))
 
 
 class OccupantsList(AbsolutePanel):
@@ -123,6 +123,13 @@
         except KeyError:
             log.error("trying to remove an unexisting nick")
 
+    def getOccupantBox(self, nick):
+        """Get the widget element of the given nick.
+
+        @return: Occupant
+        """
+        return self.occupants_list[nick]
+
     def clear(self):
         self.occupants_list.clear()
         AbsolutePanel.clear(self)
--- a/src/browser/sat_browser/panels.py	Fri Oct 17 10:44:06 2014 +0200
+++ b/src/browser/sat_browser/panels.py	Fri Oct 17 13:26:33 2014 +0200
@@ -1353,6 +1353,15 @@
         else:
             self.setTitle(self.target.bare)
 
+    def setConnected(self, jid_s, resource, availability, priority, statuses):
+        """Set connection status
+        @param jid_s (str): JID userhost as unicode
+        """
+        assert(jid_s == self.target.bare)
+        if self.type != 'group':
+            return
+        contact.setPresenceStyle(self.occupants_list.getOccupantBox(resource), availability)
+
 
 class WebPanel(base_widget.LiberviaWidget):
     """ (mini)browser like widget """