diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-12-23 10:32:29 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-12-23 10:32:29 (GMT) |
commit | 135f55589ef230ab009e3b961895a6d3b12cdc87 (patch) | |
tree | ba83a3973bdb8dde916629acd2fa8cf53127de7d | |
parent | 9f04a7ec3429303118f12607703b877d8ba43888 (diff) | |
download | swift-contrib-135f55589ef230ab009e3b961895a6d3b12cdc87.zip swift-contrib-135f55589ef230ab009e3b961895a6d3b12cdc87.tar.bz2 |
Add a timer so 20 seconds after requesting a quit, it'll quit regardless of receiving a stream close
-rw-r--r-- | Swift/Controllers/MainController.cpp | 11 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index b925857..660c12f 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -554,6 +554,9 @@ void MainController::handleNotificationClicked(const JID& jid) { void MainController::handleQuitRequest() { if (client_ && client_->isActive()) { quitRequested_ = true; + quitTimer_ = networkFactories_->getTimerFactory()->createTimer(SecondsToWaitBeforeForceQuitting * 1000); + quitTimer_->onTick.connect(boost::bind(&MainController::handleForceQuit, this)); + quitTimer_->start(); client_->disconnect(); } else { @@ -562,4 +565,12 @@ void MainController::handleQuitRequest() { } } +void MainController::handleForceQuit() { + delete client_; + client_ = NULL; + handleQuitRequest(); +} + +const int MainController::SecondsToWaitBeforeForceQuitting = 20; + } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index aece80f..8489f71 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -102,6 +102,7 @@ namespace Swift { void reconnectAfterError(); void setManagersOffline(); void handleNotificationClicked(const JID& jid); + void handleForceQuit(); private: EventLoop* eventLoop_; @@ -141,8 +142,10 @@ namespace Swift { UserSearchController* userSearchController_; int timeBeforeNextReconnect_; Timer::ref reconnectTimer_; + Timer::ref quitTimer_; StatusTracker* statusTracker_; bool myStatusLooksOnline_; bool quitRequested_; + static const int SecondsToWaitBeforeForceQuitting; }; } |