Commit de11efe7db6500a2436b19ad322cb65dad936410

Authored by Eric Menezes Noronha
1 parent 802d0b07
Exists in master

Configuração de compatibilidade da biblioteca crypto.

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,7 +10,11 @@ QT += network
10 10 TARGET = cacic-teste
11 11 CONFIG -= app_bundle
12 12 TEMPLATE = app
13   -
  13 +win32 {
  14 +LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp
  15 +} else {
  16 +LIBS += -L/usr/lib -lcryptopp
  17 +}
14 18  
15 19 SOURCES += \
16 20 testcacic.cpp \
... ... @@ -20,5 +24,5 @@ SOURCES += \
20 24 HEADERS += \
21 25 testcacic.h \
22 26 ../src/ccacic.h \
23   - ../src/CACIC_comm.h \
24 27 ../src/cacic_computer.h \
  28 + ../src/cacic_comm.h
... ...
cacic-teste/testcacic.cpp
... ... @@ -85,9 +85,11 @@ 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 }
... ...
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,7 +24,26 @@ 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 }
  29 + return "";
46 30 }
  31 +
  32 +/*
  33 + * getters/setters
  34 + */
  35 +
  36 +std::string CACIC_Computer::getIp() const
  37 +{
  38 + return ip;
  39 +}
  40 +std::string CACIC_Computer::getMac() const
  41 +{
  42 + return mac;
  43 +}
  44 +std::string CACIC_Computer::getOs() const
  45 +{
  46 + return os;
  47 +}
  48 +
  49 +
... ...
src/cacic_computer.h
... ... @@ -15,9 +15,10 @@ public:
15 15 explicit CACIC_Computer(QObject *parent = 0);
16 16 std::string pegarIPInterfaceDeRede();
17 17 std::string pegarMACInterfaceDeRede();
18   - void setIp(const std::string &value);
19   - void setMac(const std::string &value);
20   - void setOs(const std::string &value);
  18 +
  19 + std::string getIp() const;
  20 + std::string getMac() const;
  21 + std::string getOs() const;
21 22  
22 23 private:
23 24 std::string ip;
... ...