summaryrefslogtreecommitdiffstats
path: root/heimdall-frontend
diff options
context:
space:
mode:
Diffstat (limited to 'heimdall-frontend')
-rwxr-xr-xheimdall-frontend/Source/Alerts.cpp43
-rwxr-xr-xheimdall-frontend/Source/Alerts.h38
-rwxr-xr-xheimdall-frontend/Source/FirmwareInfo.cpp137
-rwxr-xr-xheimdall-frontend/Source/FirmwareInfo.h2
-rwxr-xr-xheimdall-frontend/Source/PackageData.cpp5
-rwxr-xr-xheimdall-frontend/Source/PackageData.h2
-rwxr-xr-xheimdall-frontend/Source/Packaging.cpp77
-rwxr-xr-xheimdall-frontend/Source/Packaging.h4
-rw-r--r--heimdall-frontend/Source/aboutform.cpp2
-rw-r--r--heimdall-frontend/Source/aboutform.h2
-rw-r--r--heimdall-frontend/Source/main.cpp2
-rw-r--r--heimdall-frontend/Source/mainwindow.cpp117
-rw-r--r--heimdall-frontend/Source/mainwindow.h5
-rw-r--r--heimdall-frontend/heimdall-frontend.vcxproj2
-rw-r--r--heimdall-frontend/heimdall-frontend.vcxproj.filters6
-rw-r--r--heimdall-frontend/mainwindow.ui17
16 files changed, 335 insertions, 126 deletions
diff --git a/heimdall-frontend/Source/Alerts.cpp b/heimdall-frontend/Source/Alerts.cpp
new file mode 100755
index 0000000..e8e8752
--- /dev/null
+++ b/heimdall-frontend/Source/Alerts.cpp
@@ -0,0 +1,43 @@
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.*/
+
+// Qt
+#include <QMessageBox>
+
+// Heimdall Frontend
+#include "Alerts.h"
+
+using namespace HeimdallFrontend;
+
+void Alerts::DisplayError(const QString& errorMessage)
+{
+ QMessageBox messageBox;
+ messageBox.setText(errorMessage);
+ messageBox.setIcon(QMessageBox::Critical);
+ messageBox.exec();
+}
+
+void Alerts::DisplayWarning(const QString& warningMessage)
+{
+ QMessageBox messageBox;
+ messageBox.setText(warningMessage);
+ messageBox.setIcon(QMessageBox::Warning);
+ messageBox.exec();
+}
diff --git a/heimdall-frontend/Source/Alerts.h b/heimdall-frontend/Source/Alerts.h
new file mode 100755
index 0000000..95c2b75
--- /dev/null
+++ b/heimdall-frontend/Source/Alerts.h
@@ -0,0 +1,38 @@
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.*/
+
+#ifndef ALERTS_H
+#define ALERTS_H
+
+// Qt
+#include <QString>
+
+namespace HeimdallFrontend
+{
+ class Alerts
+ {
+ public:
+
+ static void DisplayError(const QString& errorMessage);
+ static void DisplayWarning(const QString& warningMessage);
+ };
+}
+
+#endif
diff --git a/heimdall-frontend/Source/FirmwareInfo.cpp b/heimdall-frontend/Source/FirmwareInfo.cpp
index 39ec242..aee9313 100755
--- a/heimdall-frontend/Source/FirmwareInfo.cpp
+++ b/heimdall-frontend/Source/FirmwareInfo.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,6 +19,7 @@
THE SOFTWARE.*/
// Heimdall Frontend
+#include "Alerts.h"
#include "FirmwareInfo.h"
using namespace HeimdallFrontend;
@@ -50,7 +51,7 @@ bool DeviceInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundManufacturer)
{
- // TODO: "Found multiple device manufacturers."
+ Alerts::DisplayError("Found multiple <manufacturer> elements in <device>.");
return (false);
}
@@ -62,7 +63,7 @@ bool DeviceInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundProduct)
{
- // TODO: "Found multiple device product identifiers."
+ Alerts::DisplayError("Found multiple <product> elements in <device>.");
return (false);
}
@@ -74,7 +75,7 @@ bool DeviceInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundName)
{
- // TODO: "Found multiple device names."));
+ Alerts::DisplayError("Found multiple <name> elements in <device>.");
return (false);
}
@@ -82,17 +83,32 @@ bool DeviceInfo::ParseXml(QXmlStreamReader& xml)
name = xml.readElementText();
}
+ else
+ {
+ Alerts::DisplayError(QString("<%1> is not a valid child of <device>.").arg(xml.name().toString()));
+ return (false);
+ }
}
else if (nextToken == QXmlStreamReader::EndElement)
{
if (xml.name() == "device")
- return (foundManufacturer && foundProduct && foundName);
+ {
+ if (foundManufacturer && foundProduct && foundName)
+ {
+ return (true);
+ }
+ else
+ {
+ Alerts::DisplayError("Required elements are missing from <device>.");
+ return (false);
+ }
+ }
}
else
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <device>"
+ Alerts::DisplayError("Unexpected token found in <device>.");
return (false);
}
}
@@ -154,7 +170,7 @@ bool PlatformInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundName)
{
- // TODO: "Found multiple platform names."
+ Alerts::DisplayError("Found multiple <name> elements in <platform>.");
return (false);
}
@@ -166,7 +182,7 @@ bool PlatformInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundVersion)
{
- // TODO: "Found multiple platform versions."
+ Alerts::DisplayError("Found multiple <version> elements in <platform>.");
return (false);
}
@@ -176,20 +192,30 @@ bool PlatformInfo::ParseXml(QXmlStreamReader& xml)
}
else
{
- // TODO: "found unknown <platform> sub-element <" + xml.name() + ">."
+ Alerts::DisplayError(QString("<%1> is not a valid child of <platform>.").arg(xml.name().toString()));
return (false);
}
}
else if (nextToken == QXmlStreamReader::EndElement)
{
if (xml.name() == "platform")
- return (foundName && foundVersion);
+ {
+ if (foundName && foundVersion)
+ {
+ return (true);
+ }
+ else
+ {
+ Alerts::DisplayError("Required elements are missing from <platform>.");
+ return (false);
+ }
+ }
}
else
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <platform>"
+ Alerts::DisplayError("Unexpected token found in <platform>.");
return (false);
}
}
@@ -240,7 +266,7 @@ bool FileInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundId)
{
- // TODO: "Found multiple file IDs."
+ Alerts::DisplayError("Found multiple <id> elements in <file>.");
return (false);
}
@@ -252,7 +278,7 @@ bool FileInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundFilename)
{
- // TODO: "Found multiple file filenames."
+ Alerts::DisplayError("Found multiple <filename> elements in <file>.");
return (false);
}
@@ -260,17 +286,32 @@ bool FileInfo::ParseXml(QXmlStreamReader& xml)
filename = xml.readElementText();
}
+ else
+ {
+ Alerts::DisplayError(QString("<%1> is not a valid child of <file>.").arg(xml.name().toString()));
+ return (false);
+ }
}
else if (nextToken == QXmlStreamReader::EndElement)
{
if (xml.name() == "file")
- return (foundId && foundFilename);
+ {
+ if (foundId && foundFilename)
+ {
+ return (true);
+ }
+ else
+ {
+ Alerts::DisplayError("Required elements are missing from <file>.");
+ return (false);
+ }
+ }
}
else
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <file>"
+ Alerts::DisplayError("Unexpected token found in <file>.");
return (false);
}
}
@@ -353,13 +394,13 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (!xml.readNextStartElement())
{
- // TODO: "Failed to find <firmware> element."
+ Alerts::DisplayError("Failed to find <firmware> element.");
return (false);
}
if (xml.name() != "firmware")
{
- // TODO: "Expected <firmware> element but found <%s>"
+ Alerts::DisplayError(QString("Expected <firmware> element but found <%1>.").arg(xml.name().toString()));
return (false);
}
@@ -368,7 +409,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (formatVersionString.isEmpty())
{
- // TODO: <firmware> is missing a version."
+ Alerts::DisplayError("<firmware> is missing the version attribute.");
return (false);
}
@@ -377,13 +418,13 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (!parsedVersion)
{
- // TODO: "<firmware> contains a malformed version."
+ Alerts::DisplayError("<firmware> contains a malformed version.");
return (false);
}
if (formatVersion > kVersion)
{
- // TODO: "Package is for a newer version of Heimdall Frontend. Please download the latest version of Heimdall Frontend."
+ Alerts::DisplayError("Package is for a newer version of Heimdall Frontend.\nPlease download the latest version of Heimdall Frontend.");
return (false);
}
@@ -397,7 +438,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundName)
{
- // TODO: "Found multiple firmware names."
+ Alerts::DisplayError("Found multiple <name> elements in <firmware>.");
return (false);
}
@@ -408,7 +449,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundVersion)
{
- // TODO: "Found multiple firmware versions."
+ Alerts::DisplayError("Found multiple <version> elements in <firmware>.");
return (false);
}
@@ -419,7 +460,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundPlatform)
{
- // TODO: "Found multiple firmware platforms."
+ Alerts::DisplayError("Found multiple <platform> elements in <firmware>.");
return (false);
}
@@ -432,7 +473,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundDevelopers)
{
- // TODO: "Found multiple sets of firmware developers."
+ Alerts::DisplayError("Found multiple <developers> elements in <firmware>.");
return (false);
}
@@ -445,7 +486,14 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (nextToken == QXmlStreamReader::StartElement)
{
if (xml.name() == "name")
+ {
developers.append(xml.readElementText());
+ }
+ else
+ {
+ Alerts::DisplayError(QString("<%1> is not a valid child of <developers>.").arg(xml.name().toString()));
+ return (false);
+ }
}
else if (nextToken == QXmlStreamReader::EndElement)
{
@@ -456,7 +504,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <developers>"
+ Alerts::DisplayError("Unexpected token found in <developers>.");
return (false);
}
}
@@ -466,7 +514,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundUrl)
{
- // TODO: "Found multiple firmware URLs."
+ Alerts::DisplayError("Found multiple <url> elements in <firmware>.");
return (false);
}
@@ -478,7 +526,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundDonateUrl)
{
- // TODO: "Found multiple firmware donate URLs."
+ Alerts::DisplayError("Found multiple <donateurl> elements in <firmware>.");
return (false);
}
@@ -490,7 +538,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundDevices)
{
- // TODO: "Found multiple sets of firmware devices."
+ Alerts::DisplayError("Found multiple <devices> elements in <firmware>.");
return (false);
}
@@ -511,6 +559,11 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
deviceInfos.append(deviceInfo);
}
+ else
+ {
+ Alerts::DisplayError(QString("<%1> is not a valid child of <devices>.").arg(xml.name().toString()));
+ return (false);
+ }
}
else if (nextToken == QXmlStreamReader::EndElement)
{
@@ -521,7 +574,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <devices>"
+ Alerts::DisplayError("Unexpected token found in <devices>.");
return (false);
}
}
@@ -531,7 +584,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundPit)
{
- // TODO: "Found multiple firmware PIT files."
+ Alerts::DisplayError("Found multiple <pit> elements in <firmware>.");
return (false);
}
@@ -543,7 +596,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundRepartition)
{
- // TODO: "Found multiple firmware repartition values."
+ Alerts::DisplayError("Found multiple <repartition> elements in <firmware>.");
return (false);
}
@@ -555,7 +608,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundNoReboot)
{
- // TODO: "Found multiple firmware noreboot values."
+ Alerts::DisplayError("Found multiple <noreboot> elements in <firmware>.");
return (false);
}
@@ -567,7 +620,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (foundFiles)
{
- // TODO: "Found multiple sets of firmware files."
+ Alerts::DisplayError("Found multiple <files> elements in <firmware>.");
return (false);
}
@@ -588,6 +641,11 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
fileInfos.append(fileInfo);
}
+ else
+ {
+ Alerts::DisplayError(QString("<%1> is not a valid child of <files>.").arg(xml.name().toString()));
+ return (false);
+ }
}
else if (nextToken == QXmlStreamReader::EndElement)
{
@@ -598,7 +656,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <devices>"
+ Alerts::DisplayError("Unexpected token found in <devices>.");
return (false);
}
}
@@ -606,7 +664,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
}
else
{
- // TODO: "unknown <firmware> sub-element <" + xml.name() + ">."
+ Alerts::DisplayError(QString("<%1> is not a valid child of <firmware>.").arg(xml.name().toString()));
return (false);
}
}
@@ -615,16 +673,21 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (xml.name() == "firmware")
{
if (!(foundName && foundVersion && foundPlatform && foundDevelopers && foundDevices && foundPit && foundRepartition && foundNoReboot && foundFiles))
+ {
+ Alerts::DisplayError("Required elements are missing from <firmware>.");
return (false);
+ }
else
+ {
break;
+ }
}
}
else
{
if (!(nextToken == QXmlStreamReader::Characters && xml.isWhitespace()))
{
- // TODO: "Unexpected token found in <firmware>"
+ Alerts::DisplayError("Unexpected token found in <firmware>.");
return (false);
}
}
@@ -635,7 +698,7 @@ bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
if (!xml.atEnd())
{
- // TODO: "Found data after </firmware>"
+ Alerts::DisplayError("Found data after </firmware>.");
return (false);
}
diff --git a/heimdall-frontend/Source/FirmwareInfo.h b/heimdall-frontend/Source/FirmwareInfo.h
index 3fd6341..64c73cb 100755
--- a/heimdall-frontend/Source/FirmwareInfo.h
+++ b/heimdall-frontend/Source/FirmwareInfo.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/heimdall-frontend/Source/PackageData.cpp b/heimdall-frontend/Source/PackageData.cpp
index 36138cf..ad25515 100755
--- a/heimdall-frontend/Source/PackageData.cpp
+++ b/heimdall-frontend/Source/PackageData.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,6 +19,7 @@
THE SOFTWARE.*/
// Heimdall Frontend
+#include "Alerts.h"
#include "PackageData.h"
using namespace HeimdallFrontend;
@@ -47,7 +48,7 @@ bool PackageData::ReadFirmwareInfo(QFile *file)
{
if (!file->open(QFile::ReadOnly))
{
- // TODO: Error
+ Alerts::DisplayError(QString("Failed to open file: \1%s").arg(file->fileName()));
return (false);
}
diff --git a/heimdall-frontend/Source/PackageData.h b/heimdall-frontend/Source/PackageData.h
index 9952393..2039a08 100755
--- a/heimdall-frontend/Source/PackageData.h
+++ b/heimdall-frontend/Source/PackageData.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/heimdall-frontend/Source/Packaging.cpp b/heimdall-frontend/Source/Packaging.cpp
index 1034539..8db5dff 100755
--- a/heimdall-frontend/Source/Packaging.cpp
+++ b/heimdall-frontend/Source/Packaging.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -34,6 +34,7 @@
#include <QProgressDialog>
// Heimdall Frontend
+#include "Alerts.h"
#include "Packaging.h"
using namespace HeimdallFrontend;
@@ -46,7 +47,7 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (!tarFile.open())
{
- // TODO: "Error opening temporary TAR archive."
+ Alerts::DisplayError(QString("Error opening temporary TAR archive:\n%1").arg(tarFile.fileName()));
return (false);
}
@@ -62,9 +63,10 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (dataRead != TarHeader::kBlockLength)
{
- // TODO: "Package's TAR archive is malformed."
- tarFile.close();
progressDialog.close();
+ Alerts::DisplayError("Package's TAR archive is malformed.");
+
+ tarFile.close();
return (false);
}
@@ -96,7 +98,6 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (previousEmpty)
{
// Two empty blocks in a row means we've reached the end of the archive.
- // TODO: Make sure we're at the end of the file.
break;
}
}
@@ -128,8 +129,11 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (!parsed)
{
- // TODO: Error message?
+ progressDialog.close();
+ Alerts::DisplayError("Tar header contained an invalid file size.");
+
tarFile.close();
+
return (false);
}
@@ -143,8 +147,11 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (!outputFile->open())
{
- // TODO: "Failed to open output file \"%s\""
+ progressDialog.close();
+ Alerts::DisplayError(QString("Failed to open output file: \n%1").arg(outputFile->fileName()));
+
tarFile.close();
+
return (false);
}
@@ -161,7 +168,9 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
if (dataRead < fileDataToRead || dataRead % TarHeader::kBlockLength != 0)
{
- // TODO: "Unexpected error extracting package files."
+ progressDialog.close();
+ Alerts::DisplayError("Unexpected read error whilst extracting package files.");
+
tarFile.close();
outputFile->close();
@@ -193,8 +202,11 @@ bool Packaging::ExtractTar(QTemporaryFile& tarFile, PackageData *packageData)
}
else
{
- // TODO: "Heimdall packages shouldn't contain links or directories."
+ progressDialog.close();
+ Alerts::DisplayError("Heimdall packages shouldn't contain links or directories.");
+
tarFile.close();
+
return (false);
}
}
@@ -217,13 +229,13 @@ bool Packaging::WriteTarEntry(const QString& filename, QTemporaryFile *tarFile,
if (!file.open(QFile::ReadOnly))
{
- // TODO: "Failed to open \"%s\""
+ Alerts::DisplayError(QString("Failed to open file: \n%1").arg(file.fileName()));
return (false);
}
if (file.size() > TarHeader::kMaxFileSize)
{
- // TODO: "File is too large to packaged"
+ Alerts::DisplayError(QString("File is too large to be packaged:\n%1").arg(file.fileName()));
return (false);
}
@@ -240,7 +252,7 @@ bool Packaging::WriteTarEntry(const QString& filename, QTemporaryFile *tarFile,
if (utfFilename.length() > 100)
{
- // TODO: "Filename is too long"
+ Alerts::DisplayError(QString("File name is too long:\n%1").arg(qtFileInfo.fileName()));
return (false);
}
}
@@ -321,7 +333,7 @@ bool Packaging::WriteTarEntry(const QString& filename, QTemporaryFile *tarFile,
if (tarFile->write(buffer, dataRead) != dataRead)
{
- // TODO: "Failed to write data to the temporary TAR file."
+ Alerts::DisplayError("Failed to write data to the temporary TAR file.");
return (false);
}
@@ -332,7 +344,7 @@ bool Packaging::WriteTarEntry(const QString& filename, QTemporaryFile *tarFile,
if (tarFile->write(buffer, remainingBlockLength) != remainingBlockLength)
{
- // TODO: "Failed to write data to the temporary TAR file."
+ Alerts::DisplayError("Failed to write data to the temporary TAR file.");
return (false);
}
}
@@ -355,17 +367,20 @@ bool Packaging::CreateTar(const FirmwareInfo& firmwareInfo, QTemporaryFile *tarF
if (!firmwareXmlFile.open())
{
- // TODO: "Failed to create temporary file "%s"
+ progressDialog.close();
+ Alerts::DisplayError(QString("Failed to create temporary file: \n%1").arg(firmwareXmlFile.fileName()));
+
return (false);
}
firmwareInfo.WriteXml(QXmlStreamWriter(&firmwareXmlFile));
-
firmwareXmlFile.close();
if (!tarFile->open())
{
- // TODO: "Failed to open \"%s\""
+ progressDialog.close();
+ Alerts::DisplayError(QString("Failed to open file: \n%1").arg(tarFile->fileName()));
+
return (false);
}
@@ -443,7 +458,7 @@ bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageD
if (fopen == NULL)
{
- // TODO: "Failed to open package \"%s\"."
+ Alerts::DisplayError(QString("Failed to open package:\n%1").arg(packagePath));
return (false);
}
@@ -457,7 +472,7 @@ bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageD
if (!outputTar.open())
{
- // TODO: "Error opening temporary TAR archive."
+ Alerts::DisplayError("Failed to open temporary TAR archive.");
gzclose(packageFile);
return (false);
@@ -477,9 +492,10 @@ bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageD
if (bytesRead == -1)
{
- // TODO: "Error decompressing archive."
- gzclose(packageFile);
progressDialog.close();
+ Alerts::DisplayError("Error decompressing archive.");
+
+ gzclose(packageFile);
return (false);
}
@@ -523,6 +539,7 @@ bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageD
}
}
+ Alerts::DisplayError("firmware.xml is missing from the package.");
return (false);
}
@@ -532,7 +549,7 @@ bool Packaging::BuildPackage(const QString& packagePath, const FirmwareInfo& fir
if (fopen == NULL)
{
- // TODO: "Failed to open package "%s"
+ Alerts::DisplayError(QString("Failed to create package:\n%1").arg(packagePath));
return (false);
}
@@ -543,9 +560,11 @@ bool Packaging::BuildPackage(const QString& packagePath, const FirmwareInfo& fir
if (!tar.open())
{
- // TODO: "Failed to open temporary file "%s"
+ Alerts::DisplayError(QString("Failed to open temporary file: \n%1").arg(tar.fileName()));
+
fclose(compressedPackageFile);
remove(packagePath.toStdString().c_str());
+
return (false);
}
@@ -565,23 +584,23 @@ bool Packaging::BuildPackage(const QString& packagePath, const FirmwareInfo& fir
if (bytesRead == -1)
{
- // TODO: "Error reading temporary TAR file."
+ progressDialog.close();
+ Alerts::DisplayError("Error reading temporary TAR file.");
+
gzclose(packageFile);
remove(packagePath.toStdString().c_str());
- progressDialog.close();
-
return (false);
}
if (gzwrite(packageFile, buffer, bytesRead) != bytesRead)
{
- // TODO: "Error compressing package."
+ progressDialog.close();
+ Alerts::DisplayError("Error compressing package.");
+
gzclose(packageFile);
remove(packagePath.toStdString().c_str());
- progressDialog.close();
-
return (false);
}
diff --git a/heimdall-frontend/Source/Packaging.h b/heimdall-frontend/Source/Packaging.h
index 97637de..b02637a 100755
--- a/heimdall-frontend/Source/Packaging.h
+++ b/heimdall-frontend/Source/Packaging.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -100,7 +100,7 @@ namespace HeimdallFrontend
kCompressBufferLength = 262144
};
- // TODO: Add support for sparse files to both methods.
+ // TODO: Add support for sparse files to both methods?
static bool ExtractTar(QTemporaryFile& tarFile, PackageData *packageData);
static bool WriteTarEntry(const QString& filename, QTemporaryFile *tarFile, bool firmwareXml = false);
diff --git a/heimdall-frontend/Source/aboutform.cpp b/heimdall-frontend/Source/aboutform.cpp
index 08b8a3e..857ecab 100644
--- a/heimdall-frontend/Source/aboutform.cpp
+++ b/heimdall-frontend/Source/aboutform.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/heimdall-frontend/Source/aboutform.h b/heimdall-frontend/Source/aboutform.h
index 7e29136..879df86 100644
--- a/heimdall-frontend/Source/aboutform.h
+++ b/heimdall-frontend/Source/aboutform.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/heimdall-frontend/Source/main.cpp b/heimdall-frontend/Source/main.cpp
index 9db00f5..7833666 100644
--- a/heimdall-frontend/Source/main.cpp
+++ b/heimdall-frontend/Source/main.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/heimdall-frontend/Source/mainwindow.cpp b/heimdall-frontend/Source/mainwindow.cpp
index b44c3de..f5880f9 100644
--- a/heimdall-frontend/Source/mainwindow.cpp
+++ b/heimdall-frontend/Source/mainwindow.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -28,6 +28,7 @@
#include <QUrl>
// Heimdall Frontend
+#include "Alerts.h"
#include "mainwindow.h"
#include "Packaging.h"
@@ -250,9 +251,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
populatingPartitionNames = false;
+ verboseOutput = false;
+
functionTabWidget->setTabEnabled(functionTabWidget->indexOf(createPackageTab), false);
QObject::connect(actionDonate, SIGNAL(triggered()), this, SLOT(OpenDonationWebpage()));
+ QObject::connect(actionVerboseOutput, SIGNAL(toggled(bool)), this, SLOT(SetVerboseOutput(bool)));
QObject::connect(actionAboutHeimdall, SIGNAL(triggered()), this, SLOT(ShowAbout()));
QObject::connect(browseFirmwarePackageButton, SIGNAL(clicked()), this, SLOT(SelectFirmwarePackage()));
@@ -310,6 +314,11 @@ void MainWindow::OpenDonationWebpage(void)
QDesktopServices::openUrl(QUrl("http://www.glassechidna.com.au/donate/", QUrl::StrictMode));
}
+void MainWindow::SetVerboseOutput(bool enabled)
+{
+ verboseOutput = enabled;
+}
+
void MainWindow::ShowAbout(void)
{
aboutForm.show();
@@ -326,14 +335,9 @@ void MainWindow::SelectFirmwarePackage(void)
if (firmwarePackageLineEdit->text() != "")
{
if (Packaging::ExtractPackage(firmwarePackageLineEdit->text(), &loadedPackageData))
- {
UpdatePackageUserInterface();
- }
else
- {
- // TODO: Error?
loadedPackageData.Clear();
- }
}
}
@@ -360,6 +364,8 @@ void MainWindow::LoadFirmwarePackage(void)
for (int i = 0; i < packageFileInfos.length(); i++)
{
+ bool fileFound = false;
+
for (int j = 0; j < workingPackageData.GetFiles().length(); j++)
{
if (workingPackageData.GetFiles()[j]->fileTemplate() == ("XXXXXX-" + packageFileInfos[i].GetFilename()))
@@ -367,9 +373,13 @@ void MainWindow::LoadFirmwarePackage(void)
FileInfo partitionInfo(packageFileInfos[i].GetPartitionId(), QDir::current().absoluteFilePath(workingPackageData.GetFiles()[j]->fileName()));
workingPackageData.GetFirmwareInfo().GetFileInfos().append(partitionInfo);
+ fileFound = true;
break;
}
}
+
+ if (!fileFound)
+ Alerts::DisplayWarning(QString("%1 is missing from the package.").arg(packageFileInfos[i].GetFilename()));
}
// Find the PIT file and read it
@@ -383,7 +393,8 @@ void MainWindow::LoadFirmwarePackage(void)
if (!ReadPit(file))
{
- // TODO: Error
+ Alerts::DisplayError("Failed to read PIT file.");
+
loadedPackageData.Clear();
UpdatePackageUserInterface();
@@ -419,7 +430,8 @@ void MainWindow::LoadFirmwarePackage(void)
}
else
{
- // TODO: "Firmware package includes invalid partition IDs."
+ Alerts::DisplayError("Firmware package includes invalid partition IDs.");
+
loadedPackageData.GetFirmwareInfo().Clear();
currentPitData.Clear();
UpdateUnusedPartitionIds();
@@ -549,18 +561,18 @@ void MainWindow::SelectPit(void)
QString path = PromptFileSelection();
bool validPit = path != "";
- // In order to map files in the old PIT to file in the new one, we first must use partition names instead of IDs.
- QList<FileInfo> fileInfos = workingPackageData.GetFirmwareInfo().GetFileInfos();
+ if (validPit)
+ {
+ // In order to map files in the old PIT to file in the new one, we first must use partition names instead of IDs.
+ QList<FileInfo> fileInfos = workingPackageData.GetFirmwareInfo().GetFileInfos();
- int partitionNamesCount = fileInfos.length();
- QString *partitionNames = new QString[fileInfos.length()];
- for (int i = 0; i < fileInfos.length(); i++)
- partitionNames[i] = currentPitData.FindEntry(fileInfos[i].GetPartitionId())->GetPartitionName();
+ int partitionNamesCount = fileInfos.length();
+ QString *partitionNames = new QString[fileInfos.length()];
+ for (int i = 0; i < fileInfos.length(); i++)
+ partitionNames[i] = currentPitData.FindEntry(fileInfos[i].GetPartitionId())->GetPartitionName();
- currentPitData.Clear();
+ currentPitData.Clear();
- if (validPit)
- {
QFile pitFile(path);
if (ReadPit(&pitFile))
@@ -589,40 +601,45 @@ void MainWindow::SelectPit(void)
{
validPit = false;
}
- }
-
- // If the selected PIT was invalid, attempt to reload the old one.
- if (!validPit)
- {
- // TODO: "The file selected was not a valid PIT file."
- QFile originalPitFile(workingPackageData.GetFirmwareInfo().GetPitFilename());
- if (ReadPit(&originalPitFile))
+ // If the selected PIT was invalid, attempt to reload the old one.
+ if (!validPit)
{
- validPit = true;
- }
- else
- {
- // TODO: "Failed to reload working PIT data."
- workingPackageData.Clear();
- partitionsListWidget->clear();
+ Alerts::DisplayError("The file selected was not a valid PIT file.");
+
+ if (!workingPackageData.GetFirmwareInfo().GetPitFilename().isEmpty())
+ {
+ QFile originalPitFile(workingPackageData.GetFirmwareInfo().GetPitFilename());
+
+ if (ReadPit(&originalPitFile))
+ {
+ validPit = true;
+ }
+ else
+ {
+ Alerts::DisplayError("Failed to reload working PIT data.");
+
+ workingPackageData.Clear();
+ partitionsListWidget->clear();
+ }
+ }
}
- }
- UpdateUnusedPartitionIds();
+ UpdateUnusedPartitionIds();
- delete [] partitionNames;
+ delete [] partitionNames;
- pitLineEdit->setText(workingPackageData.GetFirmwareInfo().GetPitFilename());
+ pitLineEdit->setText(workingPackageData.GetFirmwareInfo().GetPitFilename());
- repartitionCheckBox->setEnabled(validPit);
- noRebootCheckBox->setEnabled(validPit);
- partitionsListWidget->setEnabled(validPit);
+ repartitionCheckBox->setEnabled(validPit);
+ noRebootCheckBox->setEnabled(validPit);
+ partitionsListWidget->setEnabled(validPit);
- addPartitionButton->setEnabled(validPit);
- removePartitionButton->setEnabled(validPit && partitionsListWidget->currentRow() >= 0);
+ addPartitionButton->setEnabled(validPit);
+ removePartitionButton->setEnabled(validPit && partitionsListWidget->currentRow() >= 0);
- UpdateStartButton();
+ UpdateStartButton();
+ }
}
void MainWindow::SetRepartition(int enabled)
@@ -665,6 +682,11 @@ void MainWindow::StartFlash(void)
if (firmwareInfo.GetNoReboot())
arguments.append("--no-reboot");
+ if (verboseOutput)
+ arguments.append("--verbose");
+
+ arguments.append("--stdout-errors");
+
flashProgressBar->setEnabled(true);
UpdateStartButton();
@@ -895,15 +917,12 @@ void MainWindow::HandleHeimdallReturned(int exitCode, QProcess::ExitStatus exitS
{
QString error = process.readAllStandardError();
- outputPlainTextEdit->insertPlainText(error);
- outputPlainTextEdit->ensureCursorVisible();
-
- int firstNewLineChar = error.indexOf('\n');
+ int lastNewLineChar = error.lastIndexOf('\n');
- if (firstNewLineChar == 0)
- error = error.mid(1);
+ if (lastNewLineChar == 0)
+ error = error.mid(1).remove("ERROR: ");
else
- error = error.left(firstNewLineChar);
+ error = error.left(lastNewLineChar).remove("ERROR: ");
flashLabel->setText(error);
}
diff --git a/heimdall-frontend/Source/mainwindow.h b/heimdall-frontend/Source/mainwindow.h
index 6e16596..b041dab 100644
--- a/heimdall-frontend/Source/mainwindow.h
+++ b/heimdall-frontend/Source/mainwindow.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Benjamin Dobell, Glass Echidna
+/* Copyright (c) 2010-2011 Benjamin Dobell, Glass Echidna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -61,6 +61,8 @@ namespace HeimdallFrontend
bool populatingPartitionNames;
QList<unsigned int> unusedPartitionIds;
+ bool verboseOutput;
+
void UpdateUnusedPartitionIds(void);
bool ReadPit(QFile *file);
@@ -84,6 +86,7 @@ namespace HeimdallFrontend
public slots:
void OpenDonationWebpage(void);
+ void SetVerboseOutput(bool enabled);
void ShowAbout(void);
void SelectFirmwarePackage(void);
diff --git a/heimdall-frontend/heimdall-frontend.vcxproj b/heimdall-frontend/heimdall-frontend.vcxproj
index 6844d0a..bc1112a 100644
--- a/heimdall-frontend/heimdall-frontend.vcxproj
+++ b/heimdall-frontend/heimdall-frontend.vcxproj
@@ -151,6 +151,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release - Static MSVC|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Source\aboutform.cpp" />
+ <ClCompile Include="Source\Alerts.cpp" />
<ClCompile Include="Source\FirmwareInfo.cpp" />
<ClCompile Include="Source\main.cpp" />
<ClCompile Include="Source\mainwindow.cpp" />
@@ -178,6 +179,7 @@
<ClInclude Include="GeneratedFiles\ui_aboutform.h" />
<ClInclude Include="GeneratedFiles\ui_mainwindow.h" />
<ClInclude Include="Source\aboutform.h" />
+ <ClInclude Include="Source\Alerts.h" />
<ClInclude Include="Source\FirmwareInfo.h" />
<ClInclude Include="Source\PackageData.h" />
<ClInclude Include="Source\Packaging.h" />
diff --git a/heimdall-frontend/heimdall-frontend.vcxproj.filters b/heimdall-frontend/heimdall-frontend.vcxproj.filters
index d1c227e..e8006c1 100644
--- a/heimdall-frontend/heimdall-frontend.vcxproj.filters
+++ b/heimdall-frontend/heimdall-frontend.vcxproj.filters
@@ -58,6 +58,9 @@
<ClCompile Include="Source\FirmwareInfo.cpp">
<Filter>Source</Filter>
</ClCompile>
+ <ClCompile Include="Source\Alerts.cpp">
+ <Filter>Source</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="mainwindow.ui">
@@ -92,5 +95,8 @@
<ClInclude Include="Source\FirmwareInfo.h">
<Filter>Source</Filter>
</ClInclude>
+ <ClInclude Include="Source\Alerts.h">
+ <Filter>Source</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/heimdall-frontend/mainwindow.ui b/heimdall-frontend/mainwindow.ui
index 020c761..4ab96a9 100644
--- a/heimdall-frontend/mainwindow.ui
+++ b/heimdall-frontend/mainwindow.ui
@@ -114,7 +114,7 @@
</rect>
</property>
<property name="title">
- <string>Included Files</string>
+ <string>Package Files</string>
</property>
<widget class="QListWidget" name="includedFilesListWidget">
<property name="geometry">
@@ -1223,7 +1223,14 @@
</property>
<addaction name="actionDonate"/>
</widget>
+ <widget class="QMenu" name="menuAdvanced">
+ <property name="title">
+ <string>Advanced</string>
+ </property>
+ <addaction name="actionVerboseOutput"/>
+ </widget>
<addaction name="menuDonate"/>
+ <addaction name="menuAdvanced"/>
<addaction name="menuHelp"/>
</widget>
<action name="actionHelp">
@@ -1246,6 +1253,14 @@
<string>Package Creation</string>
</property>
</action>
+ <action name="actionVerboseOutput">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Verbose Output</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>