Commit d4ccf4a1f0dcc67ff26e5361251be7351ab46f72

Authored by Thiago Rocha
1 parent f78ed3f8
Exists in master

Consertos para rodar no Linux/Ubuntu.

gercols/gercols.cpp
@@ -12,12 +12,12 @@ Gercols::Gercols(QObject *parent) @@ -12,12 +12,12 @@ Gercols::Gercols(QObject *parent)
12 ******************************************/ 12 ******************************************/
13 QJsonObject configTeste; 13 QJsonObject configTeste;
14 QJsonObject configComputer; 14 QJsonObject configComputer;
15 - configComputer["operating_system"] = "";  
16 - configComputer["user"] = "";  
17 - configComputer["network_interface"] = ""; 15 + configComputer["operating_system"] = QJsonValue::fromVariant(QString(""));
  16 + configComputer["user"] = QJsonValue::fromVariant(QString(""));
  17 + configComputer["network_interface"] = QJsonValue::fromVariant(QString(""));
18 configTeste["computer"] = configComputer; 18 configTeste["computer"] = configComputer;
19 - configTeste["hardware"] = "";  
20 - configTeste["software"] = ""; 19 + configTeste["hardware"] = QJsonValue::fromVariant(QString(""));
  20 + configTeste["software"] = QJsonValue::fromVariant(QString(""));
21 21
22 oCacic.setJsonToFile(configTeste,"configReq.json"); 22 oCacic.setJsonToFile(configTeste,"configReq.json");
23 /******************************************/ 23 /******************************************/
src/cacic_software.cpp
@@ -16,6 +16,7 @@ void cacic_software::iniciaColeta() @@ -16,6 +16,7 @@ void cacic_software::iniciaColeta()
16 #endif 16 #endif
17 } 17 }
18 18
  19 +#if defined(Q_OS_WIN)
19 QJsonObject cacic_software::coletaWin() 20 QJsonObject cacic_software::coletaWin()
20 { 21 {
21 QJsonObject softwaresJson; 22 QJsonObject softwaresJson;
@@ -54,6 +55,7 @@ QJsonObject cacic_software::coletaWin() @@ -54,6 +55,7 @@ QJsonObject cacic_software::coletaWin()
54 return softwaresJson; 55 return softwaresJson;
55 } 56 }
56 57
  58 +#elif defined(Q_OS_LINUX)
57 QJsonObject cacic_software::coletaLinux() 59 QJsonObject cacic_software::coletaLinux()
58 { 60 {
59 61
@@ -115,10 +117,10 @@ QJsonObject cacic_software::coletaDebian() @@ -115,10 +117,10 @@ QJsonObject cacic_software::coletaDebian()
115 ConsoleObject console; 117 ConsoleObject console;
116 QJsonObject softwaresJson; 118 QJsonObject softwaresJson;
117 119
118 - QStringList packages = console("dpkg --get-selections").split("\n"); 120 + QStringList packages = console("dpkg --get-selections | grep -v '\^lib\\|\^fonts'").split("\n");
119 121
120 foreach(QString package, packages) { 122 foreach(QString package, packages) {
121 - QString packageName = package.split(" ")[0]; 123 + QString packageName = package.split("\t")[0];
122 QJsonObject packageJson; 124 QJsonObject packageJson;
123 125
124 QStringList packageInfo = console(QString("apt-cache show ").append(packageName)).split("\n"); 126 QStringList packageInfo = console(QString("apt-cache show ").append(packageName)).split("\n");
@@ -126,11 +128,11 @@ QJsonObject cacic_software::coletaDebian() @@ -126,11 +128,11 @@ QJsonObject cacic_software::coletaDebian()
126 128
127 packageJson["name"] = QJsonValue::fromVariant(QString(packageName)); 129 packageJson["name"] = QJsonValue::fromVariant(QString(packageName));
128 foreach(QString line, packageInfo) { 130 foreach(QString line, packageInfo) {
129 - if(line.contains("Version")) 131 + if(line.contains("Version:"))
130 packageJson["version"] = line.split(":")[1].mid(1); 132 packageJson["version"] = line.split(":")[1].mid(1);
131 - if(line.contains("Description")) 133 + if(line.contains("Description-en:"))
132 packageJson["description"] = line.split(":")[1].mid(1); 134 packageJson["description"] = line.split(":")[1].mid(1);
133 - if(line.contains("Homepage")) { 135 + if(line.contains("Homepage:")) {
134 QStringList url = line.split(":"); 136 QStringList url = line.split(":");
135 QString urlString; 137 QString urlString;
136 138
@@ -141,14 +143,16 @@ QJsonObject cacic_software::coletaDebian() @@ -141,14 +143,16 @@ QJsonObject cacic_software::coletaDebian()
141 143
142 packageJson["url"] = urlString.mid(1); 144 packageJson["url"] = urlString.mid(1);
143 } 145 }
144 - if(line.contains("Installed-Size")) 146 + if(line.contains("Installed-Size:"))
145 packageJson["installed_size"] = line.split(":")[1].mid(1); 147 packageJson["installed_size"] = line.split(":")[1].mid(1);
146 } 148 }
147 softwaresJson[packageName] = packageJson; 149 softwaresJson[packageName] = packageJson;
  150 + int counterPackages = softwaresJson.size();
148 } 151 }
149 152
150 return softwaresJson; 153 return softwaresJson;
151 } 154 }
  155 +#endif
152 156
153 QJsonObject cacic_software::toJsonObject() 157 QJsonObject cacic_software::toJsonObject()
154 { 158 {
src/cacic_software.h
@@ -4,8 +4,11 @@ @@ -4,8 +4,11 @@
4 #include <ccacic.h> 4 #include <ccacic.h>
5 #include <console.h> 5 #include <console.h>
6 #include <operatingsystem.h> 6 #include <operatingsystem.h>
7 -#include <vqtconvert.h>  
8 -#include <vregistry.h> 7 +
  8 +#if defined(Q_OS_WIN)
  9 + #include <vqtconvert.h>
  10 + #include <vregistry.h>
  11 +#endif
9 12
10 class cacic_software 13 class cacic_software
11 { 14 {
src/vqtconvert.cpp
  1 +#if defined(Q_OS_WIN)
  2 +
1 #include "vqtconvert.h" 3 #include "vqtconvert.h"
2 4
3 #include <QString> 5 #include <QString>
@@ -58,3 +60,4 @@ namespace voidrealms @@ -58,3 +60,4 @@ namespace voidrealms
58 60
59 } //end voidrealms::win32 namespace 61 } //end voidrealms::win32 namespace
60 } //end voidrealms namespace 62 } //end voidrealms namespace
  63 +#endif
src/vqtconvert.h
  1 +#if defined(Q_OS_WIN)
  2 +
1 #ifndef VQTCONVERT_H 3 #ifndef VQTCONVERT_H
2 #define VQTCONVERT_H 4 #define VQTCONVERT_H
3 5
@@ -49,3 +51,4 @@ namespace voidrealms @@ -49,3 +51,4 @@ namespace voidrealms
49 } //end voidrealms::win32 namespace 51 } //end voidrealms::win32 namespace
50 } //end voidrealms namespace 52 } //end voidrealms namespace
51 #endif // VQTCONVERT_H 53 #endif // VQTCONVERT_H
  54 +#endif
src/vregistry.cpp
  1 +#if defined(Q_OS_WIN)
  2 +
1 /* 3 /*
2 Wrapper for the Windows Registry 4 Wrapper for the Windows Registry
3 Version: 1.0 5 Version: 1.0
@@ -475,3 +477,4 @@ namespace voidrealms @@ -475,3 +477,4 @@ namespace voidrealms
475 477
476 } //end voidrealms::win32 namespace 478 } //end voidrealms::win32 namespace
477 } //end voidrealms namespace 479 } //end voidrealms namespace
  480 +#endif
src/vregistry.h
  1 +#if defined(Q_OS_WIN)
  2 +
1 /* 3 /*
2 Wrapper for the Windows Registry 4 Wrapper for the Windows Registry
3 Version: 1.0 5 Version: 1.0
@@ -125,3 +127,4 @@ namespace voidrealms @@ -125,3 +127,4 @@ namespace voidrealms
125 } //end voidrealms::win32 namespace 127 } //end voidrealms::win32 namespace
126 } //end voidrealms namespace 128 } //end voidrealms namespace
127 #endif // VREGISTRY_H 129 #endif // VREGISTRY_H
  130 +#endif