diff --git a/Core/recognizesystem.cpp b/Core/recognizesystem.cpp index 53f6f41..75ffeca 100644 --- a/Core/recognizesystem.cpp +++ b/Core/recognizesystem.cpp @@ -31,6 +31,9 @@ void RecognizeSystem::recognize(QTcpSocket *socket) while(socket->bytesAvailable()) { + + if (socket->state() != QTcpSocket::ConnectedState) return; + if(packetType == PacketType::TYPE_NONE){ //определение первичного пакета stream.startTransaction(); diff --git a/Core/tcpclient.cpp b/Core/tcpclient.cpp index ae75b0e..048e570 100644 --- a/Core/tcpclient.cpp +++ b/Core/tcpclient.cpp @@ -1,5 +1,5 @@ #include "tcpclient.h" -#include "updatecontroller.h" +#include "UpdateController.h" #include "externalexecuter.h" #include @@ -7,7 +7,10 @@ TCPClient::TCPClient(QObject *parent) : QObject(parent) { - socket = NULL; + //socket = NULL; + socket = new QTcpSocket(); + socket->setParent(this); + socket->moveToThread(this->thread()); } void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *externalExecuter) @@ -15,6 +18,7 @@ void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *external this->recognizeSystem = recognize; this->externalExecuter = externalExecuter; + emit sigSendDebugLog(Tools::getTime() + " Client started"); } @@ -26,8 +30,6 @@ void TCPClient::setConnect(ServerSettings *serverSettings) return; } - socket = new QTcpSocket(this); - connect(socket,&QTcpSocket::readyRead,this,&TCPClient::slotReadyRead,Qt::DirectConnection); connect(socket,&QTcpSocket::disconnected,this,&TCPClient::setDisconnect); connect(socket,&QTcpSocket::connected,this,&TCPClient::slotConnectNotify); @@ -98,6 +100,7 @@ void TCPClient::sendUnityConnect() void TCPClient::setDisconnect() { socket->disconnect(); + emit sigServerDisconnect(); emit sigSendDebugLog("Server disabled"); } diff --git a/Core/tcpclient.h b/Core/tcpclient.h index 93001e8..bea2188 100644 --- a/Core/tcpclient.h +++ b/Core/tcpclient.h @@ -10,7 +10,7 @@ #include #include "Core\recognizesystem.h" #include "Core\tools.h" -#include "Core\updatecontroller.h" +#include "Core\UpdateController.h" #include "Core\externalexecuter.h" class UpdateController; @@ -37,6 +37,7 @@ signals: void sigSendDebugLog(QString message); void sigRecognize(QTcpSocket *socket); void sigConnectionState(bool flag); + void sigServerDisconnect(); QByteArray sigGetXmlAnswer(QString); public slots: diff --git a/RRJClient.pro.user b/RRJClient.pro.user index b653bd6..ea953d4 100644 --- a/RRJClient.pro.user +++ b/RRJClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/StaticData/authData.xml b/StaticData/authData.xml index d128b5a..eb91cc9 100644 --- a/StaticData/authData.xml +++ b/StaticData/authData.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/StaticData/hash.xml b/StaticData/hash.xml index a36eeca..d72dd6f 100644 --- a/StaticData/hash.xml +++ b/StaticData/hash.xml @@ -186,7 +186,9 @@ - + + + @@ -196,7 +198,7 @@ - + diff --git a/StaticData/temp.xml b/StaticData/temp.xml index d67ab92..592c5a2 100644 --- a/StaticData/temp.xml +++ b/StaticData/temp.xml @@ -1,2 +1,2 @@ - + diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe index b06cef1..c2714df 100644 Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ diff --git a/debug/mainwindow.o b/debug/mainwindow.o index 9ca1cfc..231edca 100644 Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ diff --git a/debug/moc_mainwindow.cpp b/debug/moc_mainwindow.cpp index 52e4873..4d9bc8a 100644 --- a/debug/moc_mainwindow.cpp +++ b/debug/moc_mainwindow.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - QByteArrayData data[25]; - char stringdata0[439]; + QByteArrayData data[26]; + char stringdata0[460]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -56,7 +56,8 @@ QT_MOC_LITERAL(20, 361, 29), // "on_languageComboBox_activated" QT_MOC_LITERAL(21, 391, 4), // "arg1" QT_MOC_LITERAL(22, 396, 17), // "slotDisableNotify" QT_MOC_LITERAL(23, 414, 19), // "slotConnectionState" -QT_MOC_LITERAL(24, 434, 4) // "flag" +QT_MOC_LITERAL(24, 434, 4), // "flag" +QT_MOC_LITERAL(25, 439, 20) // "slotServerDisconnect" }, "MainWindow\0sigInitializeClient\0\0" @@ -72,7 +73,7 @@ QT_MOC_LITERAL(24, 434, 4) // "flag" "on_connectButton_clicked\0" "on_languageComboBox_activated\0arg1\0" "slotDisableNotify\0slotConnectionState\0" - "flag" + "flag\0slotServerDisconnect" }; #undef QT_MOC_LITERAL @@ -82,7 +83,7 @@ static const uint qt_meta_data_MainWindow[] = { 8, // revision 0, // classname 0, 0, // classinfo - 14, 14, // methods + 15, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -90,22 +91,23 @@ static const uint qt_meta_data_MainWindow[] = { 5, // signalCount // signals: name, argc, parameters, tag, flags - 1, 2, 84, 2, 0x06 /* Public */, - 7, 1, 89, 2, 0x06 /* Public */, - 10, 0, 92, 2, 0x06 /* Public */, - 11, 0, 93, 2, 0x06 /* Public */, - 12, 1, 94, 2, 0x06 /* Public */, + 1, 2, 89, 2, 0x06 /* Public */, + 7, 1, 94, 2, 0x06 /* Public */, + 10, 0, 97, 2, 0x06 /* Public */, + 11, 0, 98, 2, 0x06 /* Public */, + 12, 1, 99, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 14, 0, 97, 2, 0x08 /* Private */, - 15, 0, 98, 2, 0x08 /* Private */, - 16, 0, 99, 2, 0x08 /* Private */, - 17, 0, 100, 2, 0x08 /* Private */, - 18, 0, 101, 2, 0x08 /* Private */, - 19, 0, 102, 2, 0x08 /* Private */, - 20, 1, 103, 2, 0x08 /* Private */, - 22, 0, 106, 2, 0x08 /* Private */, - 23, 1, 107, 2, 0x08 /* Private */, + 14, 0, 102, 2, 0x08 /* Private */, + 15, 0, 103, 2, 0x08 /* Private */, + 16, 0, 104, 2, 0x08 /* Private */, + 17, 0, 105, 2, 0x08 /* Private */, + 18, 0, 106, 2, 0x08 /* Private */, + 19, 0, 107, 2, 0x08 /* Private */, + 20, 1, 108, 2, 0x08 /* Private */, + 22, 0, 111, 2, 0x08 /* Private */, + 23, 1, 112, 2, 0x08 /* Private */, + 25, 0, 115, 2, 0x08 /* Private */, // signals: parameters QMetaType::Void, 0x80000000 | 3, 0x80000000 | 5, 4, 6, @@ -124,6 +126,7 @@ static const uint qt_meta_data_MainWindow[] = { QMetaType::Void, QMetaType::QString, 21, QMetaType::Void, QMetaType::Void, QMetaType::Bool, 24, + QMetaType::Void, 0 // eod }; @@ -148,6 +151,7 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, case 11: _t->on_languageComboBox_activated((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 12: _t->slotDisableNotify(); break; case 13: _t->slotConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break; + case 14: _t->slotServerDisconnect(); break; default: ; } } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { @@ -232,13 +236,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 14) + if (_id < 15) qt_static_metacall(this, _c, _id, _a); - _id -= 14; + _id -= 15; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 14) + if (_id < 15) qt_static_metacall(this, _c, _id, _a); - _id -= 14; + _id -= 15; } return _id; } diff --git a/debug/moc_mainwindow.o b/debug/moc_mainwindow.o index fa45590..b7a93a1 100644 Binary files a/debug/moc_mainwindow.o and b/debug/moc_mainwindow.o differ diff --git a/debug/moc_tcpclient.cpp b/debug/moc_tcpclient.cpp index 63e07e0..8562e9b 100644 --- a/debug/moc_tcpclient.cpp +++ b/debug/moc_tcpclient.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_TCPClient_t { - QByteArrayData data[13]; - char stringdata0[158]; + QByteArrayData data[14]; + char stringdata0[178]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -41,17 +41,18 @@ QT_MOC_LITERAL(5, 48, 11), // "QTcpSocket*" QT_MOC_LITERAL(6, 60, 6), // "socket" QT_MOC_LITERAL(7, 67, 18), // "sigConnectionState" QT_MOC_LITERAL(8, 86, 4), // "flag" -QT_MOC_LITERAL(9, 91, 15), // "sigGetXmlAnswer" -QT_MOC_LITERAL(10, 107, 18), // "slotMessageEntered" -QT_MOC_LITERAL(11, 126, 17), // "slotConnectNotify" -QT_MOC_LITERAL(12, 144, 13) // "slotReadyRead" +QT_MOC_LITERAL(9, 91, 19), // "sigServerDisconnect" +QT_MOC_LITERAL(10, 111, 15), // "sigGetXmlAnswer" +QT_MOC_LITERAL(11, 127, 18), // "slotMessageEntered" +QT_MOC_LITERAL(12, 146, 17), // "slotConnectNotify" +QT_MOC_LITERAL(13, 164, 13) // "slotReadyRead" }, "TCPClient\0sigSendDebugLog\0\0message\0" "sigRecognize\0QTcpSocket*\0socket\0" - "sigConnectionState\0flag\0sigGetXmlAnswer\0" - "slotMessageEntered\0slotConnectNotify\0" - "slotReadyRead" + "sigConnectionState\0flag\0sigServerDisconnect\0" + "sigGetXmlAnswer\0slotMessageEntered\0" + "slotConnectNotify\0slotReadyRead" }; #undef QT_MOC_LITERAL @@ -61,28 +62,30 @@ static const uint qt_meta_data_TCPClient[] = { 8, // revision 0, // classname 0, 0, // classinfo - 7, 14, // methods + 8, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 4, // signalCount + 5, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 49, 2, 0x06 /* Public */, - 4, 1, 52, 2, 0x06 /* Public */, - 7, 1, 55, 2, 0x06 /* Public */, - 9, 1, 58, 2, 0x06 /* Public */, + 1, 1, 54, 2, 0x06 /* Public */, + 4, 1, 57, 2, 0x06 /* Public */, + 7, 1, 60, 2, 0x06 /* Public */, + 9, 0, 63, 2, 0x06 /* Public */, + 10, 1, 64, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 10, 1, 61, 2, 0x0a /* Public */, - 11, 0, 64, 2, 0x0a /* Public */, - 12, 0, 65, 2, 0x08 /* Private */, + 11, 1, 67, 2, 0x0a /* Public */, + 12, 0, 70, 2, 0x0a /* Public */, + 13, 0, 71, 2, 0x08 /* Private */, // signals: parameters QMetaType::Void, QMetaType::QString, 3, QMetaType::Void, 0x80000000 | 5, 6, QMetaType::Void, QMetaType::Bool, 8, + QMetaType::Void, QMetaType::QByteArray, QMetaType::QString, 2, // slots: parameters @@ -102,11 +105,12 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v case 0: _t->sigSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: _t->sigRecognize((*reinterpret_cast< QTcpSocket*(*)>(_a[1]))); break; case 2: _t->sigConnectionState((*reinterpret_cast< bool(*)>(_a[1]))); break; - case 3: { QByteArray _r = _t->sigGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); + case 3: _t->sigServerDisconnect(); break; + case 4: { QByteArray _r = _t->sigGetXmlAnswer((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QByteArray*>(_a[0]) = std::move(_r); } break; - case 4: _t->slotMessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; - case 5: _t->slotConnectNotify(); break; - case 6: _t->slotReadyRead(); break; + case 5: _t->slotMessageEntered((*reinterpret_cast< QString(*)>(_a[1]))); break; + case 6: _t->slotConnectNotify(); break; + case 7: _t->slotReadyRead(); break; default: ; } } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { @@ -143,10 +147,17 @@ void TCPClient::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v return; } } + { + using _t = void (TCPClient::*)(); + if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPClient::sigServerDisconnect)) { + *result = 3; + return; + } + } { using _t = QByteArray (TCPClient::*)(QString ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&TCPClient::sigGetXmlAnswer)) { - *result = 3; + *result = 4; return; } } @@ -182,13 +193,13 @@ int TCPClient::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 7) + if (_id < 8) qt_static_metacall(this, _c, _id, _a); - _id -= 7; + _id -= 8; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 7) + if (_id < 8) qt_static_metacall(this, _c, _id, _a); - _id -= 7; + _id -= 8; } return _id; } @@ -215,11 +226,17 @@ void TCPClient::sigConnectionState(bool _t1) } // SIGNAL 3 +void TCPClient::sigServerDisconnect() +{ + QMetaObject::activate(this, &staticMetaObject, 3, nullptr); +} + +// SIGNAL 4 QByteArray TCPClient::sigGetXmlAnswer(QString _t1) { QByteArray _t0{}; void *_a[] = { const_cast(reinterpret_cast(std::addressof(_t0))), const_cast(reinterpret_cast(std::addressof(_t1))) }; - QMetaObject::activate(this, &staticMetaObject, 3, _a); + QMetaObject::activate(this, &staticMetaObject, 4, _a); return _t0; } QT_WARNING_POP diff --git a/debug/moc_tcpclient.o b/debug/moc_tcpclient.o index a1df8b3..b3216f5 100644 Binary files a/debug/moc_tcpclient.o and b/debug/moc_tcpclient.o differ diff --git a/debug/recognizesystem.o b/debug/recognizesystem.o index a943c0e..eb6277b 100644 Binary files a/debug/recognizesystem.o and b/debug/recognizesystem.o differ diff --git a/debug/tcpclient.o b/debug/tcpclient.o index 6cb32f8..81bff9b 100644 Binary files a/debug/tcpclient.o and b/debug/tcpclient.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index 52bcb1f..07368f4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -67,7 +67,9 @@ void MainWindow::initialize() connect(this,&MainWindow::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection); connect(this,&MainWindow::sigSendMessage,client,&TCPClient::slotMessageEntered,Qt::AutoConnection); connect(this,&MainWindow::sigSendClientAuthorization,client,&TCPClient::sendClientAutorization,Qt::AutoConnection); + connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection); + connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect); connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateHash); @@ -135,6 +137,7 @@ void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount) void MainWindow::lostConnection() { ui->loadingProgressBar->setValue(0); + slotConnectionState(false); } void MainWindow::checkLoginResult(ServerAuthorization *serverAuth) @@ -229,6 +232,19 @@ void MainWindow::slotConnectionState(bool flag) timer->start(3000); } +void MainWindow::slotServerDisconnect() +{ + ui->loadingProgressBar->hide(); + ui->updateButton->hide(); + ui->displayGroupWidget->hide(); + ui->autostartCheckBox->hide(); + + ui->loginWidget->show(); + ui->inlineTextDebug->setText(""); + ui->updateButton->setEnabled(false); + slotConnectionState(false); +} + void MainWindow::slotDisableNotify() { diff --git a/mainwindow.h b/mainwindow.h index 420ff4f..bd279eb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -57,6 +57,8 @@ private slots: void slotConnectionState(bool flag); + void slotServerDisconnect(); + private: Ui::MainWindow *ui; QTranslator translator; @@ -83,5 +85,6 @@ private: void checkLanguage(QString language); void autoStart(); void loadStaticData(); + void bindClient(); }; #endif // MAINWINDOW_H