Commit de11efe7db6500a2436b19ad322cb65dad936410
1 parent
802d0b07
Exists in
master
Configuração de compatibilidade da biblioteca crypto.
Showing
5 changed files
with
45 additions
and
30 deletions
Show diff stats
README.md
| 1 | cacic-agente | 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 | Módulo agente do software Cacic | 9 | Módulo agente do software Cacic |
cacic-teste/cacic-teste.pro
| @@ -10,7 +10,11 @@ QT += network | @@ -10,7 +10,11 @@ QT += network | ||
| 10 | TARGET = cacic-teste | 10 | TARGET = cacic-teste |
| 11 | CONFIG -= app_bundle | 11 | CONFIG -= app_bundle |
| 12 | TEMPLATE = app | 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 | SOURCES += \ | 19 | SOURCES += \ |
| 16 | testcacic.cpp \ | 20 | testcacic.cpp \ |
| @@ -20,5 +24,5 @@ SOURCES += \ | @@ -20,5 +24,5 @@ SOURCES += \ | ||
| 20 | HEADERS += \ | 24 | HEADERS += \ |
| 21 | testcacic.h \ | 25 | testcacic.h \ |
| 22 | ../src/ccacic.h \ | 26 | ../src/ccacic.h \ |
| 23 | - ../src/CACIC_comm.h \ | ||
| 24 | ../src/cacic_computer.h \ | 27 | ../src/cacic_computer.h \ |
| 28 | + ../src/cacic_comm.h |
cacic-teste/testcacic.cpp
| @@ -85,9 +85,11 @@ void CTestCacic::testDeCrypt(){ | @@ -85,9 +85,11 @@ void CTestCacic::testDeCrypt(){ | ||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | void CTestCacic::testpegarIPInterfaceDeRede(){ | 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 | void CTestCacic::testpegarMACInterfaceDeRede(){ | 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,35 +3,19 @@ | ||
| 3 | CACIC_Computer::CACIC_Computer(QObject *parent) : | 3 | CACIC_Computer::CACIC_Computer(QObject *parent) : |
| 4 | QObject(parent) | 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 | std::string CACIC_Computer::pegarIPInterfaceDeRede() { | 10 | std::string CACIC_Computer::pegarIPInterfaceDeRede() { |
| 24 | QNetworkInterface interface; | 11 | QNetworkInterface interface; |
| 25 | - QList<QHostAddress> result; | ||
| 26 | QList<QHostAddress> IpList = interface.allAddresses(); | 12 | QList<QHostAddress> IpList = interface.allAddresses(); |
| 27 | for (int i = 0; i < IpList.size(); i++){ | 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,7 +24,26 @@ std::string CACIC_Computer::pegarMACInterfaceDeRede(){ | ||
| 40 | if (!(ni.flags() & ni.IsLoopBack)){ | 24 | if (!(ni.flags() & ni.IsLoopBack)){ |
| 41 | //qDebug() << ni.hardwareAddress(); | 25 | //qDebug() << ni.hardwareAddress(); |
| 42 | return ni.hardwareAddress().toStdString(); | 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,9 +15,10 @@ public: | ||
| 15 | explicit CACIC_Computer(QObject *parent = 0); | 15 | explicit CACIC_Computer(QObject *parent = 0); |
| 16 | std::string pegarIPInterfaceDeRede(); | 16 | std::string pegarIPInterfaceDeRede(); |
| 17 | std::string pegarMACInterfaceDeRede(); | 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 | private: | 23 | private: |
| 23 | std::string ip; | 24 | std::string ip; |