diff options
Diffstat (limited to 'Swiften/Presence/PresenceOracle.cpp')
-rw-r--r-- | Swiften/Presence/PresenceOracle.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Swiften/Presence/PresenceOracle.cpp b/Swiften/Presence/PresenceOracle.cpp index 758ae7c..439a84d 100644 --- a/Swiften/Presence/PresenceOracle.cpp +++ b/Swiften/Presence/PresenceOracle.cpp @@ -59,5 +59,25 @@ Presence::ref PresenceOracle::getLastPresence(const JID& jid) const { } } +Presence::ref PresenceOracle::getHighestPriorityPresence(const JID& bareJID) const { + PresencesMap::const_iterator i = entries_.find(bareJID); + if (i == entries_.end()) { + return Presence::ref(); + } + PresenceMap presenceMap = i->second; + PresenceMap::const_iterator j = presenceMap.begin(); + Presence::ref highest; + for (; j != presenceMap.end(); j++) { + Presence::ref current = j->second; + if (!highest + || current->getPriority() > highest->getPriority() + || (current->getPriority() == highest->getPriority() + && StatusShow::typeToAvailabilityOrdering(current->getShow()) > StatusShow::typeToAvailabilityOrdering(highest->getShow()))) { + highest = current; + } + + } + return highest; +} } |