aboutsummaryrefslogtreecommitdiff
path: root/jobs/basejob.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-12 22:04:28 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-12 23:15:03 +0900
commit9e8e958b5d72b9671425b5bcd34fa016874b8677 (patch)
tree41f3f3e37fe82f28e74cbe9018e9d0d86095f4a5 /jobs/basejob.cpp
parenta4509336ad07ef91771492830a0756af68d55962 (diff)
downloadlibquotient-9e8e958b5d72b9671425b5bcd34fa016874b8677.tar.gz
libquotient-9e8e958b5d72b9671425b5bcd34fa016874b8677.zip
BaseJob: afterStart(), beforeAbandon(), up/downloadProgress()
To support the upcoming DownloadFileJob
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r--jobs/basejob.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp
index 4e0879b0..6f80bfd7 100644
--- a/jobs/basejob.cpp
+++ b/jobs/basejob.cpp
@@ -216,15 +216,21 @@ void BaseJob::Private::sendRequest()
}
}
-void BaseJob::beforeStart(const ConnectionData* connData)
-{
-}
+void BaseJob::beforeStart(const ConnectionData*)
+{ }
+
+void BaseJob::afterStart(const ConnectionData*, QNetworkReply*)
+{ }
+
+void BaseJob::beforeAbandon(QNetworkReply*)
+{ }
void BaseJob::start(const ConnectionData* connData)
{
d->connection = connData;
beforeStart(connData);
sendRequest();
+ afterStart(connData, d->reply.data());
}
void BaseJob::sendRequest()
@@ -238,6 +244,10 @@ void BaseJob::sendRequest()
connect( d->reply.data(), &QNetworkReply::finished, this, &BaseJob::gotReply );
if (d->reply->isRunning())
{
+ connect( d->reply.data(), &QNetworkReply::uploadProgress,
+ this, &BaseJob::uploadProgress);
+ connect( d->reply.data(), &QNetworkReply::downloadProgress,
+ this, &BaseJob::downloadProgress);
d->timer.start(getCurrentTimeout());
qCDebug(d->logCat) << this << "request has been sent";
emit started();
@@ -430,6 +440,7 @@ void BaseJob::setStatus(int code, QString message)
void BaseJob::abandon()
{
+ beforeAbandon(d->reply.data());
this->disconnect();
if (d->reply)
d->reply->disconnect(this);