From 06e40dd580e43e11e519acbb2d30156c18081f79 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sat, 29 Oct 2011 11:59:11 +0100 Subject: Make the --eagle-mode banner per-login, not per-run diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index f4e7adc..ce347ab 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -155,8 +155,6 @@ MainController::MainController( } loginWindow_->selectUser(selectedLoginJID); loginWindow_->setLoginAutomatically(loginAutomatically); - } else { - loginWindow_->setRememberingAllowed(false); } diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index fcaeb42..61fcaa1 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h @@ -27,8 +27,6 @@ namespace Swift { boost::signal onLoginRequest; virtual void setLoginAutomatically(bool loginAutomatically) = 0; virtual void quit() = 0; - /** Disable any GUI elements that suggest saving of passwords. */ - virtual void setRememberingAllowed(bool allowed) = 0; /** Blocking request whether a cert should be permanently trusted.*/ virtual bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref) = 0; diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 0db6071..87dd849 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -33,6 +33,7 @@ #include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" #include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h" #include "Swiften/Base/Platform.h" +#include "Swiften/Base/Paths.h" #include "QtAboutWidget.h" #include "QtSwiftUtil.h" @@ -41,7 +42,7 @@ namespace Swift{ -QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow(), forgetful_(false) { +QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode) : QMainWindow(), eagleMode_(eagleMode) { uiEventStream_ = uiEventStream; setWindowTitle("Swift"); @@ -202,18 +203,17 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow(), forg setInitialMenus(); uiEventStream_->onUIEvent.connect(boost::bind(&QtLoginWindow::handleUIEvent, this, _1)); - this->show(); -} -void QtLoginWindow::setRememberingAllowed(bool allowed) { - forgetful_ = true; - remember_->setEnabled(allowed); - loginAutomatically_->setEnabled(allowed); - xmlConsoleAction_->setEnabled(allowed); - if (!allowed) { + + remember_->setEnabled(!eagleMode_); + loginAutomatically_->setEnabled(!eagleMode_); + xmlConsoleAction_->setEnabled(!eagleMode_); + if (eagleMode_) { remember_->setChecked(false); loginAutomatically_->setChecked(false); } + + this->show(); } bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) { @@ -322,8 +322,30 @@ void QtLoginWindow::setIsLoggingIn(bool loggingIn) { void QtLoginWindow::loginClicked() { if (username_->isEnabled()) { + if (eagleMode_) { + QString clickThroughPath(P2QSTRING((Paths::getExecutablePath() / "eagle-banner.txt").string())); + QFile clickThroughFile(clickThroughPath); + if (clickThroughFile.exists() && clickThroughFile.open(QIODevice::ReadOnly)) { + QString banner; + while (!clickThroughFile.atEnd()) { + QByteArray line = clickThroughFile.readLine(); + banner += line + "\n"; + } + if (!banner.isEmpty()) { + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Confirm terms of use")); + msgBox.setText(""); + msgBox.setInformativeText(banner); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + if (msgBox.exec() != QMessageBox::Yes) { + return; + } + } + } + } onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked(), loginAutomatically_->isChecked()); - if (forgetful_) { /* Mustn't remember logins */ + if (eagleMode_) { /* Mustn't remember logins */ username_->clearEditText(); password_->setText(""); } diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 414bb20..acf327f 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -27,7 +27,7 @@ namespace Swift { class QtLoginWindow : public QMainWindow, public LoginWindow { Q_OBJECT public: - QtLoginWindow(UIEventStream* uiEventStream); + QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode); void morphInto(MainWindow *mainWindow); virtual void loggedOut(); @@ -36,7 +36,6 @@ namespace Swift { virtual void removeAvailableAccount(const std::string& jid); virtual void setLoginAutomatically(bool loginAutomatically); virtual void setIsLoggingIn(bool loggingIn); - virtual void setRememberingAllowed(bool allowed); void selectUser(const std::string& user); bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate); void hide(); @@ -87,7 +86,7 @@ namespace Swift { QAction* toggleNotificationsAction_; UIEventStream* uiEventStream_; QPointer aboutDialog_; - bool forgetful_; + bool eagleMode_; QAction* xmlConsoleAction_; QAction* fileTransferOverviewAction_; }; diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 7c0a2bd..7f11b5c 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -33,7 +33,6 @@ #include "Swift/Controllers/BuildVersion.h" #include "SwifTools/AutoUpdater/AutoUpdater.h" #include "SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h" -#include "Swiften/Base/Paths.h" #if defined(SWIFTEN_PLATFORM_WINDOWS) #include "WindowsNotifier.h" @@ -175,29 +174,6 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa mainControllers_.push_back(mainController); } - if (eagleMode) { - QString clickThroughPath(P2QSTRING((Paths::getExecutablePath() / "eagle-banner.txt").string())); - QFile clickThroughFile(clickThroughPath); - if (clickThroughFile.exists() && clickThroughFile.open(QIODevice::ReadOnly)) { - QString banner; - while (!clickThroughFile.atEnd()) { - QByteArray line = clickThroughFile.readLine(); - banner += line + "\n"; - } - if (!banner.isEmpty()) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Confirm terms of use")); - msgBox.setText(tr("Do you agree to the terms of use?")); - msgBox.setInformativeText(banner); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - if (msgBox.exec() != QMessageBox::Yes) { - exit(0); - } - } - } - } - // PlatformAutoUpdaterFactory autoUpdaterFactory; // if (autoUpdaterFactory.isSupported()) { diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index faeebdc..5f55795 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -60,7 +60,7 @@ MainWindow* QtUIFactory::createMainWindow(UIEventStream* eventStream) { } LoginWindow* QtUIFactory::createLoginWindow(UIEventStream* eventStream) { - loginWindow = new QtLoginWindow(eventStream); + loginWindow = new QtLoginWindow(eventStream, eagleMode); if (netbookSplitter) { netbookSplitter->insertWidget(0, loginWindow); } -- cgit v0.10.2-6-g49f6