[Pkg-owncloud-commits] [owncloud-client] 43/498: Ensure 'user' is available early enough for ui in httpcreds

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 89bb58ac30e656d761bf5f8f38a0d1ab77ca01ba
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Thu Apr 23 14:47:31 2015 +0200

    Ensure 'user' is available early enough for ui in httpcreds
---
 src/gui/accountmanager.cpp            | 5 +++--
 src/libsync/account.cpp               | 6 +++++-
 src/libsync/creds/httpcredentials.cpp | 8 ++++++++
 src/libsync/creds/httpcredentials.h   | 3 +++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp
index fad18d3..5bfa3c5 100644
--- a/src/gui/accountmanager.cpp
+++ b/src/gui/accountmanager.cpp
@@ -88,7 +88,6 @@ bool AccountManager::restore()
         acc->setSharedThis(acc);
 
         acc->setUrl(settings->value(QLatin1String(urlC)).toUrl());
-        acc->setCredentials(CredentialsFactory::create(settings->value(QLatin1String(authTypeC)).toString()));
 
         // We want to only restore settings for that auth type and the user value
         acc->_settingsMap.insert(QLatin1String(userC), settings->value(userC));
@@ -99,6 +98,8 @@ bool AccountManager::restore()
             acc->_settingsMap.insert(key, settings->value(key));
         }
 
+        acc->setCredentials(CredentialsFactory::create(settings->value(QLatin1String(authTypeC)).toString()));
+
         // now the cert, it is in the general group
         settings->beginGroup(QLatin1String("General"));
         acc->setApprovedCerts(QSslCertificate::fromData(settings->value(caCertsKeyC).toByteArray()));
@@ -173,4 +174,4 @@ void AccountManager::shutdown()
 }
 
 
-}
\ No newline at end of file
+}
diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp
index 462522f..95df477 100644
--- a/src/libsync/account.cpp
+++ b/src/libsync/account.cpp
@@ -114,8 +114,12 @@ void Account::setCredentials(AbstractCredentials *cred)
     if (_credentials) {
         credentials()->deleteLater();
     }
-    cred->setAccount(this);
+
+    // The order for these two is important! Reading the credential's
+    // settings accesses the account as well as account->_credentials
     _credentials = cred;
+    cred->setAccount(this);
+
     _am = _credentials->getQNAM();
     if (jar) {
         _am->setCookieJar(jar);
diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp
index 0dd0e74..306e4c0 100644
--- a/src/libsync/creds/httpcredentials.cpp
+++ b/src/libsync/creds/httpcredentials.cpp
@@ -186,6 +186,14 @@ QString HttpCredentials::certificatePasswd() const
     return _certificatePasswd;
 }
 
+void HttpCredentials::setAccount(Account* account)
+{
+    AbstractCredentials::setAccount(account);
+    if (_user.isEmpty()) {
+        fetchUser();
+    }
+}
+
 QNetworkAccessManager* HttpCredentials::getQNAM() const
 {
     AccessManager* qnam = new HttpCredentialsAccessManager(this);
diff --git a/src/libsync/creds/httpcredentials.h b/src/libsync/creds/httpcredentials.h
index f0fb4b4..b4c90c6 100644
--- a/src/libsync/creds/httpcredentials.h
+++ b/src/libsync/creds/httpcredentials.h
@@ -56,6 +56,9 @@ public:
     QString certificatePath() const;
     QString certificatePasswd() const;
 
+    // To fetch the user name as early as possible
+    void setAccount(Account* account) Q_DECL_OVERRIDE;
+
 private Q_SLOTS:
     void slotAuthentication(QNetworkReply*, QAuthenticator*);
     void slotReadJobDone(QKeychain::Job*);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list