Debian Codegraph @

src/blitzinfo.cpp

raw symbols SCIP
1 #include "blitzinfo.h"
2 #include <QFileInfo>
3 #include <quazip/quazip.h>
4 #include <quazip/quazipfile.h>
5
6 BlitzInfo::BlitzInfo(QList<QString> filenames, QString deviceOS, QString deviceRadio)
7 : QObject()
8 , osIsSafe(false)
9 , radioIsSafe(false)
10 , radioCount(0)
11 , osCount(0)
12 , _deviceOS(deviceOS)
13 , _deviceRadio(deviceRadio)
14 {
15 foreach(QString barFile, filenames)
16 blitzCheck(barFile);
17 }
18
19 void BlitzInfo::blitzCheck(QString name)
20 {
21 BarType fileType = NotInstallableType;
22 // Check if it's a 'hidden' file as we use these for temporary file downloads.
23 if (QFileInfo(name).fileName().startsWith('.'))
24 return;
25
26 QuaZipFile manifest(name, "META-INF/MANIFEST.MF", QuaZip::csSensitive);
27 if (!manifest.open(QIODevice::ReadOnly))
28 return;
29 QString appName, type;
30 while (!manifest.atEnd()) {
31 QByteArray newLine = manifest.readLine();
32 if (newLine.startsWith("Package-Name:") || newLine.startsWith("Patch-Package-Name:")) {
33 appName = newLine.split(':').last().simplified();
34 if (newLine.startsWith("Patch") && type == "system") {
35 if (appName.contains("radio"))
36 fileType = RadioType;
37 else
38 fileType = OSType;
39 }
40 }
41 else if (newLine.startsWith("Package-Type:") || newLine.startsWith("Patch-Package-Type:")) {
42 type = newLine.split(':').last().simplified();
43 if (type == "system" && fileType == NotInstallableType)
44 fileType = OSType;
45 else if (type != "patch")
46 break;
47 }
48 else if (newLine.startsWith("System-Type:")) {
49 if (newLine.split(':').last().simplified() == "radio")
50 fileType = RadioType;
51 break;
52 }
53 }
54 if (fileType != OSType && fileType != RadioType)
55 return;
56
57 if (fileType == OSType) {
58 osCount++;
59 QString installableOS = appName.split("os.").last().remove(".desktop").replace("verizon", "factory");
60 if (_deviceOS == "" || installableOS == _deviceOS || (installableOS.contains("8974") && _deviceOS.contains("8974"))) {
61 osIsSafe = true;
62 }
63 } else if (fileType == RadioType) {
64 radioCount++;
65 QString installableRadio = appName.split("radio.").last().remove(".omadm");
66 if (_deviceRadio == "" || installableRadio == _deviceRadio) {
67 radioIsSafe = true;
68 }
69 }
70 return;
71 }