mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
Попытка оптимизации
This commit is contained in:
@@ -5,10 +5,11 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
versionContainer(nullptr),
|
versionContainer(nullptr),
|
||||||
dataParser(nullptr),
|
dataParser(nullptr),
|
||||||
postProcessorSystem(nullptr)
|
postProcessorSystem(nullptr),
|
||||||
|
client(nullptr)
|
||||||
{
|
{
|
||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
filePath.clear();
|
filePath = "";
|
||||||
fileSize = 0;
|
fileSize = 0;
|
||||||
sizeReceiveData = 0;
|
sizeReceiveData = 0;
|
||||||
tmpBlock.clear();
|
tmpBlock.clear();
|
||||||
@@ -17,292 +18,301 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
|||||||
|
|
||||||
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem,Client *client)
|
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem,Client *client)
|
||||||
{
|
{
|
||||||
this->versionContainer = versionContainer;
|
this->versionContainer = versionContainer;
|
||||||
this->postProcessorSystem = postProcessorSystem;
|
|
||||||
this->dataParser = dataParser;
|
this->dataParser = dataParser;
|
||||||
|
this->postProcessorSystem = postProcessorSystem;
|
||||||
this->client = client;
|
this->client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BLOCK_SIZE = 1024 * 1024; // Размер блока
|
|
||||||
|
|
||||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||||
{
|
{
|
||||||
qDebug() << "RecognizeThreadId " << QThread::currentThreadId();
|
//qDebug() << "RecognizeThreadId " << QThread::currentThreadId();
|
||||||
|
|
||||||
QDataStream stream(socket);
|
QDataStream stream(socket);
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
while(socket->bytesAvailable())
|
while(socket->bytesAvailable())
|
||||||
{
|
{
|
||||||
|
if (socket->state() != QTcpSocket::ConnectedState)
|
||||||
if (socket->state() != QTcpSocket::ConnectedState) return;
|
{
|
||||||
|
qDebug() << "RecognizeSystem::recognize socket->state() != QTcpSocket::ConnectedState";
|
||||||
if(packetType == PacketType::TYPE_NONE){ //определение первичного пакета
|
return;
|
||||||
|
|
||||||
stream.startTransaction();
|
|
||||||
stream >> packetType;
|
|
||||||
|
|
||||||
if(!stream.commitTransaction())
|
|
||||||
{
|
|
||||||
emit sigSendDebugLog(Tools::getTime() + " CLIENT: packetType - FAIL commitTransaction");
|
|
||||||
|
|
||||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
|
||||||
emit sigSendDebugLog("ERROR: PACKET TYPE READ TIMEOUT");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//qDebug() << Tools::GetTime() << "CLIENT: type: " << packetType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_FOLDER){ //создание папок
|
/*
|
||||||
stream.startTransaction();
|
if(!socket->waitForReadyRead(TCP_READ_TIMEOUT))
|
||||||
stream >> filePath;
|
{
|
||||||
|
|
||||||
if(!stream.commitTransaction()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
|
||||||
|
|
||||||
QDir dir(filePath);
|
|
||||||
if(!dir.exists()){
|
|
||||||
if(dir.mkpath(filePath)){
|
|
||||||
qDebug() << "Dir Created";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
|
||||||
emit sigUpdateBytesAvailable();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_FILE) //загрузка файлов
|
switch ((int)packetType)
|
||||||
{
|
{
|
||||||
//ПОЛУЧЕНИЕ ПУТИ
|
case PacketType::TYPE_NONE: //определение первичного пакета
|
||||||
//ПОЛУЧЕНИЕ РАЗМЕРА ФАЙЛА
|
{
|
||||||
forever
|
stream.startTransaction();
|
||||||
|
stream >> packetType;
|
||||||
|
|
||||||
|
if(!stream.commitTransaction())
|
||||||
|
{
|
||||||
|
socket->waitForReadyRead(TCP_READ_TIMEOUT);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//qDebug() << Tools::GetTime() << "CLIENT: type: " << packetType;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case PacketType::TYPE_FOLDER: //создание папок
|
||||||
{
|
{
|
||||||
stream.startTransaction();
|
stream.startTransaction();
|
||||||
stream >> filePath;
|
stream >> filePath;
|
||||||
stream >> fileSize;
|
|
||||||
|
|
||||||
if(!stream.commitTransaction()){
|
if(!stream.commitTransaction())
|
||||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: filePath, fileSize - FAIL commitTransaction");
|
{
|
||||||
|
|
||||||
if (!socket->waitForReadyRead(TCP_READ_TIMEOUT)) {
|
|
||||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: ERROR! readyRead timeout - filePath, fileSize!!!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
||||||
|
|
||||||
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
QDir dir(filePath);
|
||||||
emit sigSendDebugLog("CLIENT: filePath: " + filePath);
|
if(!dir.exists())
|
||||||
|
|
||||||
socket->waitForReadyRead(100);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ПОЛУЧЕНИЕ САМОГО ФАЙЛА
|
|
||||||
emit sigSendDebugLog(Tools::getTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
|
||||||
|
|
||||||
//УКАЗАНИЕ ПУТИ ФАЙЛА
|
|
||||||
QFile file(filePath);
|
|
||||||
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
file.remove(); //удаление файла, если он уже есть, но необходимо обновить
|
|
||||||
emit sigSendDebugLog(Tools::getTime() + "Delete exist file: " + filePath);
|
|
||||||
socket->waitForReadyRead(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpBlock.clear();
|
|
||||||
sizeReceiveData = 0;
|
|
||||||
countSend = 0;
|
|
||||||
|
|
||||||
file.open(QFile::WriteOnly);
|
|
||||||
|
|
||||||
if(! file.isOpen())
|
|
||||||
{
|
|
||||||
int marker = 0;
|
|
||||||
QMessageBox::critical(nullptr, "P31", "POINT 31");
|
|
||||||
}
|
|
||||||
if(! file.isWritable())
|
|
||||||
{
|
|
||||||
int marker = 0;
|
|
||||||
QMessageBox::critical(nullptr, "P32", "POINT 32");
|
|
||||||
}
|
|
||||||
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
socket->waitForReadyRead(10);
|
|
||||||
|
|
||||||
if(socket->bytesAvailable() <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(fileSize - sizeReceiveData >= BLOCK_SIZE)
|
|
||||||
tmpBlock = socket->read(BLOCK_SIZE);
|
|
||||||
else
|
|
||||||
tmpBlock = socket->read(fileSize - sizeReceiveData);
|
|
||||||
|
|
||||||
qint64 bytesReceived = tmpBlock.length();
|
|
||||||
|
|
||||||
if(bytesReceived <= 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sizeReceiveData += bytesReceived;
|
|
||||||
countSend++;
|
|
||||||
|
|
||||||
qint64 toFile = file.write(tmpBlock);
|
|
||||||
|
|
||||||
if(toFile <= 0)
|
|
||||||
{
|
{
|
||||||
//emit sigUpdateBytesAvailable();
|
if(dir.mkpath(filePath))
|
||||||
QMessageBox::critical(nullptr, "P2", "POINT 33");
|
{
|
||||||
|
qDebug() << "Dir Created: " << filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit sigUpdateBytesAvailable();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::TYPE_FILE: //загрузка файлов
|
||||||
|
{
|
||||||
|
//ПОЛУЧЕНИЕ ПУТИ
|
||||||
|
//ПОЛУЧЕНИЕ РАЗМЕРА ФАЙЛА
|
||||||
|
forever
|
||||||
|
{
|
||||||
|
stream.startTransaction();
|
||||||
|
stream >> filePath;
|
||||||
|
stream >> fileSize;
|
||||||
|
|
||||||
|
if(!stream.commitTransaction())
|
||||||
|
{
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "CLIENT: filePath, fileSize - FAIL commitTransaction");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
||||||
|
|
||||||
|
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||||
|
emit sigSendDebugLog("CLIENT: filePath: " + filePath);
|
||||||
|
|
||||||
|
//socket->waitForReadyRead(100);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ПОЛУЧЕНИЕ САМОГО ФАЙЛА
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
||||||
|
|
||||||
|
//УКАЗАНИЕ ПУТИ ФАЙЛА
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
file.remove(); //удаление файла, если он уже есть, но необходимо обновить
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "Delete exist file: " + filePath);
|
||||||
|
|
||||||
|
//socket->waitForReadyRead(100);
|
||||||
|
}
|
||||||
|
|
||||||
tmpBlock.clear();
|
tmpBlock.clear();
|
||||||
|
sizeReceiveData = 0;
|
||||||
|
countSend = 0;
|
||||||
|
|
||||||
if(sizeReceiveData == fileSize)
|
file.open(QFile::WriteOnly);
|
||||||
|
|
||||||
|
if(! file.isOpen())
|
||||||
|
QMessageBox::critical(nullptr, "P1", "isOpen false. File: " + file.fileName());
|
||||||
|
|
||||||
|
if(! file.isWritable())
|
||||||
|
QMessageBox::critical(nullptr, "P2", "isWritable false. File: " + file.fileName());
|
||||||
|
|
||||||
|
while(true)
|
||||||
{
|
{
|
||||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Count send: " + QString::number(countSend));
|
if(socket->bytesAvailable() <= 0)
|
||||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Size received: " + QString::number(sizeReceiveData));
|
{
|
||||||
emit sigSendDebugLog(Tools::getTime() + "FINAL File size" + QString::number(fileSize));
|
socket->waitForReadyRead(TCP_READ_TIMEOUT);
|
||||||
emit sigUpdateBytesAvailable();
|
continue;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
else if(sizeReceiveData > fileSize)
|
if(fileSize - sizeReceiveData >= BLOCK_SIZE)
|
||||||
{
|
tmpBlock = socket->read(BLOCK_SIZE);
|
||||||
int marker = 0;
|
else
|
||||||
QMessageBox::critical(nullptr, "P40", "POINT 34");
|
tmpBlock = socket->read(fileSize - sizeReceiveData);
|
||||||
|
|
||||||
|
qint64 bytesReceived = tmpBlock.length();
|
||||||
|
|
||||||
|
if(bytesReceived <= 0)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(nullptr, "P3", "bytesReceived <= 0. File: " + file.fileName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sizeReceiveData += bytesReceived;
|
||||||
|
countSend++;
|
||||||
|
|
||||||
|
qint64 toFile = file.write(tmpBlock);
|
||||||
|
|
||||||
|
if(toFile <= 0)
|
||||||
|
{
|
||||||
|
//emit sigUpdateBytesAvailable();
|
||||||
|
QMessageBox::critical(nullptr, "P4", "write toFile <= 0. File: " + file.fileName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpBlock.clear();
|
||||||
|
|
||||||
|
if(sizeReceiveData == fileSize)
|
||||||
|
{
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "FINAL Count send: " + QString::number(countSend));
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "FINAL Size received: " + QString::number(sizeReceiveData));
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "FINAL File size" + QString::number(fileSize));
|
||||||
|
emit sigUpdateBytesAvailable();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(sizeReceiveData > fileSize)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(nullptr, "P5", "sizeReceiveData > fileSize");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
emit sigSendDebugLog(Tools::getTime() + "File loaded");
|
||||||
|
|
||||||
|
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
|
||||||
|
|
||||||
|
filePath.clear();
|
||||||
|
fileSize = 0;
|
||||||
|
tmpBlock.clear();
|
||||||
|
sizeReceiveData = 0;
|
||||||
|
countSend = 0;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
file.close();
|
case PacketType::TYPE_DELETE: //удаление лишних файлов (рекурсивно удаляет все содежимое)
|
||||||
emit sigSendDebugLog(Tools::getTime() + "File loaded");
|
|
||||||
|
|
||||||
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
|
|
||||||
|
|
||||||
filePath.clear();
|
|
||||||
fileSize = 0;
|
|
||||||
tmpBlock.clear();
|
|
||||||
sizeReceiveData = 0;
|
|
||||||
countSend = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_DELETE) //удаление лишних файлов (рекурсивно удаляет все содежимое)
|
|
||||||
{
|
|
||||||
stream.startTransaction();
|
|
||||||
stream >> filePath;
|
|
||||||
|
|
||||||
if(!stream.commitTransaction()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
|
||||||
|
|
||||||
QFileInfo fileInfo(filePath);
|
|
||||||
|
|
||||||
|
|
||||||
if(fileInfo.exists())
|
|
||||||
{
|
{
|
||||||
if(fileInfo.isFile())
|
stream.startTransaction();
|
||||||
|
stream >> filePath;
|
||||||
|
|
||||||
|
if(!stream.commitTransaction())
|
||||||
{
|
{
|
||||||
QFile file(filePath);
|
continue;
|
||||||
file.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileInfo.isDir()){
|
filePath = Tools::createReceiveFullPath(filePath,versionContainer->getServerVersionData());
|
||||||
QDir dir(filePath);
|
|
||||||
dir.removeRecursively();
|
QFileInfo fileInfo(filePath);
|
||||||
|
|
||||||
|
if(fileInfo.exists())
|
||||||
|
{
|
||||||
|
if(fileInfo.isFile())
|
||||||
|
{
|
||||||
|
QFile file(filePath);
|
||||||
|
file.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileInfo.isDir())
|
||||||
|
{
|
||||||
|
QDir dir(filePath);
|
||||||
|
dir.removeRecursively();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << Tools::getTime() << "Deleted: " << filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << Tools::getTime() << "Deleted: " << filePath;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
case PacketType::TYPE_NEEDUPDATE: //нужно обновление
|
||||||
continue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_NEEDUPDATE)
|
|
||||||
{ //нужно обновление
|
|
||||||
|
|
||||||
bool flag = false;
|
|
||||||
quint64 size = 0;
|
|
||||||
quint64 fileCount = 0;
|
|
||||||
quint64 fileDelete = 0;
|
|
||||||
|
|
||||||
stream.startTransaction();
|
|
||||||
stream >> flag;
|
|
||||||
stream >> size;
|
|
||||||
stream >> fileCount;
|
|
||||||
stream >> fileDelete;
|
|
||||||
|
|
||||||
if(!stream.commitTransaction()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit sigNeedUpdate(flag,size,fileCount,fileDelete);
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_XMLANSWER){ //ответы формата XML
|
|
||||||
QByteArray array;
|
|
||||||
stream.startTransaction();
|
|
||||||
stream >> array;
|
|
||||||
|
|
||||||
if(!stream.commitTransaction()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataParser->xmlParser(array);
|
|
||||||
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::HASH_READY)
|
|
||||||
{
|
|
||||||
emit sigCheckUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::RECALCULATE_HASH)
|
|
||||||
{
|
|
||||||
emit sigdRecalculateHashOnServerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::BUSY)
|
|
||||||
{
|
|
||||||
emit sigAnimationActivated(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(packetType == PacketType::FREE)
|
|
||||||
{
|
|
||||||
emit sigAnimationActivated(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packetType == PacketType::TYPE_XMLANSWER_DOCS_CHANGED) //на случай общего обновления
|
|
||||||
{
|
|
||||||
if (client->getIsLoggedIn())
|
|
||||||
{
|
{
|
||||||
|
bool flag = false;
|
||||||
|
quint64 size = 0;
|
||||||
|
quint64 fileCount = 0;
|
||||||
|
quint64 fileDelete = 0;
|
||||||
|
|
||||||
|
stream.startTransaction();
|
||||||
|
stream >> flag;
|
||||||
|
stream >> size;
|
||||||
|
stream >> fileCount;
|
||||||
|
stream >> fileDelete;
|
||||||
|
|
||||||
|
if(!stream.commitTransaction())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit sigNeedUpdate(flag,size,fileCount,fileDelete);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::TYPE_XMLANSWER: //ответы формата XML
|
||||||
|
{
|
||||||
|
QByteArray array;
|
||||||
|
stream.startTransaction();
|
||||||
|
stream >> array;
|
||||||
|
|
||||||
|
if(!stream.commitTransaction())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataParser->xmlParser(array);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::HASH_READY:
|
||||||
|
{
|
||||||
|
emit sigCheckUpdate();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::RECALCULATE_HASH:
|
||||||
|
{
|
||||||
|
emit sigdRecalculateHashOnServerState();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::BUSY:
|
||||||
|
{
|
||||||
|
emit sigAnimationActivated(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::FREE:
|
||||||
|
{
|
||||||
|
emit sigAnimationActivated(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::TYPE_XMLANSWER_DOCS_CHANGED: //на случай общего обновления
|
||||||
|
{
|
||||||
|
if (client->getIsLoggedIn())
|
||||||
|
{
|
||||||
|
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PacketType::UPDATE_FILE_COMPLETE:
|
||||||
|
{
|
||||||
|
postProcessorSystem->calculateCommonHash();
|
||||||
|
emit sigLoadComplete();
|
||||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (packetType == PacketType::UPDATE_FILE_COMPLETE)
|
default:
|
||||||
{
|
qCritical() << "RecognizeSystem::recognize packetType unknown!";
|
||||||
postProcessorSystem->calculateCommonHash();
|
|
||||||
emit sigLoadComplete();
|
|
||||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <Data\streamingversiondata.h>
|
#include <Data\streamingversiondata.h>
|
||||||
#include <Core\hashcomparer.h>
|
#include <Core\hashcomparer.h>
|
||||||
|
|
||||||
|
const int BLOCK_SIZE = 1024 * 1024; // Размер блока
|
||||||
|
|
||||||
class RecognizeSystem : public QObject
|
class RecognizeSystem : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -21,8 +23,10 @@ class RecognizeSystem : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit RecognizeSystem(QObject *parent = 0);
|
explicit RecognizeSystem(QObject *parent = 0);
|
||||||
~RecognizeSystem(){};
|
~RecognizeSystem(){};
|
||||||
|
|
||||||
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem,Client *client);
|
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem,Client *client);
|
||||||
void recognize(QTcpSocket *socket);
|
void recognize(QTcpSocket *socket);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigUpdateBytesAvailable();
|
void sigUpdateBytesAvailable();
|
||||||
void sigLoadComplete();
|
void sigLoadComplete();
|
||||||
@@ -40,13 +44,13 @@ private:
|
|||||||
VersionContainer *versionContainer;
|
VersionContainer *versionContainer;
|
||||||
DataParser *dataParser;
|
DataParser *dataParser;
|
||||||
PostProcessorSystem *postProcessorSystem;
|
PostProcessorSystem *postProcessorSystem;
|
||||||
PacketType packetType;
|
|
||||||
QString filePath;
|
|
||||||
QByteArray tmpBlock;
|
|
||||||
Client *client;
|
Client *client;
|
||||||
|
|
||||||
qint64 sizeReceiveData;
|
PacketType packetType;
|
||||||
|
QString filePath;
|
||||||
qint64 fileSize;
|
qint64 fileSize;
|
||||||
|
qint64 sizeReceiveData;
|
||||||
|
QByteArray tmpBlock;
|
||||||
int countSend;
|
int countSend;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user