Commit 721d36a2568e5949544560a10e286a813caede0e

Authored by Eric Menezes Noronha
1 parent 4f983034
Exists in master

Incluindo algumas rotinas que estavam em falta no installcacic.

cacic-daemon/cacicD/cacictimer.cpp
... ... @@ -216,11 +216,7 @@ bool CacicTimer::Md5IsEqual(QVariant document01,QVariant document02){
216 216 (document01.toByteArray()),QCryptographicHash::Md5).toHex());
217 217 QString getconfigMD52 = QString(QCryptographicHash::hash(
218 218 (document02.toByteArray()),QCryptographicHash::Md5).toHex());
219   - if(getconfigMD5 == getconfigMD52){
220   - return true;
221   - }else{
222   - return false;
223   - }
  219 + return getconfigMD5 == getconfigMD52;
224 220 }
225 221  
226 222 void CacicTimer::iniciarInstancias(){
... ...
install-cacic/installcacic.cpp
... ... @@ -4,7 +4,7 @@ InstallCacic::InstallCacic(QObject *parent) :
4 4 QObject(parent)
5 5 {
6 6 logManager = QLogger::QLoggerManager::getInstance();
7   - logManager->addDestination("./log.txt","Install",QLogger::DebugLevel);
  7 + logManager->addDestination("./install.log","Install",QLogger::DebugLevel);
8 8 }
9 9  
10 10 InstallCacic::~InstallCacic()
... ... @@ -28,31 +28,51 @@ void InstallCacic::run(QStringList argv, int argc) {
28 28 oCacicComm->setPassword(this->argumentos["password"]);
29 29 QJsonObject jsonLogin = oCacicComm->login(&ok);
30 30 if (ok){
  31 + QJsonObject jsonComm;
  32 + QLogger::QLog_Debug("Install", "Login: " + jsonLogin["reply"].toObject()["chavecript"].toString());
31 33 //conectado, grava a chave na classe;
32 34 oCacic.setChaveCrypt(jsonLogin["reply"].toObject()["chavecrip"].toString());
  35 + jsonComm["computador"] = oCacicComputer.toJsonObject();
  36 + QJsonObject configs = oCacicComm->comm("/ws/neo/config", &ok, jsonComm);
  37 + qDebug () << configs;
  38 + if (ok){
  39 + oCacicComm->setUrlGerente(configs["reply"].toObject()["applicationUrl"].toString());
33 40 #ifdef Q_OS_WIN
34   - oCacic.setCacicMainFolder("c:/cacic/");
  41 + oCacic.setCacicMainFolder(configs["reply"].toObject()["cacic_main_folder"].isString() ?
  42 + configs["reply"].toObject()["cacic_main_folder"].toString() :
  43 + "c:/cacic/");
35 44 #elif defined(Q_OS_LINUX)
36   - oCacic.setCacicMainFolder("/home/cacic");
  45 + oCacic.setCacicMainFolder(configs["reply"].toObject()["cacic_main_folder"].isString() ?
  46 + configs["reply"].toObject()["cacic_main_folder"].toString() :
  47 + "/usr/cacic");
37 48 #endif
38   - oCacic.createFolder(oCacic.getCacicMainFolder());
39   - //grava chave em registro;
40 49  
41   - QVariantMap registro;
42   - registro["key"] = oCacic.getChaveCrypt();
43   - registro["mainFolder"] = oCacic.getCacicMainFolder();
44   - oCacic.setValueToRegistry("Lightbase", "Cacic", registro);
45   - //starta o processo do cacic.
  50 + oCacic.createFolder(oCacic.getCacicMainFolder());
  51 + //grava chave em registro;
  52 + QVariantMap registro;
  53 + registro["key"] = oCacic.getChaveCrypt();
  54 + registro["mainFolder"] = oCacic.getCacicMainFolder();
  55 + oCacic.setValueToRegistry("Lightbase", "Cacic", registro);
  56 + //starta o processo do cacic.
  57 +
  58 + //TO DO: Fazer download do serviço
  59 + #ifdef Q_OS_WIN
  60 + oCacicComm->ftpDownload("agentes/cacic.exe");
  61 + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", false, &ok, QStringList("-install"));
  62 + #else
  63 + oCacicComm->ftpDownload("agentes/cacic");
  64 + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic", false, &ok, QStringList("-install"));
  65 + #endif
  66 + if (!ok)
  67 + std::cout << "Erro ao iniciar o processo: "
  68 + << exitStatus.toStdString() << "\n";
  69 + else {
  70 + std::cout << "Instalação realizada com sucesso.";
  71 + }
  72 + } else {
  73 + std::cout << "Falha ao pegar configurações: " << configs["error"].toString();
  74 + }
46 75  
47   - //TO DO: Fazer download do serviço
48   -#ifdef Q_OS_WIN
49   - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", false, &ok);
50   -#else
51   - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic", false, &ok);
52   -#endif
53   - if (!ok)
54   - std::cout << "Erro ao iniciar o processo: "
55   - << exitStatus.toStdString() << "\n";
56 76 } else
57 77 std::cout << "Nao foi possivel realizar o login.\n "
58 78 << jsonLogin["error"].toString().toStdString();
... ...