Commit a943aec0b0c1c50667f9a43703be8333a07993d5
1 parent
47feef3a
Exists in
master
merge
Showing
6 changed files
with
25 additions
and
36 deletions
Show diff stats
cacic-teste/testcacic.cpp
@@ -272,10 +272,9 @@ void CTestCacic::testLogger() | @@ -272,10 +272,9 @@ void CTestCacic::testLogger() | ||
272 | 272 | ||
273 | QFile logFile("./log.txt"); | 273 | QFile logFile("./log.txt"); |
274 | if(logFile.exists()) logFile.open(QIODevice::ReadOnly); | 274 | if(logFile.exists()) logFile.open(QIODevice::ReadOnly); |
275 | - | ||
276 | QVERIFY(logManager && | 275 | QVERIFY(logManager && |
277 | logFile.exists() && | 276 | logFile.exists() && |
278 | - logFile.readLine().contains("Teste do módulo logger.") | 277 | + logFile.readLine().contains("Teste") |
279 | ); | 278 | ); |
280 | 279 | ||
281 | logManager->closeLogger(); | 280 | logManager->closeLogger(); |
gercols/gercols.cpp
@@ -2,14 +2,9 @@ | @@ -2,14 +2,9 @@ | ||
2 | 2 | ||
3 | Gercols::Gercols(QObject *parent) | 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 | /* Cria um json de configuração para teste. | 6 | /* Cria um json de configuração para teste. |
12 | - ******************************************/ | 7 | + *************************************************************************/ |
13 | QJsonObject configTeste; | 8 | QJsonObject configTeste; |
14 | QJsonObject configComputer; | 9 | QJsonObject configComputer; |
15 | configComputer["operating_system"] = QJsonValue::fromVariant(QString("")); | 10 | configComputer["operating_system"] = QJsonValue::fromVariant(QString("")); |
@@ -19,8 +14,9 @@ Gercols::Gercols(QObject *parent) | @@ -19,8 +14,9 @@ Gercols::Gercols(QObject *parent) | ||
19 | configTeste["hardware"] = QJsonValue::fromVariant(QString("")); | 14 | configTeste["hardware"] = QJsonValue::fromVariant(QString("")); |
20 | configTeste["software"] = QJsonValue::fromVariant(QString("")); | 15 | configTeste["software"] = QJsonValue::fromVariant(QString("")); |
21 | 16 | ||
22 | - oColeta = new CColeta(); | ||
23 | oCacic.setJsonToFile(configTeste,"configReq.json"); | 17 | oCacic.setJsonToFile(configTeste,"configReq.json"); |
18 | + /*************************************************************************/ | ||
19 | + oColeta = new CColeta; | ||
24 | //Pega chave do registro, que será pega na instalação. | 20 | //Pega chave do registro, que será pega na instalação. |
25 | oCacic.setChaveCrypt(oCacic.getValueFromRegistry("Lightbase", "Cacic", "key").toString()); | 21 | oCacic.setChaveCrypt(oCacic.getValueFromRegistry("Lightbase", "Cacic", "key").toString()); |
26 | 22 | ||
@@ -32,14 +28,6 @@ Gercols::Gercols(QObject *parent) | @@ -32,14 +28,6 @@ Gercols::Gercols(QObject *parent) | ||
32 | void Gercols::run() | 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 | emit iniciaConfiguracao(); | 31 | emit iniciaConfiguracao(); |
44 | //emite sinal para começar a coleta | 32 | //emite sinal para começar a coleta |
45 | emit iniciaColeta(); | 33 | emit iniciaColeta(); |
@@ -52,18 +40,7 @@ void Gercols::run() | @@ -52,18 +40,7 @@ void Gercols::run() | ||
52 | else | 40 | else |
53 | qDebug() << "Erro ao realizar coleta."; | 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 | //emite sinal "finished" pra finalizar a aplicação | 45 | //emite sinal "finished" pra finalizar a aplicação |
69 | emit finished(); | 46 | emit finished(); |
gercols/gercols.pro
@@ -25,18 +25,19 @@ TEMPLATE = app | @@ -25,18 +25,19 @@ TEMPLATE = app | ||
25 | 25 | ||
26 | SOURCES += \ | 26 | SOURCES += \ |
27 | main.cpp \ | 27 | main.cpp \ |
28 | + ./gercols.cpp \ | ||
28 | ../src/ccacic.cpp \ | 29 | ../src/ccacic.cpp \ |
29 | ../src/cacic_computer.cpp \ | 30 | ../src/cacic_computer.cpp \ |
30 | ../src/cacic_software.cpp \ | 31 | ../src/cacic_software.cpp \ |
31 | ../src/cacic_hardware.cpp \ | 32 | ../src/cacic_hardware.cpp \ |
32 | ../src/operatingsystem.cpp \ | 33 | ../src/operatingsystem.cpp \ |
33 | ../src/ccoleta.cpp \ | 34 | ../src/ccoleta.cpp \ |
34 | - ./gercols.cpp \ | ||
35 | ../src/vregistry.cpp \ | 35 | ../src/vregistry.cpp \ |
36 | ../src/vqtconvert.cpp \ | 36 | ../src/vqtconvert.cpp \ |
37 | ../src/wmi.cpp \ | 37 | ../src/wmi.cpp \ |
38 | 38 | ||
39 | HEADERS += \ | 39 | HEADERS += \ |
40 | + ./gercols.h \ | ||
40 | ../src/ccacic.h \ | 41 | ../src/ccacic.h \ |
41 | ../src/cacic_computer.h \ | 42 | ../src/cacic_computer.h \ |
42 | ../src/cacic_software.h \ | 43 | ../src/cacic_software.h \ |
@@ -44,7 +45,6 @@ HEADERS += \ | @@ -44,7 +45,6 @@ HEADERS += \ | ||
44 | ../src/operatingsystem.h \ | 45 | ../src/operatingsystem.h \ |
45 | ../src/console.h \ | 46 | ../src/console.h \ |
46 | ../src/ccoleta.h \ | 47 | ../src/ccoleta.h \ |
47 | - ./gercols.h \ | ||
48 | ../src/vregistry.h \ | 48 | ../src/vregistry.h \ |
49 | ../src/vqtconvert.h \ | 49 | ../src/vqtconvert.h \ |
50 | ../src/wmi.h \ | 50 | ../src/wmi.h \ |
install-cacic/installcacic.cpp
@@ -20,9 +20,9 @@ void InstallCacic::run(QStringList argv, int argc) { | @@ -20,9 +20,9 @@ void InstallCacic::run(QStringList argv, int argc) { | ||
20 | //conectado, grava a chave na classe; | 20 | //conectado, grava a chave na classe; |
21 | oCacic.setChaveCrypt(jsonLogin["reply"].toObject()["chavecrip"].toString()); | 21 | oCacic.setChaveCrypt(jsonLogin["reply"].toObject()["chavecrip"].toString()); |
22 | #ifdef Q_OS_WIN | 22 | #ifdef Q_OS_WIN |
23 | - oCacic.setCacicMainFolder("c:/cacic"); | 23 | + oCacic.setCacicMainFolder("c:/cacic/"); |
24 | #elif Q_LINUX | 24 | #elif Q_LINUX |
25 | - oCacic.setCacicMainFolder("/home/cacic"); | 25 | + oCacic.setCacicMainFolder("/home/cacic/"); |
26 | #endif | 26 | #endif |
27 | oCacic.createFolder(oCacic.getCacicMainFolder()); | 27 | oCacic.createFolder(oCacic.getCacicMainFolder()); |
28 | //grava chave em registro; | 28 | //grava chave em registro; |
@@ -32,10 +32,12 @@ void InstallCacic::run(QStringList argv, int argc) { | @@ -32,10 +32,12 @@ void InstallCacic::run(QStringList argv, int argc) { | ||
32 | registro["mainFolder"] = oCacic.getCacicMainFolder(); | 32 | registro["mainFolder"] = oCacic.getCacicMainFolder(); |
33 | oCacic.setValueToRegistry("Lightbase", "Cacic", registro); | 33 | oCacic.setValueToRegistry("Lightbase", "Cacic", registro); |
34 | //starta o processo do cacic. | 34 | //starta o processo do cacic. |
35 | + | ||
36 | + //TO DO: Fazer download do serviço | ||
35 | #ifdef Q_OS_WIN | 37 | #ifdef Q_OS_WIN |
36 | - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", true, &ok); | 38 | + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", false, &ok); |
37 | #else | 39 | #else |
38 | - QString exitStatus = oCacic.startProcess("cacic", true, &ok); | 40 | + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic", false, &ok); |
39 | #endif | 41 | #endif |
40 | if (!ok) | 42 | if (!ok) |
41 | std::cout << "Erro ao iniciar o processo: " | 43 | std::cout << "Erro ao iniciar o processo: " |
src/cacic_comm.h
@@ -61,6 +61,10 @@ public: | @@ -61,6 +61,10 @@ public: | ||
61 | QJsonObject jsonObj; | 61 | QJsonObject jsonObj; |
62 | if (isSsl){ | 62 | if (isSsl){ |
63 | url = urlSsl.isEmpty() ? "https://" + this->urlGerente + route : this->urlSsl + route; | 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 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); | 68 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); |
65 | } else | 69 | } else |
66 | url = "http://" + urlGerente + route; | 70 | url = "http://" + urlGerente + route; |
@@ -152,6 +156,13 @@ public: | @@ -152,6 +156,13 @@ public: | ||
152 | return retorno; | 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 | QString getUrlSsl (){ | 166 | QString getUrlSsl (){ |
156 | return this->urlSsl; | 167 | return this->urlSsl; |
157 | } | 168 | } |
src/cacic_hardware.cpp
@@ -47,8 +47,8 @@ QJsonObject cacic_hardware::coletaWin() | @@ -47,8 +47,8 @@ QJsonObject cacic_hardware::coletaWin() | ||
47 | // (Verifica se é notebook) | 47 | // (Verifica se é notebook) |
48 | params.clear(); | 48 | params.clear(); |
49 | wmiResult = wmi::wmiSearch("Win32_PortableBattery", params); | 49 | wmiResult = wmi::wmiSearch("Win32_PortableBattery", params); |
50 | + hardware["IsNotebook"] = QJsonValue::fromVariant(!wmiResult.isNull()); | ||
50 | if (!wmiResult.isNull()){ | 51 | if (!wmiResult.isNull()){ |
51 | - hardware["IsNotebook"] = QJsonValue::fromVariant(!wmiResult.isNull()); | ||
52 | hardware["PortableBattery"] = wmiResult; | 52 | hardware["PortableBattery"] = wmiResult; |
53 | } | 53 | } |
54 | //Win32_Bios | 54 | //Win32_Bios |