From a793e9f8f6ee0e1ed52d3b9fbac7b236437d94f0 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 8 Oct 2010 10:53:21 +0100
Subject: Update roster header even when going offline.

Resolves: #596
Release-Notes: The roster header will no longer show you with (No message) if you specify a message when you go offline.

diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index e3079ac..ccefa4b 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -270,6 +270,7 @@ void MainController::handleConnected() {
 	resetCurrentError();
 	resetPendingReconnects();
 	bool freshLogin = rosterController_ == NULL;
+	myStatusLooksOnline_ = true;
 	if (freshLogin) {
 		serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(new DiscoInfo());
 
@@ -329,9 +330,10 @@ void MainController::reconnectAfterError() {
 void MainController::handleChangeStatusRequest(StatusShow::Type show, const String &statusText) {
 	boost::shared_ptr<Presence> presence(new Presence());
 	if (show == StatusShow::None) {
-		// FIXME: This is wrong. None doesn't mean unavailable
+		// Note: this is misleading, None doesn't mean unavailable on the wire.
 		presence->setType(Presence::Unavailable);
 		resetPendingReconnects();
+		myStatusLooksOnline_ = false;
 	}
 	else {
 		presence->setShow(show);
@@ -517,9 +519,10 @@ void MainController::logout() {
 	if (client_ /*&& client_->isAvailable()*/) {
 		client_->disconnect();
 	}
-	if (rosterController_) {
+	if (rosterController_ && myStatusLooksOnline_) {
 		rosterController_->getWindow()->setMyStatusType(StatusShow::None);
 		rosterController_->getWindow()->setMyStatusText("");
+		myStatusLooksOnline_ = false;
 	}
 	setManagersOnline(false);
 }
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 163a260..72928d0 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -178,6 +178,7 @@ namespace Swift {
 			Timer::ref reconnectTimer_;
 			StatusTracker* statusTracker_;
 			MUCRegistry* mucRegistry_;
+			bool myStatusLooksOnline_;
 
 			typedef std::map<String, VCardStorage*> VCardStorageMap;
 			VCardStorageMap vcardStorages_;
-- 
cgit v0.10.2-6-g49f6