From a8705f484480854816bc6807f1c56b0cf987faff Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 16 Oct 2009 08:08:59 +0100
Subject: Mark as offline in the roster after an error.


diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 8bd9435..6c862ec 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -291,6 +291,8 @@ void MainController::logout() {
 	if (client_ && client_->isAvailable()) {
 		client_->disconnect();
 	}
+	rosterController_->getWindow()->setMyStatusType(StatusShow::None);
+	rosterController_->getWindow()->setMyStatusText("");
 	setManagersEnabled(false);
 }
 
diff --git a/Swift/Controllers/MainWindow.h b/Swift/Controllers/MainWindow.h
index 93345ff..b15cbb5 100644
--- a/Swift/Controllers/MainWindow.h
+++ b/Swift/Controllers/MainWindow.h
@@ -18,6 +18,7 @@ namespace Swift {
 			virtual void setMyName(const String& name) = 0;
 			virtual void setMyAvatarPath(const String& path) = 0;
 			virtual void setMyStatusText(const String& status) = 0;
+			virtual void setMyStatusType(StatusShow::Type type) = 0;
 			
 			boost::signal<void (const JID&)> onStartChatRequest;
 			boost::signal<void (const JID&, const String&)> onAddContactRequest;
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index ed7e67b..2643a1b 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -124,5 +124,9 @@ void QtMainWindow::setMyStatusText(const String& status) {
 	meView_->setStatusText(P2QSTRING(status));
 }
 
+void QtMainWindow::setMyStatusType(StatusShow::Type type) {
+	meView_->setStatusType(type);
+}
+
 }
 
diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h
index afe6ccd..e0b4305 100644
--- a/Swift/QtUI/QtMainWindow.h
+++ b/Swift/QtUI/QtMainWindow.h
@@ -31,6 +31,7 @@ namespace Swift {
 			void setMyName(const String& name);
 			void setMyAvatarPath(const String& path);
 			void setMyStatusText(const String& status);
+			void setMyStatusType(const StatusShow::Type type);
 		private slots:
 			void handleStatusChanged(StatusShow::Type showType, const QString &statusMessage);
 			void handleShowOfflineToggled(bool);
diff --git a/Swift/QtUI/QtRosterHeader.cpp b/Swift/QtUI/QtRosterHeader.cpp
index b8463b7..32ad9c6 100644
--- a/Swift/QtUI/QtRosterHeader.cpp
+++ b/Swift/QtUI/QtRosterHeader.cpp
@@ -90,6 +90,10 @@ void QtRosterHeader::setStatusText(const QString& statusMessage) {
 	statusEdit_->setText(statusMessage);
 }
 
+void QtRosterHeader::setStatusType(StatusShow::Type type) {
+	statusWidget_->setStatusType(type);
+}
+
 void QtRosterHeader::setName(const QString& name) {
 	name_ = name;
 	resizeNameLabel();
diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h
index 66c9333..0c11c02 100644
--- a/Swift/QtUI/QtRosterHeader.h
+++ b/Swift/QtUI/QtRosterHeader.h
@@ -22,6 +22,7 @@ namespace Swift {
 		void setAvatar(const QString& path);
 		void setName(const QString& name);
 		void setStatusText(const QString& statusMessage);
+		void setStatusType(StatusShow::Type type);
 		QSize sizeHint() const;
 		void emitStatus();
 	signals:
diff --git a/Swift/QtUI/QtStatusWidget.cpp b/Swift/QtUI/QtStatusWidget.cpp
index b89d5bb..7002d90 100644
--- a/Swift/QtUI/QtStatusWidget.cpp
+++ b/Swift/QtUI/QtStatusWidget.cpp
@@ -30,6 +30,15 @@ StatusShow::Type QtStatusWidget::getSelectedStatusShow() {
 	return (StatusShow::Type)types_->itemData(types_->currentIndex()).toInt();
 }
 
+void QtStatusWidget::setStatusType(StatusShow::Type type) {
+	for (int i = 0; i < types_->count(); i++) {
+		if (types_->itemData(i).toInt() == type) {
+			types_->setCurrentIndex(i);
+			break;
+		}
+	}
+}
+
 }
 
 
diff --git a/Swift/QtUI/QtStatusWidget.h b/Swift/QtUI/QtStatusWidget.h
index a1c345d..d6372cb 100644
--- a/Swift/QtUI/QtStatusWidget.h
+++ b/Swift/QtUI/QtStatusWidget.h
@@ -14,6 +14,7 @@ namespace Swift {
 		public:
 			QtStatusWidget(QWidget *parent);
 			StatusShow::Type getSelectedStatusShow();
+			void setStatusType(StatusShow::Type type);
 		signals:
 			void onChangeStatusRequest(StatusShow::Type showType);
 		private slots:
-- 
cgit v0.10.2-6-g49f6