summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell@glassechidna.com.au>2011-07-08 15:40:28 +0200
committerBenjamin Dobell <benjamin.dobell@glassechidna.com.au>2011-07-08 15:40:28 +0200
commit70c1e8e5bae373c4660e460703b577336caac8b0 (patch)
treebc3ae1734140887102e897ad4b57c0add392e66f
parentVersion 1.3 beta. (diff)
downloadHeimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar.gz
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar.bz2
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar.lz
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar.xz
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.tar.zst
Heimdall-70c1e8e5bae373c4660e460703b577336caac8b0.zip
-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
-rw-r--r--heimdall/source/BeginDumpPacket.h2
-rw-r--r--heimdall/source/BridgeManager.cpp148
-rw-r--r--heimdall/source/BridgeManager.h2
-rw-r--r--heimdall/source/ControlPacket.h2
-rw-r--r--heimdall/source/DeviceInfoPacket.h2
-rw-r--r--heimdall/source/DeviceInfoResponse.h2
-rw-r--r--heimdall/source/DumpPartFileTransferPacket.h2
-rw-r--r--heimdall/source/DumpPartPitFilePacket.h2
-rw-r--r--heimdall/source/DumpResponse.h2
-rw-r--r--heimdall/source/EndFileTransferPacket.h2
-rw-r--r--heimdall/source/EndModemFileTransferPacket.h2
-rw-r--r--heimdall/source/EndPhoneFileTransferPacket.h2
-rw-r--r--heimdall/source/EndSessionPacket.h2
-rw-r--r--heimdall/source/FileTransferPacket.h2
-rw-r--r--heimdall/source/FlashPartFileTransferPacket.h2
-rw-r--r--heimdall/source/FlashPartPitFilePacket.h2
-rw-r--r--heimdall/source/Heimdall.h2
-rw-r--r--heimdall/source/InboundPacket.h2
-rw-r--r--heimdall/source/Interface.cpp80
-rw-r--r--heimdall/source/Interface.h13
-rw-r--r--heimdall/source/OutboundPacket.h2
-rw-r--r--heimdall/source/Packet.h2
-rw-r--r--heimdall/source/PitFilePacket.h2
-rw-r--r--heimdall/source/PitFileResponse.h2
-rw-r--r--heimdall/source/ReceiveFilePartPacket.h2
-rw-r--r--heimdall/source/ResponsePacket.h2
-rw-r--r--heimdall/source/SendFilePartPacket.h2
-rw-r--r--heimdall/source/SendFilePartResponse.h2
-rw-r--r--heimdall/source/main.cpp14
-rwxr-xr-xlibpit/Source/libpit.cpp2
-rwxr-xr-xlibpit/Source/libpit.h2
47 files changed, 522 insertions, 248 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>
diff --git a/heimdall/source/BeginDumpPacket.h b/heimdall/source/BeginDumpPacket.h
index 4bd6d88..8de4002 100644
--- a/heimdall/source/BeginDumpPacket.h
+++ b/heimdall/source/BeginDumpPacket.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/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index ef5faa6..af968a9 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.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
@@ -116,7 +116,7 @@ bool BridgeManager::DetectDevice(void)
int result = libusb_init(&libusbContext);
if (result != LIBUSB_SUCCESS)
{
- Interface::PrintError("Failed to initialise libusb. Error: %d\n", result);
+ Interface::PrintError("Failed to initialise libusb. libusb error: %d\n", result);
return (false);
}
@@ -135,7 +135,7 @@ bool BridgeManager::DetectDevice(void)
{
libusb_free_device_list(devices, deviceCount);
- Interface::Print("Device detected");
+ Interface::Print("Device detected\n");
return (true);
}
}
@@ -149,14 +149,19 @@ bool BridgeManager::DetectDevice(void)
bool BridgeManager::Initialise(void)
{
+ Interface::Print("Initialising connection...\n");
+
// Initialise libusb-1.0
int result = libusb_init(&libusbContext);
if (result != LIBUSB_SUCCESS)
{
- Interface::PrintError("Failed to initialise libusb. Error: %d\n", result);
+ Interface::PrintError("Failed to initialise libusb. libusb error: %d\n", result);
+ Interface::Print("Failed to connect to device!");
return (false);
}
+ Interface::Print("Detecting device...\n");
+
// Get handle to Galaxy S device
struct libusb_device **devices;
int deviceCount = libusb_get_device_list(libusbContext, &devices);
@@ -184,14 +189,14 @@ bool BridgeManager::Initialise(void)
if (!heimdallDevice)
{
- Interface::PrintError("Failed to detect compatible device\n");
+ Interface::PrintError("Failed to detect device!\n");
return (false);
}
result = libusb_open(heimdallDevice, &deviceHandle);
if (result != LIBUSB_SUCCESS)
{
- Interface::PrintError("Failed to access device. Error: %d\n", result);
+ Interface::PrintError("Failed to access device. libusb error: %d\n", result);
return (false);
}
@@ -264,8 +269,7 @@ bool BridgeManager::Initialise(void)
for (int k = 0; k < configDescriptor->usb_interface[i].altsetting[j].bNumEndpoints; k++)
{
- const libusb_endpoint_descriptor *endpoint =
- &configDescriptor->usb_interface[i].altsetting[j].endpoint[k];
+ const libusb_endpoint_descriptor *endpoint = &configDescriptor->usb_interface[i].altsetting[j].endpoint[k];
if (verbose)
{
@@ -280,8 +284,7 @@ bool BridgeManager::Initialise(void)
outEndpointAddress = endpoint->bEndpointAddress;
}
- if (interfaceIndex < 0
- && configDescriptor->usb_interface[i].altsetting[j].bNumEndpoints == 2
+ if (interfaceIndex < 0 && configDescriptor->usb_interface[i].altsetting[j].bNumEndpoints == 2
&& configDescriptor->usb_interface[i].altsetting[j].bInterfaceClass == CLASS_CDC
&& inEndpointAddress != -1 && outEndpointAddress != -1)
{
@@ -301,7 +304,7 @@ bool BridgeManager::Initialise(void)
return (false);
}
- Interface::Print("\nClaiming interface...");
+ Interface::Print("Claiming interface...\n");
result = libusb_claim_interface(deviceHandle, interfaceIndex);
#ifdef OS_LINUX
@@ -309,9 +312,9 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
detachedDriver = true;
- Interface::Print(" Failed. Attempting to detach driver...\n");
+ Interface::Print("Attempt failed. Detaching driver...\n");
libusb_detach_kernel_driver(deviceHandle, interfaceIndex);
- Interface::Print("Claiming interface again...");
+ Interface::Print("Claiming interface again...\n");
result = libusb_claim_interface(deviceHandle, interfaceIndex);
}
@@ -319,21 +322,20 @@ bool BridgeManager::Initialise(void)
if (result != LIBUSB_SUCCESS)
{
- Interface::PrintError(" Failed!\n");
+ Interface::PrintError("Claiming interface failed!\n");
return (false);
}
- Interface::Print(" Success\n");
-
- Interface::Print("Setting up interface...");
+ Interface::Print("Setting up interface...\n");
result = libusb_set_interface_alt_setting(deviceHandle, interfaceIndex, altSettingIndex);
+
if (result != LIBUSB_SUCCESS)
{
- Interface::PrintError(" Failed!\n");
+ Interface::PrintError("Setting up interface failed!\n");
return (false);
}
- Interface::Print(" Success\n");
+ Interface::Print("\n");
return (true);
}
@@ -348,7 +350,8 @@ bool BridgeManager::BeginSession(void) const
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
@@ -361,7 +364,8 @@ bool BridgeManager::BeginSession(void) const
result = libusb_control_transfer(deviceHandle, LIBUSB_REQUEST_TYPE_CLASS, 0x20, 0x0, 0, dataBuffer, 7, 1000);
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
@@ -369,7 +373,8 @@ bool BridgeManager::BeginSession(void) const
result = libusb_control_transfer(deviceHandle, LIBUSB_REQUEST_TYPE_CLASS, 0x22, 0x3, 0, nullptr, 0, 1000);
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
@@ -377,7 +382,8 @@ bool BridgeManager::BeginSession(void) const
result = libusb_control_transfer(deviceHandle, LIBUSB_REQUEST_TYPE_CLASS, 0x22, 0x2, 0, nullptr, 0, 1000);
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
@@ -390,7 +396,8 @@ bool BridgeManager::BeginSession(void) const
result = libusb_control_transfer(deviceHandle, LIBUSB_REQUEST_TYPE_CLASS, 0x20, 0x0, 0, dataBuffer, 7, 1000);
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
@@ -398,12 +405,13 @@ bool BridgeManager::BeginSession(void) const
result = libusb_control_transfer(deviceHandle, LIBUSB_REQUEST_TYPE_CLASS, 0x22, 0x2, 0, nullptr, 0, 1000);
if (result < 0)
{
- Interface::PrintError("Failed to initialise usb communication!\n");
+ Interface::PrintError("Failed to begin session!\n");
+
delete [] dataBuffer;
return (false);
}
- Interface::Print("Handshaking with Loke...");
+ Interface::Print("Handshaking with Loke...\n");
int dataTransferred;
@@ -413,10 +421,10 @@ bool BridgeManager::BeginSession(void) const
result = libusb_bulk_transfer(deviceHandle, outEndpoint, dataBuffer, 4, &dataTransferred, 1000);
if (result < 0)
{
- Interface::PrintError(" Failed!\n");
-
if (verbose)
- Interface::PrintError("ERROR: Failed to send data: \"%s\"\n", dataBuffer);
+ Interface::PrintError("Failed to send data: \"%s\"\n", dataBuffer);
+ else
+ Interface::PrintError("Failed to send data!");
delete [] dataBuffer;
return (false);
@@ -424,10 +432,10 @@ bool BridgeManager::BeginSession(void) const
if (dataTransferred != 4)
{
- Interface::PrintError(" Failed!\n");
-
if (verbose)
- Interface::PrintError("ERROR: Failed to complete sending data: \"%s\"\n", dataBuffer);
+ Interface::PrintError("Failed to complete sending of data: \"%s\"\n", dataBuffer);
+ else
+ Interface::PrintError("Failed to complete sending of data!");
delete [] dataBuffer;
return (false);
@@ -439,26 +447,27 @@ bool BridgeManager::BeginSession(void) const
result = libusb_bulk_transfer(deviceHandle, inEndpoint, dataBuffer, 7, &dataTransferred, 1000);
if (result < 0)
{
- Interface::PrintError(" Failed!\n");
+ Interface::PrintError("Failed to receive response!\n");
- if (verbose)
- Interface::PrintError("ERROR: Failed to receive response\n");
delete [] dataBuffer;
return (false);;
}
if (dataTransferred != 4 || memcmp(dataBuffer, "LOKE", 4) != 0)
{
- Interface::PrintError(" Failed!\n");
+ Interface::PrintError("Unexpected communication!\n");
if (verbose)
- Interface::PrintError("ERROR: Unexpected communication.\nExpected: \"%s\"\nReceived: \"%s\"\n", "LOKE", dataBuffer);
+ Interface::PrintError("Expected: \"%s\"\nReceived: \"%s\"\n", "LOKE", dataBuffer);
+
+ Interface::PrintError("Handshake failed!\n");
delete [] dataBuffer;
return (false);
}
- Interface::Print(" Success\n\n");
+ Interface::Print("\n");
+
return (true);
}
@@ -473,6 +482,7 @@ bool BridgeManager::EndSession(bool reboot) const
if (!success)
{
Interface::PrintError("Failed to send end session packet!\n");
+
return (false);
}
@@ -483,6 +493,7 @@ bool BridgeManager::EndSession(bool reboot) const
if (!success)
{
Interface::PrintError("Failed to receive session end confirmation!\n");
+
return (false);
}
@@ -497,6 +508,7 @@ bool BridgeManager::EndSession(bool reboot) const
if (!success)
{
Interface::PrintError("Failed to send reboot device packet!\n");
+
return (false);
}
@@ -507,6 +519,7 @@ bool BridgeManager::EndSession(bool reboot) const
if (!success)
{
Interface::PrintError("Failed to receive reboot confirmation!\n");
+
return (false);
}
}
@@ -528,13 +541,13 @@ bool BridgeManager::SendPacket(OutboundPacket *packet, int timeout) const
int retryDelay = (communicationDelay > 250) ? communicationDelay : 250;
if (verbose)
- Interface::PrintError("Error %d whilst sending packet. ", result);
+ Interface::PrintError("libusb error %d whilst sending packet.", result);
// Retry
for (int i = 0; i < 5; i++)
{
if (verbose)
- Interface::PrintError(" Retrying...\n");
+ Interface::PrintErrorSameLine(" Retrying...\n");
// Wait longer each retry
Sleep(retryDelay * (i + 1));
@@ -546,11 +559,11 @@ bool BridgeManager::SendPacket(OutboundPacket *packet, int timeout) const
break;
if (verbose)
- Interface::PrintError("Error %d whilst sending packet. ", result);
+ Interface::PrintError("libusb error %d whilst sending packet.", result);
}
if (verbose)
- Interface::PrintError("\n");
+ Interface::PrintErrorSameLine("\n");
}
if (communicationDelay != 0)
@@ -574,13 +587,13 @@ bool BridgeManager::ReceivePacket(InboundPacket *packet, int timeout) const
int retryDelay = (communicationDelay > 250) ? communicationDelay : 250;
if (verbose)
- Interface::PrintError("Error %d whilst receiving packet. ", result);
+ Interface::PrintError("libusb error %d whilst receiving packet.", result);
// Retry
for (int i = 0; i < 5; i++)
{
if (verbose)
- Interface::PrintError(" Retrying\n");
+ Interface::PrintErrorSameLine(" Retrying...\n");
// Wait longer each retry
Sleep(retryDelay * (i + 1));
@@ -592,7 +605,7 @@ bool BridgeManager::ReceivePacket(InboundPacket *packet, int timeout) const
break;
if (verbose)
- Interface::PrintError("Error %d whilst receiving packet. ", result);
+ Interface::PrintError("libusb error %d whilst receiving packet.", result);
if (i >= 3)
{
@@ -602,7 +615,7 @@ bool BridgeManager::ReceivePacket(InboundPacket *packet, int timeout) const
}
if (verbose)
- Interface::PrintError("\n");
+ Interface::PrintErrorSameLine("\n");
}
if (communicationDelay != 0)
@@ -623,7 +636,11 @@ bool BridgeManager::RequestDeviceInfo(unsigned int request, int *result) const
if (!success)
{
- Interface::PrintError("Failed to request device info packet!\nFailed Request: %d\n");
+ Interface::PrintError("Failed to request device info packet!\n");
+
+ if (verbose)
+ Interface::PrintError("Failed request: %u\n", request);
+
return (false);
}
@@ -647,7 +664,7 @@ bool BridgeManager::SendPitFile(FILE *file) const
if (!success)
{
- Interface::PrintError("Failed to request sending of PIT file!\n");
+ Interface::PrintError("Failed to initialise PIT file transfer!\n");
return (false);
}
@@ -657,7 +674,7 @@ bool BridgeManager::SendPitFile(FILE *file) const
if (!success)
{
- Interface::PrintError("Failed to confirm sending of PIT file!\n");
+ Interface::PrintError("Failed to confirm transfer initialisation!\n");
return (false);
}
@@ -804,13 +821,13 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
{
if (destination != EndFileTransferPacket::kDestinationModem && destination != EndFileTransferPacket::kDestinationPhone)
{
- Interface::PrintError("ERROR: Attempted to send file to unknown destination!\n");
+ Interface::PrintError("Attempted to send file to unknown destination!\n");
return (false);
}
if (destination == EndFileTransferPacket::kDestinationModem && fileIdentifier != -1)
{
- Interface::PrintError("ERROR: The modem file does not have an identifier!\n");
+ Interface::PrintError("The modem file does not have an identifier!\n");
return (false);
}
@@ -820,7 +837,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("Failed to initialise transfer!\n");
+ Interface::PrintError("Failed to initialise file transfer!\n");
return (false);
}
@@ -868,7 +885,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to begin file transfer sequence!\n");
+ Interface::PrintError("\nERROR: Failed to begin file transfer sequence!\n");
return (false);
}
@@ -878,7 +895,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to confirm beginning of file transfer sequence!\n");
+ Interface::PrintError("\nERROR: Failed to confirm beginning of file transfer sequence!\n");
return (false);
}
@@ -894,7 +911,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to send file part packet!\n");
+ Interface::PrintError("\nERROR: Failed to send file part packet!\n");
return (false);
}
@@ -914,11 +931,11 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to receive file part response!\n");
+ Interface::PrintError("\nERROR: Failed to receive file part response!\n");
for (int retry = 0; retry < 4; retry++)
{
- Interface::PrintError("\nRetrying...");
+ Interface::PrintError("\nERROR: Retrying...");
// Send
sendFilePartPacket = new SendFilePartPacket(file);
@@ -927,7 +944,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to send file part packet!\n");
+ Interface::PrintError("\nERROR: Failed to send file part packet!\n");
return (false);
}
@@ -973,15 +990,20 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
currentPercent = (int)(100.0f * ((float)bytesTransferred / (float)fileSize));
- if (!verbose)
+
+ if (currentPercent != previousPercent)
{
- if (currentPercent != previousPercent)
+ if (!verbose)
{
if (previousPercent < 10)
Interface::Print("\b\b%d%%", currentPercent);
else
Interface::Print("\b\b\b%d%%", currentPercent);
}
+ else
+ {
+ Interface::Print("\n%d%%\n", currentPercent);
+ }
}
previousPercent = currentPercent;
@@ -999,7 +1021,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to end phone file transfer sequence!\n");
+ Interface::PrintError("\nERROR: Failed to end phone file transfer sequence!\n");
return (false);
}
}
@@ -1013,7 +1035,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to end modem file transfer sequence!\n");
+ Interface::PrintError("\nERROR: Failed to end modem file transfer sequence!\n");
return (false);
}
}
@@ -1024,7 +1046,7 @@ bool BridgeManager::SendFile(FILE *file, int destination, int fileIdentifier) co
if (!success)
{
- Interface::PrintError("\nFailed to confirm end of file transfer sequence!\n");
+ Interface::PrintError("\nERROR: Failed to confirm end of file transfer sequence!\n");
return (false);
}
}
diff --git a/heimdall/source/BridgeManager.h b/heimdall/source/BridgeManager.h
index c28cd9c..b488ea6 100644
--- a/heimdall/source/BridgeManager.h
+++ b/heimdall/source/BridgeManager.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/source/ControlPacket.h b/heimdall/source/ControlPacket.h
index 019513e..f003654 100644
--- a/heimdall/source/ControlPacket.h
+++ b/heimdall/source/ControlPacket.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/source/DeviceInfoPacket.h b/heimdall/source/DeviceInfoPacket.h
index 153cdc5..9ec1be3 100644
--- a/heimdall/source/DeviceInfoPacket.h
+++ b/heimdall/source/DeviceInfoPacket.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/source/DeviceInfoResponse.h b/heimdall/source/DeviceInfoResponse.h
index 3bf2d8f..11a0404 100644
--- a/heimdall/source/DeviceInfoResponse.h
+++ b/heimdall/source/DeviceInfoResponse.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/source/DumpPartFileTransferPacket.h b/heimdall/source/DumpPartFileTransferPacket.h
index 60fb8c5..0e8bc7c 100644
--- a/heimdall/source/DumpPartFileTransferPacket.h
+++ b/heimdall/source/DumpPartFileTransferPacket.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/source/DumpPartPitFilePacket.h b/heimdall/source/DumpPartPitFilePacket.h
index 29025c2..39e41db 100644
--- a/heimdall/source/DumpPartPitFilePacket.h
+++ b/heimdall/source/DumpPartPitFilePacket.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/source/DumpResponse.h b/heimdall/source/DumpResponse.h
index 126982a..639c67f 100644
--- a/heimdall/source/DumpResponse.h
+++ b/heimdall/source/DumpResponse.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/source/EndFileTransferPacket.h b/heimdall/source/EndFileTransferPacket.h
index 3f3d689..a67eeaa 100644
--- a/heimdall/source/EndFileTransferPacket.h
+++ b/heimdall/source/EndFileTransferPacket.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/source/EndModemFileTransferPacket.h b/heimdall/source/EndModemFileTransferPacket.h
index 9dc4c78..f4f4d56 100644
--- a/heimdall/source/EndModemFileTransferPacket.h
+++ b/heimdall/source/EndModemFileTransferPacket.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/source/EndPhoneFileTransferPacket.h b/heimdall/source/EndPhoneFileTransferPacket.h
index f875002..e3af6ed 100644
--- a/heimdall/source/EndPhoneFileTransferPacket.h
+++ b/heimdall/source/EndPhoneFileTransferPacket.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/source/EndSessionPacket.h b/heimdall/source/EndSessionPacket.h
index 15c7162..6547efb 100644
--- a/heimdall/source/EndSessionPacket.h
+++ b/heimdall/source/EndSessionPacket.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/source/FileTransferPacket.h b/heimdall/source/FileTransferPacket.h
index daa6a75..9a2a15e 100644
--- a/heimdall/source/FileTransferPacket.h
+++ b/heimdall/source/FileTransferPacket.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/source/FlashPartFileTransferPacket.h b/heimdall/source/FlashPartFileTransferPacket.h
index 6aa57da..3bb9def 100644
--- a/heimdall/source/FlashPartFileTransferPacket.h
+++ b/heimdall/source/FlashPartFileTransferPacket.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/source/FlashPartPitFilePacket.h b/heimdall/source/FlashPartPitFilePacket.h
index 3974c3c..2eaeef9 100644
--- a/heimdall/source/FlashPartPitFilePacket.h
+++ b/heimdall/source/FlashPartPitFilePacket.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/source/Heimdall.h b/heimdall/source/Heimdall.h
index 174e7d7..918986b 100644
--- a/heimdall/source/Heimdall.h
+++ b/heimdall/source/Heimdall.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/source/InboundPacket.h b/heimdall/source/InboundPacket.h
index 3285c48..772f3c2 100644
--- a/heimdall/source/InboundPacket.h
+++ b/heimdall/source/InboundPacket.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/source/Interface.cpp b/heimdall/source/Interface.cpp
index 35105bb..6c3c58e 100644
--- a/heimdall/source/Interface.cpp
+++ b/heimdall/source/Interface.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
@@ -31,12 +31,16 @@ using namespace std;
using namespace libpit;
using namespace Heimdall;
+bool Interface::stdoutErrors = false;
+
const char *Interface::version = "v1.3 (beta)";
-const char *Interface::usage = "Usage: heimdall <action> <arguments> [--verbose] [--no-reboot] [--delay <ms>]\n\
+const char *Interface::usage = "Usage: heimdall <action> <action arguments> <common arguments>\n\
+Common Arguments:\n\
+ [--verbose] [--no-reboot] [--stdout-errors] [--delay <ms>]\n\
\n\
-action: flash\n\
-arguments:\n\
+Action: flash\n\
+Arguments:\n\
--repartition --pit <filename> [--factoryfs <filename>]\n\
[--cache <filename>] [--dbdata <filename>] [--primary-boot <filename>]\n\
[--secondary-boot <filename>] [--param <filename>] [--kernel <filename>]\n\
@@ -53,31 +57,31 @@ arguments:\n\
[--user-data <filename>] [--fota <filename>] [--hidden <filename>]\n\
[--movinand <filename>] [--data <filename>] [--ums <filename>]\n\
[--emmc <filename>] [--<partition identifier> <filename>]\n\
-description: Flashes firmware files to your phone.\n\
+Description: Flashes firmware files to your phone.\n\
WARNING: If you're repartitioning it's strongly recommended you specify\n\
all files at your disposal, including bootloaders.\n\
\n\
-action: close-pc-screen\n\
-description: Attempts to get rid off the \"connect phone to PC\" screen.\n\
+Action: close-pc-screen\n\
+Description: Attempts to get rid off the \"connect phone to PC\" screen.\n\
\n\
-action: detect\n\
-description: Indicates whether or not a download mode device can be detected.\n\
+Action: detect\n\
+Description: Indicates whether or not a download mode device can be detected.\n\
\n\
-action: dump\n\
-arguments: --chip-type <NAND | RAM> --chip-id <integer> --output <filename>\n\
-description: Attempts to dump data from the phone corresponding to the\n\
+Action: dump\n\
+Arguments: --chip-type <NAND | RAM> --chip-id <integer> --output <filename>\n\
+Description: Attempts to dump data from the phone corresponding to the\n\
specified chip type and chip ID.\n\
NOTE: Galaxy S phones don't appear to properly support this functionality.\n\
\n\
-action: print-pit\n\
-description: Dumps the PIT file from the connected device and prints it in\n\
+Action: print-pit\n\
+Description: Dumps the PIT file from the connected device and prints it in\n\
a human readable format.\n\
\n\
-action version\n\
-description: Displays the version number of this binary.\n\
+Action version\n\
+Description: Displays the version number of this binary.\n\
\n\
-action: help\n\
-description: Displays this dialogue.\n";
+Action: help\n\
+Description: Displays this dialogue.\n";
const char *Interface::releaseInfo = "Heimdall %s, Copyright (c) 2010-2011, Benjamin Dobell, Glass Echidna\n\
http://www.glassechidna.com.au\n\n\
@@ -123,11 +127,11 @@ string Interface::commonValueShortArguments[kCommonValueArgCount] = {
};
string Interface::commonValuelessArguments[kCommonValuelessArgCount] = {
- "-verbose", "-no-reboot"
+ "-verbose", "-no-reboot", "-stdout-errors"
};
string Interface::commonValuelessShortArguments[kCommonValuelessArgCount] = {
- "v", "nobt"
+ "v", "nobt", "err"
};
Action Interface::actions[Interface::kActionCount] = {
@@ -319,23 +323,49 @@ bool Interface::GetArguments(int argc, char **argv, map<string, string>& argumen
void Interface::Print(const char *format, ...)
{
va_list args;
-
va_start(args, format);
+
vfprintf(stdout, format, args);
- va_end(args);
+ fflush(stdout);
- fflush(stdout); // Make sure output isn't buffered.
+ va_end(args);
+
}
void Interface::PrintError(const char *format, ...)
{
va_list args;
-
va_start(args, format);
+
+ fprintf(stderr, "ERROR: ");
vfprintf(stderr, format, args);
+ fflush(stderr);
+
+ if (stdoutErrors)
+ {
+ fprintf(stdout, "ERROR: ");
+ vfprintf(stdout, format, args);
+ fflush(stdout);
+ }
+
va_end(args);
+}
+
+void Interface::PrintErrorSameLine(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
- fflush(stderr); // Make sure output isn't buffered.
+ vfprintf(stderr, format, args);
+ fflush(stderr);
+
+ if (stdoutErrors)
+ {
+ vfprintf(stdout, format, args);
+ fflush(stdout);
+ }
+
+ va_end(args);
}
void Interface::PrintVersion(void)
diff --git a/heimdall/source/Interface.h b/heimdall/source/Interface.h
index 7b1741d..81f17e5 100644
--- a/heimdall/source/Interface.h
+++ b/heimdall/source/Interface.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
@@ -207,15 +207,18 @@ namespace Heimdall
{
kCommonValuelessArgVerbose = 0,
kCommonValuelessArgNoReboot,
+ kCommonValuelessArgStdoutErrors,
kCommonValuelessArgCount
};
private:
+
+ static bool stdoutErrors;
static const char *version;
static const char *usage;
- static const char *releaseInfo;
+ static const char *releaseInfo;
// Flash arguments
static string flashValueArguments[kFlashValueArgCount];
@@ -243,6 +246,7 @@ namespace Heimdall
static void Print(const char *format, ...);
static void PrintError(const char *format, ...);
+ static void PrintErrorSameLine(const char *format, ...);
static void PrintVersion(void);
static void PrintUsage(void);
@@ -254,6 +258,11 @@ namespace Heimdall
{
return (flashValueArguments[kFlashValueArgPit]);
}
+
+ static void SetStdoutErrors(bool enabled)
+ {
+ stdoutErrors = enabled;
+ }
};
}
diff --git a/heimdall/source/OutboundPacket.h b/heimdall/source/OutboundPacket.h
index 8f8e6c6..83ef844 100644
--- a/heimdall/source/OutboundPacket.h
+++ b/heimdall/source/OutboundPacket.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/source/Packet.h b/heimdall/source/Packet.h
index 33469f1..fb81bd4 100644
--- a/heimdall/source/Packet.h
+++ b/heimdall/source/Packet.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/source/PitFilePacket.h b/heimdall/source/PitFilePacket.h
index d23314e..773de41 100644
--- a/heimdall/source/PitFilePacket.h
+++ b/heimdall/source/PitFilePacket.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/source/PitFileResponse.h b/heimdall/source/PitFileResponse.h
index bf8f6f6..89035bd 100644
--- a/heimdall/source/PitFileResponse.h
+++ b/heimdall/source/PitFileResponse.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/source/ReceiveFilePartPacket.h b/heimdall/source/ReceiveFilePartPacket.h
index 5671ed4..0e60344 100644
--- a/heimdall/source/ReceiveFilePartPacket.h
+++ b/heimdall/source/ReceiveFilePartPacket.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/source/ResponsePacket.h b/heimdall/source/ResponsePacket.h
index 8cafc95..6094c83 100644
--- a/heimdall/source/ResponsePacket.h
+++ b/heimdall/source/ResponsePacket.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/source/SendFilePartPacket.h b/heimdall/source/SendFilePartPacket.h
index 7734e2a..94446a8 100644
--- a/heimdall/source/SendFilePartPacket.h
+++ b/heimdall/source/SendFilePartPacket.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/source/SendFilePartResponse.h b/heimdall/source/SendFilePartResponse.h
index ba6eb6b..d3a054d 100644
--- a/heimdall/source/SendFilePartResponse.h
+++ b/heimdall/source/SendFilePartResponse.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/source/main.cpp b/heimdall/source/main.cpp
index f24b64a..8ab0b19 100644
--- a/heimdall/source/main.cpp
+++ b/heimdall/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
@@ -278,7 +278,7 @@ bool flashFile(BridgeManager *bridgeManager, unsigned int partitionIndex, const
}
else
{
- Interface::PrintError("%s upload failed!\n", partitionName);
+ Interface::Print("%s upload failed!\n", partitionName);
return (false);
}
}
@@ -309,7 +309,7 @@ bool flashFile(BridgeManager *bridgeManager, unsigned int partitionIndex, const
}
else
{
- Interface::PrintError("%s upload failed!\n", partitionName);
+ Interface::Print("%s upload failed!\n", partitionName);
return (false);
}
}
@@ -325,7 +325,7 @@ bool flashFile(BridgeManager *bridgeManager, unsigned int partitionIndex, const
}
else
{
- Interface::PrintError("%s upload failed!\n", partitionName);
+ Interface::Print("%s upload failed!\n", partitionName);
return (false);
}
}
@@ -460,7 +460,9 @@ bool attemptFlash(BridgeManager *bridgeManager, map<string, FILE *> argumentFile
if (!pitsMatch)
{
- Interface::PrintError("Local and device PIT files don't match and repartition wasn't specified!\n");
+ Interface::Print("Local and device PIT files don't match and repartition wasn't specified!\n");
+ Interface::Print("Flash aborted!\n");
+ Interface::PrintError("Flash aborted!\n");
delete pitData;
return (false);
@@ -595,6 +597,8 @@ int main(int argc, char **argv)
bool verbose = argumentMap.find(Interface::commonValuelessArguments[Interface::kCommonValuelessArgVerbose]) != argumentMap.end();
bool reboot = argumentMap.find(Interface::commonValuelessArguments[Interface::kCommonValuelessArgNoReboot]) == argumentMap.end();
+ Interface::SetStdoutErrors(argumentMap.find(Interface::commonValuelessArguments[Interface::kCommonValuelessArgStdoutErrors]) != argumentMap.end());
+
int communicationDelay = BridgeManager::kCommunicationDelayDefault;
if (argumentMap.find(Interface::commonValueArguments[Interface::kCommonValueArgDelay]) != argumentMap.end())
communicationDelay = atoi(argumentMap.find(Interface::commonValueArguments[Interface::kCommonValueArgDelay])->second.c_str());
diff --git a/libpit/Source/libpit.cpp b/libpit/Source/libpit.cpp
index 1eb3e76..205ba38 100755
--- a/libpit/Source/libpit.cpp
+++ b/libpit/Source/libpit.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/libpit/Source/libpit.h b/libpit/Source/libpit.h
index fa4a534..06917a5 100755
--- a/libpit/Source/libpit.h
+++ b/libpit/Source/libpit.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