diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-20 16:02:41 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-20 16:10:12 (GMT) |
commit | f6635d1eee1235710c61e3fad76a161959185323 (patch) | |
tree | 6eacb761405e6538656285b01fe3b5e822a12439 /Swift/Controllers | |
parent | 0ced6917acc8d5d58e62bb2503d1c9967d22cb18 (diff) | |
download | swift-contrib-f6635d1eee1235710c61e3fad76a161959185323.zip swift-contrib-f6635d1eee1235710c61e3fad76a161959185323.tar.bz2 |
Fire fewer reconnect timers after they become obsolete
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 26 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 4ca38cc..ec339b0 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -137,6 +137,7 @@ MainController::~MainController() { } void MainController::resetClient() { + resetCurrentError(); serverDiscoInfo_ = boost::shared_ptr<DiscoInfo>(); xmppRoster_ = boost::shared_ptr<XMPPRoster>(); delete chatsManager_; @@ -163,20 +164,28 @@ void MainController::resetClient() { client_ = NULL; delete mucSearchController_; mucSearchController_ = NULL; - } -void MainController::handleConnected() { +void MainController::resetPendingReconnects() { timeBeforeNextReconnect_ = -1; if (reconnectTimer_) { reconnectTimer_->stop(); reconnectTimer_.reset(); } - loginWindow_->setIsLoggingIn(false); + +} + +void MainController::resetCurrentError() { if (lastDisconnectError_) { lastDisconnectError_->conclude(); lastDisconnectError_ = boost::shared_ptr<ErrorEvent>(); } +} + +void MainController::handleConnected() { + loginWindow_->setIsLoggingIn(false); + resetCurrentError(); + resetPendingReconnects(); //FIXME: this freshLogin thing is temporary so I can see what's what before I split into a seperate method. bool freshLogin = rosterController_ == NULL; if (freshLogin) { @@ -244,6 +253,9 @@ void MainController::handleEventQueueLengthChange(int count) { } void MainController::reconnectAfterError() { + if (reconnectTimer_) { + reconnectTimer_->stop(); + } performLoginFromCachedCredentials(); //sendPresence(queuedPresence_); } @@ -395,6 +407,9 @@ void MainController::setReconnectTimer() { } else { timeBeforeNextReconnect_ = timeBeforeNextReconnect_ >= 150 ? 300 : timeBeforeNextReconnect_ * 2; } + if (reconnectTimer_) { + reconnectTimer_->stop(); + } reconnectTimer_ = timerFactory_.createTimer(timeBeforeNextReconnect_ * 1000); reconnectTimer_->onTick.connect(boost::bind(&MainController::reconnectAfterError, this)); reconnectTimer_->start(); @@ -413,10 +428,7 @@ void MainController::signOut() { } void MainController::logout() { - if (reconnectTimer_) { - reconnectTimer_->stop(); - reconnectTimer_.reset(); - } + resetPendingReconnects(); if (client_ /*&& client_->isAvailable()*/) { client_->disconnect(); } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 5fc5e8f..2f489a8 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -82,6 +82,8 @@ namespace Swift { void logout(); void signOut(); void setReconnectTimer(); + void resetPendingReconnects(); + void resetCurrentError(); void performLoginFromCachedCredentials(); void reconnectAfterError(); |