Commit dcd62bd2cbd9f8ec158d1c582113594b046275de
Exists in
master
Merge branch 'master' of https://github.com/lightbase/cacic-agente
Showing
6 changed files
with
25 additions
and
29 deletions
Show diff stats
cacic-teste/testcacic.cpp
... | ... | @@ -105,6 +105,7 @@ void CTestCacic::testConsole() |
105 | 105 | #if defined(Q_OS_LINUX) |
106 | 106 | QVERIFY(console("echo teste").toStdString() == "teste\n"); |
107 | 107 | #elif defined(Q_OS_WIN) |
108 | + qDebug() << console("echo teste"); | |
108 | 109 | QVERIFY(console("echo teste").toStdString() == "teste"); |
109 | 110 | #else |
110 | 111 | QVERIFY(false); |
... | ... | @@ -154,26 +155,6 @@ void CTestCacic::testDeCrypt(){ |
154 | 155 | |
155 | 156 | } |
156 | 157 | |
157 | -void CTestCacic::testInstallCacicStart() | |
158 | -{ | |
159 | -// char *argva[] = {"program name", "-host=teste.cacic.cpp", "-user=asda", "-password=qwesd", NULL}; | |
160 | -// int argca = sizeof(argva) / sizeof(char*) - 1; | |
161 | -// QCoreApplication a(argca, argva); | |
162 | - | |
163 | -// InstallCacic *oInstallCacic = new InstallCacic(&a); | |
164 | - | |
165 | -// QStringList args; | |
166 | -// for (int i = 0; i<argca; i++) | |
167 | -// args.append(argva[i]); | |
168 | -// // This will cause the application to exit when | |
169 | -// // the task signals finished. | |
170 | -// QObject::connect(oInstallCacic, SIGNAL(finished()), &a, SLOT(quit())); | |
171 | - | |
172 | -// // This will run the task from the application event loop. | |
173 | -// QMetaObject::invokeMethod(oInstallCacic, "run", Qt::QueuedConnection, Q_ARG(QStringList, args), Q_ARG(int, argca)); | |
174 | - QVERIFY(false); | |
175 | -} | |
176 | - | |
177 | 158 | void CTestCacic::testCacicCompToJsonObject() |
178 | 159 | { |
179 | 160 | // qDebug() << OCacicComp.toJsonObject(); |
... | ... | @@ -238,6 +219,11 @@ void CTestCacic::testSetRegistry() |
238 | 219 | QVERIFY(confirmaTeste.value("teste1") == QVariant("Teste 1")); |
239 | 220 | } |
240 | 221 | |
222 | +void CTestCacic::testGetValueFromRegistry() | |
223 | +{ | |
224 | + QVERIFY(OCacic.getValueFromRegistry("Lightbase", "Teste", "teste1") == QVariant("Teste 1")); | |
225 | +} | |
226 | + | |
241 | 227 | void CTestCacic::testRemoveRegistry() |
242 | 228 | { |
243 | 229 | OCacic.removeRegistry("Lightbase", "Teste"); | ... | ... |
cacic-teste/testcacic.h
... | ... | @@ -57,7 +57,6 @@ private slots: |
57 | 57 | void testSslConnection(); |
58 | 58 | void testEnCrypt(); |
59 | 59 | void testDeCrypt(); |
60 | - void testInstallCacicStart(); | |
61 | 60 | void testCacicCompToJsonObject(); |
62 | 61 | void testOperatingSystemToJsonObject(); |
63 | 62 | void testJsonToFile(); |
... | ... | @@ -65,6 +64,7 @@ private slots: |
65 | 64 | void testStartService(); |
66 | 65 | void testReadConfig(); |
67 | 66 | void testSetRegistry(); |
67 | + void testGetValueFromRegistry(); | |
68 | 68 | void testRemoveRegistry(); |
69 | 69 | void testIniciarDaemon(); |
70 | 70 | void cleanupTestCase(); | ... | ... |
install-cacic/install-cacic.pro.user
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <!DOCTYPE QtCreatorProject> |
3 | -<!-- Written by QtCreator 3.1.2, 2014-08-15T20:38:37. --> | |
3 | +<!-- Written by QtCreator 3.1.2, 2014-08-18T11:08:49. --> | |
4 | 4 | <qtcreator> |
5 | 5 | <data> |
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
... | ... | @@ -224,7 +224,7 @@ |
224 | 224 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">-uninstall</value> |
225 | 225 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">install-cacic.pro</value> |
226 | 226 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
227 | - <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> | |
227 | + <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> | |
228 | 228 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> |
229 | 229 | <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> |
230 | 230 | <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> | ... | ... |
install-cacic/installcacic.cpp
... | ... | @@ -19,24 +19,27 @@ void InstallCacic::run(QStringList argv, int argc) { |
19 | 19 | if (ok){ |
20 | 20 | //conectado, grava a chave na classe; |
21 | 21 | oCacic.setChaveCrypt(jsonLogin["reply"].toObject()["chavecrip"].toString()); |
22 | +#ifdef Q_OS_WIN | |
22 | 23 | oCacic.setCacicMainFolder("c:/cacic"); |
24 | +#elif Q_LINUX | |
25 | + oCacic.setCacicMainFolder("/home/cacic"); | |
26 | +#endif | |
23 | 27 | oCacic.createFolder(oCacic.getCacicMainFolder()); |
24 | 28 | //grava chave em registro; |
25 | 29 | |
26 | 30 | QVariantMap registro; |
27 | 31 | registro["key"] = oCacic.getChaveCrypt(); |
32 | + registro["mainFolder"] = oCacic.getCacicMainFolder(); | |
28 | 33 | oCacic.setValueToRegistry("Lightbase", "Cacic", registro); |
29 | 34 | //starta o processo do cacic. |
30 | 35 | #ifdef Q_OS_WIN |
31 | - QString exitStatus = oCacic.startProcess("cacic.exe", true, &ok); | |
32 | - if (!ok) | |
33 | - std::cout << "Erro ao iniciar o processo: " | |
34 | - << exitStatus.toStdString() << "\n"; | |
36 | + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", true, &ok); | |
35 | 37 | #else |
36 | 38 | oCacic.startProcess("cacic.exe", true, &ok); |
37 | - if (!ok) | |
38 | - qDebug() << "Erro ao iniciar o processo."; | |
39 | 39 | #endif |
40 | + if (!ok) | |
41 | + std::cout << "Erro ao iniciar o processo: " | |
42 | + << exitStatus.toStdString() << "\n"; | |
40 | 43 | } else |
41 | 44 | std::cout << "Nao foi possivel realizar o login.\n " |
42 | 45 | << jsonLogin["error"].toString().toStdString(); | ... | ... |
src/ccacic.cpp
... | ... | @@ -216,6 +216,12 @@ void CCacic::setValueToRegistry(QString organization, QString application, QVari |
216 | 216 | registry.sync(); |
217 | 217 | } |
218 | 218 | |
219 | +QVariant CCacic::getValueFromRegistry(QString organization, QString application, QString key) | |
220 | +{ | |
221 | + QSettings registry(organization, application); | |
222 | + return registry.value(key); | |
223 | +} | |
224 | + | |
219 | 225 | void CCacic::removeRegistry(QString organization, QString application) |
220 | 226 | { |
221 | 227 | QSettings registry(organization, application); | ... | ... |
src/ccacic.h
... | ... | @@ -37,6 +37,7 @@ public: |
37 | 37 | QJsonObject getJsonFromFile(QString filepath); |
38 | 38 | QString startProcess(QString pathprogram, bool wait, bool *ok, QStringList arguments = QStringList()); |
39 | 39 | void setValueToRegistry(QString organization, QString application, QVariantMap values); |
40 | + QVariant getValueFromRegistry(QString organization, QString application, QString key); | |
40 | 41 | void removeRegistry(QString organization, QString application); |
41 | 42 | |
42 | 43 | ... | ... |