Commit cf3a92c42f6ba9fbc405e9a7b8c1b2c7e0bb089e

Authored by Eric Menezes Noronha
1 parent ee47ba9e
Exists in master

Alteração do esquema de download por ftp, algumas alterações no test e debugs

cacic-teste/testcacic.cpp
... ... @@ -9,22 +9,8 @@ CTestCacic::CTestCacic(QObject *parent) :
9 9  
10 10 void CTestCacic::initTestCase()
11 11 {
12   - this->OCacicComm = new CacicComm("https://teste.cacic.cc/app_dev.php",
13   - "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__",
14   - "P198PVwtz5F5CfZPSUrzuaQA/QG1sTnwzl/rBnj8M7y5MglANGodG5LLD4q7oY809HuDR4g5tL64lZRBKvKPmEgWd9iAZKvT4UAm9XWN3nKKLGaznCaJohmntNGqrJP1Zd9riTHGu10mPbg/Uh3TCbBHVOICvu5sDlINlCR6A3[[MAIS]]a55RhfKNidvr5uX0kozCxr5t2DyOb5oPocEGyJKyHLQ==__CRYPTED__",
15   - "1",
16   - "0",
17   - "0",
18   - "YwpgjzZ86/eCsjvOki1KkQ==__CRYPTED__",
19   - "8PT6U445MPNr3S7WHFa20ge/8NJSspSYE/UL3zf[[MAIS]]wkEfNZ7p1B/2o6i89gTZ44Ok__CRYPTED__",
20   - "wshPlZWvLPhbUEQFQ1aQmA==__CRYPTED__",
21   - "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__",
22   - "Yot8BeM9lOh431SB7dYQXw==__CRYPTED__",
23   - "Dcr8b5IfZOJjt6qyH5dGyw==__CRYPTED__",
24   - "2.5.1.1.256.32",
25   - "2.8.1.7",
26   - "2.8.1.6");
27   - OCacicComm->setUrlSsl("https://teste.cacic.cc/app_dev.php");
  12 + this->OCacicComm = new CacicComm();
  13 + OCacicComm->setUrlGerente("http://10.209.134.100/cacic/app_dev.php");
28 14 OCacicComm->setUsuario("cacic");
29 15 OCacicComm->setPassword("cacic123");
30 16 this->testPath = QDir::currentPath() + "/teste";
... ... @@ -177,19 +163,6 @@ void CTestCacic::testJsonFromFile()
177 163 QVERIFY(OCacic.getJsonFromFile("teste.json")["teste"].toString() == "teste");
178 164 }
179 165  
180   -void CTestCacic::testStartService()
181   -{
182   - bool ok;
183   - QString exitStatus;
184   -#ifdef Q_OS_WIN
185   - exitStatus = OCacic.startProcess("../../install-cacic/debug/install-cacic.exe", true, &ok);
186   - qDebug() << exitStatus;
187   -#else
188   - exitStatus = OCacic.startProcess("../install-cacic/debug/install-cacic", true, &ok);
189   -#endif
190   - QVERIFY(ok);
191   -}
192   -
193 166 void CTestCacic::testSetRegistry()
194 167 {
195 168 QVariantMap valueMap;
... ... @@ -229,7 +202,7 @@ void CTestCacic::testGetTest()
229 202 QJsonObject envio;
230 203 envio["computador"] = OCacicComp.toJsonObject();
231 204 // qDebug() << envio;
232   - OCacicComm->setUrlGerente("http://teste.cacic.cc");
  205 +// OCacicComm->setUrlGerente("http://teste.cacic.cc");
233 206 OCacicComm->comm("/ws/neo/getTest", &ok, envio, true);
234 207 QVERIFY(ok);
235 208 }
... ... @@ -312,23 +285,43 @@ void CTestCacic::testLogger()
312 285 logFile06.close();
313 286 }
314 287  
315   -void CTestCacic::testFtpDownload()
  288 +void CTestCacic::testDownload()
316 289 {
317   - OCacicComm->ftpDownload("ftp://ftp.unicamp.br", "/pub/gnu/Licenses/gpl-2.0.txt", "");
318   - QFile downloaded("gpl-2.0.txt");
  290 + QJsonObject ftp;
  291 + ftp = OCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject()["metodoDownload"].toObject();
  292 + OCacicComm->setFtpPass(ftp["senha"].toString());
  293 + OCacicComm->setFtpUser(ftp["usuario"].toString());
  294 + OCacicComm->fileDownload(ftp["tipo"].toString(),
  295 + ftp["url"].toString(),
  296 + "/" + ftp["path"].toString() + "install-cacic",
  297 + "");
  298 + QFile downloaded("cacic-service");
319 299  
320 300 QVERIFY( downloaded.open(QIODevice::ReadOnly) );
321 301 QVERIFY( downloaded.exists() );
322 302 QVERIFY( downloaded.readAll() != "" );
323 303 }
324 304  
  305 +void CTestCacic::testStartService()
  306 +{
  307 + bool ok;
  308 + QString exitStatus;
  309 +#ifdef Q_OS_WIN
  310 + exitStatus = OCacic.startProcess("install-cacic.exe", true, &ok);
  311 + qDebug() << exitStatus;
  312 +#else
  313 + exitStatus = OCacic.startProcess("./install-cacic", false, &ok);
  314 +// qDebug() << exitStatus;
  315 +#endif
  316 + QVERIFY(ok);
  317 +}
325 318 void CTestCacic::testEnviaColeta()
326 319 {
327 320 bool ok;
328 321 QJsonObject coletaEnvio = oColeta.toJsonObject();
329 322 OCacic.setJsonToFile(oColeta.toJsonObject(), "coleta.json");
330 323 // qDebug() << coletaEnvio;
331   - qDebug() << OCacicComm->comm("/ws/neo/coleta", &ok, coletaEnvio, true);
  324 + OCacicComm->comm("/ws/neo/coleta", &ok, coletaEnvio, true);
332 325 QVERIFY(ok);
333 326 }
334 327  
... ... @@ -352,6 +345,6 @@ void CTestCacic::cleanupTestCase()
352 345 OCacic.deleteFolder("../logs");
353 346 OCacic.deleteFile("configRequest.json");
354 347 OCacic.deleteFile("teste.json");
355   - OCacic.deleteFile("getConfig.json");
  348 +// OCacic.deleteFile("getConfig.json");
356 349 OCacic.deleteFolder("./temp");
357 350 }
... ...
cacic-teste/testcacic.h
... ... @@ -45,42 +45,42 @@ signals:
45 45 public slots:
46 46  
47 47 private slots:
48   - void initTestCase();
49   - void testCommStatus();
50   -// void testComm();
51   - void testGetAndSetValueFromFile();
52   - void testGetValueFromTags();
53   - void testCreateFolder();
54   - void testDeleteFolder();
55   - void testDeleteFile();
56   - void testInterfaceDeRede();
57   - void testConsole();
58   - void testPegarUsu();
59   - void testJsonValueFromJsonString();
60   - void testcoletaIdOs();
61   - void testpegarOS();
62   - void testLogin();
63   - void testSslConnection();
64   - void testEnCrypt();
65   - void testDeCrypt();
66   - void testCacicCompToJsonObject();
67   - void testOperatingSystemToJsonObject();
68   - void testJsonToFile();
69   - void testJsonFromFile();
70   - void testStartService();
71   - void testSetRegistry();
72   - void testGetValueFromRegistry();
73   - void testRemoveRegistry();
74   - void testConvertDouble();
75   - void testGetTest();
76   - void testGetConfig();
77   - void testColetaSoftware();
78   - void testColetaHardware();
79   - void testLogger();
80   - void testFtpDownload();
81   - void testEnviaColeta();
82   - void testGetModulesValues();
83   - void cleanupTestCase();
  48 + void initTestCase();
  49 + void testCommStatus();
  50 + // void testComm();
  51 + void testGetAndSetValueFromFile();
  52 + void testGetValueFromTags();
  53 + void testCreateFolder();
  54 + void testDeleteFolder();
  55 + void testDeleteFile();
  56 + void testInterfaceDeRede();
  57 + void testConsole();
  58 + void testPegarUsu();
  59 + void testJsonValueFromJsonString();
  60 + void testcoletaIdOs();
  61 + void testpegarOS();
  62 + void testLogin();
  63 + void testSslConnection();
  64 + void testEnCrypt();
  65 + void testDeCrypt();
  66 + void testCacicCompToJsonObject();
  67 + void testOperatingSystemToJsonObject();
  68 + void testJsonToFile();
  69 + void testJsonFromFile();
  70 + void testSetRegistry();
  71 + void testGetValueFromRegistry();
  72 + void testRemoveRegistry();
  73 + void testConvertDouble();
  74 + void testGetTest();
  75 + void testGetConfig();
  76 + void testColetaSoftware();
  77 + void testColetaHardware();
  78 + void testLogger();
  79 + void testDownload();
  80 + void testStartService();
  81 + void testEnviaColeta();
  82 + void testGetModulesValues();
  83 + void cleanupTestCase();
84 84 };
85 85  
86 86 #endif // TESTINSTALLCACIC_H
... ...
install-cacic/installcacic.cpp
... ... @@ -48,7 +48,7 @@ void InstallCacic::run(QStringList argv, int argc) {
48 48 #elif defined(Q_OS_LINUX)
49 49 oCacic.setCacicMainFolder(configsJson["cacic_main_folder"].isString() ?
50 50 configsJson["cacic_main_folder"].toString() :
51   - "/usr/cacic");
  51 + "/usr/share/cacic");
52 52 #endif
53 53  
54 54 oCacic.createFolder(oCacic.getCacicMainFolder());
... ... @@ -62,6 +62,8 @@ void InstallCacic::run(QStringList argv, int argc) {
62 62 //TO DO: Fazer download do serviço
63 63 QJsonObject metodoDownload;
64 64 metodoDownload = configsJson["agentcomputer"].toObject()["metodoDownload"].toObject();
  65 + oCacicComm->setFtpPass(metodoDownload["senha"].toString());
  66 + oCacicComm->setFtpUser(metodoDownload["usuario"].toString());
65 67 #ifdef Q_OS_WIN
66 68 oCacicComm->fileDownload(metodoDownload["tipo"].toString(),
67 69 metodoDownload["url"].toString(),
... ... @@ -76,7 +78,7 @@ void InstallCacic::run(QStringList argv, int argc) {
76 78  
77 79 oCacicComm->fileDownload(metodoDownload["tipo"].toString(),
78 80 metodoDownload["url"].toString(),
79   - metodoDownload["path"].toString() + "/cacic-service",
  81 + metodoDownload["path"].toString() + "cacic-service",
80 82 oCacic.getCacicMainFolder());
81 83  
82 84 QFile fileService(oCacic.getCacicMainFolder()+"/cacic-service");
... ... @@ -93,21 +95,26 @@ void InstallCacic::run(QStringList argv, int argc) {
93 95 &ok,
94 96 arguments);
95 97 #endif
96   - if (!ok)
  98 + if (!ok) {
97 99 std::cout << "Erro ao iniciar o processo: "
98 100 << exitStatus.toStdString() << "\n";
99   - else {
  101 + QLogger::QLog_Info("Install Cacic", QString("Erro ao iniciar o processo") + exitStatus);
  102 + } else {
100 103 std::cout << "Instalação realizada com sucesso." << "\n";
  104 + QLogger::QLog_Info("Install Cacic", QString("Instalação realizada com sucesso."));
101 105 }
102 106  
103 107 } else {
104 108 std::cout << "Falha ao pegar configurações: " << configs["error"].toString().toStdString() << "\n";
  109 + QLogger::QLog_Info("Install Cacic", QString("Falha ao pegar configurações: ") + configs["error"].toString());
105 110 }
106 111  
107   - } else
  112 + } else {
108 113 std::cout << "Nao foi possivel realizar o login.\n"
109 114 << " Código: " << jsonLogin["codestatus"].toString().toStdString() << "\n"
110 115 << " " << jsonLogin["error"].toString().toStdString() << "\n";
  116 + QLogger::QLog_Info("Install Cacic", QString("Falha no login: ") + jsonLogin["error"].toString());
  117 + }
111 118 } else if ((param.contains("default")) && (param["default"] == "uninstall")){
112 119 this->uninstall();
113 120 } else {
... ... @@ -147,6 +154,7 @@ void InstallCacic::uninstall()
147 154 oCacic.deleteFolder("c:/cacic");
148 155 oCacic.removeRegistry("Lightbase", "Cacic");
149 156 std::cout << "\nCacic desinstalado com sucesso.\n";
  157 + QLogger::QLog_Info("Install Cacic", QString("Cacic desinstalado com sucesso."));
150 158 emit finished();
151 159 }
152 160  
... ...
src/cacic_comm.cpp
... ... @@ -192,15 +192,16 @@ bool CacicComm::fileDownload(const QString &amp;mode, const QString &amp;urlServer, cons
192 192  
193 193 QStringList splitPath = path.split("/");
194 194  
195   - fileHandler = new QFile(pathDownload + "/" + splitPath[splitPath.size() - 1]);
  195 + fileHandler = new QFile((!pathDownload.isEmpty() ? pathDownload + "/" : "") + splitPath[splitPath.size() - 1]);
  196 +
196 197 if( !fileHandler->open(QIODevice::WriteOnly) ) {
197 198 qDebug() << "ftpDownload: fileHandler nâo pode abrir arquivo.";
198   - return false;
199 199 }
200 200  
201   - QUrl url(urlServer);
202   - url.setScheme(mode);
203   - url.setPath(path);
  201 + QUrl url(mode + "://" + (urlServer.endsWith("/") ? urlServer : urlServer + "/") + path);
  202 +// url.setScheme(mode);
  203 +// url.setUrl(urlServer);
  204 +// url.setPath(path);
204 205 if (!this->ftpUser.isEmpty())
205 206 url.setUserName(ftpUser);
206 207 if (!this->ftpPass.isEmpty())
... ... @@ -223,6 +224,8 @@ void CacicComm::fileDownloadFinished(QNetworkReply* reply)
223 224 if (reply->size() > 0){
224 225 QTextStream out(fileHandler);
225 226 out << reply->readAll();
  227 + fileHandler->setPermissions(QFileDevice::ExeOwner);
  228 +// qDebug() << fileHandler->permissions();
226 229 fileHandler->close();
227 230 reply->close();
228 231 } else
... ...
src/ccoleta.cpp
... ... @@ -7,18 +7,18 @@ CColeta::CColeta(QObject *parent)
7 7  
8 8 void CColeta::coletaHardware()
9 9 {
10   - qDebug() << "coletaHardware() começando sua execução";
  10 +// qDebug() << "coletaHardware() começando sua execução";
11 11 oHardware.iniciaColeta();
12   - qDebug() << "coletaHardware() executado";
  12 +// qDebug() << "coletaHardware() executado";
13 13 emit hardwareFinish();
14 14 }
15 15  
16 16  
17 17 void CColeta::coletaSoftware()
18 18 {
19   - qDebug() << "coletaSoftware() começando sua execução";
  19 +// qDebug() << "coletaSoftware() começando sua execução";
20 20 oSoftware.iniciaColeta();
21   - qDebug() << "coletaSoftware() executado";
  21 +// qDebug() << "coletaSoftware() executado";
22 22 emit softwareFinish();
23 23 }
24 24  
... ...
src/checkmodules.cpp
... ... @@ -11,7 +11,7 @@ CheckModules::CheckModules(const QString &amp;workingPath)
11 11 qDebug() << applicationUrl;
12 12 QJsonArray modulos;
13 13 //pega o jsonarray dos módulos
14   - modulos = configFile["agentcomputer"].toObject()["modulos"].toArray();
  14 + modulos = configFile["agentcomputer"].toObject()["modulos"].toObject()["cacic"].toArray();
15 15 foreach (QJsonValue modulo, modulos){
16 16 //grava o nome com o hash de cada modulo
17 17 modules[modulo.toObject()["nome"].toString()] = modulo.toObject()["hash"].toString();
... ... @@ -56,161 +56,26 @@ bool CheckModules::verificaModulo(const QString &amp;moduloName, const QString &amp;modu
56 56 metodoDownload = oCacic.getJsonFromFile("getConfig.json")["agentcomputer"].toObject()["metodoDownload"].toObject();
57 57 oCacicComm.setFtpUser(metodoDownload["usuario"].toString());
58 58 oCacicComm.setFtpPass(metodoDownload["senha"].toString());
59   - if(metodoDownload["tipo"].toString() == "ftp"){
60   - qDebug() << moduloName << "ftp download";
61   - downloadOk = oCacicComm.ftpDownload(this->applicationUrl,
62   - metodoDownload["path"].toString() + "/" + moduloName,
63   - oCacic.getCacicMainFolder() + "/temp/");
64   - } else if (metodoDownload["tipo"].toString() == "http"){
65   - qDebug() << moduloName << "http download";
66   - downloadOk = oCacicComm.httpDownload(this->applicationUrl,
67   - metodoDownload["path"].toString() + "/" + moduloName,
68   - oCacic.getCacicMainFolder() + "/temp/");
  59 + qDebug() << moduloName << "ftp download";
  60 + downloadOk = oCacicComm.fileDownload(metodoDownload["tipo"].toString(),
  61 + this->applicationUrl,
  62 + metodoDownload["path"].toString() + "/" + moduloName,
  63 + oCacic.getCacicMainFolder() + "/temp/");
  64 +
  65 + if (downloadOk){
  66 + //faz uma verificação do novo módulo.
  67 + novoModulo = new QFile(oCacic.getCacicMainFolder() + "/temp/" + moduloName);
  68 + if (!(novoModulo->exists() && novoModulo->size()>1 && oCacic.Md5IsEqual(QVariant::fromValue(modulo), moduloHash))){
  69 + qDebug() << moduloName << "falha no download..";
  70 + novoModulo->remove();
  71 + return false;
  72 + } else {
  73 + qDebug() << moduloName << "Sucesso!";
  74 + return true;
  75 + }
69 76 } else {
70   - qDebug() << moduloName << "metodo de download incorreto";
71 77 return false;
72 78 }
73   - //faz uma verificação do novo módulo.
74   - novoModulo = new QFile(oCacic.getCacicMainFolder() + "/temp/" + moduloName);
75   - if (!(novoModulo->exists() && novoModulo->size()>1 && oCacic.Md5IsEqual(QVariant::fromValue(modulo), moduloHash))){
76   - qDebug() << moduloName << "falha no download..";
77   - novoModulo->remove();
78   - return false;
79   - } else {
80   - qDebug() << moduloName << "Sucesso!";
81   - return true;
82   - }
83 79  
84 80 }
85 81 }
86   -
87   -//QStringList CheckModules::verificaModulos(){
88   -// // Compara o novo arquivo de configuração com um antigo e se forem diferentes
89   -// // mantem o mais recente; caso iguais simplesmente apaga o novo.
90   -// QFile *fileOld;
91   -// QFile *fileNew;
92   -
93   -// fileOld = new QFile(this->applicationDirPath + "/getConfig.json");
94   -// fileNew = new QFile(this->applicationDirPath + "/getConfigNew.json");
95   -
96   -// if( fileOld->exists() && fileNew->exists() ){
97   -// if( Md5IsEqual(QVariant::fromValue(fileOld), QVariant::fromValue(fileNew)) ) {
98   -// fileNew->remove();
99   -// } else {
100   -// // Renomeia getConfigNew.json para getConfig.json
101   -// fileOld->remove();
102   -// fileNew->rename("getConfigNew.json","getConfig.json");
103   -// }
104   -// jsonConfig = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json");
105   -// } else if( fileOld->exists() ){
106   -// jsonConfig = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json");
107   -// } else {
108   -// QLogger::QLog_Error("Cacic Daemon (Timer)", "Arquivo de configuração não criado.");
109   -// }
110   -// delete fileOld;
111   -// delete fileNew;
112   -// lerArquivoConfig(jsonConfig["agentcomputer"].toObject());
113   -
114   -// QStringList nomesModulos;
115   -
116   -// int countExecNotFound = 0;
117   -// QMap<QString, QString>::const_iterator moduloIterator = moduleMap.constBegin();
118   -// while (moduloIterator != moduleMap.constEnd()) {
119   -// QString nomeModulo = moduloIterator.value();
120   -// QString hashModulo = moduloIterator.key();
121   -// // Calcula hash do binario atual
122   -//#if defined(Q_OS_WIN)
123   -// fileOld = new QFile(this->applicationDirPath + "/" + nomeModulo + ".exe");
124   -//#else
125   -// fileOld = new QFile(this->applicationDirPath + "/" + nomeModulo);
126   -//#endif
127   -// if(!fileOld->exists()) {
128   -// QLogger::QLog_Error("Cacic Daemon (Timer)", QString("Módulo ").append(nomeModulo).append(" não encontrado."));
129   -// countExecNotFound++;
130   -
131   -// if( countExecNotFound == moduleMap.size() ) {
132   -// QLogger::QLog_Error("Cacic Daemon (Timer)", "Não foi possível encontrar nenhum módulo executável!");
133   -// return QStringList();
134   -// }
135   -
136   -// // pula para o próximo módulo no moduloMap
137   -// moduloIterator++;
138   -// continue;
139   -// }
140   -
141   -// QString oldMd5 = QString(QCryptographicHash::hash(fileOld->readAll(),QCryptographicHash::Md5).toHex());
142   -// if ( oldMd5 != hashModulo ) {
143   -
144   -//#if defined(Q_OS_WIN)
145   -// fileOld->rename(this->applicationDirPath + "/" + nomeModulo + ".exe",
146   -// this->applicationDirPath + "/" + nomeModulo + "Old.exe");
147   -//#elif defined(Q_OS_LINUX)
148   -// fileOld->rename(this->applicationDirPath + "/" + nomeModulo,
149   -// this->applicationDirPath + "/" + nomeModulo + "Old");
150   -//#endif
151   -
152   -// // Download nova versão do executável
153   -// QList<QMap<QString,QString> >::const_iterator metodosIterator = metodosDownload.constBegin();
154   -// bool downloadSucess = false;
155   -// while ( !downloadSucess && metodosIterator != metodosDownload.constEnd() ) {
156   -// if( metodosIterator->value("tipo") == "ftp" || metodosIterator->value("tipo") == "" ) {
157   -// if ( OCacicComm->ftpDownload( metodosIterator->value("url"), metodosIterator->value("path") ) )
158   -// downloadSucess = true;
159   -// } else if ( metodosIterator->value("tipo") == "http" ) {
160   -// if( OCacicComm->httpDownload( metodosIterator->value("url"), metodosIterator->value("path") ) )
161   -// downloadSucess = true;
162   -// }
163   -// metodosIterator++;
164   -// }
165   -// fileOld->remove();
166   -// delete fileOld;
167   -// }
168   -
169   -// nomesModulos.append(nomeModulo);
170   -
171   -// moduloIterator++;
172   -// }
173   -
174   -// return nomesModulos;
175   -//}
176   -
177   -//void CheckModules::lerArquivoConfig ( const QJsonObject& jsonConfig )
178   -//{
179   -// /* lê json de configurações e armazena quais módulos executáveis.
180   -// * E faz o mesmo tipo de comparação de hashs, com o fim de:
181   -// * ou mantem o binário do módulo ou baixa um novo.
182   -// */
183   -// foreach( QJsonValue individualModule, jsonConfig["modulos"].toArray() ) {
184   -// QString moduloKey, moduloValue;
185   -
186   -// moduloKey = individualModule.toObject()["hash"].toString();
187   -// moduloValue = individualModule.toObject()["nome"].toString();
188   -
189   -// moduleMap.insert(moduloKey, moduloValue);
190   -// }
191   -
192   -// if ( jsonConfig["metodoDownload"].isArray() ) {
193   -
194   -// foreach (QJsonValue individualMetodo, jsonConfig["metodoDownload"].toArray() ) {
195   -// QMap<QString, QString> newEntry;
196   -
197   -// newEntry.insert(QString("tipo"), individualMetodo.toObject()["tipo"].toString() );
198   -// newEntry.insert(QString("url"), individualMetodo.toObject()["url"].toString() );
199   -// newEntry.insert(QString("path"), individualMetodo.toObject()["path"].toString() );
200   -// newEntry.insert(QString("usuario"), individualMetodo.toObject()["usario"].toString() );
201   -// newEntry.insert(QString("senha"), individualMetodo.toObject()["senha"].toString() );
202   -
203   -// metodosDownload.append( newEntry );
204   -// }
205   -// } else {
206   -// QMap<QString, QString> newEntry;
207   -
208   -// newEntry.insert(QString("tipo"), jsonConfig["metodoDownload"].toObject()["tipo"].toString() );
209   -// newEntry.insert(QString("url"), jsonConfig["metodoDownload"].toObject()["url"].toString() );
210   -// newEntry.insert(QString("path"), jsonConfig["metodoDownload"].toObject()["path"].toString() );
211   -// newEntry.insert(QString("usuario"), jsonConfig["metodoDownload"].toObject()["usario"].toString() );
212   -// newEntry.insert(QString("senha"), jsonConfig["metodoDownload"].toObject()["senha"].toString() );
213   -
214   -// metodosDownload.append( newEntry );
215   -// }
216   -//}
... ...