summaryrefslogtreecommitdiffstats
path: root/heimdall-frontend/source/PackageData.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--heimdall-frontend/source/PackageData.h65
1 files changed, 58 insertions, 7 deletions
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);
}
};
}