diff options
Diffstat (limited to 'heimdall-frontend/source')
-rw-r--r-- | heimdall-frontend/source/FirmwareInfo.h | 5 | ||||
-rw-r--r-- | heimdall-frontend/source/PackageData.cpp | 12 | ||||
-rw-r--r-- | heimdall-frontend/source/PackageData.h | 65 | ||||
-rw-r--r-- | heimdall-frontend/source/Packaging.cpp | 2 | ||||
-rw-r--r-- | heimdall-frontend/source/mainwindow.cpp | 4 | ||||
-rw-r--r-- | heimdall-frontend/source/qml/DropFiles.qml | 4 |
6 files changed, 76 insertions, 16 deletions
diff --git a/heimdall-frontend/source/FirmwareInfo.h b/heimdall-frontend/source/FirmwareInfo.h index 64bf2bc..55eb304 100644 --- a/heimdall-frontend/source/FirmwareInfo.h +++ b/heimdall-frontend/source/FirmwareInfo.h @@ -393,6 +393,11 @@ namespace HeimdallFrontend return QQmlListProperty<FileInfo>{this, nullptr, &FirmwareInfo::FileInfoAppend, &FirmwareInfo::FileInfoCount, &FirmwareInfo::FileInfoAtIndex, &FirmwareInfo::FileInfoClearAll}; } + + void CopyFrom(const FirmwareInfo& firmwareInfo) + { + // TODO: + } }; } diff --git a/heimdall-frontend/source/PackageData.cpp b/heimdall-frontend/source/PackageData.cpp index c17917b..42718bf 100644 --- a/heimdall-frontend/source/PackageData.cpp +++ b/heimdall-frontend/source/PackageData.cpp @@ -38,17 +38,17 @@ PackageData::PackageData() PackageData::~PackageData() { - Clear(true); + Clear(); } -void PackageData::Clear(bool deletePackageDirectory) +void PackageData::Clear(void) { - if (deletePackageDirectory) + for (QDir& dir : ownedDirectories) { - packageDirectory.removeRecursively(); + dir.removeRecursively(); } - packageDirectory.setPath(QString()); + ownedDirectories.clear(); firmwareInfo.Clear(); filePaths.clear(); } @@ -71,7 +71,7 @@ bool PackageData::ReadFirmwareInfo(const QString& path) bool PackageData::IsCleared(void) const { - return (packageDirectory.path().length() == 0 + return (ownedDirectories.length() == 0 && firmwareInfo.IsCleared() && filePaths.isEmpty()); } diff --git a/heimdall-frontend/source/PackageData.h b/heimdall-frontend/source/PackageData.h index 71302db..f480339 100644 --- a/heimdall-frontend/source/PackageData.h +++ b/heimdall-frontend/source/PackageData.h @@ -35,13 +35,32 @@ namespace HeimdallFrontend Q_PROPERTY(HeimdallFrontend::FirmwareInfo *firmwareInfo READ GetFirmwareInfo) Q_PROPERTY(QList<QString> filePaths READ GetFilePaths) - Q_PROPERTY(QString packagePath READ GetPackagePath) private: FirmwareInfo firmwareInfo; QList<QString> filePaths; - QDir packageDirectory; + QList<QDir> ownedDirectories; + + QString findPit(void) const + { + QString pitIdentifier = firmwareInfo.GetPitFilename(); + + if (pitIdentifier.length() == 0) + { + pitIdentifier = ".pit"; + } + + for (const QString& path : filePaths) + { + if (path.endsWith(pitIdentifier)) + { + return path; + } + } + + return QLatin1String(""); + } public: @@ -50,7 +69,7 @@ namespace HeimdallFrontend PackageData(); ~PackageData(); - void Clear(bool deletePackageDirectory = true); + void Clear(void); bool ReadFirmwareInfo(const QString& path); bool IsCleared(void) const; @@ -75,14 +94,46 @@ namespace HeimdallFrontend return (filePaths); } - void SetPackagePath(const QString& path) + const QList<QDir>& GetOwnedDirectories(void) const + { + return (ownedDirectories); + } + + QList<QDir>& GetOwnedDirectories(void) { - packageDirectory.setPath(path); + return (ownedDirectories); } - QString GetPackagePath() const + bool TakeFrom(PackageData& other, QString& failureReason, bool dryRun = false) { - return packageDirectory.path(); + if (!firmwareInfo.IsCleared() && !other.firmwareInfo.IsCleared()) + { + failureReason = QLatin1String("Only one firmware.xml can be used at a time"); + return (false); + } + + if (findPit().length() > 0 && other.findPit().length() > 0) + { + failureReason = QLatin1String("Only one PIT file can be used at a time"); + return (false); + } + + if (!dryRun) + { + if (firmwareInfo.IsCleared()) + { + firmwareInfo.CopyFrom(other.firmwareInfo); + } + + filePaths.append(other.filePaths); + ownedDirectories.append(other.ownedDirectories); + + other.ownedDirectories.clear(); + + firmwareInfo.CopyFrom(other.firmwareInfo); + } + + return (true); } }; } diff --git a/heimdall-frontend/source/Packaging.cpp b/heimdall-frontend/source/Packaging.cpp index 39894a5..157195e 100644 --- a/heimdall-frontend/source/Packaging.cpp +++ b/heimdall-frontend/source/Packaging.cpp @@ -560,7 +560,7 @@ bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageD outputDirectory.setAutoRemove(false); packageData->GetFilePaths().append(decompressedFilePaths); - packageData->SetPackagePath(outputDirectory.path()); + packageData->GetOwnedDirectories().append(outputDirectory.path()); return (true); } } diff --git a/heimdall-frontend/source/mainwindow.cpp b/heimdall-frontend/source/mainwindow.cpp index 255c0b5..d28cdc7 100644 --- a/heimdall-frontend/source/mainwindow.cpp +++ b/heimdall-frontend/source/mainwindow.cpp @@ -553,7 +553,6 @@ void MainWindow::LoadFirmwarePackage(void) } workingPackageData.GetFilePaths().append(loadedPackageData.GetFilePaths()); - workingPackageData.SetPackagePath(loadedPackageData.GetPackagePath()); QString pitFilename = loadedPackageData.GetFirmwareInfo()->GetPitFilename(); @@ -581,7 +580,8 @@ void MainWindow::LoadFirmwarePackage(void) workingPackageData.GetFirmwareInfo()->SetRepartition(loadedPackageData.GetFirmwareInfo()->GetRepartition()); workingPackageData.GetFirmwareInfo()->SetNoReboot(loadedPackageData.GetFirmwareInfo()->GetNoReboot()); - loadedPackageData.Clear(false); + workingPackageData.GetOwnedDirectories().append(loadedPackageData.GetOwnedDirectories()); + loadedPackageData.GetOwnedDirectories().clear(); UpdateUnusedPartitionIds(); UpdatePackageUserInterface(); diff --git a/heimdall-frontend/source/qml/DropFiles.qml b/heimdall-frontend/source/qml/DropFiles.qml index 2745b4e..bc96cbc 100644 --- a/heimdall-frontend/source/qml/DropFiles.qml +++ b/heimdall-frontend/source/qml/DropFiles.qml @@ -15,6 +15,10 @@ DropFilesForm { id: fileModel } + Native.PackageData { + id: packageData + } + function setFileGridVisible(visible) { if (fileGridContainer.visible !== visible) { dropFilesContainer.visible = !visible; |