summary refs log tree commit diff
path: root/src/ChatPage.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-09 02:17:04 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-09 02:17:04 +0300
commit239780557f6641c225828e0cb6508f47c0bc15aa (patch)
tree1a064cfd3cdb11dd46aa7b04737e7a07c2333eba /src/ChatPage.cc
parentImplement initial registration stage (diff)
downloadnheko-239780557f6641c225828e0cb6508f47c0bc15aa.tar.xz
Add logout button
Logout from the current session and invalidate the current token
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r--src/ChatPage.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc
index b5707cb9..e6b05c1d 100644
--- a/src/ChatPage.cc
+++ b/src/ChatPage.cc
@@ -53,6 +53,9 @@ ChatPage::ChatPage(QWidget *parent)
 	sync_timer_ = new QTimer(this);
 	connect(sync_timer_, SIGNAL(timeout()), this, SLOT(startSync()));
 
+	connect(user_info_widget_, SIGNAL(logout()), matrix_client_, SLOT(logout()));
+	connect(matrix_client_, SIGNAL(loggedOut()), this, SLOT(logout()));
+
 	connect(room_list_,
 		SIGNAL(roomChanged(const RoomInfo &)),
 		this,
@@ -94,6 +97,29 @@ ChatPage::ChatPage(QWidget *parent)
 		SLOT(messageSent(QString, int)));
 }
 
+void ChatPage::logout()
+{
+	sync_timer_->stop();
+
+	QSettings settings;
+	settings.remove("auth/access_token");
+	settings.remove("auth/home_server");
+	settings.remove("auth/user_id");
+	settings.remove("client/transaction_id");
+
+	// Clear the environment.
+	room_list_->clear();
+	view_manager_->clearAll();
+
+	top_bar_->reset();
+	user_info_widget_->reset();
+	matrix_client_->reset();
+
+	room_avatars_.clear();
+
+	emit close();
+}
+
 void ChatPage::messageSent(QString event_id, int txn_id)
 {
 	Q_UNUSED(event_id);