Commit d893697d070950e39bd90f8f95445141504ca536
1 parent
7b3a3bee
Exists in
master
Correção da coleta em isNotebook. Exclusão de arquivo temporário.
Showing
3 changed files
with
9 additions
and
46 deletions
Show diff stats
gercols/gercols.cpp
| @@ -2,21 +2,6 @@ | @@ -2,21 +2,6 @@ | ||
| 2 | 2 | ||
| 3 | Gercols::Gercols(QObject *parent) | 3 | Gercols::Gercols(QObject *parent) |
| 4 | { | 4 | { |
| 5 | - | ||
| 6 | -// Cria um json de configuração para teste. | ||
| 7 | -// *************************************************************************/ | ||
| 8 | -// QJsonObject configTeste; | ||
| 9 | -// QJsonObject configComputer; | ||
| 10 | -// configComputer["operating_system"] = QJsonValue::fromVariant(QString("")); | ||
| 11 | -// configComputer["user"] = QJsonValue::fromVariant(QString("")); | ||
| 12 | -// configComputer["network_interface"] = QJsonValue::fromVariant(QString("")); | ||
| 13 | -// configTeste["computer"] = configComputer; | ||
| 14 | -// configTeste["hardware"] = QJsonValue::fromVariant(QString("")); | ||
| 15 | -// configTeste["software"] = QJsonValue::fromVariant(QString("")); | ||
| 16 | - | ||
| 17 | -// oCacic.setJsonToFile(configTeste,"configReq.json"); | ||
| 18 | -// /************************************************************************ | ||
| 19 | - | ||
| 20 | oColeta = new CColeta; | 5 | oColeta = new CColeta; |
| 21 | //Pega chave do registro, que será pega na instalação. | 6 | //Pega chave do registro, que será pega na instalação. |
| 22 | oCacic.setChaveCrypt(oCacic.getValueFromRegistry("Lightbase", "Cacic", "key").toString()); | 7 | oCacic.setChaveCrypt(oCacic.getValueFromRegistry("Lightbase", "Cacic", "key").toString()); |
| @@ -33,11 +18,6 @@ void Gercols::run() | @@ -33,11 +18,6 @@ void Gercols::run() | ||
| 33 | //emite sinal para começar a coleta | 18 | //emite sinal para começar a coleta |
| 34 | emit iniciaColeta(); | 19 | emit iniciaColeta(); |
| 35 | 20 | ||
| 36 | - /* Json de teste sendo excluído | ||
| 37 | - */ | ||
| 38 | -// oCacic.deleteFile("configReq.json"); | ||
| 39 | - /***********************************/ | ||
| 40 | - | ||
| 41 | oColeta->waitToCollect(); | 21 | oColeta->waitToCollect(); |
| 42 | //salva json em arquivo | 22 | //salva json em arquivo |
| 43 | if (!oColeta->toJsonObject().isEmpty()) | 23 | if (!oColeta->toJsonObject().isEmpty()) |
src/cacic_hardware.cpp
| @@ -294,6 +294,7 @@ QJsonObject cacic_hardware::coletaLinux() | @@ -294,6 +294,7 @@ QJsonObject cacic_hardware::coletaLinux() | ||
| 294 | coletaLinuxIsNotebook(hardware); | 294 | coletaLinuxIsNotebook(hardware); |
| 295 | coletaLinuxPrinters(hardware); | 295 | coletaLinuxPrinters(hardware); |
| 296 | 296 | ||
| 297 | + lshwFile.remove(); | ||
| 297 | return hardware; | 298 | return hardware; |
| 298 | } | 299 | } |
| 299 | 300 | ||
| @@ -434,7 +435,9 @@ void cacic_hardware::coletaLinuxIsNotebook(QJsonObject &hardware) | @@ -434,7 +435,9 @@ void cacic_hardware::coletaLinuxIsNotebook(QJsonObject &hardware) | ||
| 434 | foreach(QString line, consoleOutput){ | 435 | foreach(QString line, consoleOutput){ |
| 435 | if(line.contains("Type:") | 436 | if(line.contains("Type:") |
| 436 | && (line.contains("Notebook") || line.contains("Portable")) ){ | 437 | && (line.contains("Notebook") || line.contains("Portable")) ){ |
| 437 | - hardware["isNotebook"] = QJsonValue::fromVariant(QString("true")); | 438 | + QJsonObject notebook; |
| 439 | + notebook["value"] = QJsonValue::fromVariant(true); | ||
| 440 | + hardware["isNotebook"] = notebook; | ||
| 438 | } | 441 | } |
| 439 | } | 442 | } |
| 440 | 443 |
src/ccoleta.cpp
| @@ -44,40 +44,20 @@ void CColeta::run() | @@ -44,40 +44,20 @@ void CColeta::run() | ||
| 44 | { | 44 | { |
| 45 | /* Versão do json de testes */ | 45 | /* Versão do json de testes */ |
| 46 | QJsonObject coleta = oCacic.getJsonFromFile("getConfig.json"); | 46 | QJsonObject coleta = oCacic.getJsonFromFile("getConfig.json"); |
| 47 | - qDebug() << coleta; | ||
| 48 | - QJsonObject actions = coleta["reply"].toObject()["agentecomputer"].toObject()["actions"].toObject(); | ||
| 49 | - if( actions.contains("col_hard") ){ | 47 | +// qDebug() << coleta; |
| 48 | + QJsonObject actions = coleta["reply"].toObject()["agentcomputer"].toObject()["actions"].toObject(); | ||
| 49 | +// qDebug() << actions["col_hard"] << actions["col_soft"]; | ||
| 50 | + if( actions.contains("col_hard") && actions["col_hard"].toBool()){ | ||
| 50 | this->hardwareIsFinish = false; | 51 | this->hardwareIsFinish = false; |
| 51 | emit beginHardware(); | 52 | emit beginHardware(); |
| 52 | } else | 53 | } else |
| 53 | this->hardwareIsFinish = true; | 54 | this->hardwareIsFinish = true; |
| 54 | 55 | ||
| 55 | - if ( actions.contains("col_soft") ){ | 56 | + if ( actions.contains("col_soft") && actions["col_soft"].toBool()){ |
| 56 | this->softwareIsFinish = false; | 57 | this->softwareIsFinish = false; |
| 57 | emit beginSoftware(); | 58 | emit beginSoftware(); |
| 58 | } else | 59 | } else |
| 59 | this->softwareIsFinish = true; | 60 | this->softwareIsFinish = true; |
| 60 | - /************************************************************/ | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - /* Versão do json definitiva, obtiva através do getConfig() | ||
| 64 | - QJsonObject coleta = oCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject(); | ||
| 65 | - | ||
| 66 | - foreach ( QJsonValue action, coleta["actions"].toArray() ){ | ||
| 67 | - QJsonObject jsonAction = action.toObject(); | ||
| 68 | - | ||
| 69 | - if( jsonAction.contains("col_hard") && jsonAction["col_hard"] == QJsonValue.fromVariant(QString("true")) ){ | ||
| 70 | - this->hardwareIsFinish = false; | ||
| 71 | - emit beginHardware(); | ||
| 72 | - } else | ||
| 73 | - this->hardwareIsFinish = true; | ||
| 74 | - if ( jsonAction.contains("col_soft") && jsonAction["col_soft"] == QJsonValue.fromVariant(QString("true")) ){ | ||
| 75 | - this->softwareIsFinish = false; | ||
| 76 | - emit beginSoftware(); | ||
| 77 | - } else | ||
| 78 | - this->softwareIsFinish = true; | ||
| 79 | - } | ||
| 80 | - /************************************************************/ | ||
| 81 | 61 | ||
| 82 | } | 62 | } |
| 83 | 63 |