summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-10-04 18:20:42 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-10-04 18:20:42 (GMT)
commitf2009dabdf83fb6a5151a3b5b1277edbe79f0ad2 (patch)
treefe516ff1a3bf22028a924ff258328a28d35b29d0 /Swift
parent7e72c9caae6c522f6c64b357434396b633876509 (diff)
downloadswift-contrib-f2009dabdf83fb6a5151a3b5b1277edbe79f0ad2.zip
swift-contrib-f2009dabdf83fb6a5151a3b5b1277edbe79f0ad2.tar.bz2
Handle errors during initial login correctly.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/LoginWindow.h1
-rw-r--r--Swift/Controllers/MainController.cpp16
-rw-r--r--Swift/Controllers/MainController.h1
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp1
4 files changed, 16 insertions, 3 deletions
diff --git a/Swift/Controllers/LoginWindow.h b/Swift/Controllers/LoginWindow.h
index bab505b..cfa20c7 100644
--- a/Swift/Controllers/LoginWindow.h
+++ b/Swift/Controllers/LoginWindow.h
@@ -16,6 +16,7 @@ namespace Swift {
virtual void setMessage(const String&) = 0;
virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0;
boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool)> onLoginRequest;
+ boost::signal<void ()> onCancelLoginRequest;
};
}
#endif
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 958a2ed..8bd9435 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -79,6 +79,7 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF
delete profileSettings;
}
loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4));
+ loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this));
}
MainController::~MainController() {
@@ -259,10 +260,17 @@ void MainController::handleError(const ClientError& error) {
case ClientError::ClientCertificateLoadError: message = "Error loading certificate (Invalid password?)"; break;
case ClientError::ClientCertificateError: message = "Certificate not authorized"; break;
}
- loginWindow_->setMessage(message);
+ if (!rosterController_) { //hasn't been logged in yet
+ signOut();
+ loginWindow_->setMessage(message);
+ }
logout();
}
+void MainController::handleCancelLoginRequest() {
+ signOut();
+}
+
void MainController::signOut() {
logout();
loginWindow_->loggedOut();
@@ -280,7 +288,7 @@ void MainController::signOut() {
}
void MainController::logout() {
- if (client_->isAvailable()) {
+ if (client_ && client_->isAvailable()) {
client_->disconnect();
}
setManagersEnabled(false);
@@ -294,7 +302,9 @@ void MainController::setManagersEnabled(bool enabled) {
foreach (JIDMUCControllerPair controllerPair, mucControllers_) {
controllerPair.second->setEnabled(enabled);
}
- rosterController_->setEnabled(enabled);
+ if (rosterController_) {
+ rosterController_->setEnabled(enabled);
+ }
}
void MainController::handleChatRequest(const String &contact) {
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 5c2b523..2971493 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -55,6 +55,7 @@ namespace Swift {
void handleConnected();
void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember);
+ void handleCancelLoginRequest();
void handleChatRequest(const String& contact);
void handleJoinMUCRequest(const JID& muc, const String& nick);
void handleIncomingPresence(boost::shared_ptr<Presence> presence);
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index a7c9740..23eece6 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -147,6 +147,7 @@ void QtLoginWindow::loggedOut() {
void QtLoginWindow::loginClicked() {
setEnabled(false);
+ message_->setText("");
onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked());
}