changeset 304:2ab513a47e3b

browser_side: fix presence/status update (do not share between different resources)
author souliane <souliane@mailoo.org>
date Wed, 18 Dec 2013 09:54:27 +0100 (2013-12-18)
parents 6ce8515ee8f5
children d002cd631271
files browser_side/contact.py libervia.py
diffstat 2 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/contact.py	Wed Dec 18 09:51:10 2013 +0100
+++ b/browser_side/contact.py	Wed Dec 18 09:54:27 2013 +0100
@@ -293,13 +293,13 @@
         @param jid: JID userhost as unicode
         """
         if availability == 'unavailable':
-            if self.connected.has_key(jid):
-                if self.connected[jid].has_key(resource):
+            if jid in self.connected:
+                if resource in self.connected[jid]:
                     del self.connected[jid][resource]
                 if not self.connected[jid]:
                     del self.connected[jid]
         else:
-            if not self.connected.has_key(jid):
+            if not jid in self.connected:
                 self.connected[jid] = {}
             self.connected[jid][resource] = (availability, priority, statuses)
         self._contact_list.setState(jid, "availability", availability)
--- a/libervia.py	Wed Dec 18 09:51:10 2013 +0100
+++ b/libervia.py	Wed Dec 18 09:54:27 2013 +0100
@@ -627,13 +627,13 @@
             self.contact_panel.setContactMessageWaiting(other.bare, True)
 
     def _presenceUpdateCb(self, entity, show, priority, statuses):
-        _entity = JID(entity)
-        #XXX: QnD way to get our status
-        if self.whoami and self.whoami.bare == _entity.bare and statuses:
+        entity_jid = JID(entity)
+        if self.whoami and self.whoami == entity_jid:  # XXX: QnD way to get our presence/status
             self.status_panel.setPresence(show)
-            self.status_panel.changeStatus(statuses.values()[0])
-        if (not self.whoami or self.whoami.bare != _entity.bare):
-            self.contact_panel.setConnected(_entity.bare, _entity.resource, show, priority, statuses)
+            if statuses:
+                self.status_panel.changeStatus(statuses.values()[0])
+        else:
+            self.contact_panel.setConnected(entity_jid.bare, entity_jid.resource, show, priority, statuses)
 
     def _roomJoinedCb(self, room_jid, room_nicks, user_nick):
         _target = JID(room_jid)