summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;