summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-10-03 15:10:46 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-10-03 15:10:46 (GMT)
commita719c9898cba1e5a618996ae506256a0c2556cc4 (patch)
treee811aa9a9e8cee0c25adaa608fd9c56001469bc9
parent0a88cbb890213472c4e780593f4bd3866f7588e4 (diff)
downloadswift-contrib-a719c9898cba1e5a618996ae506256a0c2556cc4.zip
swift-contrib-a719c9898cba1e5a618996ae506256a0c2556cc4.tar.bz2
Show contacts as unavailable after subscription removal.
Resolves: #455
-rw-r--r--Swift/Controllers/RosterController.cpp9
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index 5288df1..96056ca 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -146,7 +146,6 @@ void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName,
roster_->removeContactFromGroup(jid, group);
}
}
-
}
void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) {
@@ -225,7 +224,13 @@ void RosterController::handleRosterSetError(boost::optional<ErrorPayload> error,
}
void RosterController::handleIncomingPresence(boost::shared_ptr<Presence> newPresence) {
- roster_->applyOnItems(SetPresence(newPresence));
+ boost::shared_ptr<Presence> 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());
+ }
+ roster_->applyOnItems(SetPresence(appliedPresence));
}
void RosterController::handleSubscriptionRequest(const JID& jid, const String& message) {
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
index 1c27395..9251fad 100644
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ b/Swiften/Roster/ContactRosterItem.cpp
@@ -80,8 +80,13 @@ void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr<
offlinePresence_ = boost::shared_ptr<Presence>();
}
if (presence->getType() == Presence::Unavailable) {
- if (presences_.find(resource) != presences_.end()) {
- presences_.erase(resource);
+ if (resource.isEmpty()) {
+ /* Unavailable from the bare JID means all resources are offline.*/
+ presences_.clear();
+ } else {
+ if (presences_.find(resource) != presences_.end()) {
+ presences_.erase(resource);
+ }
}
if (presences_.size() > 0) {
offlinePresence_ = presence;