forked from LongSoft/UEFITool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.cpp
158 lines (150 loc) · 4.76 KB
/
types.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* types.cpp
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
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)
{
case Subtypes::DescriptorRegion:
return QObject::tr("Descriptor");
case Subtypes::GbeRegion:
return QObject::tr("GbE");
case Subtypes::MeRegion:
return QObject::tr("ME");
case Subtypes::BiosRegion:
return QObject::tr("BIOS");
case Subtypes::PdrRegion:
return QObject::tr("PDR");
case Subtypes::EcRegion:
return QObject::tr("EC");
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");
case Types::FreeSpace:
return QObject::tr("Free space");
default:
return QObject::tr("Unknown");
}
}
QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
{
switch (type) {
case Types::Root:
case Types::Image:
if (subtype == Subtypes::IntelImage)
return QObject::tr("Intel");
else if (subtype == Subtypes::UefiImage)
return QObject::tr("UEFI");
else
return QObject::tr("Unknown subtype");
case Types::Padding:
if (subtype == Subtypes::ZeroPadding)
return QObject::tr("Empty (0x00)");
else if (subtype == Subtypes::OnePadding)
return QObject::tr("Empty (0xFF)");
else if (subtype == Subtypes::DataPadding)
return QObject::tr("Non-empty");
else
return QObject::tr("Unknown subtype");
case Types::Volume:
if (subtype == Subtypes::UnknownVolume)
return QObject::tr("Unknown");
else if (subtype == Subtypes::Ffs2Volume)
return QObject::tr("FFSv2");
else if (subtype == Subtypes::Ffs3Volume)
return QObject::tr("FFSv3");
else
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");
else if (subtype == Subtypes::ToshibaCapsule)
return QObject::tr("Toshiba");
else
return QObject::tr("Unknown subtype");
case Types::Region:
return regionTypeToQString(subtype);
case Types::File:
return fileTypeToQString(subtype);
case Types::Section:
return sectionTypeToQString(subtype);
case Types::FreeSpace:
return QString();
default:
return QObject::tr("Unknown subtype");
}
}
QString compressionTypeToQString(const UINT8 algorithm)
{
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");
}
}
QString actionTypeToQString(const UINT8 action)
{
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");
case Actions::DoNotRebuild:
return QObject::tr("Do not rebuild");
default:
return QObject::tr("Unknown");
}
}