summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/MainController.cpp18
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swift/Controllers/UIInterfaces/LoginWindow.h3
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp4
-rw-r--r--Swift/QtUI/QtLoginWindow.h2
5 files changed, 28 insertions, 1 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index eb03e50..92a3f2a 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -100,6 +100,7 @@ MainController::MainController(
eventWindowController_ = NULL;
discoResponder_ = NULL;
mucSearchController_ = NULL;
+ quitRequested_ = false;
timeBeforeNextReconnect_ = -1;
mucSearchWindowFactory_ = mucSearchWindowFactory;
@@ -136,6 +137,7 @@ MainController::MainController(
loginWindow_->setLoginAutomatically(loginAutomatically);
loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5));
loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this));
+ loginWindow_->onQuitRequest.connect(boost::bind(&MainController::handleQuitRequest, this));
idleDetector_.setIdleTimeSeconds(600);
idleDetector_.onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1));
@@ -401,7 +403,11 @@ void MainController::performLoginFromCachedCredentials() {
}
void MainController::handleDisconnected(const boost::optional<ClientError>& error) {
- if (error) {
+ if (quitRequested_) {
+ resetClient();
+ loginWindow_->quit();
+ }
+ else if (error) {
String message;
switch(error->getType()) {
case ClientError::UnknownError: message = "Unknown Error"; break;
@@ -506,5 +512,15 @@ void MainController::handleNotificationClicked(const JID& jid) {
uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(jid)));
}
+void MainController::handleQuitRequest() {
+ if (client_ && client_->isActive()) {
+ quitRequested_ = true;
+ client_->disconnect();
+ }
+ else {
+ resetClient();
+ loginWindow_->quit();
+ }
+}
}
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index da65567..c36c136 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -89,6 +89,7 @@ namespace Swift {
void handleConnected();
void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically);
void handleCancelLoginRequest();
+ void handleQuitRequest();
void handleChangeStatusRequest(StatusShow::Type show, const String &statusText);
void handleDisconnected(const boost::optional<ClientError>& error);
void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, const boost::optional<ErrorPayload>&);
@@ -152,5 +153,6 @@ namespace Swift {
Timer::ref reconnectTimer_;
StatusTracker* statusTracker_;
bool myStatusLooksOnline_;
+ bool quitRequested_;
};
}
diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h
index c752d0a..54d8099 100644
--- a/Swift/Controllers/UIInterfaces/LoginWindow.h
+++ b/Swift/Controllers/UIInterfaces/LoginWindow.h
@@ -25,7 +25,10 @@ namespace Swift {
virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0;
boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest;
virtual void setLoginAutomatically(bool loginAutomatically) = 0;
+ virtual void quit() = 0;
+
boost::signal<void ()> onCancelLoginRequest;
+ boost::signal<void ()> onQuitRequest;
};
}
#endif
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 4206a4b..bcadc3a 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -321,6 +321,10 @@ void QtLoginWindow::handleToggleNotifications(bool enabled) {
}
void QtLoginWindow::handleQuit() {
+ onQuitRequest();
+}
+
+void QtLoginWindow::quit() {
QApplication::quit();
}
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 1a4343e..242b5b4 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -39,6 +39,8 @@ namespace Swift {
static QRect defaultPosition();
void setGentleGeometry(const QRect&);
void selectUser(const String& user);
+ virtual void quit();
+
signals:
void geometryChanged();