Example #1
0
    bool operator()(const Presence::ref& a, const Presence::ref& b) {
        int aPreference = preferenceFromStatusShow(a->getShow());
        int bPreference = preferenceFromStatusShow(b->getShow());

        if (aPreference != bPreference) {
            return aPreference < bPreference;
        }
        if (a->getPriority() != b->getPriority()) {
            return a->getPriority() < b->getPriority();
        }
        return a->getFrom().getResource() < b->getFrom().getResource();
    }
Example #2
0
Presence::ref PresenceOracle::getHighestPriorityPresence(const JID& bareJID) const {
    PresencesMap::const_iterator i = entries_.find(bareJID);
    if (i == entries_.end()) {
        return Presence::ref();
    }
    Presence::ref highest;
    for (const auto& jidPresence : i->second) {
        Presence::ref current = jidPresence.second;
        if (!highest
                || current->getPriority() > highest->getPriority()
                || (current->getPriority() == highest->getPriority()
                        && StatusShow::typeToAvailabilityOrdering(current->getShow()) > StatusShow::typeToAvailabilityOrdering(highest->getShow()))) {
            highest = current;
        }
    }
    return highest;
}