[Pkg-owncloud-commits] [owncloud-client] 01/27: HTTP Credentials: Read the password from the old location if not found.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Jul 29 16:23:57 UTC 2014
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 a9f1de84f013ce83f694aeaa310142f39535b7f0
Author: Klaas Freitag <freitag at owncloud.com>
Date: Wed Jul 2 15:45:23 2014 +0200
HTTP Credentials: Read the password from the old location if not found.
Earlier clients used QtKeychain without a QSettings object, which made
QtKeychain to write the password encrypted into a settings default
location, ie. the registry under windows.
If we can not find a password at the new location it is tried to read
the password from the old default location once. That makes people
happy in migration scenarios.
---
src/creds/httpcredentials.cpp | 44 ++++++++++++++++++++++++++++++++-----------
src/creds/httpcredentials.h | 1 +
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/src/creds/httpcredentials.cpp b/src/creds/httpcredentials.cpp
index f5ab3b6..18d0602 100644
--- a/src/creds/httpcredentials.cpp
+++ b/src/creds/httpcredentials.cpp
@@ -101,7 +101,8 @@ HttpCredentials::HttpCredentials()
: _user(),
_password(),
_ready(false),
- _fetchJobInProgress(false)
+ _fetchJobInProgress(false),
+ _readPwdFromDeprecatedPlace(false)
{
}
@@ -230,6 +231,7 @@ void HttpCredentials::fetch(Account *account)
job->setProperty("account", QVariant::fromValue(account));
job->start();
_fetchJobInProgress = true;
+ _readPwdFromDeprecatedPlace = true;
}
}
bool HttpCredentials::stillValid(QNetworkReply *reply)
@@ -261,18 +263,38 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
_ready = true;
emit fetched();
} else {
- if( error != NoError ) {
+
+ if( _password.isEmpty() || error == EntryNotFound ) {
+ if( _readPwdFromDeprecatedPlace ) {
+ // there simply was not a password. Lets restart a read job without
+ // a settings object as we did it in older client releases.
+ ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
+
+ const QString kck = keychainKey(account->url().toString(), _user);
+ job->setKey(kck);
+
+ connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*)));
+ job->setProperty("account", QVariant::fromValue(account));
+ job->start();
+ _readPwdFromDeprecatedPlace = false; // do try that only once.
+ _fetchJobInProgress = true;
+ // Note: if this read job succeeds, the value from the old place is still
+ // NOT persisted into the new account.
+ } else {
+
+ bool ok;
+ QString pwd = queryPassword(&ok);
+ _fetchJobInProgress = false;
+ if (ok) {
+ _password = pwd;
+ _ready = true;
+ persist(account);
+ }
+ emit fetched();
+ }
+ } else {
qDebug() << "Error while reading password" << job->errorString();
}
- bool ok;
- QString pwd = queryPassword(&ok);
- _fetchJobInProgress = false;
- if (ok) {
- _password = pwd;
- _ready = true;
- persist(account);
- }
- emit fetched();
}
}
diff --git a/src/creds/httpcredentials.h b/src/creds/httpcredentials.h
index 38402fc..22d739d 100644
--- a/src/creds/httpcredentials.h
+++ b/src/creds/httpcredentials.h
@@ -63,6 +63,7 @@ private:
QString _password;
bool _ready;
bool _fetchJobInProgress; //True if the keychain job is in progress or the input dialog visible
+ bool _readPwdFromDeprecatedPlace;
};
} // ns Mirall
--
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