diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-10-24 12:17:55 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-10-24 13:06:26 (GMT) |
commit | 0f078be02cd6818aeacc935a1ab790b41267a00d (patch) | |
tree | acf7c1a08769c8332ccf9e07b00c48cf83f24172 /Swift/Controllers/RosterController.cpp | |
parent | b107bdd08df9ae3a978ad8f966a26eb8d551bd13 (diff) | |
download | swift-contrib-0f078be02cd6818aeacc935a1ab790b41267a00d.zip swift-contrib-0f078be02cd6818aeacc935a1ab790b41267a00d.tar.bz2 |
Use the highest priority for a contact's roster item, not the newest.
Resolves: #654
Release-Notes: Contacts online from several clients at once should now show the highest priority presence, not the most recent.
Diffstat (limited to 'Swift/Controllers/RosterController.cpp')
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index 9e50f0e..dfe34b0 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -236,12 +236,15 @@ void RosterController::handleIncomingPresence(Presence::ref newPresence) { return; } Presence::ref appliedPresence(newPresence); - if (newPresence->getType() == Presence::Unsubscribe) { - /* In 3921bis, subscription removal isn't followed by a presence push of unavailable*/ - appliedPresence = boost::shared_ptr<Presence>(new Presence()); - appliedPresence->setFrom(newPresence->getFrom().toBare()); + JID newJID(appliedPresence->getFrom()); + Presence::ref highestPresence = presenceOracle_->getHighestPriorityPresence(appliedPresence->getFrom().toBare()); + JID highestJID(highestPresence->getFrom()); + bool highestPriority = (newJID == highestJID || highestPresence->getType() == Presence::Unavailable); + if (!highestPriority) { + /* Update in case there are full-JID roster entries.*/ + roster_->applyOnItems(SetPresence(appliedPresence, JID::WithResource)); } - roster_->applyOnItems(SetPresence(appliedPresence)); + roster_->applyOnItems(SetPresence(highestPresence)); } void RosterController::handleSubscriptionRequest(const JID& jid, const String& message) { |