Commit 0cf007a92f1b0bc1fed412dd435449ea5d4f1da8
Exists in
master
Merge branch 'master' of https://github.com/lightbase/cacic-agente
Conflicts: cacic-teste/cacic-teste.pro src/cacic_computer.cpp src/cacic_computer.h
Showing
5 changed files
with
43 additions
and
29 deletions
Show diff stats
README.md
1 | 1 | cacic-agente |
2 | 2 | ============ |
3 | +Requisitos: | |
4 | +- Crypto++ (http://www.cryptopp.com/#download) | |
5 | +Instalando no Windows: | |
6 | +*Caso dê problemas durante a compilação e for solicitado o "this->" antes de alguns métodos, deve ser corrigido em cada arquivo. | |
7 | +*Depois disso basta seguir esse tutorial: https://sites.google.com/site/ievgensychov/cryptopp | |
3 | 8 | |
4 | 9 | Módulo agente do software Cacic | ... | ... |
cacic-teste/cacic-teste.pro
... | ... | @@ -10,8 +10,11 @@ QT += network |
10 | 10 | TARGET = cacic-teste |
11 | 11 | CONFIG -= app_bundle |
12 | 12 | TEMPLATE = app |
13 | +win32 { | |
14 | +LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp | |
15 | +} else { | |
13 | 16 | LIBS += -L/usr/lib -lcryptopp |
14 | - | |
17 | +} | |
15 | 18 | |
16 | 19 | SOURCES += \ |
17 | 20 | testcacic.cpp \ |
... | ... | @@ -21,5 +24,5 @@ SOURCES += \ |
21 | 24 | HEADERS += \ |
22 | 25 | testcacic.h \ |
23 | 26 | ../src/ccacic.h \ |
24 | - ../src/CACIC_comm.h \ | |
25 | 27 | ../src/cacic_computer.h \ |
28 | + ../src/cacic_comm.h | ... | ... |
cacic-teste/testcacic.cpp
... | ... | @@ -85,11 +85,13 @@ void CTestCacic::testDeCrypt(){ |
85 | 85 | } |
86 | 86 | |
87 | 87 | void CTestCacic::testpegarIPInterfaceDeRede(){ |
88 | - QVERIFY(OCacicComp.pegarIPInterfaceDeRede() == "10.1.0.89"); | |
88 | +// qDebug() << QString::fromStdString(OCacicComp.getIp()); | |
89 | + QVERIFY(OCacicComp.getIp() != ""); | |
89 | 90 | } |
90 | 91 | |
91 | 92 | void CTestCacic::testpegarMACInterfaceDeRede(){ |
92 | - QVERIFY(OCacicComp.pegarMACInterfaceDeRede() == "E0:3F:49:E4:70:12"); | |
93 | +// qDebug() << QString::fromStdString(OCacicComp.getMac()); | |
94 | + QVERIFY(OCacicComp.getMac() != ""); | |
93 | 95 | } |
94 | 96 | |
95 | 97 | void CTestCacic::testpegarOS(){ | ... | ... |
src/cacic_computer.cpp
... | ... | @@ -3,35 +3,19 @@ |
3 | 3 | CACIC_Computer::CACIC_Computer(QObject *parent) : |
4 | 4 | QObject(parent) |
5 | 5 | { |
6 | -} | |
7 | - | |
8 | -void CACIC_Computer::setIp(const std::string &value) | |
9 | -{ | |
10 | - ip = value; | |
11 | -} | |
12 | - | |
13 | -void CACIC_Computer::setMac(const std::string &value) | |
14 | -{ | |
15 | - mac = value; | |
16 | -} | |
17 | - | |
18 | -void CACIC_Computer::setOs(const std::string &value) | |
19 | -{ | |
20 | - os = value; | |
6 | + ip = pegarIPInterfaceDeRede(); | |
7 | + mac = pegarMACInterfaceDeRede(); | |
21 | 8 | } |
22 | 9 | |
23 | 10 | std::string CACIC_Computer::pegarIPInterfaceDeRede() { |
24 | 11 | QNetworkInterface interface; |
25 | - QList<QHostAddress> result; | |
26 | 12 | QList<QHostAddress> IpList = interface.allAddresses(); |
27 | 13 | for (int i = 0; i < IpList.size(); i++){ |
28 | - if((!IpList.at(i).isLoopback()) & (IpList.at(i).scopeId() == Q_NULLPTR)){ | |
29 | - result.append(IpList.at(i)); | |
30 | - setIp(IpList.at(i).toString().toStdString()); | |
31 | - break; | |
14 | + if((!IpList.at(i).isLoopback()) & (IpList.at(i).scopeId() == "")){ | |
15 | + return IpList.at(i).toString().toStdString(); | |
32 | 16 | } |
33 | 17 | } |
34 | - return result.at(0).toString().toStdString(); | |
18 | + return ""; | |
35 | 19 | } |
36 | 20 | |
37 | 21 | |
... | ... | @@ -40,8 +24,7 @@ std::string CACIC_Computer::pegarMACInterfaceDeRede(){ |
40 | 24 | if (!(ni.flags() & ni.IsLoopBack)){ |
41 | 25 | //qDebug() << ni.hardwareAddress(); |
42 | 26 | return ni.hardwareAddress().toStdString(); |
43 | - break; | |
44 | - } | |
27 | + } | |
45 | 28 | } |
46 | 29 | return "ERROR MAC"; |
47 | 30 | } |
... | ... | @@ -55,4 +38,24 @@ std::string CACIC_Computer::pegarOS(){ |
55 | 38 | // qDebug() << x << sear; |
56 | 39 | // x++; |
57 | 40 | // } |
41 | + return ""; | |
58 | 42 | } |
43 | + | |
44 | +/* | |
45 | + * getters/setters | |
46 | + */ | |
47 | + | |
48 | +std::string CACIC_Computer::getIp() const | |
49 | +{ | |
50 | + return ip; | |
51 | +} | |
52 | +std::string CACIC_Computer::getMac() const | |
53 | +{ | |
54 | + return mac; | |
55 | +} | |
56 | +std::string CACIC_Computer::getOs() const | |
57 | +{ | |
58 | + return os; | |
59 | +} | |
60 | + | |
61 | + | ... | ... |
src/cacic_computer.h
... | ... | @@ -16,9 +16,10 @@ public: |
16 | 16 | std::string pegarIPInterfaceDeRede(); |
17 | 17 | std::string pegarMACInterfaceDeRede(); |
18 | 18 | std::string pegarOS(); |
19 | - void setIp(const std::string &value); | |
20 | - void setMac(const std::string &value); | |
21 | 19 | void setOs(const std::string &value); |
20 | + std::string getIp() const; | |
21 | + std::string getMac() const; | |
22 | + std::string getOs() const; | |
22 | 23 | |
23 | 24 | private: |
24 | 25 | std::string ip; | ... | ... |