Mercurial > libervia-web
comparison browser_side/contact.py @ 413:7a8991cda2fa
browser_side: display presence with the highest priority
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 20 Mar 2014 22:16:02 +0100 |
parents | 564208366dd6 |
children | d52f529a6d42 |
comparison
equal
deleted
inserted
replaced
412:9977de10b7da | 413:7a8991cda2fa |
---|---|
320 del self.connected[jid] | 320 del self.connected[jid] |
321 else: | 321 else: |
322 if not jid in self.connected: | 322 if not jid in self.connected: |
323 self.connected[jid] = {} | 323 self.connected[jid] = {} |
324 self.connected[jid][resource] = (availability, priority, statuses) | 324 self.connected[jid][resource] = (availability, priority, statuses) |
325 self._contact_list.setState(jid, "availability", availability) | 325 |
326 # check if the contact is connected with another resource, use the one with highest priority | |
327 if jid in self.connected: | |
328 max_resource = max_priority = None | |
329 for tmp_resource in self.connected[jid]: | |
330 if max_priority is None or self.connected[jid][tmp_resource][1] >= max_priority: | |
331 max_resource = tmp_resource | |
332 max_priority = self.connected[jid][tmp_resource][1] | |
333 if availability == "unavailable": # do not check the priority here, because 'unavailable' has a dummy one | |
334 priority = max_priority | |
335 availability = self.connected[jid][max_resource][0] | |
336 if jid not in self.connected or priority >= max_priority: | |
337 # case 1: jid not in self.connected means all resources are disconnected, update with 'unavailable' | |
338 # case 2: update (or confirm) with the values of the resource which takes precedence | |
339 self._contact_list.setState(jid, "availability", availability) | |
326 | 340 |
327 # update the connected contacts chooser live | 341 # update the connected contacts chooser live |
328 if hasattr(self.host, "room_contacts_chooser") and self.host.room_contacts_chooser is not None: | 342 if hasattr(self.host, "room_contacts_chooser") and self.host.room_contacts_chooser is not None: |
329 self.host.room_contacts_chooser.resetContacts() | 343 self.host.room_contacts_chooser.resetContacts() |
330 | 344 |