diff --git a/Core/recognizesystem.cpp b/Core/recognizesystem.cpp index 0fd0f85..249959b 100644 --- a/Core/recognizesystem.cpp +++ b/Core/recognizesystem.cpp @@ -50,25 +50,6 @@ void RecognizeSystem::Recognize(QTcpSocket *socket) //qDebug() << Tools::GetTime() << "CLIENT: type: " << packetType; } - if(packetType == PacketType::TYPE_MSG){ //поведение на тип пакета с сообщением - - stream.startTransaction(); - stream >> message; - - if(!stream.commitTransaction()){ - emit onSendDebugLog(Tools::GetTime() + "CLIENT: Message - FAIL commitTransaction"); - if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){ - emit onSendDebugLog(Tools::GetTime() + "ERROR: MESSAGE READ TIMEOUT"); - return; - } - continue; - } - - emit onSendDebugLog(Tools::GetTime() + " CLIENT: Message from server " + message); //результат обрабатывать тут? - packetType = PacketType::TYPE_NONE; - continue; - } - if(packetType == PacketType::TYPE_FOLDER){ //создание папок stream.startTransaction(); stream >> filePath; @@ -227,14 +208,16 @@ void RecognizeSystem::Recognize(QTcpSocket *socket) if(packetType == PacketType::TYPE_NEEDUPDATE){ //нужно обновление - bool flag; - quint64 size; + bool flag = false; + quint64 size = 0; + quint64 fileCount = 0; stream.startTransaction(); stream >> flag; stream >> size; + stream >> fileCount; - emit onNeedUpdate(flag,size); + emit onNeedUpdate(flag,size,fileCount); packetType = PacketType::TYPE_NONE; } diff --git a/Core/recognizesystem.h b/Core/recognizesystem.h index 35dd251..fceda5e 100644 --- a/Core/recognizesystem.h +++ b/Core/recognizesystem.h @@ -24,7 +24,7 @@ public: signals: void UpdateBytesAvailable(qint64 size,quint64 sended); void LoadComplete(); - void onNeedUpdate(bool flag,qint64 size); + void onNeedUpdate(bool flag,qint64 size,quint64 fileCount); void onSendDebugLog(QString message); void SockedDisabled(); void SaveLoginData(ServerAuthorization *serverAuth); diff --git a/Core/tools.cpp b/Core/tools.cpp index ee86959..a0d5681 100644 --- a/Core/tools.cpp +++ b/Core/tools.cpp @@ -36,3 +36,23 @@ QString Tools::CreateFullPath(QString path) return fullPath; } + +QString Tools::convertFileSize(quint64 fileSize) +{ + quint64 megaByte = fileSize / (1024 * 1024); + QString resultSize; + + if (megaByte == 0) + { + auto kiloByte = fileSize / 1024; + resultSize = QString::number(kiloByte) + "кб. "; + } + else + { + resultSize = QString::number(megaByte) + "мб. "; + } + + + QString result = "Доступно обновление: " + resultSize; + return result; +} diff --git a/Core/tools.h b/Core/tools.h index 4807f79..5bf24b8 100644 --- a/Core/tools.h +++ b/Core/tools.h @@ -32,6 +32,7 @@ public: static QString GetTime(); static QString CreateLocalPath(QString path); static QString CreateFullPath(QString path); + static QString convertFileSize(quint64 fileSize); }; #endif // GLOBAL_H diff --git a/RRJClient.pro.user b/RRJClient.pro.user index 2c0531c..869b933 100644 --- a/RRJClient.pro.user +++ b/RRJClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/debug/RRJClient.exe b/debug/RRJClient.exe index a456458..b39afc9 100644 Binary files a/debug/RRJClient.exe and b/debug/RRJClient.exe differ diff --git a/debug/mainwindow.o b/debug/mainwindow.o index dcc281b..f7b6aa7 100644 Binary files a/debug/mainwindow.o and b/debug/mainwindow.o differ diff --git a/debug/moc_mainwindow.o b/debug/moc_mainwindow.o index 305b1b9..108efe9 100644 Binary files a/debug/moc_mainwindow.o and b/debug/moc_mainwindow.o differ diff --git a/debug/moc_recognizesystem.cpp b/debug/moc_recognizesystem.cpp index c7b5f0e..3e82bff 100644 --- a/debug/moc_recognizesystem.cpp +++ b/debug/moc_recognizesystem.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_RecognizeSystem_t { - QByteArrayData data[16]; - char stringdata0[197]; + QByteArrayData data[17]; + char stringdata0[207]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -40,22 +40,23 @@ QT_MOC_LITERAL(4, 43, 6), // "sended" QT_MOC_LITERAL(5, 50, 12), // "LoadComplete" QT_MOC_LITERAL(6, 63, 12), // "onNeedUpdate" QT_MOC_LITERAL(7, 76, 4), // "flag" -QT_MOC_LITERAL(8, 81, 14), // "onSendDebugLog" -QT_MOC_LITERAL(9, 96, 7), // "message" -QT_MOC_LITERAL(10, 104, 14), // "SockedDisabled" -QT_MOC_LITERAL(11, 119, 13), // "SaveLoginData" -QT_MOC_LITERAL(12, 133, 20), // "ServerAuthorization*" -QT_MOC_LITERAL(13, 154, 10), // "serverAuth" -QT_MOC_LITERAL(14, 165, 22), // "SocketWaitForReadyRead" -QT_MOC_LITERAL(15, 188, 8) // "waitTime" +QT_MOC_LITERAL(8, 81, 9), // "fileCount" +QT_MOC_LITERAL(9, 91, 14), // "onSendDebugLog" +QT_MOC_LITERAL(10, 106, 7), // "message" +QT_MOC_LITERAL(11, 114, 14), // "SockedDisabled" +QT_MOC_LITERAL(12, 129, 13), // "SaveLoginData" +QT_MOC_LITERAL(13, 143, 20), // "ServerAuthorization*" +QT_MOC_LITERAL(14, 164, 10), // "serverAuth" +QT_MOC_LITERAL(15, 175, 22), // "SocketWaitForReadyRead" +QT_MOC_LITERAL(16, 198, 8) // "waitTime" }, "RecognizeSystem\0UpdateBytesAvailable\0" "\0size\0sended\0LoadComplete\0onNeedUpdate\0" - "flag\0onSendDebugLog\0message\0SockedDisabled\0" - "SaveLoginData\0ServerAuthorization*\0" - "serverAuth\0SocketWaitForReadyRead\0" - "waitTime" + "flag\0fileCount\0onSendDebugLog\0message\0" + "SockedDisabled\0SaveLoginData\0" + "ServerAuthorization*\0serverAuth\0" + "SocketWaitForReadyRead\0waitTime" }; #undef QT_MOC_LITERAL @@ -75,20 +76,20 @@ static const uint qt_meta_data_RecognizeSystem[] = { // signals: name, argc, parameters, tag, flags 1, 2, 49, 2, 0x06 /* Public */, 5, 0, 54, 2, 0x06 /* Public */, - 6, 2, 55, 2, 0x06 /* Public */, - 8, 1, 60, 2, 0x06 /* Public */, - 10, 0, 63, 2, 0x06 /* Public */, - 11, 1, 64, 2, 0x06 /* Public */, - 14, 1, 67, 2, 0x06 /* Public */, + 6, 3, 55, 2, 0x06 /* Public */, + 9, 1, 62, 2, 0x06 /* Public */, + 11, 0, 65, 2, 0x06 /* Public */, + 12, 1, 66, 2, 0x06 /* Public */, + 15, 1, 69, 2, 0x06 /* Public */, // signals: parameters QMetaType::Void, QMetaType::LongLong, QMetaType::ULongLong, 3, 4, QMetaType::Void, - QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, 7, 3, - QMetaType::Void, QMetaType::QString, 9, + QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, QMetaType::ULongLong, 7, 3, 8, + QMetaType::Void, QMetaType::QString, 10, QMetaType::Void, - QMetaType::Void, 0x80000000 | 12, 13, - QMetaType::Void, QMetaType::Int, 15, + QMetaType::Void, 0x80000000 | 13, 14, + QMetaType::Void, QMetaType::Int, 16, 0 // eod }; @@ -101,7 +102,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int switch (_id) { case 0: _t->UpdateBytesAvailable((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< quint64(*)>(_a[2]))); break; case 1: _t->LoadComplete(); break; - case 2: _t->onNeedUpdate((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; + case 2: _t->onNeedUpdate((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2])),(*reinterpret_cast< quint64(*)>(_a[3]))); break; case 3: _t->onSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break; case 4: _t->SockedDisabled(); break; case 5: _t->SaveLoginData((*reinterpret_cast< ServerAuthorization*(*)>(_a[1]))); break; @@ -125,7 +126,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int } } { - using _t = void (RecognizeSystem::*)(bool , qint64 ); + using _t = void (RecognizeSystem::*)(bool , qint64 , quint64 ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&RecognizeSystem::onNeedUpdate)) { *result = 2; return; @@ -216,9 +217,9 @@ void RecognizeSystem::LoadComplete() } // SIGNAL 2 -void RecognizeSystem::onNeedUpdate(bool _t1, qint64 _t2) +void RecognizeSystem::onNeedUpdate(bool _t1, qint64 _t2, quint64 _t3) { - void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))), const_cast(reinterpret_cast(std::addressof(_t2))) }; + void *_a[] = { nullptr, const_cast(reinterpret_cast(std::addressof(_t1))), const_cast(reinterpret_cast(std::addressof(_t2))), const_cast(reinterpret_cast(std::addressof(_t3))) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } diff --git a/debug/moc_recognizesystem.o b/debug/moc_recognizesystem.o index ea43446..54255a6 100644 Binary files a/debug/moc_recognizesystem.o and b/debug/moc_recognizesystem.o differ diff --git a/debug/recognizesystem.o b/debug/recognizesystem.o index e07ed9c..f265eac 100644 Binary files a/debug/recognizesystem.o and b/debug/recognizesystem.o differ diff --git a/debug/tools.o b/debug/tools.o index 791d0d4..5a3d806 100644 Binary files a/debug/tools.o and b/debug/tools.o differ diff --git a/mainwindow.cpp b/mainwindow.cpp index aa23adf..3223dba 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -102,15 +102,19 @@ void MainWindow::LoadComplete() ui->startButton->setEnabled(true); } -void MainWindow::SetNeedUpdate(bool flag,quint64 size) +void MainWindow::SetNeedUpdate(bool flag,quint64 size, quint64 fileCount) { maxBytesAvailable = 0; - if(flag){ - quint64 megaByte = size / (1024 * 1024); - QString result = "Доступно обновление: " + QString::number(megaByte) + " мегабайт"; + QString availableSizeText; + + if (flag){ + QString result = Tools::convertFileSize(size); + result += "Количество файлов: " + QString::number(fileCount); ui->inlineTextDebug->setText(result); maxBytesAvailable = size; - }else{ + } + else + { ui->inlineTextDebug->setText("Установлена последняя версия"); } diff --git a/mainwindow.h b/mainwindow.h index 209afb0..7917d9a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -72,7 +72,7 @@ private: void Initialize(); void UpdateProgress(qint64 size,quint64 sended); void LoadComplete(); - void SetNeedUpdate(bool flag,quint64 size); + void SetNeedUpdate(bool flag,quint64 size,quint64 fileCount); void LostConnection(); void CheckLoginResult(ServerAuthorization * serverAuth); void CheckAppAvailable();