Commit a65e13cfb5a1a588df74f7378d97891e3930e9a7
1 parent
b1048928
Exists in
master
alteração da coleta, inclusão da coleta de software para windows
Showing
15 changed files
with
104 additions
and
98 deletions
Show diff stats
cacic-teste/cacic-teste.pro
... | ... | @@ -22,11 +22,12 @@ SOURCES += \ |
22 | 22 | ../src/ccacic.cpp \ |
23 | 23 | ../src/cacic_computer.cpp \ |
24 | 24 | ../src/operatingsystem.cpp \ |
25 | - ../src/qtservice/src/qtservice.cpp \ | |
26 | - ../src/qtservice/src/qtservice_unix.cpp \ | |
27 | - ../src/qtservice/src/qtservice_win.cpp \ | |
28 | - ../src/qtservice/src/qtunixserversocket.cpp \ | |
29 | - ../src/qtservice/src/qtunixsocket.cpp | |
25 | + ../src/cacic_software.cpp \ | |
26 | +# ../src/qtservice/src/qtservice.cpp \ | |
27 | +# ../src/qtservice/src/qtservice_unix.cpp \ | |
28 | +# ../src/qtservice/src/qtservice_win.cpp \ | |
29 | +# ../src/qtservice/src/qtunixserversocket.cpp \ | |
30 | +# ../src/qtservice/src/qtunixsocket.cpp | |
30 | 31 | |
31 | 32 | |
32 | 33 | HEADERS += \ |
... | ... | @@ -36,10 +37,11 @@ HEADERS += \ |
36 | 37 | ../src/cacic_comm.h \ |
37 | 38 | ../src/console.h \ |
38 | 39 | ../src/operatingsystem.h \ |
39 | - ../src/qtservice/src/qtservice.h \ | |
40 | - ../src/qtservice/src/qtservice_p.h \ | |
41 | - ../src/qtservice/src/qtunixserversocket.h \ | |
42 | - ../src/qtservice/src/qtunixsocket.h | |
40 | + ../src/cacic_software.h \ | |
41 | +# ../src/qtservice/src/qtservice.h \ | |
42 | +# ../src/qtservice/src/qtservice_p.h \ | |
43 | +# ../src/qtservice/src/qtunixserversocket.h \ | |
44 | +# ../src/qtservice/src/qtunixsocket.h | |
43 | 45 | |
44 | 46 | INCLUDEPATH += ../src \ |
45 | 47 | ../src/crypto++/include/ | ... | ... |
cacic-teste/testcacic.cpp
... | ... | @@ -237,6 +237,12 @@ void CTestCacic::testIniciarDaemon(){ |
237 | 237 | |
238 | 238 | } |
239 | 239 | |
240 | +void CTestCacic::testColetaSoftware() | |
241 | +{ | |
242 | + OCacicSoftware.iniciaColeta(); | |
243 | + QVERIFY(!OCacicSoftware.toJsonObject().empty()); | |
244 | +} | |
245 | + | |
240 | 246 | void CTestCacic::cleanupTestCase() |
241 | 247 | { |
242 | 248 | OCacic.deleteFile("configRequest.json"); | ... | ... |
cacic-teste/testcacic.h
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | #include <cacic_comm.h> |
5 | 5 | #include <ccacic.h> |
6 | 6 | #include <cacic_computer.h> |
7 | +#include <cacic_software.h> | |
7 | 8 | #include <console.h> |
8 | 9 | #include <operatingsystem.h> |
9 | 10 | #include <QtTest/QtTest> |
... | ... | @@ -28,11 +29,12 @@ private: |
28 | 29 | CacicComm OCacicComm; |
29 | 30 | CCacic OCacic; |
30 | 31 | CACIC_Computer OCacicComp; |
32 | + cacic_software OCacicSoftware; | |
31 | 33 | QString testPath; |
32 | 34 | QString testIniPath; |
33 | 35 | QJsonObject session; |
34 | 36 | QString cripTeste; |
35 | - cacicD OcacicD; | |
37 | +// cacicD OcacicD; | |
36 | 38 | |
37 | 39 | signals: |
38 | 40 | |
... | ... | @@ -67,6 +69,7 @@ private slots: |
67 | 69 | void testGetValueFromRegistry(); |
68 | 70 | void testRemoveRegistry(); |
69 | 71 | void testIniciarDaemon(); |
72 | + void testColetaSoftware(); | |
70 | 73 | void cleanupTestCase(); |
71 | 74 | }; |
72 | 75 | ... | ... |
cacicD/cacicD.pro
cacicD/main.cpp
gercols/gercols.cpp
... | ... | @@ -22,11 +22,9 @@ Gercols::Gercols(QObject *parent) |
22 | 22 | oCacic.setJsonToFile(configTeste,"configReq.json"); |
23 | 23 | /******************************************/ |
24 | 24 | |
25 | - getConfigJson(); | |
26 | 25 | qDebug() << "TESTE"; |
27 | 26 | oColeta = new CColeta(); |
28 | - oColeta->setColeta(configReq); | |
29 | -qDebug() << oColeta->getColeta(); | |
27 | + | |
30 | 28 | QObject::connect(this, SIGNAL(iniciaConfiguracao()), oColeta, SLOT(configuraColetas())); |
31 | 29 | QObject::connect(this, SIGNAL(iniciaColeta()), oColeta, SLOT(run())); |
32 | 30 | |
... | ... | @@ -49,15 +47,9 @@ void Gercols::run() |
49 | 47 | |
50 | 48 | |
51 | 49 | //salva coleta em json |
52 | - qDebug() << oColeta->getColeta(); | |
50 | + qDebug() << oColeta->toJsonObject(); | |
53 | 51 | //salva json em arquivo |
54 | - oCacic.setJsonToFile(oColeta->getColeta(), "coleta.json"); | |
52 | + oCacic.setJsonToFile(oColeta->toJsonObject(), "coleta.json"); | |
55 | 53 | //emite sinal "finished" pra finalizar a aplicação |
56 | 54 | emit finished(); |
57 | 55 | } |
58 | - | |
59 | -bool Gercols::getConfigJson() | |
60 | -{ | |
61 | - configReq = oCacic.getJsonFromFile("configReq.json"); | |
62 | - oCacic.deleteFile("configReq.json"); | |
63 | -} | ... | ... |
gercols/gercols.h
gercols/gercols.pro
... | ... | @@ -25,6 +25,7 @@ SOURCES += \ |
25 | 25 | main.cpp \ |
26 | 26 | ../src/ccacic.cpp \ |
27 | 27 | ../src/cacic_computer.cpp \ |
28 | + ../src/cacic_software.cpp \ | |
28 | 29 | ../src/operatingsystem.cpp \ |
29 | 30 | ../src/ccoleta.cpp \ |
30 | 31 | ./gercols.cpp |
... | ... | @@ -33,6 +34,7 @@ SOURCES += \ |
33 | 34 | HEADERS += \ |
34 | 35 | ../src/ccacic.h \ |
35 | 36 | ../src/cacic_computer.h \ |
37 | + ../src/cacic_software.h \ | |
36 | 38 | ../src/operatingsystem.h \ |
37 | 39 | ../src/console.h \ |
38 | 40 | ../src/ccoleta.h \ | ... | ... |
install-cacic/install-cacic.pro.user
src/cacic_software.cpp
... | ... | @@ -3,3 +3,41 @@ |
3 | 3 | cacic_software::cacic_software() |
4 | 4 | { |
5 | 5 | } |
6 | + | |
7 | +void cacic_software::iniciaColeta() | |
8 | +{ | |
9 | +#ifdef Q_OS_WIN | |
10 | + this->coletaSoftware = coletaWin(); | |
11 | +#else | |
12 | + this->coletaSoftware = coletaLinux(); | |
13 | +#endif | |
14 | +} | |
15 | + | |
16 | +QJsonObject cacic_software::coletaWin() | |
17 | +{ | |
18 | + QJsonObject softwaresJson; | |
19 | + QSettings softwares("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", QSettings::NativeFormat); | |
20 | +// qDebug() << softwares.childGroups(); | |
21 | + foreach (QString group, softwares.childGroups()){ | |
22 | + QVariantMap software; | |
23 | + softwares.beginGroup(group); | |
24 | + software["DisplayName"] = softwares.value("DisplayName"); | |
25 | + software["Publisher"] = softwares.value("Publisher"); | |
26 | + software["InstallLocation"] = softwares.value("InstallLocation"); | |
27 | + software["InstallDate"] = softwares.value("InstallDate"); | |
28 | + software["URLInfoAbout"] = softwares.value("URLInfoAbout"); | |
29 | + softwares.endGroup(); | |
30 | + softwaresJson[group] = QJsonObject::fromVariantMap(software); | |
31 | + } | |
32 | +// qDebug() << softwaresJson; | |
33 | + return softwaresJson; | |
34 | +} | |
35 | + | |
36 | +void cacic_software::coletaLinux() | |
37 | +{ | |
38 | + | |
39 | +} | |
40 | +QJsonObject cacic_software::toJsonObject() | |
41 | +{ | |
42 | + return coletaSoftware; | |
43 | +} | ... | ... |
src/cacic_software.h
1 | 1 | #ifndef CACIC_SOFTWARE_H |
2 | 2 | #define CACIC_SOFTWARE_H |
3 | - | |
3 | +#include <QtCore> | |
4 | +#include <ccacic.h> | |
4 | 5 | class cacic_software |
5 | 6 | { |
6 | 7 | public: |
7 | 8 | cacic_software(); |
9 | + void iniciaColeta(); | |
10 | + QJsonObject toJsonObject(); | |
11 | + | |
12 | +private: | |
13 | + QJsonObject coletaWin(); | |
14 | + void coletaLinux(); | |
15 | + | |
16 | + CCacic oCacic; | |
17 | + QJsonObject coletaSoftware; | |
8 | 18 | }; |
9 | 19 | |
10 | 20 | #endif // CACIC_SOFTWARE_H | ... | ... |
src/ccacic.cpp
src/ccacic.h
... | ... | @@ -19,11 +19,10 @@ |
19 | 19 | //#include <sha.h> |
20 | 20 | //#include <md5.h> |
21 | 21 | |
22 | -class CCacic : public QObject | |
22 | +class CCacic | |
23 | 23 | { |
24 | - Q_OBJECT | |
25 | 24 | public: |
26 | - explicit CCacic(QObject *parent = 0); | |
25 | + CCacic(); | |
27 | 26 | QString getValueFromFile(QString sectionName, QString keyName, QString filePath); |
28 | 27 | void setValueToFile(QString sectionName, QString keyName, QString value, QString filePath); |
29 | 28 | QString getValueFromTags(QString fullString, QString tag, QString tagType = "[]"); |
... | ... | @@ -69,10 +68,6 @@ private: |
69 | 68 | QString chksisInfFilePath; |
70 | 69 | QString chaveCrypt; |
71 | 70 | |
72 | -signals: | |
73 | - | |
74 | -public slots: | |
75 | - | |
76 | 71 | }; |
77 | 72 | |
78 | 73 | #endif // CCACIC_H | ... | ... |
src/ccoleta.cpp
... | ... | @@ -5,89 +5,49 @@ CColeta::CColeta(QObject *parent) |
5 | 5 | |
6 | 6 | } |
7 | 7 | |
8 | -void CColeta::coletaComputer() | |
9 | -{ | |
10 | - qDebug() << "coletaComputer() executado"; | |
11 | - QJsonObject coletaComputer = coleta["computer"].toObject(); | |
12 | - if( coletaComputer.contains("operating_system") ) | |
13 | - emit beginOperatingSystem(); | |
14 | - if( coletaComputer.contains("user") ) | |
15 | - emit beginUser(); | |
16 | - | |
17 | -} | |
18 | - | |
19 | 8 | void CColeta::coletaHardware() |
20 | 9 | { |
21 | 10 | qDebug() << "coletaHardware() executado"; |
22 | - QJsonObject coletaHardware = coleta["hardware"].toObject(); | |
23 | -} | |
24 | - | |
25 | -void CColeta::coletaNetworkInterfaces() | |
26 | -{ | |
27 | - qDebug() << "coletaOperatingSystem() executado"; | |
28 | - | |
29 | -// QJsonObject coletaComputer = coleta["computer"].toObject(); | |
30 | -// coletaComputer["network_interfaces"] = QJsonValue::fromVariant(QString(oComputer.getNetworkInterface())); | |
31 | - | |
32 | -// coleta["computer"] = coletaComputer; | |
11 | +// oHardware.iniciaColeta(); | |
33 | 12 | } |
34 | 13 | |
35 | -void CColeta::coletaOperatingSystem() | |
36 | -{ | |
37 | - qDebug() << "coletaOperatingSystem() executado"; | |
38 | - | |
39 | - QJsonObject coletaComputer = coleta["computer"].toObject(); | |
40 | - coletaComputer["operating_system"] = QJsonValue::fromVariant(QString(oComputer.getOs().getNomeOs())); | |
41 | - | |
42 | - coleta["computer"] = coletaComputer; | |
43 | -} | |
44 | 14 | |
45 | 15 | void CColeta::coletaSoftware() |
46 | 16 | { |
47 | 17 | qDebug() << "coletaSoftware() executado"; |
48 | - QJsonObject coletaSoftware = coleta["software"].toObject(); | |
49 | -} | |
50 | - | |
51 | -void CColeta::coletaUser() | |
52 | -{ | |
53 | - qDebug() << "coletauser() executado"; | |
54 | - | |
55 | - QJsonObject coletaComputer = coleta["computer"].toObject(); | |
56 | - coletaComputer["user"] = QJsonValue::fromVariant(QString::fromStdString(oComputer.getUser())); | |
57 | - | |
58 | - coleta["computer"] = coletaComputer; | |
18 | + oSoftware.iniciaColeta(); | |
59 | 19 | } |
60 | 20 | |
61 | 21 | void CColeta::configuraColetas(){ |
62 | - QObject::connect(this, SIGNAL(beginComputer()), this, SLOT(coletaComputer())); | |
63 | - QObject::connect(this, SIGNAL(beginNetworkInterfaces()), this, SLOT(coletaNetworkInterfaces())); | |
64 | - QObject::connect(this, SIGNAL(beginOperatingSystem()), this, SLOT(coletaOperatingSystem())); | |
65 | - QObject::connect(this, SIGNAL(beginUser()), this, SLOT(coletaUser())); | |
66 | 22 | QObject::connect(this, SIGNAL(beginHardware()), this, SLOT(coletaHardware())); |
67 | 23 | QObject::connect(this, SIGNAL(beginSoftware()), this, SLOT(coletaSoftware())); |
68 | 24 | } |
69 | 25 | |
70 | -QJsonObject CColeta::getColeta() const | |
26 | +CACIC_Computer CColeta::getOComputer() const | |
71 | 27 | { |
72 | - return coleta; | |
28 | + return oComputer; | |
73 | 29 | } |
74 | 30 | |
75 | -CACIC_Computer CColeta::getOComputer() const | |
31 | +cacic_software CColeta::getOSoftware() const | |
76 | 32 | { |
77 | - return oComputer; | |
33 | + return oSoftware; | |
78 | 34 | } |
79 | 35 | |
80 | 36 | void CColeta::run() |
81 | 37 | { |
82 | - if( coleta.contains("computer") ) | |
83 | - emit beginComputer(); | |
38 | + QJsonObject coleta = oCacic.getJsonFromFile("configReq.json"); | |
39 | + | |
84 | 40 | if( coleta.contains("hardware") ) |
85 | 41 | emit beginHardware(); |
86 | 42 | if ( coleta.contains("software") ) |
87 | 43 | emit beginSoftware(); |
44 | + | |
88 | 45 | } |
89 | 46 | |
90 | -void CColeta::setColeta(QJsonObject config) | |
47 | +QJsonObject CColeta::toJsonObject() | |
91 | 48 | { |
92 | - this->coleta = config; | |
49 | + QJsonObject coletaJson; | |
50 | + coletaJson["computer"] = oComputer.toJsonObject(); | |
51 | + coletaJson["software"] = oSoftware.toJsonObject(); | |
52 | + return coletaJson; | |
93 | 53 | } | ... | ... |
src/ccoleta.h
... | ... | @@ -4,8 +4,9 @@ |
4 | 4 | #include <QObject> |
5 | 5 | #include <QJsonObject> |
6 | 6 | #include <QDebug> |
7 | +#include <ccacic.h> | |
7 | 8 | #include <cacic_computer.h> |
8 | -#include "cacic_computer.h" | |
9 | +#include <cacic_software.h> | |
9 | 10 | |
10 | 11 | |
11 | 12 | class CColeta : public QObject |
... | ... | @@ -13,24 +14,21 @@ class CColeta : public QObject |
13 | 14 | Q_OBJECT |
14 | 15 | |
15 | 16 | private: |
16 | - QJsonObject coleta; | |
17 | - | |
17 | + CCacic oCacic; | |
18 | 18 | CACIC_Computer oComputer; |
19 | + cacic_software oSoftware; | |
19 | 20 | |
20 | 21 | public: |
21 | 22 | explicit CColeta(QObject *parent = 0); |
22 | 23 | |
23 | - QJsonObject getColeta() const; | |
24 | 24 | CACIC_Computer getOComputer() const; |
25 | - void setColeta(QJsonObject config); | |
25 | + cacic_software getOSoftware() const; | |
26 | + | |
27 | + QJsonObject toJsonObject(); | |
26 | 28 | |
27 | 29 | public slots: |
28 | - void coletaComputer(); | |
29 | 30 | void coletaHardware(); |
30 | - void coletaNetworkInterfaces(); | |
31 | - void coletaOperatingSystem(); | |
32 | 31 | void coletaSoftware(); |
33 | - void coletaUser(); | |
34 | 32 | void configuraColetas(); |
35 | 33 | void run(); |
36 | 34 | ... | ... |