From 5dcea6769d7ad61282edbf19481cd25b676383f6 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 23 Oct 2010 20:09:54 +0100
Subject: Make sure presence isn't type error before updating roster.

Resolves: #622
Release-Notes: Errors received from your contacts when setting your status will no longer cause the contacts to mirror your new status.

diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index 580e12b..9e50f0e 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -231,8 +231,11 @@ void RosterController::handleRosterSetError(boost::optional<ErrorPayload> error,
 	eventController_->handleIncomingEvent(errorEvent);
 }
 
-void RosterController::handleIncomingPresence(boost::shared_ptr<Presence> newPresence) {
-	boost::shared_ptr<Presence> appliedPresence(newPresence);
+void RosterController::handleIncomingPresence(Presence::ref newPresence) {
+	if (newPresence->getType() == Presence::Error) {
+		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());
diff --git a/Swiften/Roster/SetPresence.h b/Swiften/Roster/SetPresence.h
index 9bbf326..e710931 100644
--- a/Swiften/Roster/SetPresence.h
+++ b/Swiften/Roster/SetPresence.h
@@ -17,7 +17,7 @@ class RosterItem;
 
 class SetPresence : public RosterItemOperation {
 	public:
-		SetPresence(boost::shared_ptr<Presence> presence, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, compareType == JID::WithoutResource ? presence->getFrom().toBare() : presence->getFrom()), presence_(presence), compareType_(compareType) {
+		SetPresence(Presence::ref presence, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, compareType == JID::WithoutResource ? presence->getFrom().toBare() : presence->getFrom()), presence_(presence), compareType_(compareType) {
 		}
 
 		virtual void operator() (RosterItem* item) const {
@@ -28,7 +28,7 @@ class SetPresence : public RosterItemOperation {
 		}
 	
 	private:
-		boost::shared_ptr<Presence> presence_;
+		Presence::ref presence_;
 		JID::CompareType compareType_;
 };
 
-- 
cgit v0.10.2-6-g49f6