Commit e665e55d9d5455d6f8977f5fa50dac43e85d7361
1 parent
d0bdc415
Exists in
master
Test cacic alterado devido a algumas modificações na classe comm; Installcacic c…
…omeçando a ser implementado, já verificando os argumentos; Acrescentado 'sinal' na função de comunicação para retorno true ou false para saber se deu certo ou não
Showing
10 changed files
with
170 additions
and
70 deletions
Show diff stats
cacic-teste/testcacic.cpp
... | ... | @@ -58,8 +58,9 @@ void CTestCacic::testCommStatus() |
58 | 58 | |
59 | 59 | void CTestCacic::testComm() |
60 | 60 | { |
61 | + bool ok; | |
61 | 62 | if (OCacicComm.commStatus()){ |
62 | - QJsonObject jsonreply = OCacicComm.comm("/ws/get/test"); | |
63 | + QJsonObject jsonreply = OCacicComm.comm("/ws/get/test", &ok); | |
63 | 64 | // qDebug() << jsonreply["codestatus"].toString(); |
64 | 65 | QVERIFY(OCacic.getValueFromTags(jsonreply["reply"].toString(), "Comm_Status", "<>") == QString("OK")); |
65 | 66 | } else |
... | ... | @@ -100,16 +101,18 @@ void CTestCacic::testJsonValueFromJsonString() |
100 | 101 | } |
101 | 102 | |
102 | 103 | void CTestCacic::testLogin(){ |
103 | - QJsonObject jsonReply = OCacicComm.login(); | |
104 | + bool ok; | |
105 | + QJsonObject jsonReply = OCacicComm.login(&ok); | |
104 | 106 | QJsonValue sessionvalue = jsonReply["reply"]; |
105 | 107 | // qDebug() << sessionvalue.toObject()["session"].toString(); |
106 | 108 | // qDebug() << sessionvalue.toString(); |
107 | - QVERIFY(sessionvalue.isObject()); | |
109 | + QVERIFY(ok); | |
108 | 110 | } |
109 | 111 | |
110 | 112 | void CTestCacic::testSslConnection() |
111 | 113 | { |
112 | - QJsonObject json = OCacicComm.comm("", QJsonObject(), true); | |
114 | + bool ok; | |
115 | + QJsonObject json = OCacicComm.comm("", &ok, QJsonObject(), true); | |
113 | 116 | QJsonValue jsonvalue = json["codestatus"]; |
114 | 117 | // qDebug() << jsonvalue.toDouble(); |
115 | 118 | QVERIFY(jsonvalue.toDouble() == 200 || jsonvalue.toDouble() == 302); |
... | ... | @@ -130,6 +133,26 @@ void CTestCacic::testDeCrypt(){ |
130 | 133 | |
131 | 134 | } |
132 | 135 | |
136 | +void CTestCacic::testInstallCacicStart() | |
137 | +{ | |
138 | +// char *argva[] = {"program name", "-host=teste.cacic.cpp", "-user=asda", "-password=qwesd", NULL}; | |
139 | +// int argca = sizeof(argva) / sizeof(char*) - 1; | |
140 | +// QCoreApplication a(argca, argva); | |
141 | + | |
142 | +// InstallCacic *oInstallCacic = new InstallCacic(&a); | |
143 | + | |
144 | +// QStringList args; | |
145 | +// for (int i = 0; i<argca; i++) | |
146 | +// args.append(argva[i]); | |
147 | +// // This will cause the application to exit when | |
148 | +// // the task signals finished. | |
149 | +// QObject::connect(oInstallCacic, SIGNAL(finished()), &a, SLOT(quit())); | |
150 | + | |
151 | +// // This will run the task from the application event loop. | |
152 | +// QMetaObject::invokeMethod(oInstallCacic, "run", Qt::QueuedConnection, Q_ARG(QStringList, args), Q_ARG(int, argca)); | |
153 | + QVERIFY(false); | |
154 | +} | |
155 | + | |
133 | 156 | void CTestCacic::cleanupTestCase() |
134 | 157 | { |
135 | 158 | ... | ... |
cacic-teste/testcacic.h
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | #include <iostream> |
13 | 13 | #include <QtNetwork/QtNetwork> |
14 | 14 | #include <QJsonObject> |
15 | +#include "../install-cacic/installcacic.h" | |
15 | 16 | |
16 | 17 | class CTestCacic : public QObject |
17 | 18 | { |
... | ... | @@ -20,12 +21,12 @@ public: |
20 | 21 | explicit CTestCacic(QObject *parent = 0); |
21 | 22 | |
22 | 23 | private: |
23 | - CacicComm OCacicComm; | |
24 | - CCacic OCacic; | |
25 | - CACIC_Computer OCacicComp; | |
26 | - QString testPath; | |
27 | - QString testIniPath; | |
28 | - QJsonObject session; | |
24 | + CacicComm OCacicComm; | |
25 | + CCacic OCacic; | |
26 | + CACIC_Computer OCacicComp; | |
27 | + QString testPath; | |
28 | + QString testIniPath; | |
29 | + QJsonObject session; | |
29 | 30 | |
30 | 31 | signals: |
31 | 32 | |
... | ... | @@ -48,6 +49,7 @@ private slots: |
48 | 49 | void testSslConnection(); |
49 | 50 | void testEnCrypt(); |
50 | 51 | void testDeCrypt(); |
52 | + void testInstallCacicStart(); | |
51 | 53 | void cleanupTestCase(); |
52 | 54 | }; |
53 | 55 | ... | ... |
install-cacic/install-cacic.pro
... | ... | @@ -13,6 +13,12 @@ CONFIG += console |
13 | 13 | CONFIG -= app_bundle |
14 | 14 | CONFIG += c++11 |
15 | 15 | |
16 | +win32 { | |
17 | + LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp | |
18 | +} else { | |
19 | + LIBS += -L/usr/lib -lcryptopp | |
20 | +} | |
21 | + | |
16 | 22 | TEMPLATE = app |
17 | 23 | |
18 | 24 | SOURCES += main.cpp \ |
... | ... | @@ -25,3 +31,6 @@ HEADERS += \ |
25 | 31 | ../src/ccacic.h \ |
26 | 32 | ../src/cacic_computer.h \ |
27 | 33 | ../src/cacic_comm.h |
34 | + | |
35 | +INCLUDEPATH += ../src \ | |
36 | + ../src/crypto++/include/ | ... | ... |
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.1, 2014-08-05T11:41:11. --> | |
3 | +<!-- Written by QtCreator 3.1.2, 2014-08-13T18:44:40. --> | |
4 | 4 | <qtcreator> |
5 | 5 | <data> |
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
... | ... | @@ -54,14 +54,14 @@ |
54 | 54 | <data> |
55 | 55 | <variable>ProjectExplorer.Project.Target.0</variable> |
56 | 56 | <valuemap type="QVariantMap"> |
57 | - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.3.0 GCC 64bit</value> | |
58 | - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.3.0 GCC 64bit</value> | |
59 | - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.53.gcc_64_kit</value> | |
57 | + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.3.0 MinGW 32bit</value> | |
58 | + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.3.0 MinGW 32bit</value> | |
59 | + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.53.win32_mingw482_kit</value> | |
60 | 60 | <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> |
61 | 61 | <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> |
62 | 62 | <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> |
63 | 63 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> |
64 | - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eduardo/srv/cacic-agente-new/build-install-cacic-Desktop_Qt_5_3_0_GCC_64bit-Debug</value> | |
64 | + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/LightBase/cacic-agente-project/builds/install-cacic</value> | |
65 | 65 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
66 | 66 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
67 | 67 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
... | ... | @@ -78,10 +78,7 @@ |
78 | 78 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
79 | 79 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
80 | 80 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
81 | - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> | |
82 | - <value type="QString">-w</value> | |
83 | - <value type="QString">-r</value> | |
84 | - </valuelist> | |
81 | + <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> | |
85 | 82 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
86 | 83 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
87 | 84 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
... | ... | @@ -97,10 +94,7 @@ |
97 | 94 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
98 | 95 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
99 | 96 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
100 | - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> | |
101 | - <value type="QString">-w</value> | |
102 | - <value type="QString">-r</value> | |
103 | - </valuelist> | |
97 | + <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> | |
104 | 98 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
105 | 99 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
106 | 100 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
... | ... | @@ -120,7 +114,7 @@ |
120 | 114 | <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> |
121 | 115 | </valuemap> |
122 | 116 | <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> |
123 | - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/eduardo/srv/cacic-agente-new/build-install-cacic-Desktop_Qt_5_3_0_GCC_64bit-Release</value> | |
117 | + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/LightBase/cacic-agente-project/cacic-agente/build-install-cacic-Release</value> | |
124 | 118 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> |
125 | 119 | <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> |
126 | 120 | <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> |
... | ... | @@ -137,10 +131,7 @@ |
137 | 131 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
138 | 132 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
139 | 133 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
140 | - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> | |
141 | - <value type="QString">-w</value> | |
142 | - <value type="QString">-r</value> | |
143 | - </valuelist> | |
134 | + <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> | |
144 | 135 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> |
145 | 136 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> |
146 | 137 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
... | ... | @@ -156,10 +147,7 @@ |
156 | 147 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> |
157 | 148 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> |
158 | 149 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> |
159 | - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> | |
160 | - <value type="QString">-w</value> | |
161 | - <value type="QString">-r</value> | |
162 | - </valuelist> | |
150 | + <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/> | |
163 | 151 | <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> |
164 | 152 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> |
165 | 153 | <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> |
... | ... | @@ -231,9 +219,9 @@ |
231 | 219 | <value type="int" key="PE.EnvironmentAspect.Base">2</value> |
232 | 220 | <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> |
233 | 221 | <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">install-cacic</value> |
234 | - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">install-cacic2</value> | |
235 | - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/eduardo/srv/cacic-agente/install-cacic/install-cacic.pro</value> | |
236 | - <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> | |
222 | + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> | |
223 | + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/LightBase/cacic-agente-project/cacic-agente/install-cacic/install-cacic.pro</value> | |
224 | + <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments">-host=10.1.0.137/cacic/web/app_dev.php -user=cacic -password=cacic123</value> | |
237 | 225 | <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">install-cacic.pro</value> |
238 | 226 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> |
239 | 227 | <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value> |
... | ... | @@ -254,7 +242,7 @@ |
254 | 242 | </data> |
255 | 243 | <data> |
256 | 244 | <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> |
257 | - <value type="QByteArray">{05f74523-32aa-49a4-aa35-22a4457a2f3f}</value> | |
245 | + <value type="QByteArray">{2d43e969-a5af-4db4-9730-35c8f8cce80d}</value> | |
258 | 246 | </data> |
259 | 247 | <data> |
260 | 248 | <variable>ProjectExplorer.Project.Updater.FileVersion</variable> | ... | ... |
install-cacic/installcacic.cpp
... | ... | @@ -4,13 +4,61 @@ |
4 | 4 | InstallCacic::InstallCacic(QObject *parent) : |
5 | 5 | QObject(parent) |
6 | 6 | { |
7 | + | |
8 | +} | |
9 | + | |
10 | +void InstallCacic::run(QStringList argv, int argc) { | |
11 | + QMap<QString, QString> args; | |
12 | + bool ok; | |
13 | + //valida os parametros repassados | |
14 | + validaParametros(argv, argc, &ok); | |
15 | + //se tiver usuario, senha e url | |
16 | + if (ok){ | |
17 | + oCacicComm.setUrlGerente(this->argumentos["host"]); | |
18 | + oCacicComm.setUsuario(this->argumentos["user"]); | |
19 | + oCacicComm.setPassword(this->argumentos["password"]); | |
20 | + QJsonObject jsonLogin = oCacicComm.login(&ok); | |
21 | + if (ok){ | |
22 | + //TODO: Conectado. armazenar chave em arquivo e sessao na comm; | |
23 | + qDebug() << "Logado"; | |
24 | + } | |
25 | + else | |
26 | + qDebug() << "falha no login"; | |
27 | + } else { | |
28 | + std::cout << "Parametros incorretos. ([obrigatorios] <opcional>)\n"; | |
29 | + std::cout << " [-host=url_gerente] <Descricao aqui>\n"; | |
30 | + std::cout << " [-user=usuario] <Descricao aqui>\n"; | |
31 | + std::cout << " [-password=senha] <Descricao aqui>\n"; | |
32 | + std::cout << " <-help> <Descricao aqui>\n"; | |
33 | + } | |
34 | + | |
35 | + emit finished(); | |
7 | 36 | } |
8 | 37 | |
9 | -void InstallCacic::run() { | |
10 | - int code; | |
11 | - std::cout << "Hello World\n"; | |
12 | - std::cin >> code; | |
13 | - emit finished(code); | |
38 | +QMap<QString, QString> InstallCacic::validaParametros(QStringList argv, int argc, bool *ok) | |
39 | +{ | |
40 | + QMap<QString, QString> map; | |
41 | + for (int i = 0; i<argc; i++){ | |
42 | + QString aux = argv[i]; | |
43 | + QStringList auxList = aux.split("="); | |
44 | + if ((auxList.at(0).at(0) == '-') && (auxList.size() > 1)) | |
45 | + map[auxList.at(0).mid(1)] = auxList.at(1); | |
46 | + } | |
47 | + *ok = (bool) map.contains("host") && map.contains("user") && map.contains("password"); | |
48 | + if (*ok){ | |
49 | + this->argumentos = map; | |
50 | + } | |
51 | + return map; | |
52 | +} | |
53 | + | |
54 | +QMap<QString, QString> InstallCacic::getArgumentos() | |
55 | +{ | |
56 | + return argumentos; | |
57 | +} | |
58 | + | |
59 | +void InstallCacic::setArgumentos(QMap<QString, QString> value) | |
60 | +{ | |
61 | + this->argumentos = value; | |
14 | 62 | } |
15 | 63 | |
16 | 64 | ... | ... |
install-cacic/installcacic.h
... | ... | @@ -2,6 +2,10 @@ |
2 | 2 | #define INSTALLCACIC_H |
3 | 3 | |
4 | 4 | #include <QObject> |
5 | +#include <QtCore> | |
6 | +#include <cacic_comm.h> | |
7 | +#include <cacic_computer.h> | |
8 | +#include <ccacic.h> | |
5 | 9 | |
6 | 10 | class InstallCacic : public QObject |
7 | 11 | { |
... | ... | @@ -9,13 +13,20 @@ class InstallCacic : public QObject |
9 | 13 | public: |
10 | 14 | explicit InstallCacic(QObject *parent = 0); |
11 | 15 | |
12 | -private: | |
16 | + QMap<QString, QString> getArgumentos(); | |
17 | + void setArgumentos(QMap<QString, QString> value); | |
18 | + QMap<QString, QString> validaParametros(QStringList argv, int argc, bool *ok); | |
13 | 19 | |
20 | +private: | |
21 | + QMap<QString, QString> argumentos; | |
22 | + CacicComm oCacicComm; | |
23 | + CACIC_Computer oCacicComputer; | |
24 | + CCacic oCacic; | |
14 | 25 | signals: |
15 | - void finished(int); | |
26 | + void finished(); | |
16 | 27 | |
17 | 28 | public slots: |
18 | - void run(); | |
29 | + void run(QStringList argv, int argc); | |
19 | 30 | }; |
20 | 31 | |
21 | 32 | #endif // INSTALLCACIC_H | ... | ... |
install-cacic/main.cpp
... | ... | @@ -5,15 +5,16 @@ |
5 | 5 | int main(int argc, char *argv[]) |
6 | 6 | { |
7 | 7 | QCoreApplication a(argc, argv); |
8 | - | |
8 | + QStringList args; | |
9 | + for (int i = 0; i<argc; i++) | |
10 | + args.append(argv[i]); | |
9 | 11 | InstallCacic *installcacic = new InstallCacic(&a); |
10 | 12 | |
11 | 13 | // This will cause the application to exit when |
12 | 14 | // the task signals finished. |
13 | - QObject::connect(installcacic, SIGNAL(finished(int)), &a, SLOT(quit())); | |
15 | + QObject::connect(installcacic, SIGNAL(finished()), &a, SLOT(quit())); | |
14 | 16 | |
15 | 17 | // This will run the task from the application event loop. |
16 | - QTimer::singleShot(0, installcacic, SLOT(run())); | |
17 | - | |
18 | + QMetaObject::invokeMethod(installcacic, "run", Qt::QueuedConnection, Q_ARG(QStringList, args), Q_ARG(int, argc)); | |
18 | 19 | return a.exec(); |
19 | 20 | } | ... | ... |
src/cacic_comm.h
... | ... | @@ -26,7 +26,6 @@ private: |
26 | 26 | |
27 | 27 | public: |
28 | 28 | CacicComm (){ |
29 | - | |
30 | 29 | } |
31 | 30 | |
32 | 31 | CacicComm (QString urlGerente, QString operatingSystem, QString computerSystem, QString csCipher, |
... | ... | @@ -53,15 +52,16 @@ public: |
53 | 52 | |
54 | 53 | } |
55 | 54 | |
56 | - QJsonObject comm(QString route, const QJsonObject &json = QJsonObject(), bool isSsl = false) | |
55 | + QJsonObject comm(QString route, bool *ok, const QJsonObject &json = QJsonObject(), bool isSsl = false) | |
57 | 56 | { |
57 | + *ok = false; | |
58 | 58 | QByteArray data; |
59 | 59 | QNetworkRequest req; |
60 | 60 | QUrl url; |
61 | 61 | QString strReply; |
62 | 62 | QJsonObject jsonObj; |
63 | 63 | if (isSsl){ |
64 | - url = urlSsl + route; | |
64 | + url = urlSsl.isEmpty() ? "https://" + this->urlGerente + route : this->urlSsl + route; | |
65 | 65 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); |
66 | 66 | } else |
67 | 67 | url = urlGerente + route; |
... | ... | @@ -106,7 +106,7 @@ public: |
106 | 106 | QJsonValue::fromVariant(replyVariant.toString()); |
107 | 107 | // qDebug() << "Response:" << jsonObj["reply"]; |
108 | 108 | // qDebug() << "Response:" << strReply; |
109 | - | |
109 | + *ok = true; | |
110 | 110 | delete reply; |
111 | 111 | } else { |
112 | 112 | //failure |
... | ... | @@ -156,14 +156,16 @@ public: |
156 | 156 | * @return retorna json com sessão e chave de criptografia |
157 | 157 | * exemplo: 200 OK |
158 | 158 | */ |
159 | - QJsonObject login() { | |
159 | + QJsonObject login(bool *ok) { | |
160 | + *ok = false; | |
160 | 161 | // Cria dados de login |
161 | 162 | QVariantMap login; |
162 | 163 | login["user"] = this->usuario; |
163 | 164 | login["password"] = this->password; |
164 | 165 | // QJsonValue sessionvalue = OCacic.jsonValueFromJsonString(json["reply"].toString(), "session"); |
165 | 166 | // Cria conexão e retorna Json da sessão |
166 | - QJsonObject retorno = this->comm("/ws/neo/login", QJsonObject::fromVariantMap(login), true); | |
167 | +// qDebug() << "Conectando."; | |
168 | + QJsonObject retorno = this->comm("/ws/neo/login", ok, QJsonObject::fromVariantMap(login), true); | |
167 | 169 | return retorno; |
168 | 170 | } |
169 | 171 | |
... | ... | @@ -175,6 +177,22 @@ public: |
175 | 177 | this->urlSsl = value; |
176 | 178 | } |
177 | 179 | |
180 | + QString getUrlGerente (){ | |
181 | + return this->urlGerente; | |
182 | + } | |
183 | + | |
184 | + void setUrlGerente(QString value){ | |
185 | + if (value.contains("http://", Qt::CaseInsensitive)){ | |
186 | + value = value.mid(value.indexOf("http://") + 7); | |
187 | + } else if (value.contains("https://", Qt::CaseInsensitive)){ | |
188 | + value = value.mid(value.indexOf("https://") + 8); | |
189 | + } | |
190 | + if (value.endsWith("/")){ | |
191 | + value.remove(value.size()-1, 1); | |
192 | + } | |
193 | + this->urlGerente = value; | |
194 | + } | |
195 | + | |
178 | 196 | QString getPassword() |
179 | 197 | { |
180 | 198 | return this->password; | ... | ... |
src/ccacic.cpp
... | ... | @@ -137,15 +137,15 @@ std::string CCacic::enCrypt(std::string str_in, std::string key, std::string iv) |
137 | 137 | } |
138 | 138 | |
139 | 139 | /*deCrypt |
140 | - * @parameter std::string str_in: string encriptada convertida em base64. | |
141 | - * std::string key: chave utilizada na encriptação (32 caracteres) 32*8 = 256 bits | |
142 | - * *exemplo: qwertyuiopasdfghjklzxcvbnmqwerty | |
143 | - * std::string iv: IV (Vetor de Inicialização) deve ser aleatório. | |
144 | - * *Um IV jamais deve ser utilizado mais de uma vez com a mesma chave. | |
145 | - * *(http://pt.wikipedia.org/wiki/Modo_de_opera%C3%A7%C3%A3o_%28criptografia%29#Vetor_de_inicializa.C3.A7.C3.A3o_.28IV.29) | |
146 | - * *exemplo de iv: 0123456789123456 | |
147 | - * @return QString: retorna a string desencriptada convertida em base64. | |
148 | - * */ | |
140 | +// * @parameter std::string str_in: string encriptada convertida em base64. | |
141 | +// * std::string key: chave utilizada na encriptação (32 caracteres) 32*8 = 256 bits | |
142 | +// * *exemplo: qwertyuiopasdfghjklzxcvbnmqwerty | |
143 | +// * std::string iv: IV (Vetor de Inicialização) deve ser aleatório. | |
144 | +// * *Um IV jamais deve ser utilizado mais de uma vez com a mesma chave. | |
145 | +// * *(http://pt.wikipedia.org/wiki/Modo_de_opera%C3%A7%C3%A3o_%28criptografia%29#Vetor_de_inicializa.C3.A7.C3.A3o_.28IV.29) | |
146 | +// * *exemplo de iv: 0123456789123456 | |
147 | +// * @return QString: retorna a string desencriptada convertida em base64. | |
148 | +// * */ | |
149 | 149 | std::string CCacic::deCrypt(std::string str_in, std::string key, std::string iv) { |
150 | 150 | std::string str_out; |
151 | 151 | CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((byte*)key.c_str(), key.length(), (byte*)iv.c_str()); | ... | ... |
src/ccacic.h
... | ... | @@ -4,19 +4,19 @@ |
4 | 4 | #include <QCoreApplication> |
5 | 5 | #include <QObject> |
6 | 6 | #include <QFile> |
7 | -#include <aes.h> | |
8 | -#include <base64.h> | |
9 | -#include <modes.h> | |
10 | -#include <filters.h> | |
11 | -#include <hex.h> | |
12 | -#include <sha.h> | |
13 | -#include <md5.h> | |
14 | 7 | #include <QSettings> |
15 | 8 | #include <QDir> |
16 | 9 | #include <QDebug> |
17 | 10 | #include <QJsonDocument> |
18 | 11 | #include <QJsonObject> |
19 | 12 | #include <QJsonValue> |
13 | +#include <aes.h> | |
14 | +#include <base64.h> | |
15 | +#include <modes.h> | |
16 | +//#include <filters.h> | |
17 | +//#include <hex.h> | |
18 | +//#include <sha.h> | |
19 | +//#include <md5.h> | |
20 | 20 | |
21 | 21 | class CCacic : public QObject |
22 | 22 | { | ... | ... |