Commit ebde75cb07ab3cf8e54cb52dadbc4b0131775ce9

Authored by LightBase Consultoria em Software Publico
2 parents 6cdb3e6b 9989db7c
Exists in master

semaforo e chamada do gercols

cacic-daemon/cacicD/cacicd.cpp
... ... @@ -34,6 +34,9 @@ void cacicD::start() {
34 34 qDebug() << "\nServiço iniciado em" << application()->applicationDirPath();
35 35 QLogger::QLog_Info("Cacic Daemon", QString("Servico iniciado em ").append(application()->applicationDirPath()).append("."));
36 36 QJsonObject result = ccacic->getJsonFromFile(application()->applicationDirPath().append("/getConfig.json"));
  37 +
  38 + QJsonObject result = ccacic->getJsonFromFile(application()->applicationDirPath() + "/getConfig.json");
  39 +
37 40 if(!result.contains("error") && !result.isEmpty()){
38 41 Ocacictimer->iniciarTimer(result["codestatus"].toInt());
39 42 }else{
... ...
cacic-daemon/cacicD/cacictimer.cpp
... ... @@ -11,6 +11,47 @@ CacicTimer::CacicTimer(QString dirpath)
11 11  
12 12 void CacicTimer::iniciarTimer(int x)
13 13 {
  14 +=======
  15 + OCacicComm = new CacicComm();
  16 + ccacic = new CCacic();
  17 + timer = new QTimer(this);
  18 + logManager = QLogger::QLoggerManager::getInstance();
  19 +
  20 + OCacicComm = CacicComm("http://teste.cacic.cc",
  21 + "rG/HcIDVTZ3pPKCf[[MAIS]]I6aigUb7OMeij3FfC7qNaznk0rBRYb6q6kSK3eNfjgptS8BfwW5yJqCvD2ai7xlw9I6P21j6cvQUqlHmAJpCbfwR13urdRE9AhjfokMcPrH6R1/zXPGMHveLRRgKLcqWu2X96rmoQQdRq9EW1SXmYUAx1dCV[[MAIS]]3Ha61XBw5pq58q35zH8Gjt998rTi3ecV8ShXXevqyK[[MAIS]]W07xpgTjbbd6Fbs/35gPfdRRgMNFjq7Gq[[MAIS]]llFgYMJ6UcEhw8f0ZLQo2oL/eRW/CNyeBW6wG0hIo6EIdpi/Ht0/95Uwn2Og[[MAIS]]2UPXsmKKuTMeGwUvPdbEfexlinUO0[[MAIS]]j9qIa2dpjtl0Y5Fyk1Bvw2ZYRTXwgJpUHsBboWmtTFpgX3wSGOWMipE80K8ktRTVYOp[[MAIS]]4qS/SzKWXpfCuZoCncfwE0lCEoreTH[[MAIS]]MLrTkHJP2oqYMAyFyQcjC0UGr3BQGa2edSNXjG7jrTdddga/SODUiF94jgh/QBwhiZby34b__CRYPTED__",
  22 + "P198PVwtz5F5CfZPSUrzuaQA/QG1sTnwzl/rBnj8M7y5MglANGodG5LLD4q7oY809HuDR4g5tL64lZRBKvKPmEgWd9iAZKvT4UAm9XWN3nKKLGaznCaJohmntNGqrJP1Zd9riTHGu10mPbg/Uh3TCbBHVOICvu5sDlINlCR6A3[[MAIS]]a55RhfKNidvr5uX0kozCxr5t2DyOb5oPocEGyJKyHLQ==__CRYPTED__",
  23 + "1",
  24 + "0",
  25 + "0",
  26 + "YwpgjzZ86/eCsjvOki1KkQ==__CRYPTED__",
  27 + "8PT6U445MPNr3S7WHFa20ge/8NJSspSYE/UL3zf[[MAIS]]wkEfNZ7p1B/2o6i89gTZ44Ok__CRYPTED__",
  28 + "wshPlZWvLPhbUEQFQ1aQmA==__CRYPTED__",
  29 + "E9aKtVz/OSmGv7v1xW4FwaFukOob3qQ/HFDIz916K3ys82qfX9vBDz[[MAIS]]M2cdoYedhNkXt[[MAIS]]UVb10nD[[MAIS]]tOfbn7mlOlTDoGzUl9CgdPCsb[[MAIS]]Qa4wzuCrMw0BcCuaKfr62E3b8vh6Ug4JJbOgBo3ohG3x5O7Ap0D94GKtAWjMuTXRBbhGxPrRS4M6AhzvaN5P8pWd9FikrCLWuMs4ebnRlftef3RmVKScBDQ5zmK6sKxYNmX[[MAIS]]kKn/Gi2[[MAIS]]HftZ7HD9JLvZBpYhp4yjqShblQ67d6PlWgrRWXxwDseIiJe3NlF70zrCPBBelkeAhVDXMXnsYtLms3ElsLzxa3c5vpWzTfgyE[[MAIS]]hvALy4ivew7zaxEwrg2KY1T7GOSWZ7vljIvbhVZJgtzbnYiulFjJTtm5W4uJMKLuUJNzB0rxMkzToIE9/kDmeO2OKiwFbIfbe2Wdq0VpllOkjKtj9WM676iBSpYAXG0MsmLMj9CZ/sNi06hGF[[MAIS]]rXxiOSk66M0Hq[[MAIS]]OeUBh4z3Ra6f9yPJn0K9hIQyT[[MAIS]]Dr/QW/QdJIOkLTW8ZyyAF4DW9ojiTlUdySvB5EB1jyZ5nNTpzyE38qIdg7uM1tdWdm9FZGYxMdHwi1tS2dBeIWkDfWEjih01xiVt2dmdRgo0zIZvmmYDJ9LhCU3XPDlwdeQ8[[MAIS]]F7fnxDfxGqZQjZJ[[MAIS]]Y/Q8bdLpgbhcd3gt3SzjMLE0M[[MAIS]]hTmHG1KP2CzCibZ7grFAN3Y3jSPjmEj5Fzs26tdhdjNzSIt1FCueea8P2c4NmxPYkJCg0D1mgNrkH3L5svsO[[MAIS]]6YYrl3df4s[[MAIS]]fcK/to9s/pnkKfBKrAPF6Z4s2WPsALUPBDS5ty7RC2vqXRvH6hPR4o7xhXzQOQ/1xytr/RoEWEVeZ2wgHVVbbtFsALul/IDc7B45wmwxBx9iZHVwpQJVlNZZUBtwKqKhnXz5pM[[MAIS]]7yUAkfhMcO09pPd5kB2MBdRJs[[MAIS]]2FIk0GRUw05IHkc1rZEX5Ow==__CRYPTED__",
  30 + "Yot8BeM9lOh431SB7dYQXw==__CRYPTED__",
  31 + "Dcr8b5IfZOJjt6qyH5dGyw==__CRYPTED__",
  32 + "2.5.1.1.256.32",
  33 + "2.8.1.7",
  34 + "2.8.1.6");
  35 + OCacicComm->setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php");
  36 + OCacicComm->setUsuario("cacic");
  37 + OCacicComm->setPassword("cacic123");
  38 +
  39 + connect(timer,SIGNAL(timeout()),this,SLOT(mslot()));
  40 +}
  41 +
  42 +CacicTimer::~CacicTimer()
  43 +{
  44 + logManager->closeLogger();
  45 + delete logManager;
  46 + delete ccacic;
  47 + delete OCacicComm;
  48 +}
  49 +
  50 +void CacicTimer::iniciarTimer(int x, QString applicationDirPath)
  51 +{
  52 + setApplicationDirPath(applicationDirPath);
  53 + logManager->addDestination(getApplicationDirPath().append("/cacicLog.txt"), QStringList("Cacic Daemon"), QLogger::InfoLevel);
  54 + logManager->addDestination(getApplicationDirPath().append("/cacicLog.txt"), QStringList("Cacic Daemon"), QLogger::ErrorLevel);
14 55 timer->start(x);
15 56 }
16 57  
... ... @@ -22,11 +63,101 @@ void CacicTimer::mslot(){
22 63 iniciarGercols();
23 64 cMutex->unlock();
24 65 QLogger::QLog_Info("Cacic Timer", QString("semáforo aberto."));
  66 + qDebug() << "getConfig() success. - " + QDateTime::currentDateTime().toLocalTime().toString();
  67 + QLogger::QLog_Info("Cacic Daemon", "getConfig() executado com sucesso.");
  68 +
  69 + // Compara o novo arquivo de configuração com um antigo e se forem diferentes
  70 + // mantem o mais recente; caso iguais simplesmente apaga o novo.
  71 + QFile *fileOld;
  72 + QFile *fileNew;
  73 +
  74 + fileOld = new QFile(getApplicationDirPath().append("/getConfig.json"));
  75 + fileNew = new QFile(getApplicationDirPath().append("/getConfigNew.json"));
  76 + if( fileOld->exists() && fileNew->exists() ){
  77 + if( Md5IsEqual(QVariant::fromValue(fileOld), QVariant::fromValue(fileNew)) ) {
  78 + fileNew->remove();
  79 + } else {
  80 + // Renomeia getConfigNew.json para getConfig.json
  81 + fileOld->remove();
  82 + fileNew->rename("getConfigNew.json","getConfig.json");
  83 + }
  84 + jsonConfig = ccacic->getJsonFromFile(getApplicationDirPath().append("/getConfig.json"));
  85 + } else if( fileOld->exists() ){
  86 + jsonConfig = ccacic->getJsonFromFile(getApplicationDirPath().append("/getConfig.json"));
  87 + } else {
  88 + QLogger::QLog_Error("Cacic Daemon", "Arquivo de configuração não criado.");
  89 + }
  90 + delete fileOld;
  91 + delete fileNew;
  92 +
  93 + /* lê json de configurações e armazena quais módulos executáveis.
  94 + * E faz o mesmo tipo de comparação de hashs, com o fim de:
  95 + * ou mantem o binário do módulo ou baixa um novo.
  96 + */
  97 +
  98 + /* Aqui estou assumindo um formato do .json em que:
  99 + * há a key modulos contem uma lista com o nome dos executaveis e os seus valores hash md5
  100 + * há a key metodo que explicita o método de download dos executaveis
  101 + */
  102 + foreach( QJsonValue moduloValues, jsonConfig["modulos"].toArray() ) {
  103 + QString moduloKey, moduloValue;
  104 +
  105 + moduloKey = moduloValues.toObject()["md5"].toString();
  106 + moduloValue = moduloValues.toObject()["nome"].toString();
  107 +
  108 + moduleMap.insert(moduloKey, moduloValue);
  109 + }
  110 + metodoDownload = jsonConfig["metodo"].toString();
  111 +
  112 + int countExecNotFound = 0;
  113 + QMap<QString, QString>::const_iterator mapIterator = moduleMap.constBegin();
  114 + while (mapIterator != moduleMap.constEnd()) {
  115 + QString nomeModulo = mapIterator.value();
  116 + QString hashModulo = mapIterator.key();
  117 +
  118 + // Calcula hash do binario atual
  119 +#if defined(Q_OS_WIN)
  120 + fileOld = new QFile(getApplicationDirPath().append("/").append(modulo).append(".exe"));
  121 +#else
  122 + fileOld = new QFile(getApplicationDirPath().append("/").append(nomeModulo));
  123 +#endif
  124 + if(!fileOld->exists()) {
  125 + QLogger::QLog_Error("Cacic Daemon", QString("Módulo ").append(nomeModulo).append(" não encontrado."));
  126 +
  127 + countExecNotFound++;
  128 + if( countExecNotFound == moduleMap.size() ) {
  129 + QLogger::QLog_Error("Cacic Daemon", "Não foi possível encontrar nenhum módulo executável!");
  130 + return;
  131 + }
  132 + continue;
  133 + }
  134 +
  135 + QString oldMd5 = QString(QCryptographicHash::hash(fileOld->readAll(),QCryptographicHash::Md5).toHex());
  136 +
  137 + if ( oldMd5 != hashModulo ) {
  138 +
  139 + fileOld->rename(getApplicationDirPath().append("/").append(nomeModulo),
  140 + getApplicationDirPath().append("/").append("nomeModulo").append("Old") );
  141 +
  142 + // Download nova versão do executável
  143 + if(metodoDownload == "ftp" || metodoDownload == "") {
  144 +// OCacicComm->ftpDownload( QString("/ws/get/").append(nomeModulo) );
  145 + }
  146 +
  147 +
  148 + fileOld->remove();
  149 + delete fileOld;
  150 + }
  151 +
  152 + mapIterator++;
  153 + }
25 154 }else{
26 155 qDebug() << "getConfig() failed. - " + QDateTime::currentDateTime().toLocalTime().toString();
  156 + QLogger::QLog_Error("Cacic Daemon", "Falha na obtenção do arquivo de configuração.");
27 157 }
28 158 }else{
29 159 qDebug() << "getTest() failed. - " + QDateTime::currentDateTime().toLocalTime().toString();
  160 + QLogger::QLog_Error("Cacic Daemon", "Falha na execução do getTest().");
30 161 }
31 162 }
32 163  
... ... @@ -68,7 +199,7 @@ bool CacicTimer::getConfig(){
68 199 // return false;
69 200 // }
70 201 try{
71   - ccacic->setJsonToFile(jsonresult, getApplicationDirPath() + "/getConfig.json");
  202 + ccacic->setJsonToFile(jsonresult, getApplicationDirPath().append("/getConfigNew.json"));
72 203 return true;
73 204 } catch (...) {
74 205 qDebug() << "Erro ao salvar o arquivo de configurações.";
... ... @@ -130,11 +261,11 @@ void CacicTimer::registraFim()
130 261 {
131 262 }
132 263  
133   -bool CacicTimer::compararHashMD5(QJsonDocument getconfigfile,QJsonDocument getConfig){
  264 +bool CacicTimer::Md5IsEqual(QVariant document01,QVariant document02){
134 265 QString getconfigMD5 = QString(QCryptographicHash::hash(
135   - (getconfigfile.toVariant().toByteArray()),QCryptographicHash::Md5).toHex());
  266 + (document01.toByteArray()),QCryptographicHash::Md5).toHex());
136 267 QString getconfigMD52 = QString(QCryptographicHash::hash(
137   - (getConfig.toVariant().toByteArray()),QCryptographicHash::Md5).toHex());
  268 + (document02.toByteArray()),QCryptographicHash::Md5).toHex());
138 269 if(getconfigMD5 == getconfigMD52){
139 270 return true;
140 271 }else{
... ...
cacic-daemon/cacicD/cacictimer.h
... ... @@ -7,6 +7,7 @@
7 7 #include <QDateTime>
8 8 #include <QMutex>
9 9 #include <QProcess>
  10 +#include <QMap>
10 11 #include "ccacic.h"
11 12 #include "cacic_comm.h"
12 13 #include "cacic_computer.h"
... ... @@ -26,6 +27,8 @@ public:
26 27 bool getTest();
27 28 bool getConfig();
28 29 bool compararHashMD5(QJsonDocument getconfigfile,QJsonDocument getConfig);
  30 + bool Md5IsEqual(QVariant document01,QVariant document02);
  31 + QString getApplicationDirPath() const;
29 32 void setApplicationDirPath(const QString &value);
30 33 QString getApplicationDirPath() const;
31 34 void setDirProgram(const QString &value);
... ... @@ -41,6 +44,11 @@ private:
41 44 void iniciarGercols();
42 45 void iniciarInstancias();
43 46 void definirDirGercols(QString applicationDirPath);
  47 + QJsonObject jsonConfig;
  48 + QLogger::QLoggerManager *logManager;
  49 + QString applicationDirPath;
  50 + QString metodoDownload;
  51 + QMap<QString, QString> moduleMap; // key = hash md5, value = nome do modulo
44 52  
45 53 private slots:
46 54 void mslot();
... ...
cacic-teste/testcacic.cpp
... ... @@ -266,6 +266,7 @@ void CTestCacic::testColeta()
266 266 void CTestCacic::testLogger()
267 267 {
268 268 QLogger::QLoggerManager *logManager = QLogger::QLoggerManager::getInstance();
  269 + logManager->addDestination("./log.txt","teste",QLogger::DebugLevel);
269 270 logManager->addDestination("log01.txt","teste01",QLogger::DebugLevel);
270 271 logManager->addDestination("./log02.txt","teste02",QLogger::DebugLevel);
271 272 logManager->addDestination("../log03.txt","teste03",QLogger::DebugLevel);
... ...
gercols/gercols.cpp
... ... @@ -2,14 +2,9 @@
2 2  
3 3 Gercols::Gercols(QObject *parent)
4 4 {
5   - /*Aqui vamos conectar o slot principal. Acho que algo do tipo:
6   - * sinal iniciaColeta() chama o slot configuraColetas() que verifica
7   - * quais coletas serao necessárias e realiza a conexão dos sinais com
8   - * slots de coletas (coletaHardware, coletaSoftware, etc..)
9   - */
10 5  
11 6 /* Cria um json de configuração para teste.
12   - ******************************************/
  7 + *************************************************************************/
13 8 QJsonObject configTeste;
14 9 QJsonObject configComputer;
15 10 configComputer["operating_system"] = QJsonValue::fromVariant(QString(""));
... ... @@ -19,8 +14,9 @@ Gercols::Gercols(QObject *parent)
19 14 configTeste["hardware"] = QJsonValue::fromVariant(QString(""));
20 15 configTeste["software"] = QJsonValue::fromVariant(QString(""));
21 16  
22   - oColeta = new CColeta();
23 17 oCacic.setJsonToFile(configTeste,"configReq.json");
  18 + /*************************************************************************/
  19 + oColeta = new CColeta;
24 20 //Pega chave do registro, que será pega na instalação.
25 21 oCacic.setChaveCrypt(oCacic.getValueFromRegistry("Lightbase", "Cacic", "key").toString());
26 22  
... ... @@ -32,14 +28,6 @@ Gercols::Gercols(QObject *parent)
32 28 void Gercols::run()
33 29 {
34 30  
35   - /* Pega configurações do Json de configurações localizado
36   - * na pasta principal do cacic (deverá ser pega do registro,
37   - * estou tentando implementar isso no installcacic).
38   - */
39   -
40   - //Inicializa as classes e seta valores necessários oCacic.setCacicMainFolder(), por exemplo.
41   - // ... ainda a ser pensado
42   -
43 31 emit iniciaConfiguracao();
44 32 //emite sinal para começar a coleta
45 33 emit iniciaColeta();
... ... @@ -52,18 +40,7 @@ void Gercols::run()
52 40 else
53 41 qDebug() << "Erro ao realizar coleta.";
54 42  
55   - //O processo de criptografia e IV será tratado depois. Vamos começar a ajudar o Eli, depois vemos esse lance.
56   -// oCacic.deleteFile("coleta.json");
57   -
58   - //IV sendo gerado como uma string de 32 caracteres
59   -// std::string strIv = oCacic.genRandomString();
60   -
61   -// QString coletaEncriptada = oCacic.enCrypt(coletaString.toStdString(), strIv);
62   -
63   -// QJsonObject gercolsJson;
64   -// gercolsJson["coleta"] = QJsonValue::fromVariant(coletaEncriptada);
65   -// gercolsJson["iv"] = QJsonValue::fromVariant( QString::fromStdString(strIv) );
66   -// oCacic.setJsonToFile(gercolsJson, "gercols.json");
  43 + //O processo de criptografia e IV será tratado depois.
67 44  
68 45 //emite sinal "finished" pra finalizar a aplicação
69 46 emit finished();
... ...
gercols/gercols.pro
... ... @@ -25,18 +25,19 @@ TEMPLATE = app
25 25  
26 26 SOURCES += \
27 27 main.cpp \
  28 + ./gercols.cpp \
28 29 ../src/ccacic.cpp \
29 30 ../src/cacic_computer.cpp \
30 31 ../src/cacic_software.cpp \
31 32 ../src/cacic_hardware.cpp \
32 33 ../src/operatingsystem.cpp \
33 34 ../src/ccoleta.cpp \
34   - ./gercols.cpp \
35 35 ../src/vregistry.cpp \
36 36 ../src/vqtconvert.cpp \
37 37 ../src/wmi.cpp \
38 38  
39 39 HEADERS += \
  40 + ./gercols.h \
40 41 ../src/ccacic.h \
41 42 ../src/cacic_computer.h \
42 43 ../src/cacic_software.h \
... ... @@ -44,7 +45,6 @@ HEADERS += \
44 45 ../src/operatingsystem.h \
45 46 ../src/console.h \
46 47 ../src/ccoleta.h \
47   - ./gercols.h \
48 48 ../src/vregistry.h \
49 49 ../src/vqtconvert.h \
50 50 ../src/wmi.h \
... ...
install-cacic/install-cacic.pro
... ... @@ -7,7 +7,6 @@
7 7 QT += core
8 8 QT += network
9 9 QT -= gui
10   -QT += axcontainer
11 10  
12 11 TARGET = install-cacic
13 12 CONFIG += console
... ... @@ -16,6 +15,7 @@ CONFIG += c++11
16 15  
17 16 win32 {
18 17 LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp
  18 + QT += axcontainer
19 19 } else {
20 20 LIBS += -L/usr/lib -lcryptopp
21 21 }
... ... @@ -27,7 +27,8 @@ SOURCES += main.cpp \
27 27 ../src/ccacic.cpp \
28 28 ../src/cacic_computer.cpp \
29 29 ../src/operatingsystem.cpp \
30   - ../src/wmi.cpp
  30 + ../src/wmi.cpp \
  31 + ../src/QLogger.cpp
31 32  
32 33 HEADERS += \
33 34 installcacic.h \
... ... @@ -35,7 +36,8 @@ HEADERS += \
35 36 ../src/cacic_computer.h \
36 37 ../src/cacic_comm.h \
37 38 ../src/operatingsystem.h \
38   - ../src/wmi.h
  39 + ../src/wmi.h \
  40 + ../src/QLogger.h
39 41  
40 42 INCLUDEPATH += ../src \
41 43 ../src/crypto++/include/
... ...
install-cacic/installcacic.cpp
... ... @@ -3,10 +3,13 @@
3 3 InstallCacic::InstallCacic(QObject *parent) :
4 4 QObject(parent)
5 5 {
6   -
  6 + logManager = QLogger::QLoggerManager::getInstance();
  7 + logManager->addDestination("./log.txt","Install",QLogger::DebugLevel);
7 8 }
8 9  
9 10 void InstallCacic::run(QStringList argv, int argc) {
  11 +
  12 + QLogger::QLog_Debug("Install", "Inicio de instalacao");
10 13 bool ok;
11 14 //valida os parametros repassados
12 15 QMap<QString, QString> param = validaParametros(argv, argc, &ok);
... ... @@ -20,8 +23,8 @@ void InstallCacic::run(QStringList argv, int argc) {
20 23 //conectado, grava a chave na classe;
21 24 oCacic.setChaveCrypt(jsonLogin["reply"].toObject()["chavecrip"].toString());
22 25 #ifdef Q_OS_WIN
23   - oCacic.setCacicMainFolder("c:/cacic");
24   -#elif Q_LINUX
  26 + oCacic.setCacicMainFolder("c:/cacic/");
  27 +#elif defined(Q_OS_LINUX)
25 28 oCacic.setCacicMainFolder("/home/cacic");
26 29 #endif
27 30 oCacic.createFolder(oCacic.getCacicMainFolder());
... ... @@ -32,10 +35,12 @@ void InstallCacic::run(QStringList argv, int argc) {
32 35 registro["mainFolder"] = oCacic.getCacicMainFolder();
33 36 oCacic.setValueToRegistry("Lightbase", "Cacic", registro);
34 37 //starta o processo do cacic.
  38 +
  39 + //TO DO: Fazer download do serviço
35 40 #ifdef Q_OS_WIN
36   - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", true, &ok);
  41 + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", false, &ok);
37 42 #else
38   - QString exitStatus = oCacic.startProcess("cacic", true, &ok);
  43 + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic", false, &ok);
39 44 #endif
40 45 if (!ok)
41 46 std::cout << "Erro ao iniciar o processo: "
... ... @@ -57,6 +62,7 @@ void InstallCacic::run(QStringList argv, int argc) {
57 62 << " [-help] Lista todos comandos.\n";
58 63 }
59 64  
  65 + logManager->closeLogger();
60 66 emit finished();
61 67 }
62 68  
... ...
install-cacic/installcacic.h
... ... @@ -7,6 +7,7 @@
7 7 #include <cacic_computer.h>
8 8 #include <ccacic.h>
9 9 #include "iostream"
  10 +#include "QLogger.h"
10 11  
11 12 class InstallCacic : public QObject
12 13 {
... ... @@ -25,6 +26,7 @@ private:
25 26 CacicComm oCacicComm;
26 27 CACIC_Computer oCacicComputer;
27 28 CCacic oCacic;
  29 + QLogger::QLoggerManager *logManager;
28 30 signals:
29 31 void finished();
30 32  
... ...
src/cacic_comm.h
... ... @@ -61,6 +61,10 @@ public:
61 61 QJsonObject jsonObj;
62 62 if (isSsl){
63 63 url = urlSsl.isEmpty() ? "https://" + this->urlGerente + route : this->urlSsl + route;
  64 + if (!url.isValid()){
  65 + jsonObj["error"] = QVariant("Invalid Url");
  66 + return jsonObj;
  67 + }
64 68 req.setSslConfiguration(QSslConfiguration::defaultConfiguration());
65 69 } else
66 70 url = "http://" + urlGerente + route;
... ... @@ -152,6 +156,13 @@ public:
152 156 return retorno;
153 157 }
154 158  
  159 + bool ftpDownload(QString path){
  160 + QUrl url(urlGerente);
  161 + url.setScheme("ftp");
  162 + url.setPath(path);
  163 +
  164 + }
  165 +
155 166 QString getUrlSsl (){
156 167 return this->urlSsl;
157 168 }
... ...
src/cacic_hardware.cpp
... ... @@ -47,8 +47,8 @@ QJsonObject cacic_hardware::coletaWin()
47 47 // (Verifica se é notebook)
48 48 params.clear();
49 49 wmiResult = wmi::wmiSearch("Win32_PortableBattery", params);
  50 + hardware["IsNotebook"] = QJsonValue::fromVariant(!wmiResult.isNull());
50 51 if (!wmiResult.isNull()){
51   - hardware["IsNotebook"] = QJsonValue::fromVariant(!wmiResult.isNull());
52 52 hardware["PortableBattery"] = wmiResult;
53 53 }
54 54 //Win32_Bios
... ... @@ -397,6 +397,10 @@ void cacic_hardware::coletaLinuxMotherboard(QJsonObject &amp;hardware)
397 397 motherboard["product_name"] = QJsonValue::fromVariant( QString(line.split(":")[1].mid(1)) );
398 398 } else if(line.contains("Version:")){
399 399 motherboard["version"] = QJsonValue::fromVariant( QString(line.split(":")[1].mid(1)) );
  400 + } else if(line.contains("Asset Tag:")){
  401 + motherboard["asset_tag"] = QJsonValue::fromVariant( QString(line.split(":")[1].mid(1)) );
  402 + } else if(line.contains("Serial Number:")){
  403 + motherboard["serial_number"] = QJsonValue::fromVariant( QString(line.split(":")[1].mid(1)) );
400 404 }
401 405 }
402 406  
... ...