コード例 #1
0
ファイル: PresenceOracle.cpp プロジェクト: swift/swift
    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();
    }
コード例 #2
0
ファイル: PresenceOracle.cpp プロジェクト: swift/swift
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;
}