# HG changeset patch # User souliane # Date 1413545193 -7200 # Node ID 12823bcbd05bf59f7fea358b66cc67d0695f9d23 # Parent 7a823c6568e267524c1610b39458c497d02865d9 browser_side: display MUC occupants presences diff -r 7a823c6568e2 -r 12823bcbd05b src/browser/libervia_main.py --- 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) diff -r 7a823c6568e2 -r 12823bcbd05b src/browser/sat_browser/base_panels.py --- 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("
%s%s%s
" % (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) diff -r 7a823c6568e2 -r 12823bcbd05b src/browser/sat_browser/panels.py --- 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 """