From 8486a2fd2be03c7d2eeb0ad8539c23e2bdf5a7b6 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 21 Jan 2016 13:33:03 +0100 Subject: [PATCH] Bring back the automatic authentication popups Users have complained that they don't see the notification when it is shown and are not aware that their files aren't syncing. Remove the non-interactive credentials fetch logic and add make sure that the shibboleth popup will flash in the taskbar instead. This will still not allow the popup to show in front in all cases, but this is a compromise that we have to chose. This reverts commit dcb687929f1323e9fea8a9e4bd48cdd3fa8312d9. Issue https://github.com/owncloud/enterprise/issues/990 --- src/gui/accountstate.cpp | 18 +++++------------- src/gui/accountstate.h | 4 +--- src/gui/application.cpp | 2 +- src/gui/creds/shibbolethcredentials.cpp | 7 +++---- src/libsync/creds/tokencredentials.cpp | 2 +- src/libsync/creds/tokencredentials.h | 2 +- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 1f93932af..7a14b2d5d 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -30,7 +30,6 @@ AccountState::AccountState(AccountPtr account) , _state(AccountState::Disconnected) , _connectionStatus(ConnectionValidator::Undefined) , _waitingForNewCredentials(false) - , _credentialsFetchMode(Interactive) { qRegisterMetaType("AccountState*"); @@ -84,7 +83,7 @@ void AccountState::setState(State state) _connectionStatus = ConnectionValidator::Undefined; _connectionErrors.clear(); } else if (oldState == SignedOut && _state == Disconnected) { - checkConnectivity(Interactive); + checkConnectivity(); } } @@ -145,7 +144,7 @@ void AccountState::tagLastSuccessfullETagRequest() _timeSinceLastETagCheck.restart(); } -void AccountState::checkConnectivity(CredentialFetchMode credentialsFetchMode) +void AccountState::checkConnectivity() { if (isSignedOut() || _waitingForNewCredentials) { return; @@ -167,7 +166,6 @@ void AccountState::checkConnectivity(CredentialFetchMode credentialsFetchMode) return; } - _credentialsFetchMode = credentialsFetchMode; ConnectionValidator * conValidator = new ConnectionValidator(account()); _connectionValidator = conValidator; connect(conValidator, SIGNAL(connectionResult(ConnectionValidator::Status,QStringList)), @@ -261,13 +259,7 @@ void AccountState::slotCredentialsFetched(AbstractCredentials* credentials) { if (!credentials->ready()) { // No exiting credentials found in the keychain - if (_credentialsFetchMode == Interactive) - credentials->askFromUser(); - else { - Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("You need to re-login to continue using the account %1.").arg(_account->displayName())); - setState(SignedOut); - _waitingForNewCredentials = false; - } + credentials->askFromUser(); return; } @@ -277,7 +269,7 @@ void AccountState::slotCredentialsFetched(AbstractCredentials* credentials) // connection validation, even if it's currently running. delete _connectionValidator; - checkConnectivity(_credentialsFetchMode); + checkConnectivity(); } void AccountState::slotCredentialsAsked(AbstractCredentials* credentials) @@ -294,7 +286,7 @@ void AccountState::slotCredentialsAsked(AbstractCredentials* credentials) // connection validation, even if it's currently running. delete _connectionValidator; - checkConnectivity(_credentialsFetchMode); + checkConnectivity(); } std::unique_ptr AccountState::settings() diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index d75efd16d..936a6e01b 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -59,7 +59,6 @@ public: /// An error like invalid credentials where retrying won't help. ConfigurationError }; - enum CredentialFetchMode { Interactive, NonInteractive }; /// The actual current connectivity status. typedef ConnectionValidator::Status ConnectionStatus; @@ -91,7 +90,7 @@ public: /// Triggers a ping to the server to update state and /// connection status and errors. - void checkConnectivity(CredentialFetchMode credentialsFetchMode); + void checkConnectivity(); /** Returns a new settings object for this account, already in the right groups. */ std::unique_ptr settings(); @@ -127,7 +126,6 @@ private: ConnectionStatus _connectionStatus; QStringList _connectionErrors; bool _waitingForNewCredentials; - CredentialFetchMode _credentialsFetchMode; QElapsedTimer _timeSinceLastETagCheck; QPointer _connectionValidator; }; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index af1764b8e..90eca8a17 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -271,7 +271,7 @@ void Application::slotCheckConnection() // when the error is permanent. if (state != AccountState::SignedOut && state != AccountState::ConfigurationError) { - accountState->checkConnectivity(AccountState::NonInteractive); + accountState->checkConnectivity(); } } diff --git a/src/gui/creds/shibbolethcredentials.cpp b/src/gui/creds/shibbolethcredentials.cpp index 2c09b7791..536315e3c 100644 --- a/src/gui/creds/shibbolethcredentials.cpp +++ b/src/gui/creds/shibbolethcredentials.cpp @@ -28,6 +28,7 @@ #include "account.h" #include "theme.h" #include "cookiejar.h" +#include "owncloudgui.h" #include "syncengine.h" #include @@ -269,9 +270,7 @@ void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job) void ShibbolethCredentials::showLoginWindow() { if (!_browser.isNull()) { - _browser->activateWindow(); - _browser->raise(); - // FIXME On OS X this does not raise properly + ownCloudGui::raiseDialog(_browser); return; } @@ -286,7 +285,7 @@ void ShibbolethCredentials::showLoginWindow() this, SLOT(onShibbolethCookieReceived(QNetworkCookie)), Qt::QueuedConnection); connect(_browser, SIGNAL(rejected()), this, SLOT(slotBrowserRejected())); - _browser->show(); + ownCloudGui::raiseDialog(_browser); } QList ShibbolethCredentials::accountCookies(Account* account) diff --git a/src/libsync/creds/tokencredentials.cpp b/src/libsync/creds/tokencredentials.cpp index 80be092cb..217e0f8ef 100644 --- a/src/libsync/creds/tokencredentials.cpp +++ b/src/libsync/creds/tokencredentials.cpp @@ -121,7 +121,7 @@ bool TokenCredentials::ready() const return _ready; } -void TokenCredentials::fetch(FetchMode) +void TokenCredentials::fetch() { Q_EMIT fetched(); } diff --git a/src/libsync/creds/tokencredentials.h b/src/libsync/creds/tokencredentials.h index d107edf0a..adcf32883 100644 --- a/src/libsync/creds/tokencredentials.h +++ b/src/libsync/creds/tokencredentials.h @@ -44,7 +44,7 @@ public: QString authType() const Q_DECL_OVERRIDE; QNetworkAccessManager* getQNAM() const Q_DECL_OVERRIDE; bool ready() const Q_DECL_OVERRIDE; - void fetch(FetchMode mode = Interactive) Q_DECL_OVERRIDE; + void fetch() Q_DECL_OVERRIDE; bool stillValid(QNetworkReply *reply) Q_DECL_OVERRIDE; void persist() Q_DECL_OVERRIDE; QString user() const Q_DECL_OVERRIDE; -- 2.30.2