From de11efe7db6500a2436b19ad322cb65dad936410 Mon Sep 17 00:00:00 2001 From: ericmenezesn@gmail.com Date: Wed, 23 Jul 2014 12:39:56 -0300 Subject: [PATCH] Configuração de compatibilidade da biblioteca crypto. --- README.md | 5 +++++ cacic-teste/cacic-teste.pro | 8 ++++++-- cacic-teste/testcacic.cpp | 6 ++++-- src/cacic_computer.cpp | 49 ++++++++++++++++++++++++++----------------------- src/cacic_computer.h | 7 ++++--- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index f18776a..51bbb9e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ cacic-agente ============ +Requisitos: +- Crypto++ (http://www.cryptopp.com/#download) +Instalando no Windows: +*Caso dê problemas durante a compilação e for solicitado o "this->" antes de alguns métodos, deve ser corrigido em cada arquivo. +*Depois disso basta seguir esse tutorial: https://sites.google.com/site/ievgensychov/cryptopp Módulo agente do software Cacic diff --git a/cacic-teste/cacic-teste.pro b/cacic-teste/cacic-teste.pro index a034083..fa949f6 100644 --- a/cacic-teste/cacic-teste.pro +++ b/cacic-teste/cacic-teste.pro @@ -10,7 +10,11 @@ QT += network TARGET = cacic-teste CONFIG -= app_bundle TEMPLATE = app - +win32 { +LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp +} else { +LIBS += -L/usr/lib -lcryptopp +} SOURCES += \ testcacic.cpp \ @@ -20,5 +24,5 @@ SOURCES += \ HEADERS += \ testcacic.h \ ../src/ccacic.h \ - ../src/CACIC_comm.h \ ../src/cacic_computer.h \ + ../src/cacic_comm.h diff --git a/cacic-teste/testcacic.cpp b/cacic-teste/testcacic.cpp index 4c92be5..0b83ace 100644 --- a/cacic-teste/testcacic.cpp +++ b/cacic-teste/testcacic.cpp @@ -85,9 +85,11 @@ void CTestCacic::testDeCrypt(){ } void CTestCacic::testpegarIPInterfaceDeRede(){ - QVERIFY(OCacicComp.pegarIPInterfaceDeRede() == "10.1.0.89"); +// qDebug() << QString::fromStdString(OCacicComp.getIp()); + QVERIFY(OCacicComp.getIp() != ""); } void CTestCacic::testpegarMACInterfaceDeRede(){ - QVERIFY(OCacicComp.pegarMACInterfaceDeRede() == "E0:3F:49:E4:70:12"); +// qDebug() << QString::fromStdString(OCacicComp.getMac()); + QVERIFY(OCacicComp.getMac() != ""); } diff --git a/src/cacic_computer.cpp b/src/cacic_computer.cpp index d823d10..4daec59 100644 --- a/src/cacic_computer.cpp +++ b/src/cacic_computer.cpp @@ -3,35 +3,19 @@ CACIC_Computer::CACIC_Computer(QObject *parent) : QObject(parent) { -} - -void CACIC_Computer::setIp(const std::string &value) -{ - ip = value; -} - -void CACIC_Computer::setMac(const std::string &value) -{ - mac = value; -} - -void CACIC_Computer::setOs(const std::string &value) -{ - os = value; + ip = pegarIPInterfaceDeRede(); + mac = pegarMACInterfaceDeRede(); } std::string CACIC_Computer::pegarIPInterfaceDeRede() { QNetworkInterface interface; - QList result; QList IpList = interface.allAddresses(); for (int i = 0; i < IpList.size(); i++){ - if((!IpList.at(i).isLoopback()) & (IpList.at(i).scopeId() == Q_NULLPTR)){ - result.append(IpList.at(i)); - setIp(IpList.at(i).toString().toStdString()); - break; + if((!IpList.at(i).isLoopback()) & (IpList.at(i).scopeId() == "")){ + return IpList.at(i).toString().toStdString(); } } - return result.at(0).toString().toStdString() ; + return ""; } @@ -40,7 +24,26 @@ std::string CACIC_Computer::pegarMACInterfaceDeRede(){ if (!(ni.flags() & ni.IsLoopBack)){ //qDebug() << ni.hardwareAddress(); return ni.hardwareAddress().toStdString(); - break; - } + } } + return ""; } + +/* + * getters/setters + */ + +std::string CACIC_Computer::getIp() const +{ + return ip; +} +std::string CACIC_Computer::getMac() const +{ + return mac; +} +std::string CACIC_Computer::getOs() const +{ + return os; +} + + diff --git a/src/cacic_computer.h b/src/cacic_computer.h index 0d03f79..62e65f5 100644 --- a/src/cacic_computer.h +++ b/src/cacic_computer.h @@ -15,9 +15,10 @@ public: explicit CACIC_Computer(QObject *parent = 0); std::string pegarIPInterfaceDeRede(); std::string pegarMACInterfaceDeRede(); - void setIp(const std::string &value); - void setMac(const std::string &value); - void setOs(const std::string &value); + + std::string getIp() const; + std::string getMac() const; + std::string getOs() const; private: std::string ip; -- libgit2 0.21.2