SCRATCH separate the generic updater logic from the application

This commit is contained in:
Petr Mrázek
2015-02-08 17:56:14 +01:00
parent 7a71ecd8af
commit 4730f54df7
31 changed files with 1056 additions and 1104 deletions

View File

@ -31,7 +31,7 @@ void ByteArrayDownload::start()
auto worker = ENV.qnam();
QNetworkReply *rep = worker->get(request);
m_reply = std::shared_ptr<QNetworkReply>(rep);
m_reply.reset(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));

View File

@ -77,7 +77,7 @@ void CacheDownload::start()
auto worker = ENV.qnam();
QNetworkReply *rep = worker->get(request);
m_reply = std::shared_ptr<QNetworkReply>(rep);
m_reply.reset(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));

View File

@ -86,7 +86,7 @@ void MD5EtagDownload::start()
auto worker = ENV.qnam();
QNetworkReply *rep = worker->get(request);
m_reply = std::shared_ptr<QNetworkReply>(rep);
m_reply.reset(rep);
connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(rep, SIGNAL(finished()), SLOT(downloadFinished()));

View File

@ -19,6 +19,7 @@
#include <QUrl>
#include <memory>
#include <QNetworkReply>
#include <logic/QObjectPtr.h>
enum JobStatus
{
@ -58,7 +59,7 @@ public:
public:
/// the network reply
std::shared_ptr<QNetworkReply> m_reply;
QObjectPtr<QNetworkReply> m_reply;
/// the content of the content-type header
QString m_content_type;

View File

@ -29,7 +29,7 @@ void NetJob::partSucceeded(int index)
m_doing.remove(index);
m_done.insert(index);
disconnect(downloads[index].get(), 0, this, 0);
downloads[index].get()->disconnect(this);
startMoreParts();
}
@ -46,7 +46,7 @@ void NetJob::partFailed(int index)
slot.failures++;
m_todo.enqueue(index);
}
disconnect(downloads[index].get(), 0, this, 0);
downloads[index].get()->disconnect(this);
startMoreParts();
}

View File

@ -108,6 +108,7 @@ private:
qint64 current_progress = 0;
qint64 total_progress = 1;
int failures = 0;
bool connected = false;
};
QString m_job_name;
QList<NetActionPtr> downloads;