summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-06-20 16:02:41 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-06-20 16:10:12 (GMT)
commitf6635d1eee1235710c61e3fad76a161959185323 (patch)
tree6eacb761405e6538656285b01fe3b5e822a12439 /Swift/Controllers/MainController.cpp
parent0ced6917acc8d5d58e62bb2503d1c9967d22cb18 (diff)
downloadswift-f6635d1eee1235710c61e3fad76a161959185323.zip
swift-f6635d1eee1235710c61e3fad76a161959185323.tar.bz2
Fire fewer reconnect timers after they become obsolete
Diffstat (limited to 'Swift/Controllers/MainController.cpp')
-rw-r--r--Swift/Controllers/MainController.cpp26
1 files changed, 19 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();
}