diff options
Diffstat (limited to 'api/logic/minecraft/forge/ForgeXzDownload.cpp')
-rw-r--r-- | api/logic/minecraft/forge/ForgeXzDownload.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/api/logic/minecraft/forge/ForgeXzDownload.cpp b/api/logic/minecraft/forge/ForgeXzDownload.cpp index 4d94dd12..8bcd43aa 100644 --- a/api/logic/minecraft/forge/ForgeXzDownload.cpp +++ b/api/logic/minecraft/forge/ForgeXzDownload.cpp @@ -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; } |