From 239780557f6641c225828e0cb6508f47c0bc15aa Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 9 Apr 2017 02:17:04 +0300 Subject: Add logout button Logout from the current session and invalidate the current token --- src/ChatPage.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/ChatPage.cc') 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); -- cgit 1.5.1