bridge, frontends: display presence with the highest priority + reset your own presence when you (dis)connect
This commit is contained in:
parent
005ec59a8a
commit
bc9efbda82
1 changed files with 39 additions and 20 deletions
|
|
@ -179,10 +179,10 @@ class QuickApp(object):
|
|||
priority = presences[contact][res][1]
|
||||
statuses = presences[contact][res][2]
|
||||
self.presenceUpdate(jabber_id, show, priority, statuses, profile)
|
||||
data = self.bridge.getEntityData(contact, ['avatar', 'nick'], profile)
|
||||
for key in ('avatar', 'nick'):
|
||||
if key in data:
|
||||
self.entityDataUpdated(contact, key, data[key], profile)
|
||||
data = self.bridge.getEntityData(contact, ['avatar', 'nick'], profile)
|
||||
for key in ('avatar', 'nick'):
|
||||
if key in data:
|
||||
self.entityDataUpdated(contact, key, data[key], profile)
|
||||
|
||||
#The waiting subscription requests
|
||||
waitingSub = self.bridge.getWaitingSub(profile)
|
||||
|
|
@ -313,7 +313,7 @@ class QuickApp(object):
|
|||
self.setStatusOnline(True, show, statuses)
|
||||
return
|
||||
|
||||
self.contact_list.updatePresence(from_jid, show, priority, statuses)
|
||||
presences = self.profiles[profile].setdefault('presences', {})
|
||||
|
||||
if show != 'unavailable':
|
||||
|
||||
|
|
@ -321,13 +321,32 @@ class QuickApp(object):
|
|||
if from_jid.bare in self.profiles[profile]['watched'] and not from_jid.bare in self.profiles[profile]['onlineContact']:
|
||||
self.showAlert(_("Watched jid [%s] is connected !") % from_jid.bare)
|
||||
|
||||
presences[jabber_id] = {'show': show, 'priority': priority, 'statuses': statuses}
|
||||
self.profiles[profile]['onlineContact'].add(from_jid) # FIXME onlineContact is useless with CM, must be removed
|
||||
|
||||
#TODO: vcard data (avatar)
|
||||
|
||||
if show == "unavailable" and from_jid in self.profiles[profile]['onlineContact']:
|
||||
try:
|
||||
del presences[jabber_id]
|
||||
except KeyError:
|
||||
pass
|
||||
self.profiles[profile]['onlineContact'].remove(from_jid)
|
||||
|
||||
# check if the contact is connected with another resource, use the one with highest priority
|
||||
jids = [jid for jid in presences if JID(jid).bare == from_jid.bare]
|
||||
if jids:
|
||||
max_jid = max(jids, key=lambda jid: presences[jid]['priority'])
|
||||
data = presences[max_jid]
|
||||
max_priority = data['priority']
|
||||
if show == "unavailable": # do not check the priority here, because 'unavailable' has a dummy one
|
||||
from_jid = JID(max_jid)
|
||||
show, priority, statuses = data['show'], data['priority'], data['statuses']
|
||||
if not jids or priority >= max_priority:
|
||||
# case 1: not jids means all resources are disconnected, send the 'unavailable' presence
|
||||
# case 2: update (or confirm) with the values of the resource which takes precedence
|
||||
self.contact_list.updatePresence(from_jid, show, priority, statuses)
|
||||
|
||||
def roomJoined(self, room_jid, room_nicks, user_nick, profile):
|
||||
"""Called when a MUC room is joined"""
|
||||
if not self.check_profile(profile):
|
||||
|
|
|
|||
Loading…
Reference in a new issue