| 76 | } |
| 77 | |
| 78 | void Technic::SolderPackInstallTask::fileListSucceeded() |
| 79 | { |
| 80 | setStatus(tr("Downloading modpack:")); |
| 81 | QStringList modUrls; |
| 82 | try |
| 83 | { |
| 84 | QJsonDocument doc = Json::requireDocument(m_response); |
| 85 | QJsonObject obj = Json::requireObject(doc); |
| 86 | QString minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__"); |
| 87 | if (!minecraftVersion.isEmpty()) |
| 88 | m_minecraftVersion = minecraftVersion; |
| 89 | QJsonArray mods = Json::requireArray(obj, "mods", "'mods'"); |
| 90 | for (auto mod: mods) |
| 91 | { |
| 92 | QJsonObject modObject = Json::requireValueObject(mod); |
| 93 | modUrls.append(Json::requireString(modObject, "url", "'url'")); |
| 94 | } |
| 95 | } |
| 96 | catch (const JSONValidationError &e) |
| 97 | { |
| 98 | emitFailed(e.cause()); |
| 99 | m_filesNetJob.reset(); |
| 100 | return; |
| 101 | } |
| 102 | m_filesNetJob = new NetJob(tr("Downloading modpack"), m_network); |
| 103 | int i = 0; |
| 104 | for (auto &modUrl: modUrls) |
| 105 | { |
| 106 | auto path = FS::PathCombine(m_outputDir.path(), QString("%1").arg(i)); |
| 107 | m_filesNetJob->addNetAction(Net::Download::makeFile(modUrl, path)); |
| 108 | i++; |
| 109 | } |
| 110 | |
| 111 | m_modCount = modUrls.size(); |
| 112 | |
| 113 | connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded); |
| 114 | connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged); |
| 115 | connect(m_filesNetJob.get(), &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed); |
| 116 | m_filesNetJob->start(); |
| 117 | } |
| 118 | |
| 119 | void Technic::SolderPackInstallTask::downloadSucceeded() |
| 120 | { |
nothing calls this directly
no test coverage detected