[Pkg-owncloud-commits] [owncloud-client] 12/30: Use the mirall config file for all Keychain jobs.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Mar 15 21:28:29 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 1eb08755183fdf88b79f51cdd60f446ee8c8c0e3
Author: Klaas Freitag <freitag at owncloud.com>
Date: Mon Mar 3 16:35:57 2014 +0100
Use the mirall config file for all Keychain jobs.
Also set the job as parent to get proper deletion of the
settings object.
---
src/creds/httpcredentials.cpp | 38 +++++++++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/creds/httpcredentials.cpp b/src/creds/httpcredentials.cpp
index 33b74ce..1e18a35 100644
--- a/src/creds/httpcredentials.cpp
+++ b/src/creds/httpcredentials.cpp
@@ -190,10 +190,11 @@ void HttpCredentials::fetch(Account *account)
return;
}
+ // User must be fetched from config file
fetchUser(account);
QSettings *settings = account->settingsWithGroup(Theme::instance()->appName());
- QString kck = keychainKey(account->url().toString(), _user );
+ const QString kck = keychainKey(account->url().toString(), _user );
QString key = QString::fromLatin1( "%1/data" ).arg( kck );
if( settings && settings->contains(key) ) {
@@ -209,8 +210,11 @@ void HttpCredentials::fetch(Account *account)
Q_EMIT fetched();
} else {
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
+ settings->setParent(job); // make the job parent to make setting deleted properly
+ job->setSettings(settings);
+
job->setInsecureFallback(false);
- job->setKey(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();
@@ -227,10 +231,11 @@ bool HttpCredentials::stillValid(QNetworkReply *reply)
void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
{
ReadPasswordJob *readJob = static_cast<ReadPasswordJob*>(job);
- delete readJob->settings();
_password = readJob->textData();
Account *account = qvariant_cast<Account*>(readJob->property("account"));
+ _fetchJobInProgress = false;
+
if( _user.isEmpty()) {
qDebug() << "Strange: User is empty!";
}
@@ -242,7 +247,6 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
// Still, the password can be empty which indicates a problem and
// the password dialog has to be opened.
_ready = true;
- _fetchJobInProgress = false;
emit fetched();
} else {
if( error != NoError ) {
@@ -250,7 +254,6 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
}
bool ok;
QString pwd = queryPassword(&ok);
- _fetchJobInProgress = false;
if (ok) {
_password = pwd;
_ready = true;
@@ -278,13 +281,26 @@ QString HttpCredentials::queryPassword(bool *ok)
void HttpCredentials::invalidateToken(Account *account)
{
_password = QString();
+ _ready = false;
+
+ // User must be fetched from config file to generate a valid key
+ fetchUser(account);
+
+ const QString kck = keychainKey(account->url().toString(), _user);
+ if( kck.isEmpty() ) {
+ qDebug() << "InvalidateToken: User is empty, bailing out!";
+ return;
+ }
+
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
- job->setSettings(account->settingsWithGroup(Theme::instance()->appName()));
+ QSettings *settings = account->settingsWithGroup(Theme::instance()->appName());
+ settings->setParent(job); // make the job parent to make setting deleted properly
+ job->setSettings(settings);
job->setInsecureFallback(true);
- connect(job, SIGNAL(destroyed(QObject*)), job->settings(), SLOT(deleteLater()));
- job->setKey(keychainKey(account->url().toString(), _user));
+ job->setKey(kck);
job->start();
- _ready = false;
+
+ account->clearCookieJar();
}
void HttpCredentials::persist(Account *account)
@@ -295,6 +311,10 @@ void HttpCredentials::persist(Account *account)
}
account->setCredentialSetting(QLatin1String(userC), _user);
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
+ QSettings *settings = account->settingsWithGroup(Theme::instance()->appName());
+ settings->setParent(job); // make the job parent to make setting deleted properly
+ job->setSettings(settings);
+
job->setInsecureFallback(false);
connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotWriteJobDone(QKeychain::Job*)));
job->setKey(keychainKey(account->url().toString(), _user));
--
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