Bring back the automatic authentication popups
authorJocelyn Turcotte <jturcotte@woboq.com>
Thu, 21 Jan 2016 12:33:03 +0000 (13:33 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Fri, 22 Jan 2016 13:25:36 +0000 (14:25 +0100)
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
src/gui/accountstate.h
src/gui/application.cpp
src/gui/creds/shibbolethcredentials.cpp
src/libsync/creds/tokencredentials.cpp
src/libsync/creds/tokencredentials.h

index 1f93932af751cfe41e3c457a79c4b0e14d321179..7a14b2d5d09f05a03d98a92cf46cddc012d018de 100644 (file)
@@ -30,7 +30,6 @@ AccountState::AccountState(AccountPtr account)
     , _state(AccountState::Disconnected)
     , _connectionStatus(ConnectionValidator::Undefined)
     , _waitingForNewCredentials(false)
-    , _credentialsFetchMode(Interactive)
 {
     qRegisterMetaType<AccountState*>("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<QSettings> AccountState::settings()
index d75efd16d1456ba8987d91c64027f2f3c92cad5b..936a6e01be97e19372a79aeb94b4db75df7deb6e 100644 (file)
@@ -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<QSettings> settings();
@@ -127,7 +126,6 @@ private:
     ConnectionStatus _connectionStatus;
     QStringList _connectionErrors;
     bool _waitingForNewCredentials;
-    CredentialFetchMode _credentialsFetchMode;
     QElapsedTimer _timeSinceLastETagCheck;
     QPointer<ConnectionValidator> _connectionValidator;
 };
index af1764b8eb22a42d5b06d12a824efb89679d333c..90eca8a178a24aec978e969552f2b780d7b5d84b 100644 (file)
@@ -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();
         }
     }
 
index 2c09b77910f3b590bb0e1f6ad70f1d2593a07dcc..536315e3cf75175cb45f29ca459503dbcbc63694 100644 (file)
@@ -28,6 +28,7 @@
 #include "account.h"
 #include "theme.h"
 #include "cookiejar.h"
+#include "owncloudgui.h"
 #include "syncengine.h"
 
 #include <keychain.h>
@@ -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<QNetworkCookie> ShibbolethCredentials::accountCookies(Account* account)
index 80be092cb4be7c791971a1ca4beb5d67906e77fe..217e0f8ef116ce53660bfd3f20dd531549a1c8e4 100644 (file)
@@ -121,7 +121,7 @@ bool TokenCredentials::ready() const
     return _ready;
 }
 
-void TokenCredentials::fetch(FetchMode)
+void TokenCredentials::fetch()
 {
     Q_EMIT fetched();
 }
index d107edf0a4ebf50616446491a70d2aea2fed03ac..adcf32883047024982452337797209c5e6359367 100644 (file)
@@ -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;