mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
refactoring
This commit is contained in:
@@ -17,14 +17,14 @@ RecognizeSystem::~RecognizeSystem()
|
||||
|
||||
}
|
||||
|
||||
void RecognizeSystem::Initialize(UpdateController *updateController,DataParser *dataParser)
|
||||
void RecognizeSystem::initialize(UpdateController *updateController,DataParser *dataParser)
|
||||
{
|
||||
this->updateController = updateController;
|
||||
this->dataParser = dataParser;
|
||||
connect(this,&RecognizeSystem::SaveLoginData,dataParser,&DataParser::CreateAuthData);
|
||||
connect(this,&RecognizeSystem::sigSaveLoginData,dataParser,&DataParser::createAuthData);
|
||||
}
|
||||
|
||||
void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -37,10 +37,10 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
stream >> packetType;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
emit onSendDebugLog(Tools::GetTime() + " CLIENT: packetType - FAIL commitTransaction");
|
||||
emit sigSendDebugLog(Tools::getTime() + " CLIENT: packetType - FAIL commitTransaction");
|
||||
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
emit onSendDebugLog("ERROR: PACKET TYPE READ TIMEOUT");
|
||||
emit sigSendDebugLog("ERROR: PACKET TYPE READ TIMEOUT");
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
@@ -58,7 +58,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
continue;
|
||||
}
|
||||
|
||||
filePath = Tools::CreateFullPath(filePath);
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
|
||||
QDir dir(filePath);
|
||||
if(!dir.exists()){
|
||||
@@ -83,28 +83,28 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
stream >> fileSize;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: filePath, fileSize - FAIL commitTransaction");
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: filePath, fileSize - FAIL commitTransaction");
|
||||
|
||||
if (!socket->waitForReadyRead(TCP_READ_TIMEOUT)) {
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: ERROR! readyRead timeout - filePath, fileSize!!!");
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: ERROR! readyRead timeout - filePath, fileSize!!!");
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
filePath = Tools::CreateFullPath(filePath);
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
|
||||
emit onSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit onSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit sigSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
|
||||
emit SocketWaitForReadyRead(100);
|
||||
emit sigSocketWaitForReadyRead(100);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//ПОЛУЧЕНИЕ САМОГО ФАЙЛА
|
||||
emit onSendDebugLog(Tools::GetTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
||||
emit sigSendDebugLog(Tools::getTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
||||
|
||||
//УКАЗАНИЕ ПУТИ ФАЙЛА
|
||||
QFile file(filePath);
|
||||
@@ -112,7 +112,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
if (file.exists())
|
||||
{
|
||||
file.remove(); //удаление файла, если он уже есть, но необходимо обновить
|
||||
emit onSendDebugLog(Tools::GetTime() + "Delete exist file: " + filePath);
|
||||
emit sigSendDebugLog(Tools::getTime() + "Delete exist file: " + filePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
if(!stream.commitTransaction()){
|
||||
|
||||
if(socket->state() == QAbstractSocket::UnconnectedState){
|
||||
emit SockedDisabled();
|
||||
emit sigSocketDisabled();
|
||||
return;
|
||||
}
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
@@ -138,7 +138,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
}
|
||||
|
||||
quint64 toFile = file.write(tmpBlock);
|
||||
emit onSendDebugLog(Tools::GetTime() + "CLIENT: toFile :" + toFile);
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: toFile :" + toFile);
|
||||
|
||||
sizeReceiveData += toFile;
|
||||
countSend++;
|
||||
@@ -146,16 +146,16 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
tmpBlock.clear();
|
||||
|
||||
if(sizeReceiveData == fileSize){
|
||||
emit onSendDebugLog(Tools::GetTime() + "FINAL Count send: " + QString::number(countSend));
|
||||
emit onSendDebugLog(Tools::GetTime() + "FINAL Size received: " + QString::number(sizeReceiveData));
|
||||
emit onSendDebugLog(Tools::GetTime() + "FINAL File size" + QString::number(fileSize));
|
||||
emit UpdateBytesAvailable(fileSize,sizeReceiveData);
|
||||
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(fileSize,sizeReceiveData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
emit onSendDebugLog(Tools::GetTime() + "File loaded");
|
||||
emit sigSendDebugLog(Tools::getTime() + "File loaded");
|
||||
|
||||
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
|
||||
|
||||
@@ -175,7 +175,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
continue;
|
||||
}
|
||||
|
||||
filePath = Tools::CreateFullPath(filePath);
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
|
||||
QFileInfo fileInfo(filePath);
|
||||
|
||||
@@ -192,7 +192,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
dir.removeRecursively();
|
||||
}
|
||||
|
||||
qDebug() << Tools::GetTime() << "Deleted: " << filePath;
|
||||
qDebug() << Tools::getTime() << "Deleted: " << filePath;
|
||||
}
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
@@ -201,8 +201,8 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
}
|
||||
|
||||
if(packetType ==PacketType::TYPE_FINISH){ //для повторного создания хэша после загрузки
|
||||
updateController->CalculateHash();
|
||||
emit LoadComplete();
|
||||
updateController->calculateHash();
|
||||
emit sigLoadComplete();
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
stream >> size;
|
||||
stream >> fileCount;
|
||||
|
||||
emit onNeedUpdate(flag,size,fileCount);
|
||||
emit sigNeedUpdate(flag,size,fileCount);
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
continue;
|
||||
}
|
||||
|
||||
XMLParser(array);
|
||||
xmlParser(array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
|
||||
}
|
||||
}
|
||||
|
||||
void RecognizeSystem::XMLParser(QByteArray array)
|
||||
void RecognizeSystem::xmlParser(QByteArray array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
|
||||
@@ -262,7 +262,7 @@ void RecognizeSystem::XMLParser(QByteArray array)
|
||||
if(name == "Code"){
|
||||
if (value == "END"){
|
||||
|
||||
emit SockedDisabled();
|
||||
emit sigSocketDisabled();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ void RecognizeSystem::XMLParser(QByteArray array)
|
||||
}
|
||||
}
|
||||
|
||||
emit SaveLoginData(serverAuth);
|
||||
emit sigSaveLoginData(serverAuth);
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
|
||||
Reference in New Issue
Block a user