# HG changeset patch # User souliane # Date 1395350162 -3600 # Node ID 7a8991cda2fa3cffeb5ec3704cdb6af8fdfa1999 # Parent 9977de10b7da513035204e7acb70506cf1723dba browser_side: display presence with the highest priority diff -r 9977de10b7da -r 7a8991cda2fa browser_side/contact.py --- a/browser_side/contact.py Wed Mar 19 20:27:46 2014 +0100 +++ b/browser_side/contact.py Thu Mar 20 22:16:02 2014 +0100 @@ -322,7 +322,21 @@ if not jid in self.connected: self.connected[jid] = {} self.connected[jid][resource] = (availability, priority, statuses) - self._contact_list.setState(jid, "availability", availability) + + # check if the contact is connected with another resource, use the one with highest priority + if jid in self.connected: + max_resource = max_priority = None + for tmp_resource in self.connected[jid]: + if max_priority is None or self.connected[jid][tmp_resource][1] >= max_priority: + max_resource = tmp_resource + max_priority = self.connected[jid][tmp_resource][1] + if availability == "unavailable": # do not check the priority here, because 'unavailable' has a dummy one + priority = max_priority + availability = self.connected[jid][max_resource][0] + if jid not in self.connected or priority >= max_priority: + # case 1: jid not in self.connected means all resources are disconnected, update with 'unavailable' + # case 2: update (or confirm) with the values of the resource which takes precedence + self._contact_list.setState(jid, "availability", availability) # update the connected contacts chooser live if hasattr(self.host, "room_contacts_chooser") and self.host.room_contacts_chooser is not None: diff -r 9977de10b7da -r 7a8991cda2fa libervia_server/__init__.py --- a/libervia_server/__init__.py Wed Mar 19 20:27:46 2014 +0100 +++ b/libervia_server/__init__.py Thu Mar 20 22:16:02 2014 +0100 @@ -215,7 +215,7 @@ @param status: any string to describe your status """ profile = ISATSession(self.session).profile - self.sat_host.bridge.setPresence('', presence, 0, {'': status}, profile) + self.sat_host.bridge.setPresence('', presence, {'': status}, profile) def jsonrpc_sendMessage(self, to_jid, msg, subject, type_, options={}):