void MainWindow::startPatching() { Q_D(MainWindow); d->bytes = 0; d->maxBytes = 0; d->files = 0; d->maxFiles = 0; d->progressBar->setMaximum(0); d->progressBar->setValue(0); d->detailsLbl->clear(); if (!d->supported) { if (d->presetSel->currentIndex() == 0) { d->patchInfo = new mbp::PatchInfo(); // TODO: Memory leak here! d->patchInfo->addAutoPatcher("StandardPatcher", mbp::PatchInfo::AutoPatcherArgs()); d->patchInfo->setHasBootImage(d->hasBootImageCb->isChecked()); if (d->patchInfo->hasBootImage()) { d->patchInfo->setRamdisk(d->device->id() + "/default"); QString text = d->bootImageLe->text().trimmed(); if (!text.isEmpty()) { QStringList split = text.split(QStringLiteral(",")); std::vector<std::string> bootImages; for (const QString &bootImage : split) { bootImages.push_back(bootImage.toUtf8().constData()); } d->patchInfo->setBootImages(std::move(bootImages)); } } d->patchInfo->setDeviceCheck(!d->deviceCheckCb->isChecked()); } else { d->patchInfo = d->patchInfos[d->presetSel->currentIndex() - 1]; } } d->state = MainWindowPrivate::Patching; updateWidgetsVisibility(); FileInfoPtr fileInfo = new mbp::FileInfo(); fileInfo->setFilename(d->fileName.toUtf8().constData()); fileInfo->setDevice(d->device); fileInfo->setPatchInfo(d->patchInfo); QString romId; if (d->instLocSel->currentIndex() >= d->instLocs.size()) { romId = QStringLiteral("data-slot-%1").arg(d->instLocLe->text()); } else { romId = d->instLocs[d->instLocSel->currentIndex()].id; } fileInfo->setRomId(romId.toUtf8().constData()); emit runThread(d->patcher, fileInfo); }
void MainWindow::startPatching() { Q_D(MainWindow); d->bytes = 0; d->maxBytes = 0; d->files = 0; d->maxFiles = 0; d->progressBar->setMaximum(0); d->progressBar->setValue(0); d->detailsLbl->clear(); d->state = MainWindowPrivate::Patching; updateWidgetsVisibility(); QString romId; if (d->instLocSel->currentIndex() == d->instLocs.size()) { romId = QStringLiteral("data-slot-%1").arg(d->instLocLe->text()); } else if (d->instLocSel->currentIndex() == d->instLocs.size() + 1) { romId = QStringLiteral("extsd-slot-%1").arg(d->instLocLe->text()); } else { romId = d->instLocs[d->instLocSel->currentIndex()].id; } QStringList suffixes; suffixes << QStringLiteral(".tar.md5"); suffixes << QStringLiteral(".tar.md5.gz"); suffixes << QStringLiteral(".tar.md5.xz"); suffixes << QStringLiteral(".zip"); QFileInfo qFileInfo(d->fileName); QString suffix; QString outputName; bool isOdin = false; for (const QString &suffix : suffixes) { if (d->fileName.endsWith(suffix)) { // Input name: <parent path>/<base name>.<suffix> // Output name: <parent path>/<base name>_<rom id>.zip outputName = d->fileName.left(d->fileName.size() - suffix.size()) % QStringLiteral("_") % romId % QStringLiteral(".zip"); isOdin = suffix.contains(QStringLiteral(".tar.md5")); break; } } if (outputName.isEmpty()) { outputName = qFileInfo.completeBaseName() % QStringLiteral("_") % romId % QStringLiteral(".") % qFileInfo.suffix(); } QString inputPath(QDir::toNativeSeparators(qFileInfo.filePath())); QString outputPath(QDir::toNativeSeparators( qFileInfo.dir().filePath(outputName))); FileInfoPtr fileInfo = new mbp::FileInfo(); fileInfo->setInputPath(inputPath.toUtf8().constData()); fileInfo->setOutputPath(outputPath.toUtf8().constData()); fileInfo->setDevice(d->device); fileInfo->setRomId(romId.toUtf8().constData()); if (isOdin) { d->patcher = d->pc->createPatcher("OdinPatcher"); } else { d->patcher = d->pc->createPatcher("MultiBootPatcher"); } emit runThread(d->patcher, fileInfo); }