Remove *Credentials::_fetchJobInProgress
authorJocelyn Turcotte <jturcotte@woboq.com>
Sat, 5 Sep 2015 13:51:11 +0000 (15:51 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Sat, 5 Sep 2015 14:00:45 +0000 (16:00 +0200)
Now that fetchFromKeychain is solely called from AccountState::slotInvalidCredentials
and that this one already protects the fetch call using _waitingForNewCredentials,
we can remove that extra check.

src/gui/creds/shibbolethcredentials.cpp
src/gui/creds/shibbolethcredentials.h
src/libsync/creds/httpcredentials.cpp
src/libsync/creds/httpcredentials.h

index 12b9b7d82ec3a866d7bf1694a0ece9e4dd01ceb5..0a1cac4b3ede6ec12e2665a1931ba24972999b42 100644 (file)
@@ -51,14 +51,12 @@ ShibbolethCredentials::ShibbolethCredentials()
       _url(),
       _ready(false),
       _stillValid(false),
-      _fetchJobInProgress(false),
       _browser(0)
 {}
 
 ShibbolethCredentials::ShibbolethCredentials(const QNetworkCookie& cookie)
   : _ready(true),
     _stillValid(true),
-    _fetchJobInProgress(false),
     _browser(0),
     _shibCookie(cookie)
 {
@@ -153,15 +151,10 @@ bool ShibbolethCredentials::ready() const
 
 void ShibbolethCredentials::fetchFromKeychain()
 {
-    if(_fetchJobInProgress) {
-        return;
-    }
-
     if (_user.isEmpty()) {
         _user = _account->credentialSetting(QLatin1String(userC)).toString();
     }
     if (_ready) {
-        _fetchJobInProgress = false;
         Q_EMIT fetched();
     } else {
         _url = _account->url();
@@ -171,7 +164,6 @@ void ShibbolethCredentials::fetchFromKeychain()
         job->setKey(keychainKey(_account->url().toString(), "shibAssertion"));
         connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
         job->start();
-        _fetchJobInProgress = true;
     }
 }
 
@@ -197,7 +189,6 @@ void ShibbolethCredentials::persist()
 void ShibbolethCredentials::invalidateToken()
 {
     _ready = false;
-    _fetchJobInProgress = true;
 
     CookieJar *jar = static_cast<CookieJar*>(_account->networkAccessManager()->cookieJar());
 
@@ -263,7 +254,6 @@ void ShibbolethCredentials::slotUserFetched(const QString &user)
 
     _stillValid = true;
     _ready = true;
-    _fetchJobInProgress = false;
     Q_EMIT asked();
 }
 
@@ -271,7 +261,6 @@ void ShibbolethCredentials::slotUserFetched(const QString &user)
 void ShibbolethCredentials::slotBrowserRejected()
 {
     _ready = false;
-    _fetchJobInProgress = false;
     Q_EMIT asked();
 }
 
@@ -290,11 +279,9 @@ void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job)
 
         _ready = true;
         _stillValid = true;
-        _fetchJobInProgress = false;
         Q_EMIT fetched();
     } else {
         _ready = false;
-        _fetchJobInProgress = false;
         Q_EMIT fetched();
     }
 }
index 19bbbb25ac956421cfaf73a0c3dd9fc8b556dcd2..99ecdac474efa7ea9e83974b03bc16d0349ffc9e 100644 (file)
@@ -88,7 +88,6 @@ private:
 
     bool _ready;
     bool _stillValid;
-    bool _fetchJobInProgress;
     QPointer<ShibbolethWebView> _browser;
     QNetworkCookie _shibCookie;
     QString _user;
index cfeba26a4dc80338587e3754d4c59de3c0e1a8d2..f31265a8cae82edd4bb36ce46fa9a966dcfb62b5 100644 (file)
@@ -82,8 +82,7 @@ const char authenticationFailedC[] = "owncloud-authentication-failed";
 } // ns
 
 HttpCredentials::HttpCredentials()
-    : _ready(false),
-      _fetchJobInProgress(false)
+    : _ready(false)
 {
 }
 
@@ -92,8 +91,7 @@ HttpCredentials::HttpCredentials(const QString& user, const QString& password, c
       _password(password),
       _ready(true),
       _certificatePath(certificatePath),
-      _certificatePasswd(certificatePasswd),
-      _fetchJobInProgress(false)
+      _certificatePasswd(certificatePasswd)
 {
 }
 
@@ -197,11 +195,6 @@ QString HttpCredentials::fetchUser()
 
 void HttpCredentials::fetchFromKeychain()
 {
-    // FIXME: Should this check go if we check in AccountState instead?
-    if (_fetchJobInProgress) {
-        return;
-    }
-
     // User must be fetched from config file
     fetchUser();
     _certificatePath = _account->credentialSetting(QLatin1String(certifPathC)).toString();
@@ -231,7 +224,6 @@ void HttpCredentials::fetchFromKeychain()
         job->setKey(kck);
         connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
         job->start();
-        _fetchJobInProgress = true;
     }
 }
 bool HttpCredentials::stillValid(QNetworkReply *reply)
@@ -250,7 +242,6 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
 
     QKeychain::Error error = job->error();
 
-    _fetchJobInProgress = false;
     if( !_password.isEmpty() && error == NoError ) {
 
         // All cool, the keychain did not come back with error.
index bbd0a3d2ccf0383bde28fbe61cc9f6b1f6f3fd02..ce3d9c42b532299bb4b78b1a930e9bfcfb211245 100644 (file)
@@ -73,7 +73,6 @@ protected:
 private:
     QString _certificatePath;
     QString _certificatePasswd;
-    bool _fetchJobInProgress; //True if the keychain job is in progress or the input dialog visible
 };
 
 } // namespace OCC