2014-02-27 17:14:41 +08:00
|
|
|
/* types.cpp
|
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
2014-02-27 17:14:41 +08:00
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include "types.h"
|
|
|
|
#include "ffs.h"
|
|
|
|
|
|
|
|
QString regionTypeToQString(const UINT8 type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2015-02-06 16:47:19 +08:00
|
|
|
case Subtypes::DescriptorRegion:
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("Descriptor");
|
2015-02-06 16:47:19 +08:00
|
|
|
case Subtypes::GbeRegion:
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("GbE");
|
2015-02-06 16:47:19 +08:00
|
|
|
case Subtypes::MeRegion:
|
2015-01-31 22:00:00 +08:00
|
|
|
return QObject::tr("ME/TXE");
|
2015-02-06 16:47:19 +08:00
|
|
|
case Subtypes::BiosRegion:
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("BIOS");
|
2015-02-06 16:47:19 +08:00
|
|
|
case Subtypes::PdrRegion:
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("PDR");
|
|
|
|
default:
|
|
|
|
return QObject::tr("Unknown");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
QString itemTypeToQString(const UINT8 type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Types::Root:
|
|
|
|
return QObject::tr("Root");
|
|
|
|
case Types::Image:
|
|
|
|
return QObject::tr("Image");
|
|
|
|
case Types::Capsule:
|
|
|
|
return QObject::tr("Capsule");
|
|
|
|
case Types::Region:
|
|
|
|
return QObject::tr("Region");
|
|
|
|
case Types::Volume:
|
|
|
|
return QObject::tr("Volume");
|
|
|
|
case Types::Padding:
|
|
|
|
return QObject::tr("Padding");
|
|
|
|
case Types::File:
|
|
|
|
return QObject::tr("File");
|
|
|
|
case Types::Section:
|
|
|
|
return QObject::tr("Section");
|
2015-02-06 16:47:19 +08:00
|
|
|
case Types::FreeSpace:
|
|
|
|
return QObject::tr("Free space");
|
2014-02-27 17:14:41 +08:00
|
|
|
default:
|
|
|
|
return QObject::tr("Unknown");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-06 16:47:19 +08:00
|
|
|
QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case Types::Root:
|
|
|
|
case Types::Image:
|
2015-02-06 16:47:19 +08:00
|
|
|
if (subtype == Subtypes::IntelImage)
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("Intel");
|
2015-02-06 16:47:19 +08:00
|
|
|
else if (Subtypes::UefiImage)
|
2015-01-31 22:00:00 +08:00
|
|
|
return QObject::tr("UEFI");
|
2014-02-27 17:14:41 +08:00
|
|
|
else
|
2015-02-06 16:47:19 +08:00
|
|
|
return QObject::tr("Unknown subtype");
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::Padding:
|
2015-02-06 16:47:19 +08:00
|
|
|
if (subtype == Subtypes::ZeroPadding)
|
2015-01-31 22:00:00 +08:00
|
|
|
return QObject::tr("Empty (0x00)");
|
2015-02-06 16:47:19 +08:00
|
|
|
else if (subtype == Subtypes::OnePadding)
|
2015-01-31 22:00:00 +08:00
|
|
|
return QObject::tr("Empty (0xFF)");
|
2015-02-06 16:47:19 +08:00
|
|
|
else if (subtype == Subtypes::DataPadding)
|
2015-01-31 22:00:00 +08:00
|
|
|
return QObject::tr("Non-empty");
|
2014-11-18 23:01:20 +08:00
|
|
|
else
|
2015-02-06 16:47:19 +08:00
|
|
|
return QObject::tr("Unknown subtype");
|
|
|
|
case Types::Volume:
|
|
|
|
if (subtype == Subtypes::UnknownVolume)
|
2014-02-27 17:14:41 +08:00
|
|
|
return QObject::tr("Unknown");
|
2015-02-06 16:47:19 +08:00
|
|
|
else if (subtype == Subtypes::Ffs2Volume)
|
|
|
|
return QObject::tr("FFSv2");
|
|
|
|
else if (subtype == Subtypes::Ffs3Volume)
|
|
|
|
return QObject::tr("FFSv3");
|
2014-02-27 17:14:41 +08:00
|
|
|
else
|
2015-02-06 16:47:19 +08:00
|
|
|
return QObject::tr("Unknown subtype");
|
|
|
|
case Types::Capsule:
|
|
|
|
if (subtype == Subtypes::AptioSignedCapsule)
|
|
|
|
return QObject::tr("Aptio signed");
|
|
|
|
else if (subtype == Subtypes::AptioUnsignedCapsule)
|
|
|
|
return QObject::tr("Aptio unsigned");
|
|
|
|
else if (subtype == Subtypes::UefiCapsule)
|
|
|
|
return QObject::tr("UEFI 2.0 ");
|
2015-01-31 22:00:00 +08:00
|
|
|
else
|
2015-02-06 16:47:19 +08:00
|
|
|
return QObject::tr("Unknown subtype");
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::Region:
|
2015-02-06 16:47:19 +08:00
|
|
|
return regionTypeToQString(subtype);
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::File:
|
2015-02-06 16:47:19 +08:00
|
|
|
return fileTypeToQString(subtype);
|
2014-02-27 17:14:41 +08:00
|
|
|
case Types::Section:
|
2015-02-06 16:47:19 +08:00
|
|
|
return sectionTypeToQString(subtype);
|
|
|
|
case Types::FreeSpace:
|
|
|
|
return QString();
|
2014-02-27 17:14:41 +08:00
|
|
|
default:
|
2015-02-06 16:47:19 +08:00
|
|
|
return QObject::tr("Unknown subtype");
|
2014-02-27 17:14:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
QString compressionTypeToQString(const UINT8 algorithm)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (algorithm) {
|
|
|
|
case COMPRESSION_ALGORITHM_NONE:
|
|
|
|
return QObject::tr("None");
|
|
|
|
case COMPRESSION_ALGORITHM_EFI11:
|
|
|
|
return QObject::tr("EFI 1.1");
|
|
|
|
case COMPRESSION_ALGORITHM_TIANO:
|
|
|
|
return QObject::tr("Tiano");
|
|
|
|
case COMPRESSION_ALGORITHM_LZMA:
|
|
|
|
return QObject::tr("LZMA");
|
|
|
|
case COMPRESSION_ALGORITHM_IMLZMA:
|
|
|
|
return QObject::tr("Intel modified LZMA");
|
|
|
|
default:
|
|
|
|
return QObject::tr("Unknown");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 22:00:00 +08:00
|
|
|
QString actionTypeToQString(const UINT8 action)
|
2014-02-27 17:14:41 +08:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case Actions::NoAction:
|
|
|
|
return "";
|
|
|
|
case Actions::Create:
|
|
|
|
return QObject::tr("Create");
|
|
|
|
case Actions::Insert:
|
|
|
|
return QObject::tr("Insert");
|
|
|
|
case Actions::Replace:
|
|
|
|
return QObject::tr("Replace");
|
|
|
|
case Actions::Remove:
|
|
|
|
return QObject::tr("Remove");
|
|
|
|
case Actions::Rebuild:
|
|
|
|
return QObject::tr("Rebuild");
|
|
|
|
case Actions::Rebase:
|
|
|
|
return QObject::tr("Rebase");
|
|
|
|
default:
|
|
|
|
return QObject::tr("Unknown");
|
|
|
|
}
|
2014-07-25 07:59:51 +08:00
|
|
|
}
|