NOISSUE refactor NetAction to be based on Task

Still missing some things, this is part 1.
This commit is contained in:
Petr Mrázek 2017-04-29 02:24:00 +02:00
parent 243f7e4fb4
commit e1465f4848
42 changed files with 299 additions and 314 deletions

View File

@ -26,7 +26,7 @@ InstanceCopyTask::InstanceCopyTask(SettingsObjectPtr settings, BaseInstanceProvi
void InstanceCopyTask::executeTask()
{
setStatus(tr("Copying instance %1").arg(m_origInstance->name()));
setStatusText(tr("Copying instance %1").arg(m_origInstance->name()));
m_stagingPath = m_target->getStagedInstancePath();
FS::copy folderCopy(m_origInstance->instanceRoot(), m_stagingPath);
folderCopy.followSymlinks(false).blacklist(m_matcher.get());

View File

@ -19,7 +19,7 @@ InstanceCreationTask::InstanceCreationTask(SettingsObjectPtr settings, BaseInsta
void InstanceCreationTask::executeTask()
{
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
setStatusText(tr("Creating instance from version %1").arg(m_version->name()));
/*
auto minecraftVersion = std::dynamic_pointer_cast<MinecraftVersion>(m_version);
if(!minecraftVersion)

View File

@ -38,7 +38,7 @@ void InstanceImportTask::executeTask()
}
else
{
setStatus(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
setStatusText(tr("Downloading modpack:\n%1").arg(m_sourceUrl.toString()));
m_downloadRequired = true;
const QString path = m_sourceUrl.host() + '/' + m_sourceUrl.path();
@ -94,7 +94,7 @@ static QFileInfo findRecursive(const QString &dir, const QString &name)
void InstanceImportTask::extractAndTweak()
{
setStatus(tr("Extracting modpack"));
setStatusText(tr("Extracting modpack"));
m_stagingPath = m_target->getStagedInstancePath();
QDir extractDir(m_stagingPath);
qDebug() << "Attempting to create instance from" << m_archivePath;
@ -321,7 +321,7 @@ void InstanceImportTask::processFlame(const QFileInfo & manifest)
{
setProgress(current, total);
});
setStatus(tr("Downloading mods..."));
setStatusText(tr("Downloading mods..."));
m_filesNetJob->start();
}
);
@ -337,7 +337,7 @@ void InstanceImportTask::processFlame(const QFileInfo & manifest)
});
connect(m_modIdResolver.get(), &Flame::FileResolvingTask::status, [&](QString status)
{
setStatus(status);
setStatusText(status);
});
m_modIdResolver->start();
}

View File

@ -144,7 +144,7 @@ JavaListLoadTask::~JavaListLoadTask()
void JavaListLoadTask::executeTask()
{
setStatus(tr("Detecting Java installations..."));
setStatusText(tr("Detecting Java installations..."));
JavaUtils ju;
QList<QString> candidate_paths = ju.FindJavaPaths();

View File

@ -28,7 +28,7 @@ void Update::executeTask()
{
connect(m_updateTask.get(), SIGNAL(finished()), this, SLOT(updateFinished()));
connect(m_updateTask.get(), &Task::progress, this, &Task::setProgress);
connect(m_updateTask.get(), &Task::status, this, &Task::setStatus);
connect(m_updateTask.get(), &Task::status, this, &Task::setStatusText);
emit progressReportingRequest();
return;
}

View File

@ -199,7 +199,7 @@ NetActionPtr AssetObject::getDownloadAction()
auto rawHash = QByteArray::fromHex(hash.toLatin1());
objectDL->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash));
}
objectDL->m_total_progress = size;
objectDL->setProgress(0, size);
return objectDL;
}
return nullptr;

View File

@ -43,7 +43,7 @@ void SkinUpload::executeTask()
QNetworkReply *rep = ENV.qnam().put(request, multiPart);
m_reply = std::shared_ptr<QNetworkReply>(rep);
setStatus(tr("Uploading skin"));
setStatusText(tr("Uploading skin"));
connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));

View File

@ -237,7 +237,7 @@ QString YggdrasilTask::getStateMessage() const
void YggdrasilTask::changeState(YggdrasilTask::State newState, QString reason)
{
m_state = newState;
setStatus(getStateMessage());
setStatusText(getStateMessage());
if (newState == STATE_SUCCEEDED)
{
emitSucceeded();

View File

@ -10,7 +10,7 @@ Flame::FileResolvingTask::FileResolvingTask(Flame::Manifest& toProcess)
void Flame::FileResolvingTask::executeTask()
{
setStatus(tr("Resolving mod IDs..."));
setStatusText(tr("Resolving mod IDs..."));
setProgress(0, m_toProcess.files.size());
m_dljob.reset(new NetJob("Mod id resolver"));
results.resize(m_toProcess.files.size());

View File

@ -28,31 +28,31 @@ ForgeXzDownload::ForgeXzDownload(QString relative_path, MetaEntryPtr entry) : Ne
m_entry = entry;
m_target_path = entry->getFullPath();
m_pack200_xz_file.setFileTemplate("./dl_temp.XXXXXX");
m_status = Job_NotStarted;
m_status = Status::NotStarted;
m_url_path = relative_path;
m_url = "http://files.minecraftforge.net/maven/" + m_url_path + ".pack.xz";
}
void ForgeXzDownload::start()
void ForgeXzDownload::executeTask()
{
if(m_status == Job_Aborted)
if(m_status == Status::Aborted)
{
qWarning() << "Attempt to start an aborted Download:" << m_url.toString();
emit aborted(m_index_within_job);
emit aborted();
return;
}
m_status = Job_InProgress;
m_status = Status::InProgress;
if (!m_entry->isStale())
{
m_status = Job_Finished;
emit succeeded(m_index_within_job);
m_status = Status::Finished;
emit succeeded();
return;
}
// can we actually create the real, final file?
if (!FS::ensureFilePathExists(m_target_path))
{
m_status = Job_Failed;
emit failed(m_index_within_job);
m_status = Status::Failed;
emit failed();
return;
}
@ -72,9 +72,9 @@ void ForgeXzDownload::start()
void ForgeXzDownload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
m_total_progress = bytesTotal;
m_progressTotal = bytesTotal;
m_progress = bytesReceived;
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
emit progress(bytesReceived, bytesTotal);
}
void ForgeXzDownload::downloadError(QNetworkReply::NetworkError error)
@ -82,29 +82,29 @@ void ForgeXzDownload::downloadError(QNetworkReply::NetworkError error)
if(error == QNetworkReply::OperationCanceledError)
{
qCritical() << "Aborted " << m_url.toString();
m_status = Job_Aborted;
m_status = Status::Aborted;
}
else
{
// error happened during download.
qCritical() << "Failed " << m_url.toString() << " with reason " << error;
m_status = Job_Failed;
m_status = Status::Failed;
}
}
void ForgeXzDownload::failAndTryNextMirror()
{
m_status = Job_Failed;
emit failed(m_index_within_job);
m_status = Status::Failed;
emit failed();
}
void ForgeXzDownload::downloadFinished()
{
// if the download succeeded
if (m_status != Job_Failed && m_status != Job_Aborted)
if (m_status != Status::Failed && m_status != Status::Aborted)
{
// nothing went wrong...
m_status = Job_Finished;
m_status = Status::Finished;
if (m_pack200_xz_file.isOpen())
{
// we actually downloaded something! process and isntall it
@ -114,25 +114,25 @@ void ForgeXzDownload::downloadFinished()
else
{
// something bad happened -- on the local machine!
m_status = Job_Failed;
m_status = Status::Failed;
m_pack200_xz_file.remove();
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
}
else if(m_status == Job_Aborted)
else if(m_status == Status::Aborted)
{
m_pack200_xz_file.remove();
m_reply.reset();
emit failed(m_index_within_job);
emit aborted(m_index_within_job);
emit failed();
emit aborted();
return;
}
// else the download failed
else
{
m_status = Job_Failed;
m_status = Status::Failed;
m_pack200_xz_file.close();
m_pack200_xz_file.remove();
m_reply.reset();
@ -152,7 +152,7 @@ void ForgeXzDownload::downloadReadyRead()
* Can't open the file... the job failed
*/
m_reply->abort();
emit failed(m_index_within_job);
emit failed();
return;
}
}
@ -345,7 +345,7 @@ void ForgeXzDownload::decompressAndInstall()
}
catch (std::runtime_error &err)
{
m_status = Job_Failed;
m_status = Status::Failed;
qCritical() << "Error unpacking " << pack200_file.fileName() << " : " << err.what();
QFile f(m_target_path);
if (f.exists())
@ -374,18 +374,18 @@ void ForgeXzDownload::decompressAndInstall()
ENV.metacache()->updateEntry(m_entry);
m_reply.reset();
emit succeeded(m_index_within_job);
emit succeeded();
}
bool ForgeXzDownload::abort()
{
if(m_reply)
m_reply->abort();
m_status = Job_Aborted;
m_status = Status::Aborted;
return true;
}
bool ForgeXzDownload::canAbort()
bool ForgeXzDownload::canAbort() const
{
return true;
}

View File

@ -41,7 +41,7 @@ public:
return ForgeXzDownloadPtr(new ForgeXzDownload(relative_path, entry));
}
virtual ~ForgeXzDownload(){};
bool canAbort() override;
bool canAbort() const override;
protected
slots:
@ -52,7 +52,7 @@ slots:
public
slots:
void start() override;
void executeTask() override;
bool abort() override;
private:

View File

@ -131,7 +131,7 @@ std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
return;
}
setStatus(tr("Installing mods: Backing up minecraft.jar ..."));
setStatusText(tr("Installing mods: Backing up minecraft.jar ..."));
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
{
emitFailed("It seems both the active and base jar are gone. A fresh base jar will "
@ -155,7 +155,7 @@ std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
return;
}
setStatus(tr("Installing mods: Opening minecraft.jar ..."));
setStatusText(tr("Installing mods: Opening minecraft.jar ..."));
QString outputJarPath = runnableJar.filePath();
QString inputJarPath = baseJar.filePath();

View File

@ -58,7 +58,7 @@ void LegacyUpdate::fmllibsStart()
auto &libList = fmlLibsMapping[version];
// determine if we need some libs for FML or forge
setStatus(tr("Checking for FML libraries..."));
setStatusText(tr("Checking for FML libraries..."));
for (unsigned i = 0; i < modList->size(); i++)
{
auto &mod = modList->operator[](i);
@ -105,7 +105,7 @@ void LegacyUpdate::fmllibsStart()
}
// download missing libs to our place
setStatus(tr("Dowloading FML libraries..."));
setStatusText(tr("Dowloading FML libraries..."));
auto dljob = new NetJob("FML libraries");
auto metacache = ENV.metacache();
for (auto &lib : fmlLibsToProcess)
@ -128,7 +128,7 @@ void LegacyUpdate::fmllibsFinished()
legacyDownloadJob.reset();
if(!fmlLibsToProcess.isEmpty())
{
setStatus(tr("Copying FML libraries into the instance..."));
setStatusText(tr("Copying FML libraries into the instance..."));
LegacyInstance *inst = (LegacyInstance *)m_inst;
auto metacache = ENV.metacache();
int index = 0;
@ -183,7 +183,7 @@ void LegacyUpdate::lwjglStart()
return;
}
setStatus(tr("Downloading new LWJGL..."));
setStatusText(tr("Downloading new LWJGL..."));
auto version = std::dynamic_pointer_cast<LWJGLVersion>(list->findVersion(lwjglVersion));
if (!version)
{
@ -247,7 +247,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
saveMe.open(QIODevice::WriteOnly);
saveMe.write(m_reply->readAll());
saveMe.close();
setStatus(tr("Installing new LWJGL..."));
setStatusText(tr("Installing new LWJGL..."));
extractLwjgl();
jarStart();
}
@ -323,7 +323,7 @@ void LegacyUpdate::extractLwjgl()
// Now if destFileName is still empty, go to the next file.
if (!destFileName.isEmpty())
{
setStatus(tr("Installing new LWJGL - extracting ") + name + "...");
setStatusText(tr("Installing new LWJGL - extracting ") + name + "...");
QFile output(destFileName);
output.open(QIODevice::WriteOnly);
output.write(file.readAll());
@ -353,7 +353,7 @@ void LegacyUpdate::jarStart()
return;
}
setStatus(tr("Checking for jar updates..."));
setStatusText(tr("Checking for jar updates..."));
// Make directories
QDir binDir(inst->binRoot());
if (!binDir.exists() && !binDir.mkpath("."))
@ -363,7 +363,7 @@ void LegacyUpdate::jarStart()
}
// Build a list of URLs that will need to be downloaded.
setStatus(tr("Downloading new minecraft.jar ..."));
setStatusText(tr("Downloading new minecraft.jar ..."));
QString version_id = inst->intendedVersionId();

View File

@ -116,7 +116,7 @@ void OneSixUpdate::next()
disconnect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
disconnect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
disconnect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
disconnect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
disconnect(task.get(), &Task::status, this, &OneSixUpdate::setStatusText);
}
if(m_currentTask == m_tasks.size())
{
@ -132,7 +132,7 @@ void OneSixUpdate::next()
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatusText);
// if the task is already running, do not start it again
if(!task->isRunning())
{

View File

@ -10,7 +10,7 @@ AssetUpdateTask::AssetUpdateTask(OneSixInstance * inst)
}
void AssetUpdateTask::executeTask()
{
setStatus(tr("Updating assets index..."));
setStatusText(tr("Updating assets index..."));
auto profile = m_inst->getMinecraftProfile();
auto assets = profile->getMinecraftAssets();
QUrl indexUrl = assets->url;
@ -63,7 +63,7 @@ void AssetUpdateTask::assetIndexFinished()
auto job = index.getDownloadJob();
if(job)
{
setStatus(tr("Getting the assets files from Mojang..."));
setStatusText(tr("Getting the assets files from Mojang..."));
downloadJob = job;
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);

View File

@ -32,7 +32,7 @@ void FMLLibrariesTask::executeTask()
auto &libList = fmlLibsMapping[version];
// determine if we need some libs for FML or forge
setStatus(tr("Checking for FML libraries..."));
setStatusText(tr("Checking for FML libraries..."));
forge_present = (profile->versionPatch("net.minecraftforge") != nullptr);
// we don't...
if (!forge_present)
@ -58,7 +58,7 @@ void FMLLibrariesTask::executeTask()
}
// download missing libs to our place
setStatus(tr("Dowloading FML libraries..."));
setStatusText(tr("Dowloading FML libraries..."));
auto dljob = new NetJob("FML libraries");
auto metacache = ENV.metacache();
for (auto &lib : fmlLibsToProcess)
@ -86,7 +86,7 @@ void FMLLibrariesTask::fmllibsFinished()
downloadJob.reset();
if (!fmlLibsToProcess.isEmpty())
{
setStatus(tr("Copying FML libraries into the instance..."));
setStatusText(tr("Copying FML libraries into the instance..."));
OneSixInstance *inst = (OneSixInstance *)m_inst;
auto metacache = ENV.metacache();
int index = 0;

View File

@ -9,7 +9,7 @@ LibrariesTask::LibrariesTask(OneSixInstance * inst)
void LibrariesTask::executeTask()
{
setStatus(tr("Getting the library files from Mojang..."));
setStatusText(tr("Getting the library files from Mojang..."));
qDebug() << m_inst->name() << ": downloading libraries";
OneSixInstance *inst = (OneSixInstance *)m_inst;
inst->reloadProfile();

View File

@ -21,34 +21,34 @@ public:
}
public:
JobStatus init(QNetworkRequest & request) override
Task::Status init(QNetworkRequest & request) override
{
m_output->clear();
if(initAllValidators(request))
return Job_InProgress;
return Job_Failed;
return Task::Status::InProgress;
return Task::Status::Failed;
};
JobStatus write(QByteArray & data) override
Task::Status write(QByteArray & data) override
{
m_output->append(data);
if(writeAllValidators(data))
return Job_InProgress;
return Job_Failed;
return Task::Status::InProgress;
return Task::Status::Failed;
}
JobStatus abort() override
Task::Status abort() override
{
m_output->clear();
failAllValidators();
return Job_Failed;
return Task::Status::Failed;
}
JobStatus finalize(QNetworkReply &reply) override
Task::Status finalize(QNetworkReply &reply) override
{
if(finalizeAllValidators(reply))
return Job_Finished;
return Job_Failed;
return Task::Status::Finished;
return Task::Status::Failed;
}
bool hasLocalData() override

View File

@ -28,7 +28,7 @@ namespace Net {
Download::Download():NetAction()
{
m_status = Job_NotStarted;
m_status = Status::NotStarted;
}
Download::Ptr Download::makeCached(QUrl url, MetaEntryPtr entry, Options options)
@ -66,30 +66,30 @@ void Download::addValidator(Validator * v)
m_sink->addValidator(v);
}
void Download::start()
void Download::executeTask()
{
if(m_status == Job_Aborted)
if(m_status == Status::Aborted)
{
qWarning() << "Attempt to start an aborted Download:" << m_url.toString();
emit aborted(m_index_within_job);
emit aborted();
return;
}
QNetworkRequest request(m_url);
m_status = m_sink->init(request);
switch(m_status)
{
case Job_Finished:
emit succeeded(m_index_within_job);
case Status::Finished:
emit succeeded();
qDebug() << "Download cache hit " << m_url.toString();
return;
case Job_InProgress:
case Status::InProgress:
qDebug() << "Downloading " << m_url.toString();
break;
case Job_NotStarted:
case Job_Failed:
emit failed(m_index_within_job);
case Status::NotStarted:
case Status::Failed:
emit failed();
return;
case Job_Aborted:
case Status::Aborted:
return;
}
@ -106,9 +106,9 @@ void Download::start()
void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
m_total_progress = bytesTotal;
m_progressTotal = bytesTotal;
m_progress = bytesReceived;
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
emit progress(bytesReceived, bytesTotal);
}
void Download::downloadError(QNetworkReply::NetworkError error)
@ -116,7 +116,7 @@ void Download::downloadError(QNetworkReply::NetworkError error)
if(error == QNetworkReply::OperationCanceledError)
{
qCritical() << "Aborted " << m_url.toString();
m_status = Job_Aborted;
m_status = Status::Aborted;
}
else
{
@ -124,13 +124,13 @@ void Download::downloadError(QNetworkReply::NetworkError error)
{
if(m_sink->hasLocalData())
{
m_status = Job_Failed_Proceed;
m_status = Status::Failed_Proceed;
return;
}
}
// error happened during download.
qCritical() << "Failed " << m_url.toString() << " with reason " << error;
m_status = Job_Failed;
m_status = Status::Failed;
}
}
@ -172,28 +172,28 @@ void Download::downloadFinished()
}
// if the download failed before this point ...
if (m_status == Job_Failed_Proceed)
if (m_status == Status::Failed_Proceed)
{
qDebug() << "Download failed but we are allowed to proceed:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit succeeded(m_index_within_job);
emit succeeded();
return;
}
else if (m_status == Job_Failed)
else if (m_status == Status::Failed)
{
qDebug() << "Download failed in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
else if(m_status == Job_Aborted)
else if(m_status == Status::Aborted)
{
qDebug() << "Download aborted in previous step:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit aborted(m_index_within_job);
emit aborted();
return;
}
@ -207,26 +207,26 @@ void Download::downloadFinished()
// otherwise, finalize the whole graph
m_status = m_sink->finalize(*m_reply.get());
if (m_status != Job_Finished)
if (m_status != Status::Finished)
{
qDebug() << "Download failed to finalize:" << m_url.toString();
m_sink->abort();
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
m_reply.reset();
qDebug() << "Download succeeded:" << m_url.toString();
emit succeeded(m_index_within_job);
emit succeeded();
}
void Download::downloadReadyRead()
{
if(m_status == Job_InProgress)
if(m_status == Status::InProgress)
{
auto data = m_reply->readAll();
m_status = m_sink->write(data);
if(m_status == Job_Failed)
if(m_status == Status::Failed)
{
qCritical() << "Failed to process response chunk for " << m_target_path;
}
@ -234,7 +234,7 @@ void Download::downloadReadyRead()
}
else
{
qCritical() << "Cannot write to " << m_target_path << ", illegal status" << m_status;
qCritical() << "Cannot write to " << m_target_path << ", illegal status" << int(m_status);
}
}
@ -248,12 +248,12 @@ bool Net::Download::abort()
}
else
{
m_status = Job_Aborted;
m_status = Status::Aborted;
}
return true;
}
bool Net::Download::canAbort()
bool Net::Download::canAbort() const
{
return true;
}

View File

@ -50,7 +50,7 @@ public: /* methods */
}
void addValidator(Validator * v);
bool abort() override;
bool canAbort() override;
bool canAbort() const override;
private: /* methods */
bool handleRedirect();
@ -62,7 +62,7 @@ protected slots:
void downloadReadyRead() override;
public slots:
void start() override;
void executeTask() override;
private: /* data */
// FIXME: remove this, it has no business being here.

View File

@ -17,10 +17,10 @@ FileSink::~FileSink()
// nil
};
JobStatus FileSink::init(QNetworkRequest& request)
Task::Status FileSink::init(QNetworkRequest& request)
{
auto result = initCache(request);
if(result != Job_InProgress)
if(result != Task::Status::InProgress)
{
return result;
}
@ -28,27 +28,27 @@ JobStatus FileSink::init(QNetworkRequest& request)
if (!FS::ensureFilePathExists(m_filename))
{
qCritical() << "Could not create folder for " + m_filename;
return Job_Failed;
return Task::Status::Failed;
}
wroteAnyData = false;
m_output_file.reset(new QSaveFile(m_filename));
if (!m_output_file->open(QIODevice::WriteOnly))
{
qCritical() << "Could not open " + m_filename + " for writing";
return Job_Failed;
return Task::Status::Failed;
}
if(initAllValidators(request))
return Job_InProgress;
return Job_Failed;
return Task::Status::InProgress;
return Task::Status::Failed;
}
JobStatus FileSink::initCache(QNetworkRequest &)
Task::Status FileSink::initCache(QNetworkRequest &)
{
return Job_InProgress;
return Task::Status::InProgress;
}
JobStatus FileSink::write(QByteArray& data)
Task::Status FileSink::write(QByteArray& data)
{
if (!writeAllValidators(data) || m_output_file->write(data) != data.size())
{
@ -56,20 +56,20 @@ JobStatus FileSink::write(QByteArray& data)
m_output_file->cancelWriting();
m_output_file.reset();
wroteAnyData = false;
return Job_Failed;
return Task::Status::Failed;
}
wroteAnyData = true;
return Job_InProgress;
return Task::Status::InProgress;
}
JobStatus FileSink::abort()
Task::Status FileSink::abort()
{
m_output_file->cancelWriting();
failAllValidators();
return Job_Failed;
return Task::Status::Failed;
}
JobStatus FileSink::finalize(QNetworkReply& reply)
Task::Status FileSink::finalize(QNetworkReply& reply)
{
// if we wrote any data to the save file, we try to commit the data to the real file.
if (wroteAnyData)
@ -77,13 +77,13 @@ JobStatus FileSink::finalize(QNetworkReply& reply)
// ask validators for data consistency
// we only do this for actual downloads, not 'your data is still the same' cache hits
if(!finalizeAllValidators(reply))
return Job_Failed;
return Task::Status::Failed;
// nothing went wrong...
if (!m_output_file->commit())
{
qCritical() << "Failed to commit changes to " << m_filename;
m_output_file->cancelWriting();
return Job_Failed;
return Task::Status::Failed;
}
}
// then get rid of the save file
@ -92,9 +92,9 @@ JobStatus FileSink::finalize(QNetworkReply& reply)
return finalizeCache(reply);
}
JobStatus FileSink::finalizeCache(QNetworkReply &)
Task::Status FileSink::finalizeCache(QNetworkReply &)
{
return Job_Finished;
return Task::Status::Finished;
}
bool FileSink::hasLocalData()

View File

@ -10,15 +10,15 @@ public: /* con/des */
virtual ~FileSink();
public: /* methods */
JobStatus init(QNetworkRequest & request) override;
JobStatus write(QByteArray & data) override;
JobStatus abort() override;
JobStatus finalize(QNetworkReply & reply) override;
Task::Status init(QNetworkRequest & request) override;
Task::Status write(QByteArray & data) override;
Task::Status abort() override;
Task::Status finalize(QNetworkReply & reply) override;
bool hasLocalData() override;
protected: /* methods */
virtual JobStatus initCache(QNetworkRequest &);
virtual JobStatus finalizeCache(QNetworkReply &reply);
virtual Task::Status initCache(QNetworkRequest &);
virtual Task::Status finalizeCache(QNetworkReply &reply);
protected: /* data */
QString m_filename;

View File

@ -17,11 +17,11 @@ MetaCacheSink::~MetaCacheSink()
// nil
};
JobStatus MetaCacheSink::initCache(QNetworkRequest& request)
Task::Status MetaCacheSink::initCache(QNetworkRequest& request)
{
if (!m_entry->isStale())
{
return Job_Finished;
return Task::Status::Finished;
}
// check if file exists, if it does, use its information for the request
QFile current(m_filename);
@ -36,10 +36,10 @@ JobStatus MetaCacheSink::initCache(QNetworkRequest& request)
request.setRawHeader(QString("If-None-Match").toLatin1(), m_entry->getETag().toLatin1());
}
}
return Job_InProgress;
return Task::Status::InProgress;
}
JobStatus MetaCacheSink::finalizeCache(QNetworkReply & reply)
Task::Status MetaCacheSink::finalizeCache(QNetworkReply & reply)
{
QFileInfo output_file_info(m_filename);
if(wroteAnyData)
@ -54,7 +54,7 @@ JobStatus MetaCacheSink::finalizeCache(QNetworkReply & reply)
m_entry->setLocalChangedTimestamp(output_file_info.lastModified().toUTC().toMSecsSinceEpoch());
m_entry->setStale(false);
ENV.metacache()->updateEntry(m_entry);
return Job_Finished;
return Task::Status::Finished;
}
bool MetaCacheSink::hasLocalData()

View File

@ -12,8 +12,8 @@ public: /* con/des */
bool hasLocalData() override;
protected: /* methods */
JobStatus initCache(QNetworkRequest & request) override;
JobStatus finalizeCache(QNetworkReply & reply) override;
Task::Status initCache(QNetworkRequest & request) override;
Task::Status finalizeCache(QNetworkReply & reply) override;
private: /* data */
MetaEntryPtr m_entry;

View File

@ -15,6 +15,8 @@
#pragma once
#include "tasks/Task.h"
#include <QObject>
#include <QUrl>
#include <memory>
@ -23,82 +25,28 @@
#include "multimc_logic_export.h"
enum JobStatus
{
Job_NotStarted,
Job_InProgress,
Job_Finished,
Job_Failed,
Job_Aborted,
Job_Failed_Proceed
};
typedef std::shared_ptr<class NetAction> NetActionPtr;
class MULTIMC_LOGIC_EXPORT NetAction : public QObject
class MULTIMC_LOGIC_EXPORT NetAction : public Task
{
Q_OBJECT
protected:
explicit NetAction() : QObject(0) {};
explicit NetAction(QObject *parent = 0) : Task(parent) {};
public:
virtual ~NetAction() {};
public:
virtual qint64 totalProgress() const
{
return m_total_progress;
}
virtual qint64 currentProgress() const
{
return m_progress;
}
virtual qint64 numberOfFailures() const
{
return m_failures;
}
virtual bool abort()
{
return false;
}
virtual bool canAbort()
{
return false;
}
public:
/// the network reply
unique_qobject_ptr<QNetworkReply> m_reply;
/// source URL
QUrl m_url;
/// The file's status
JobStatus m_status = Job_NotStarted;
/// index within the parent job
int m_index_within_job = 0;
qint64 m_progress = 0;
qint64 m_total_progress = 1;
/// number of failures up to this point
int m_failures = 0;
Status m_status = Status::NotStarted;
signals:
void started(int index);
void netActionProgress(int index, qint64 current, qint64 total);
void succeeded(int index);
void failed(int index);
void aborted(int index);
void failed();
void aborted();
protected
slots:
protected slots:
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) = 0;
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
virtual void downloadFinished() = 0;
virtual void downloadReadyRead() = 0;
public
slots:
virtual void start() = 0;
};

View File

@ -18,22 +18,24 @@
#include <QDebug>
void NetJob::partSucceeded(int index)
void NetJob::partSucceeded()
{
auto index = m_partsIndex[(NetAction *)QObject::sender()];
// do progress. all slots are 1 in size at least
auto &slot = parts_progress[index];
partProgress(index, slot.total_progress, slot.total_progress);
auto &slot = m_parts[index];
setPartProgress(index, slot.total_progress, slot.total_progress);
m_doing.remove(index);
m_done.insert(index);
downloads[index].get()->disconnect(this);
slot.download->disconnect(this);
startMoreParts();
}
void NetJob::partFailed(int index)
void NetJob::partFailed()
{
auto index = m_partsIndex[(NetAction *)QObject::sender()];
m_doing.remove(index);
auto &slot = parts_progress[index];
auto &slot = m_parts[index];
if (slot.failures == 3)
{
m_failed.insert(index);
@ -43,22 +45,30 @@ void NetJob::partFailed(int index)
slot.failures++;
m_todo.enqueue(index);
}
downloads[index].get()->disconnect(this);
slot.download->disconnect(this);
startMoreParts();
}
void NetJob::partAborted(int index)
void NetJob::partAborted()
{
auto index = m_partsIndex[(NetAction *)QObject::sender()];
m_aborted = true;
m_doing.remove(index);
auto &slot = m_parts[index];
m_failed.insert(index);
downloads[index].get()->disconnect(this);
slot.download->disconnect(this);
startMoreParts();
}
void NetJob::partProgress(int index, qint64 bytesReceived, qint64 bytesTotal)
void NetJob::partProgress(qint64 bytesReceived, qint64 bytesTotal)
{
auto &slot = parts_progress[index];
auto index = m_partsIndex[(NetAction *)QObject::sender()];
setPartProgress(index, bytesReceived, bytesTotal);
}
void NetJob::setPartProgress(int index, qint64 bytesReceived, qint64 bytesTotal)
{
auto &slot = m_parts[index];
current_progress -= slot.current_progress;
slot.current_progress = bytesReceived;
@ -74,7 +84,7 @@ void NetJob::executeTask()
{
qDebug() << m_job_name.toLocal8Bit() << " started.";
m_running = true;
for (int i = 0; i < downloads.size(); i++)
for (int i = 0; i < m_parts.size(); i++)
{
m_todo.enqueue(i);
}
@ -114,24 +124,28 @@ void NetJob::startMoreParts()
return;
int doThis = m_todo.dequeue();
m_doing.insert(doThis);
auto part = downloads[doThis];
auto part = m_parts[doThis].download;
// connect signals :D
connect(part.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
connect(part.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
connect(part.get(), SIGNAL(aborted(int)), SLOT(partAborted(int)));
connect(part.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
SLOT(partProgress(int, qint64, qint64)));
connectAction(part.get());
part->start();
}
}
void NetJob::connectAction(NetAction* action)
{
connect(action, &NetAction::succeeded, this, &NetJob::partSucceeded);
connect(action, &NetAction::failed, this, &NetJob::partFailed);
connect(action, &NetAction::aborted, this, &NetJob::partAborted);
connect(action, &NetAction::progress, this, &NetJob::partProgress);
}
QStringList NetJob::getFailedFiles()
{
QStringList failed;
for (auto index: m_failed)
{
failed.push_back(downloads[index]->m_url.toString());
failed.push_back(m_parts[index].download->m_url.toString());
}
failed.sort();
return failed;
@ -143,13 +157,13 @@ bool NetJob::canAbort() const
// can abort the waiting?
for(auto index: m_todo)
{
auto part = downloads[index];
auto part = m_parts[index].download;
canFullyAbort &= part->canAbort();
}
// can abort the active?
for(auto index: m_doing)
{
auto part = downloads[index];
auto part = m_parts[index].download;
canFullyAbort &= part->canAbort();
}
return canFullyAbort;
@ -165,8 +179,32 @@ bool NetJob::abort()
auto toKill = m_doing.toList();
for(auto index: toKill)
{
auto part = downloads[index];
auto part = m_parts[index].download;
fullyAborted &= part->abort();
}
return fullyAborted;
}
void NetJob::addNetAction(NetActionPtr action)
{
m_partsIndex[action.get()] = m_parts.count();
part_info pi;
{
pi.current_progress = action->getProgress();
pi.total_progress = action->getTotalProgress();
pi.failures = 0;
pi.download = action;
}
m_parts.append(pi);
total_progress += pi.total_progress;
current_progress += pi.current_progress;
// if this is already running, the action needs to be started right away!
if (isRunning())
{
setProgress(current_progress, total_progress);
connectAction(action.get());
action->start();
}
}

View File

@ -32,48 +32,26 @@ class MULTIMC_LOGIC_EXPORT NetJob : public Task
public:
explicit NetJob(QString job_name) : Task(), m_job_name(job_name) {}
virtual ~NetJob() {}
bool addNetAction(NetActionPtr action)
{
action->m_index_within_job = downloads.size();
downloads.append(action);
part_info pi;
{
pi.current_progress = action->currentProgress();
pi.total_progress = action->totalProgress();
pi.failures = action->numberOfFailures();
}
parts_progress.append(pi);
total_progress += pi.total_progress;
// if this is already running, the action needs to be started right away!
if (isRunning())
{
setProgress(current_progress, total_progress);
connect(action.get(), SIGNAL(succeeded(int)), SLOT(partSucceeded(int)));
connect(action.get(), SIGNAL(failed(int)), SLOT(partFailed(int)));
connect(action.get(), SIGNAL(netActionProgress(int, qint64, qint64)),
SLOT(partProgress(int, qint64, qint64)));
action->start();
}
return true;
}
void addNetAction(NetActionPtr action);
NetActionPtr operator[](int index)
{
return downloads[index];
return m_parts[index].download;
}
const NetActionPtr at(const int index)
{
return downloads.at(index);
return m_parts[index].download;
}
NetActionPtr first()
{
if (downloads.size())
return downloads[0];
if (m_parts.size())
return m_parts[0].download;
return NetActionPtr();
}
int size() const
{
return downloads.size();
return m_parts.size();
}
virtual bool isRunning() const override
{
@ -91,22 +69,27 @@ public slots:
virtual bool abort() override;
private slots:
void partProgress(int index, qint64 bytesReceived, qint64 bytesTotal);
void partSucceeded(int index);
void partFailed(int index);
void partAborted(int index);
void partProgress(qint64 bytesReceived, qint64 bytesTotal);
void partSucceeded();
void partFailed();
void partAborted();
private:
void setPartProgress(int index, qint64 bytesReceived, qint64 bytesTotal);
void connectAction(NetAction * action);
private:
struct part_info
{
NetActionPtr download;
qint64 current_progress = 0;
qint64 total_progress = 1;
int failures = 0;
bool connected = false;
};
QString m_job_name;
QList<NetActionPtr> downloads;
QList<part_info> parts_progress;
QList<part_info> m_parts;
QMap<NetAction *, int> m_partsIndex;
QQueue<int> m_todo;
QSet<int> m_doing;
QSet<int> m_done;

View File

@ -39,7 +39,7 @@ void PasteUpload::executeTask()
QNetworkReply *rep = ENV.qnam().post(request, buf);
m_reply = std::shared_ptr<QNetworkReply>(rep);
setStatus(tr("Uploading to paste.ee"));
setStatusText(tr("Uploading to paste.ee"));
connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress);
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));

View File

@ -13,10 +13,10 @@ public: /* con/des */
virtual ~Sink() {};
public: /* methods */
virtual JobStatus init(QNetworkRequest & request) = 0;
virtual JobStatus write(QByteArray & data) = 0;
virtual JobStatus abort() = 0;
virtual JobStatus finalize(QNetworkReply & reply) = 0;
virtual Task::Status init(QNetworkRequest & request) = 0;
virtual Task::Status write(QByteArray & data) = 0;
virtual Task::Status abort() = 0;
virtual Task::Status finalize(QNetworkReply & reply) = 0;
virtual bool hasLocalData() = 0;
void addValidator(Validator * validator)

View File

@ -60,7 +60,7 @@ void NotificationChecker::checkForNotifications()
m_checkJob->start();
}
void NotificationChecker::downloadSucceeded(int)
void NotificationChecker::downloadSucceeded()
{
m_entries.clear();

View File

@ -43,7 +43,7 @@ slots:
private
slots:
void downloadSucceeded(int);
void downloadSucceeded();
signals:
void notificationCheckFinished();

View File

@ -13,12 +13,12 @@
ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> screenshots) : NetAction(), m_screenshots(screenshots)
{
m_url = URLConstants::IMGUR_BASE_URL + "album.json";
m_status = Job_NotStarted;
m_status = Status::NotStarted;
}
void ImgurAlbumCreation::start()
void ImgurAlbumCreation::executeTask()
{
m_status = Job_InProgress;
m_status = Status::InProgress;
QNetworkRequest request(m_url);
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@ -43,11 +43,11 @@ void ImgurAlbumCreation::start()
void ImgurAlbumCreation::downloadError(QNetworkReply::NetworkError error)
{
qDebug() << m_reply->errorString();
m_status = Job_Failed;
m_status = Status::Failed;
}
void ImgurAlbumCreation::downloadFinished()
{
if (m_status != Job_Failed)
if (m_status != Status::Failed)
{
QByteArray data = m_reply->readAll();
m_reply.reset();
@ -56,33 +56,33 @@ void ImgurAlbumCreation::downloadFinished()
if (jsonError.error != QJsonParseError::NoError)
{
qDebug() << jsonError.errorString();
emit failed(m_index_within_job);
emit failed();
return;
}
auto object = doc.object();
if (!object.value("success").toBool())
{
qDebug() << doc.toJson();
emit failed(m_index_within_job);
emit failed();
return;
}
m_deleteHash = object.value("data").toObject().value("deletehash").toString();
m_id = object.value("data").toObject().value("id").toString();
m_status = Job_Finished;
emit succeeded(m_index_within_job);
m_status = Status::Finished;
emit succeeded();
return;
}
else
{
qDebug() << m_reply->readAll();
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
}
void ImgurAlbumCreation::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
m_total_progress = bytesTotal;
m_progressTotal = bytesTotal;
m_progress = bytesReceived;
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
emit progress(bytesReceived, bytesTotal);
}

View File

@ -34,7 +34,7 @@ slots:
public
slots:
virtual void start();
virtual void executeTask();
private:
QList<ScreenshotPtr> m_screenshots;

View File

@ -15,13 +15,13 @@
ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot)
{
m_url = URLConstants::IMGUR_BASE_URL + "upload.json";
m_status = Job_NotStarted;
m_status = Status::NotStarted;
}
void ImgurUpload::start()
void ImgurUpload::executeTask()
{
finished = false;
m_status = Job_InProgress;
m_status = Status::InProgress;
QNetworkRequest request(m_url);
request.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Uncached)");
request.setRawHeader("Authorization", "Client-ID 5b97b0713fba4a3");
@ -30,7 +30,7 @@ void ImgurUpload::start()
QFile f(m_shot->m_file.absoluteFilePath());
if (!f.open(QFile::ReadOnly))
{
emit failed(m_index_within_job);
emit failed();
return;
}
@ -65,10 +65,10 @@ void ImgurUpload::downloadError(QNetworkReply::NetworkError error)
qCritical() << "Double finished ImgurUpload!";
return;
}
m_status = Job_Failed;
m_status = Status::Failed;
finished = true;
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
}
void ImgurUpload::downloadFinished()
{
@ -86,7 +86,7 @@ void ImgurUpload::downloadFinished()
qDebug() << "imgur server did not reply with JSON" << jsonError.errorString();
finished = true;
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
auto object = doc.object();
@ -95,19 +95,19 @@ void ImgurUpload::downloadFinished()
qDebug() << "Screenshot upload not successful:" << doc.toJson();
finished = true;
m_reply.reset();
emit failed(m_index_within_job);
emit failed();
return;
}
m_shot->m_imgurId = object.value("data").toObject().value("id").toString();
m_shot->m_url = object.value("data").toObject().value("link").toString();
m_status = Job_Finished;
m_status = Status::Finished;
finished = true;
emit succeeded(m_index_within_job);
emit succeeded();
return;
}
void ImgurUpload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
m_total_progress = bytesTotal;
m_progressTotal = bytesTotal;
m_progress = bytesReceived;
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
emit progress(bytesReceived, bytesTotal);
}

View File

@ -25,7 +25,7 @@ slots:
public
slots:
virtual void start();
virtual void executeTask();
private:
ScreenshotPtr m_shot;

View File

@ -42,7 +42,7 @@ void SequentialTask::subTaskFailed(const QString &msg)
}
void SequentialTask::subTaskStatus(const QString &msg)
{
setStatus(msg);
setStatusText(msg);
}
void SequentialTask::subTaskProgress(qint64 current, qint64 total)
{

View File

@ -21,12 +21,12 @@ Task::Task(QObject *parent) : QObject(parent)
{
}
void Task::setStatus(const QString &new_status)
void Task::setStatusText(const QString &new_status)
{
if(m_status != new_status)
if(m_statusText != new_status)
{
m_status = new_status;
emit status(m_status);
m_statusText = new_status;
emit status(m_statusText);
}
}

View File

@ -23,6 +23,16 @@
class MULTIMC_LOGIC_EXPORT Task : public QObject
{
Q_OBJECT
public:
enum class Status
{
NotStarted,
InProgress,
Finished,
Failed,
Aborted,
Failed_Proceed
};
public:
explicit Task(QObject *parent = 0);
virtual ~Task() {};
@ -43,19 +53,22 @@ public:
*/
virtual QString failReason() const;
virtual bool canAbort() const { return false; }
QString getStatus()
virtual bool canAbort() const
{
return m_status;
return false;
}
qint64 getProgress()
QString getStatusText()
{
return m_statusText;
}
virtual qint64 getProgress()
{
return m_progress;
}
qint64 getTotalProgress()
virtual qint64 getTotalProgress()
{
return m_progressTotal;
}
@ -68,10 +81,12 @@ signals:
void failed(QString reason);
void status(QString status);
public
slots:
public slots:
virtual void start();
virtual bool abort() { return false; };
virtual bool abort()
{
return false;
};
protected:
virtual void executeTask() = 0;
@ -81,7 +96,7 @@ protected slots:
virtual void emitFailed(QString reason);
public slots:
void setStatus(const QString &status);
void setStatusText(const QString &status);
void setProgress(qint64 current, qint64 total);
protected:
@ -89,8 +104,9 @@ protected:
bool m_finished = false;
bool m_succeeded = false;
QString m_failReason = "";
QString m_status;
int m_progress = 0;
int m_progressTotal = 100;
QString m_statusText;
qint64 m_progress = 0;
qint64 m_progressTotal = 1;
};

View File

@ -32,7 +32,7 @@ void ThreadTask::iternal_started()
void ThreadTask::iternal_status(QString status)
{
setStatus(status);
setStatusText(status);
}
void ThreadTask::iternal_succeeded()

View File

@ -26,7 +26,7 @@
namespace GoUpdate
{
DownloadTask::DownloadTask(Status status, QString target, QObject *parent)
DownloadTask::DownloadTask(GoUpdate::Status status, QString target, QObject *parent)
: Task(parent), m_updateFilesDir(target)
{
m_status = status;
@ -41,7 +41,7 @@ void DownloadTask::executeTask()
void DownloadTask::loadVersionInfo()
{
setStatus(tr("Loading version information..."));
setStatusText(tr("Loading version information..."));
NetJob *netJob = new NetJob("Version Info");
@ -70,7 +70,7 @@ void DownloadTask::vinfoDownloadFailed()
{
// Something failed. We really need the second download (current version info), so parse
// downloads anyways as long as the first one succeeded.
if (m_newVersionFileListDownload->m_status != Job_Failed)
if (m_newVersionFileListDownload->m_status != Status::Failed)
{
processDownloadedVersionInfo();
return;
@ -86,7 +86,7 @@ void DownloadTask::processDownloadedVersionInfo()
VersionFileList m_currentVersionFileList;
VersionFileList m_newVersionFileList;
setStatus(tr("Reading file list for new version..."));
setStatusText(tr("Reading file list for new version..."));
qDebug() << "Reading file list for new version...";
QString error;
if (!parseVersionInfo(newVersionFileListData, m_newVersionFileList, error))
@ -97,9 +97,9 @@ void DownloadTask::processDownloadedVersionInfo()
}
// if we have the current version info, use it.
if (m_currentVersionFileListDownload && m_currentVersionFileListDownload->m_status != Job_Failed)
if (m_currentVersionFileListDownload && m_currentVersionFileListDownload->m_status != Status::Failed)
{
setStatus(tr("Reading file list for current version..."));
setStatusText(tr("Reading file list for current version..."));
qDebug() << "Reading file list for current version...";
// if this fails, it's not a complete loss.
QString error;
@ -114,7 +114,7 @@ void DownloadTask::processDownloadedVersionInfo()
m_newVersionFileListDownload.reset();
m_vinfoNetJob.reset();
setStatus(tr("Processing file lists - figuring out how to install the update..."));
setStatusText(tr("Processing file lists - figuring out how to install the update..."));
// make a new netjob for the actual update files
NetJobPtr netJob (new NetJob("Update Files"));
@ -131,7 +131,7 @@ void DownloadTask::processDownloadedVersionInfo()
QObject::connect(netJob.get(), &NetJob::progress, this, &DownloadTask::fileDownloadProgressChanged);
QObject::connect(netJob.get(), &NetJob::failed, this, &DownloadTask::fileDownloadFailed);
setStatus(tr("Downloading %1 update files.").arg(QString::number(netJob->size())));
setStatusText(tr("Downloading %1 update files.").arg(QString::number(netJob->size())));
qDebug() << "Begin downloading update files to" << m_updateFilesDir.path();
m_filesNetJob = netJob;
m_filesNetJob->start();

View File

@ -37,7 +37,7 @@ public:
*
* target is a template - XXXXXX at the end will be replaced with a random generated string, ensuring uniqueness
*/
explicit DownloadTask(Status status, QString target, QObject* parent = 0);
explicit DownloadTask(GoUpdate::Status status, QString target, QObject* parent = 0);
/// Get the directory that will contain the update files.
QString updateFilesDir();
@ -71,7 +71,7 @@ protected:
NetJobPtr m_filesNetJob;
Status m_status;
GoUpdate::Status m_status;
OperationList m_operations;

View File

@ -87,7 +87,7 @@ int ProgressDialog::execWithTask(Task *task)
if(task->isRunning())
{
changeProgress(task->getProgress(), task->getTotalProgress());
changeStatus(task->getStatus());
changeStatus(task->getStatusText());
return QDialog::exec();
}
else if(handleImmediateResult(result))