Commit de0e086c21c74d86a1e0a52a3a968febc5ed7656
Exists in
master
Merge branch 'master' of https://github.com/lightbase/cacic-agente
Showing
15 changed files
with
213 additions
and
49 deletions
Show diff stats
cacicD/cacicD.pro
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | #------------------------------------------------- |
| 6 | 6 | |
| 7 | 7 | QT += core |
| 8 | - | |
| 9 | 8 | QT -= gui |
| 10 | 9 | |
| 11 | 10 | TARGET = cacicD |
| ... | ... | @@ -21,13 +20,18 @@ TEMPLATE = app |
| 21 | 20 | |
| 22 | 21 | SOURCES += main.cpp \ |
| 23 | 22 | ../src/ccacic.cpp \ |
| 24 | - cacicd.cpp | |
| 23 | + cacicd.cpp \ | |
| 24 | + ../src/cacic_computer.cpp \ | |
| 25 | + ../src/operatingsystem.cpp | |
| 25 | 26 | |
| 26 | 27 | HEADERS += \ |
| 27 | 28 | ../src/ccacic.h \ |
| 28 | - cacicd.h | |
| 29 | + cacicd.h \ | |
| 30 | + ../src/cacic_computer.h \ | |
| 31 | + ../src/operatingsystem.h | |
| 29 | 32 | |
| 30 | 33 | include(../src/qtservice/src/qtservice.pri) |
| 31 | 34 | |
| 32 | 35 | INCLUDEPATH += ../src \ |
| 33 | 36 | ../src/crypto++/include/ |
| 37 | + | ... | ... |
cacicD/cacicd.cpp
| ... | ... | @@ -22,12 +22,20 @@ cacicD::~cacicD() |
| 22 | 22 | void cacicD::start() |
| 23 | 23 | { |
| 24 | 24 | try{ |
| 25 | - QCoreApplication *app = application(); | |
| 26 | - qDebug() << "Serviço iniciado."; | |
| 27 | - qDebug() << app->applicationDirPath(); | |
| 28 | - | |
| 25 | + this->app = application(); | |
| 26 | + qDebug() << "\nServiço iniciado em" << app->applicationDirPath(); | |
| 27 | + if(getTest()){ | |
| 28 | + qDebug() << "\ngetTest() success."; | |
| 29 | + }else{ | |
| 30 | + qDebug() << "\ngetTest() error."; | |
| 31 | + } | |
| 32 | + if(getConfig()){ | |
| 33 | + qDebug() << "\ngetconfig() success."; | |
| 34 | + }else{ | |
| 35 | + qDebug() << "\ngetconfig() error."; | |
| 36 | + } | |
| 29 | 37 | } catch (...){ |
| 30 | - qCritical() << "Error desconhecido no desconstrutor."; | |
| 38 | + qCritical() << "Error desconhecido ao iniciar o serviço."; | |
| 31 | 39 | } |
| 32 | 40 | } |
| 33 | 41 | |
| ... | ... | @@ -57,3 +65,70 @@ void cacicD::stop() |
| 57 | 65 | qCritical() << "Error desconhecido ao parar o serviço."; |
| 58 | 66 | } |
| 59 | 67 | } |
| 68 | + | |
| 69 | +bool cacicD::getTest(){ | |
| 70 | + try{ | |
| 71 | + CacicComm OCacicComm; | |
| 72 | + OCacicComm.setUrlGerente("http://10.1.0.137/cacic/web/app_dev.php"); | |
| 73 | + OCacicComm.setUsuario("cacic"); | |
| 74 | + OCacicComm.setPassword("cacic123"); | |
| 75 | + bool ok; | |
| 76 | + QJsonObject as; | |
| 77 | + as["computador"] = OCacic_Computer.toJsonObject(); | |
| 78 | + QJsonObject jsonresult = OCacicComm.comm("/ws/neo/login", &ok, as); | |
| 79 | + try{ | |
| 80 | + saveJson(QJsonDocument::fromVariant(jsonresult.toVariantMap()), "getTest.conf"); | |
| 81 | + return true; | |
| 82 | + } catch (...) { | |
| 83 | + qDebug() << "Erro ao salvar o arquivo de configurações."; | |
| 84 | + return false; | |
| 85 | + } | |
| 86 | + } catch (...){ | |
| 87 | + qDebug() << "Erro ao conectar com o servidor."; | |
| 88 | + return false; | |
| 89 | + } | |
| 90 | +} | |
| 91 | + | |
| 92 | +bool cacicD::getConfig(){ | |
| 93 | + try{ | |
| 94 | + CacicComm OCacicComm; | |
| 95 | + OCacicComm.setUrlGerente("http://10.1.0.137/cacic/web/app_dev.php"); | |
| 96 | + OCacicComm.setUsuario("cacic"); | |
| 97 | + OCacicComm.setPassword("cacic123"); | |
| 98 | + bool ok; | |
| 99 | + QJsonObject as; | |
| 100 | + as["computador"] = OCacic_Computer.toJsonObject(); | |
| 101 | + QJsonObject jsonresult = OCacicComm.comm("/ws/neo/login", &ok, as); | |
| 102 | + try{ | |
| 103 | + saveJson(QJsonDocument::fromVariant(jsonresult.toVariantMap()), "getConfig.conf"); | |
| 104 | + return true; | |
| 105 | + } catch (...) { | |
| 106 | + qDebug() << "Erro ao salvar o arquivo de configurações."; | |
| 107 | + return false; | |
| 108 | + } | |
| 109 | + } catch (...){ | |
| 110 | + qDebug() << "Erro ao conectar com o servidor."; | |
| 111 | + return false; | |
| 112 | + } | |
| 113 | +} | |
| 114 | + | |
| 115 | +void cacicD::saveJson(QJsonDocument document, QString fileName) { | |
| 116 | +#if defined(Q_OS_LINUX) | |
| 117 | + QFile jsonFile(app->applicationDirPath().append("/" + fileName)); | |
| 118 | +#elif defined(Q_OS_WIN) | |
| 119 | + QFile jsonFile(app->applicationDirPath().append("\\" + fileName)); | |
| 120 | +#endif | |
| 121 | + jsonFile.open(QFile::WriteOnly); | |
| 122 | + jsonFile.write(document.toJson()); | |
| 123 | + jsonFile.close(); | |
| 124 | +} | |
| 125 | + | |
| 126 | +QJsonDocument cacicD::loadJson(QString fileName) { | |
| 127 | +#if defined(Q_OS_LINUX) | |
| 128 | + QFile jsonFile(app->applicationDirPath().append("/" + fileName)); | |
| 129 | +#elif defined(Q_OS_WIN) | |
| 130 | + QFile jsonFile(app->applicationDirPath().append("\\" + fileName)); | |
| 131 | +#endif | |
| 132 | + jsonFile.open(QFile::ReadOnly); | |
| 133 | + return QJsonDocument().fromJson(jsonFile.readAll()); | |
| 134 | +} | ... | ... |
cacicD/cacicd.h
| ... | ... | @@ -4,40 +4,34 @@ |
| 4 | 4 | #include <QCoreApplication> |
| 5 | 5 | #include <QObject> |
| 6 | 6 | #include <QDebug> |
| 7 | +#include <QDir> | |
| 8 | +#include <QTextStream> | |
| 9 | +#include <QVariant> | |
| 7 | 10 | #include "qtservice.h" |
| 11 | +#include "cacic_comm.h" | |
| 12 | +#include "cacic_computer.h" | |
| 8 | 13 | |
| 9 | 14 | |
| 10 | 15 | class cacicD : public QtService<QCoreApplication> |
| 11 | 16 | { |
| 12 | 17 | public: |
| 13 | - /** | |
| 14 | - * @brief cacicD Construtor | |
| 15 | - * @param argc | |
| 16 | - * @param argv | |
| 17 | - */ | |
| 18 | 18 | cacicD(int argc, char **argv); |
| 19 | - /** | |
| 20 | - * @brief cacicD Desconstrutor | |
| 21 | - */ | |
| 22 | 19 | ~cacicD(); |
| 23 | - /** | |
| 24 | - * @brief inicia o serviço | |
| 25 | - */ | |
| 26 | 20 | void start(); |
| 27 | - /** | |
| 28 | - * @brief pausa o serviço | |
| 29 | - */ | |
| 30 | 21 | void pause(); |
| 31 | - /** | |
| 32 | - * @brief resume a execução do serviço | |
| 33 | - */ | |
| 34 | 22 | void resume(); |
| 35 | - /** | |
| 36 | - * @brief para a execução do serviço | |
| 37 | - */ | |
| 38 | 23 | void stop(); |
| 24 | + QCoreApplication *app; | |
| 25 | + void saveJson(QJsonDocument document, QString fileName); | |
| 26 | + QJsonDocument loadJson(QString fileName); | |
| 39 | 27 | |
| 40 | - | |
| 28 | +private: | |
| 29 | + QString testPath; | |
| 30 | + QString testIniPath; | |
| 31 | + QJsonObject session; | |
| 32 | + CACIC_Computer OCacic_Computer; | |
| 33 | + bool getTest(); | |
| 34 | + bool getConfig(); | |
| 41 | 35 | }; |
| 42 | 36 | |
| 43 | 37 | #endif // CACICD_H | ... | ... |
gercols/gercols.cpp
| ... | ... | @@ -12,16 +12,41 @@ Gercols::Gercols(QObject *parent) |
| 12 | 12 | ******************************************/ |
| 13 | 13 | QJsonObject configTeste; |
| 14 | 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 | 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 | 22 | oCacic.setJsonToFile(configTeste,"configReq.json"); |
| 23 | 23 | /******************************************/ |
| 24 | 24 | |
| 25 | + // Inicializa o objeto de comunicação e seta chave criptográfica | |
| 26 | + oCacicComm = CacicComm("http://teste.cacic.cc", | |
| 27 | + "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__", | |
| 28 | + "P198PVwtz5F5CfZPSUrzuaQA/QG1sTnwzl/rBnj8M7y5MglANGodG5LLD4q7oY809HuDR4g5tL64lZRBKvKPmEgWd9iAZKvT4UAm9XWN3nKKLGaznCaJohmntNGqrJP1Zd9riTHGu10mPbg/Uh3TCbBHVOICvu5sDlINlCR6A3[[MAIS]]a55RhfKNidvr5uX0kozCxr5t2DyOb5oPocEGyJKyHLQ==__CRYPTED__", | |
| 29 | + "1", | |
| 30 | + "0", | |
| 31 | + "0", | |
| 32 | + "YwpgjzZ86/eCsjvOki1KkQ==__CRYPTED__", | |
| 33 | + "8PT6U445MPNr3S7WHFa20ge/8NJSspSYE/UL3zf[[MAIS]]wkEfNZ7p1B/2o6i89gTZ44Ok__CRYPTED__", | |
| 34 | + "wshPlZWvLPhbUEQFQ1aQmA==__CRYPTED__", | |
| 35 | + "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__", | |
| 36 | + "Yot8BeM9lOh431SB7dYQXw==__CRYPTED__", | |
| 37 | + "Dcr8b5IfZOJjt6qyH5dGyw==__CRYPTED__", | |
| 38 | + "2.5.1.1.256.32", | |
| 39 | + "2.8.1.7", | |
| 40 | + "2.8.1.6"); | |
| 41 | + oCacicComm.setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php"); | |
| 42 | + oCacicComm.setUsuario("cacic"); | |
| 43 | + oCacicComm.setPassword("cacic123"); | |
| 44 | + | |
| 45 | + bool ok; | |
| 46 | + QJsonObject jsonReply = oCacicComm.login(&ok); | |
| 47 | + QJsonObject sessionvalue = jsonReply["reply"].toObject(); | |
| 48 | + oCacic.setChaveCrypt(sessionvalue["chavecrip"].toString()); | |
| 49 | + | |
| 25 | 50 | qDebug() << "TESTE"; |
| 26 | 51 | oColeta = new CColeta(); |
| 27 | 52 | |
| ... | ... | @@ -45,9 +70,32 @@ void Gercols::run() |
| 45 | 70 | //emite sinal para começar a coleta |
| 46 | 71 | emit iniciaColeta(); |
| 47 | 72 | |
| 73 | + oCacic.deleteFile("configReq.json"); | |
| 74 | + | |
| 48 | 75 | //salva json em arquivo |
| 49 | 76 | oCacic.setJsonToFile(oColeta->toJsonObject(), "coleta.json"); |
| 50 | - oCacic.deleteFile("configReq.json"); | |
| 77 | + | |
| 78 | + QFile coletaFile("coleta.json"); | |
| 79 | + if (!coletaFile.open(QIODevice::ReadWrite)) { | |
| 80 | + qDebug() << "Não foi possível abrir o coleta.json"; | |
| 81 | + emit finished(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + QString coletaString; | |
| 85 | + coletaString = coletaFile.readAll(); | |
| 86 | + coletaFile.close(); | |
| 87 | +// oCacic.deleteFile("coleta.json"); | |
| 88 | + | |
| 89 | + //IV sendo gerado como uma string de 32 caracteres | |
| 90 | + std::string strIv = oCacic.genRandomString(); | |
| 91 | + | |
| 92 | + QString coletaEncriptada = oCacic.enCrypt(coletaString.toStdString(), strIv); | |
| 93 | + | |
| 94 | + QJsonObject gercolsJson; | |
| 95 | + gercolsJson["coleta"] = QJsonValue::fromVariant(coletaEncriptada); | |
| 96 | + gercolsJson["iv"] = QJsonValue::fromVariant( QString::fromStdString(strIv) ); | |
| 97 | + oCacic.setJsonToFile(gercolsJson, "gercols.json"); | |
| 98 | + | |
| 51 | 99 | //emite sinal "finished" pra finalizar a aplicação |
| 52 | 100 | emit finished(); |
| 53 | 101 | } | ... | ... |
gercols/gercols.h
| ... | ... | @@ -4,11 +4,13 @@ |
| 4 | 4 | #include <QJsonObject> |
| 5 | 5 | #include <ccoleta.h> |
| 6 | 6 | #include <ccacic.h> |
| 7 | +#include <cacic_comm.h> | |
| 7 | 8 | |
| 8 | 9 | class Gercols : public QObject |
| 9 | 10 | { |
| 10 | 11 | Q_OBJECT |
| 11 | 12 | private: |
| 13 | + CacicComm oCacicComm; | |
| 12 | 14 | CCacic oCacic; |
| 13 | 15 | CColeta *oColeta; |
| 14 | 16 | QJsonObject configReq; | ... | ... |
src/cacic_comm.h
| ... | ... | @@ -64,7 +64,7 @@ public: |
| 64 | 64 | url = urlSsl.isEmpty() ? "https://" + this->urlGerente + route : this->urlSsl + route; |
| 65 | 65 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); |
| 66 | 66 | } else |
| 67 | - url = urlGerente + route; | |
| 67 | + url = "http://" + urlGerente + route; | |
| 68 | 68 | req.setUrl(url); |
| 69 | 69 | req.setHeader(QNetworkRequest::LocationHeader, "Cacic Agente"); |
| 70 | 70 | if (json.empty()) | ... | ... |
src/cacic_software.cpp
| ... | ... | @@ -16,6 +16,7 @@ void cacic_software::iniciaColeta() |
| 16 | 16 | #endif |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | +#if defined(Q_OS_WIN) | |
| 19 | 20 | QJsonObject cacic_software::coletaWin() |
| 20 | 21 | { |
| 21 | 22 | QJsonObject softwaresJson; |
| ... | ... | @@ -54,6 +55,7 @@ QJsonObject cacic_software::coletaWin() |
| 54 | 55 | return softwaresJson; |
| 55 | 56 | } |
| 56 | 57 | |
| 58 | +#elif defined(Q_OS_LINUX) | |
| 57 | 59 | QJsonObject cacic_software::coletaLinux() |
| 58 | 60 | { |
| 59 | 61 | |
| ... | ... | @@ -115,10 +117,10 @@ QJsonObject cacic_software::coletaDebian() |
| 115 | 117 | ConsoleObject console; |
| 116 | 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 | 122 | foreach(QString package, packages) { |
| 121 | - QString packageName = package.split(" ")[0]; | |
| 123 | + QString packageName = package.split("\t")[0]; | |
| 122 | 124 | QJsonObject packageJson; |
| 123 | 125 | |
| 124 | 126 | QStringList packageInfo = console(QString("apt-cache show ").append(packageName)).split("\n"); |
| ... | ... | @@ -126,11 +128,11 @@ QJsonObject cacic_software::coletaDebian() |
| 126 | 128 | |
| 127 | 129 | packageJson["name"] = QJsonValue::fromVariant(QString(packageName)); |
| 128 | 130 | foreach(QString line, packageInfo) { |
| 129 | - if(line.contains("Version")) | |
| 131 | + if(line.contains("Version:")) | |
| 130 | 132 | packageJson["version"] = line.split(":")[1].mid(1); |
| 131 | - if(line.contains("Description")) | |
| 133 | + if(line.contains("Description-en:")) | |
| 132 | 134 | packageJson["description"] = line.split(":")[1].mid(1); |
| 133 | - if(line.contains("Homepage")) { | |
| 135 | + if(line.contains("Homepage:")) { | |
| 134 | 136 | QStringList url = line.split(":"); |
| 135 | 137 | QString urlString; |
| 136 | 138 | |
| ... | ... | @@ -141,14 +143,16 @@ QJsonObject cacic_software::coletaDebian() |
| 141 | 143 | |
| 142 | 144 | packageJson["url"] = urlString.mid(1); |
| 143 | 145 | } |
| 144 | - if(line.contains("Installed-Size")) | |
| 146 | + if(line.contains("Installed-Size:")) | |
| 145 | 147 | packageJson["installed_size"] = line.split(":")[1].mid(1); |
| 146 | 148 | } |
| 147 | 149 | softwaresJson[packageName] = packageJson; |
| 150 | + int counterPackages = softwaresJson.size(); | |
| 148 | 151 | } |
| 149 | 152 | |
| 150 | 153 | return softwaresJson; |
| 151 | 154 | } |
| 155 | +#endif | |
| 152 | 156 | |
| 153 | 157 | QJsonObject cacic_software::toJsonObject() |
| 154 | 158 | { | ... | ... |
src/cacic_software.h
| ... | ... | @@ -4,8 +4,11 @@ |
| 4 | 4 | #include <ccacic.h> |
| 5 | 5 | #include <console.h> |
| 6 | 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 | 13 | class cacic_software |
| 11 | 14 | { | ... | ... |
src/ccacic.cpp
| ... | ... | @@ -95,9 +95,9 @@ bool CCacic::deleteFolder(QString path) |
| 95 | 95 | */ |
| 96 | 96 | bool CCacic::deleteFile(QString path) |
| 97 | 97 | { |
| 98 | - QDir folder(path); | |
| 99 | - if (folder.exists()) | |
| 100 | - return folder.remove(path); | |
| 98 | + QFile file(path); | |
| 99 | + if (file.exists()) | |
| 100 | + return file.remove(path); | |
| 101 | 101 | else |
| 102 | 102 | return true; |
| 103 | 103 | } |
| ... | ... | @@ -295,6 +295,23 @@ QString CCacic::convertDouble(const double &number, const int &precision) |
| 295 | 295 | return QString::fromStdString(ss.str()); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | +std::string CCacic::genRandomString(const int &len) | |
| 299 | +{ | |
| 300 | + char* s; | |
| 301 | + | |
| 302 | + static const char alphanum[] = | |
| 303 | + "0123456789" | |
| 304 | + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| 305 | + "abcdefghijklmnopqrstuvwxyz"; | |
| 306 | + | |
| 307 | + for (int i = 0; i < len; ++i) { | |
| 308 | + s[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; | |
| 309 | + } | |
| 310 | + | |
| 311 | + s[len] = 0; | |
| 312 | + return std::string(s); | |
| 313 | +} | |
| 314 | + | |
| 298 | 315 | /*Getters/Setters |
| 299 | 316 | * End. |
| 300 | 317 | */ | ... | ... |
src/ccacic.h
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <QJsonValue> |
| 14 | 14 | #include <sstream> |
| 15 | 15 | #include <iostream> |
| 16 | +#include <string> | |
| 16 | 17 | #include "../src/crypto++/include/aes.h" |
| 17 | 18 | #include "../src/crypto++/include/base64.h" |
| 18 | 19 | #include "../src/crypto++/include/modes.h" |
| ... | ... | @@ -41,6 +42,7 @@ public: |
| 41 | 42 | QVariant getValueFromRegistry(QString organization, QString application, QString key); |
| 42 | 43 | void removeRegistry(QString organization, QString application); |
| 43 | 44 | QString convertDouble(const double &number, const int &precision = 10); |
| 45 | + std::string genRandomString(const int &len = 32); | |
| 44 | 46 | |
| 45 | 47 | //Geters/seters: |
| 46 | 48 | ... | ... |
src/ccoleta.cpp
| ... | ... | @@ -7,15 +7,18 @@ CColeta::CColeta(QObject *parent) |
| 7 | 7 | |
| 8 | 8 | void CColeta::coletaHardware() |
| 9 | 9 | { |
| 10 | - qDebug() << "coletaHardware() executado"; | |
| 10 | + | |
| 11 | + qDebug() << "coletaHardware() começando sua execução"; | |
| 11 | 12 | oHardware.iniciaColeta(); |
| 13 | + qDebug() << "coletaHardware() executado"; | |
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
| 15 | 17 | void CColeta::coletaSoftware() |
| 16 | 18 | { |
| 17 | - qDebug() << "coletaSoftware() executado"; | |
| 19 | + qDebug() << "coletaSoftware() começando sua execução"; | |
| 18 | 20 | oSoftware.iniciaColeta(); |
| 21 | + qDebug() << "coletaSoftware() executado"; | |
| 19 | 22 | |
| 20 | 23 | } |
| 21 | 24 | ... | ... |
src/vqtconvert.cpp
src/vqtconvert.h
src/vregistry.cpp
src/vregistry.h