[Pkg-owncloud-commits] [owncloud-client] 17/103: AbstractNetworkJob Allow finished() to defer Job deletion
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Apr 30 18:08:54 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 ef9a318cd9967c19919e55152782579fbc17e608
Author: Daniel Molkentin <danimo at owncloud.com>
Date: Mon Apr 14 15:08:43 2014 +0200
AbstractNetworkJob Allow finished() to defer Job deletion
This allows to reuse the Job
---
src/creds/shibboleth/shibbolethuserjob.cpp | 5 +++--
src/creds/shibboleth/shibbolethuserjob.h | 2 +-
src/mirall/networkjobs.cpp | 29 +++++++++++++++++++----------
src/mirall/networkjobs.h | 19 +++++++++++--------
src/mirall/owncloudsetupwizard.cpp | 6 ++++--
src/mirall/owncloudsetupwizard.h | 4 ++--
src/mirall/propagator_qnam.h | 6 ++++--
7 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/src/creds/shibboleth/shibbolethuserjob.cpp b/src/creds/shibboleth/shibbolethuserjob.cpp
index d64fd26..2db343e 100644
--- a/src/creds/shibboleth/shibbolethuserjob.cpp
+++ b/src/creds/shibboleth/shibbolethuserjob.cpp
@@ -35,7 +35,7 @@ void ShibbolethUserJob::start()
AbstractNetworkJob::start();
}
-void ShibbolethUserJob::finished()
+bool ShibbolethUserJob::finished()
{
bool success = false;
QVariantMap json = QtJson::parse(QString::fromUtf8(reply()->readAll()), success).toMap();
@@ -43,12 +43,13 @@ void ShibbolethUserJob::finished()
if (!success || json.isEmpty()) {
qDebug() << "cloud/user: invalid JSON!";
emit userFetched(QString());
- return;
+ return true;
}
QString user = json.value("ocs").toMap().value("data").toMap().value("id").toString();
qDebug() << "cloud/user: " << json << "->" << user;
emit userFetched(user);
+ return true;
}
diff --git a/src/creds/shibboleth/shibbolethuserjob.h b/src/creds/shibboleth/shibbolethuserjob.h
index b6d4483..f6427a4 100644
--- a/src/creds/shibboleth/shibbolethuserjob.h
+++ b/src/creds/shibboleth/shibbolethuserjob.h
@@ -36,7 +36,7 @@ signals:
void tryAgain();
private slots:
- virtual void finished();
+ virtual bool finished();
};
diff --git a/src/mirall/networkjobs.cpp b/src/mirall/networkjobs.cpp
index 4c2a6bf..7a952fc 100644
--- a/src/mirall/networkjobs.cpp
+++ b/src/mirall/networkjobs.cpp
@@ -148,7 +148,7 @@ void AbstractNetworkJob::slotFinished()
_responseTimestamp = QString::fromAscii(_reply->rawHeader("Date"));
_duration = _durationTimer.elapsed();
- finished();
+ bool discard = finished();
AbstractCredentials *creds = _account->credentials();
if (!creds->stillValid(_reply) &&! _ignoreCredentialFailure
&& _account->state() != Account::InvalidCredidential) {
@@ -164,7 +164,9 @@ void AbstractNetworkJob::slotFinished()
creds->fetch(_account);
}
}
- deleteLater();
+ if (discard) {
+ deleteLater();
+ }
}
quint64 AbstractNetworkJob::duration()
@@ -228,7 +230,7 @@ void RequestEtagJob::start()
AbstractNetworkJob::start();
}
-void RequestEtagJob::finished()
+bool RequestEtagJob::finished()
{
if (reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 207) {
// Parse DAV response
@@ -247,6 +249,7 @@ void RequestEtagJob::finished()
}
emit etagRetreived(etag);
}
+ return true;
}
/*********************************************************************************************/
@@ -265,9 +268,10 @@ void MkColJob::start()
AbstractNetworkJob::start();
}
-void MkColJob::finished()
+bool MkColJob::finished()
{
emit finished(reply()->error());
+ return true;
}
/*********************************************************************************************/
@@ -297,7 +301,7 @@ void LsColJob::start()
AbstractNetworkJob::start();
}
-void LsColJob::finished()
+bool LsColJob::finished()
{
if (reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 207) {
// Parse DAV response
@@ -323,6 +327,7 @@ void LsColJob::finished()
}
emit directoryListing(folders);
}
+ return true;
}
/*********************************************************************************************/
@@ -364,7 +369,7 @@ bool CheckServerJob::installed(const QVariantMap &info)
return info.value(QLatin1String("installed")).toBool();
}
-void CheckServerJob::finished()
+bool CheckServerJob::finished()
{
account()->setSslConfiguration(reply()->sslConfiguration());
@@ -383,7 +388,7 @@ void CheckServerJob::finished()
resetTimeout();
setReply(getRequest(redirectUrl));
setupConnections(reply());
- return;
+ return true;
}
}
@@ -402,6 +407,7 @@ void CheckServerJob::finished()
} else {
qDebug() << "No proper answer on " << requestedUrl;
}
+ return true;
}
/*********************************************************************************************/
@@ -451,7 +457,7 @@ QList<QByteArray> PropfindJob::properties() const
return _properties;
}
-void PropfindJob::finished()
+bool PropfindJob::finished()
{
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@@ -486,6 +492,7 @@ void PropfindJob::finished()
qDebug() << "Quota request *not* successful, http result code is" << http_result_code
<< (http_result_code == 302 ? reply()->header(QNetworkRequest::LocationHeader).toString() : QLatin1String(""));
}
+ return true;
}
/*********************************************************************************************/
@@ -502,9 +509,10 @@ void EntityExistsJob::start()
AbstractNetworkJob::start();
}
-void EntityExistsJob::finished()
+bool EntityExistsJob::finished()
{
emit exists(reply());
+ return true;
}
/*********************************************************************************************/
@@ -535,7 +543,7 @@ void CheckQuotaJob::start()
AbstractNetworkJob::start();
}
-void CheckQuotaJob::finished()
+bool CheckQuotaJob::finished()
{
if (reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 207) {
// Parse DAV response
@@ -560,6 +568,7 @@ void CheckQuotaJob::finished()
qint64 total = quotaUsedBytes + quotaAvailableBytes;
emit quotaRetrieved(total, quotaUsedBytes);
}
+ return true;
}
NetworkJobTimeoutPauser::NetworkJobTimeoutPauser(QNetworkReply *reply)
diff --git a/src/mirall/networkjobs.h b/src/mirall/networkjobs.h
index 99407f6..9785a86 100644
--- a/src/mirall/networkjobs.h
+++ b/src/mirall/networkjobs.h
@@ -87,7 +87,7 @@ protected:
QNetworkReply* headRequest(const QUrl &url);
int maxRedirects() const { return 10; }
- virtual void finished() = 0;
+ virtual bool finished() = 0;
QString _responseTimestamp;
QElapsedTimer _durationTimer;
quint64 _duration;
@@ -118,7 +118,7 @@ signals:
void exists(QNetworkReply*);
private slots:
- virtual void finished();
+ virtual bool finished();
};
/**
@@ -134,7 +134,7 @@ signals:
void directoryListing(const QStringList &items);
private slots:
- virtual void finished();
+ virtual bool finished();
};
/**
@@ -152,7 +152,7 @@ signals:
void result(const QVariantMap &values);
private slots:
- virtual void finished();
+ virtual bool finished();
private:
QList<QByteArray> _properties;
@@ -171,7 +171,7 @@ signals:
void finished(QNetworkReply::NetworkError);
private slots:
- virtual void finished();
+ virtual bool finished();
};
/**
@@ -189,14 +189,16 @@ public:
signals:
void instanceFound(const QUrl&url, const QVariantMap &info);
+ void instanceNotFound(QNetworkReply *reply);
void timeout(const QUrl&url);
private slots:
- virtual void finished();
+ virtual bool finished();
virtual void slotTimeout();
private:
bool _followRedirects;
+ bool _subdirFallback;
int _redirectCount;
};
@@ -214,7 +216,7 @@ signals:
void etagRetreived(const QString &etag);
private slots:
- virtual void finished();
+ virtual bool finished();
};
/**
@@ -230,7 +232,8 @@ signals:
void quotaRetrieved(qint64 totalBytes, qint64 availableBytes);
private slots:
- virtual void finished();
+ /** Return true if you want the job to be deleted after this slot has finished running. */
+ virtual bool finished();
};
} // namespace Mirall
diff --git a/src/mirall/owncloudsetupwizard.cpp b/src/mirall/owncloudsetupwizard.cpp
index aebcad1..548eafa 100644
--- a/src/mirall/owncloudsetupwizard.cpp
+++ b/src/mirall/owncloudsetupwizard.cpp
@@ -446,7 +446,7 @@ void DetermineAuthTypeJob::start()
AbstractNetworkJob::start();
}
-void DetermineAuthTypeJob::finished()
+bool DetermineAuthTypeJob::finished()
{
QUrl redirection = reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
qDebug() << Q_FUNC_INFO << redirection.toString();
@@ -472,6 +472,7 @@ void DetermineAuthTypeJob::finished()
emit authType(WizardCommon::HttpCreds);
}
}
+ return true;
}
ValidateDavAuthJob::ValidateDavAuthJob(Account *account, QObject *parent)
@@ -487,9 +488,10 @@ void ValidateDavAuthJob::start()
AbstractNetworkJob::start();
}
-void ValidateDavAuthJob::finished()
+bool ValidateDavAuthJob::finished()
{
emit authResult(reply());
+ return true;
}
} // ns Mirall
diff --git a/src/mirall/owncloudsetupwizard.h b/src/mirall/owncloudsetupwizard.h
index ee9f329..681b776 100644
--- a/src/mirall/owncloudsetupwizard.h
+++ b/src/mirall/owncloudsetupwizard.h
@@ -39,7 +39,7 @@ public:
signals:
void authResult(QNetworkReply*);
private slots:
- void finished();
+ bool finished();
};
class DetermineAuthTypeJob : public AbstractNetworkJob {
@@ -50,7 +50,7 @@ public:
signals:
void authType(WizardCommon::AuthType);
private slots:
- void finished();
+ bool finished();
private:
int _redirects;
};
diff --git a/src/mirall/propagator_qnam.h b/src/mirall/propagator_qnam.h
index 9c694e5..93a39fa 100644
--- a/src/mirall/propagator_qnam.h
+++ b/src/mirall/propagator_qnam.h
@@ -62,8 +62,9 @@ public:
virtual void start();
- virtual void finished() {
+ virtual bool finished() {
emit finishedSignal();
+ return true;
}
signals:
@@ -110,8 +111,9 @@ public:
_device(device), _headers(headers), _expectedEtagForResume(expectedEtagForResume) {}
virtual void start();
- virtual void finished() {
+ virtual bool finished() {
emit finishedSignal();
+ return true;
}
QString errorString() {
--
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