mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14c1ffb66f | ||
|
|
5b63141ddf | ||
|
|
6665f417c9 | ||
|
|
633881847b | ||
|
|
a2e64ecb68 | ||
|
|
4829647e98 | ||
|
|
b706de2961 | ||
|
|
a4d4709118 | ||
|
|
60c3d6244e | ||
|
|
c9c62d22c0 |
@@ -1,6 +1,7 @@
|
||||
#include "UpdateController.h"
|
||||
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QThread>
|
||||
|
||||
UpdateController::UpdateController(QObject *parent) :
|
||||
@@ -8,6 +9,7 @@ UpdateController::UpdateController(QObject *parent) :
|
||||
versionContainer(nullptr)
|
||||
{
|
||||
applicationFolderPath = QDir::currentPath() + applicationFolderName;
|
||||
hashCalculator = new FastHashCalculator;
|
||||
}
|
||||
|
||||
void UpdateController::initialize(VersionContainer *versionContainer,DataParserOutput *dataParserOut, SendSystem *sendSystem)
|
||||
@@ -20,18 +22,26 @@ void UpdateController::initialize(VersionContainer *versionContainer,DataParserO
|
||||
void UpdateController::calculateCommonHash()
|
||||
{
|
||||
appDataList.clear();
|
||||
appDataList = calculateHash(applicationFolderPath,"StreamingAssets");
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
qDebug() << "Start calculate... ";
|
||||
|
||||
hashCalculator->calculateHashes(applicationFolderPath,"StreamingAssets");
|
||||
appDataList = *hashCalculator->getHashList();
|
||||
calculateStreamingHash();
|
||||
appDataList.append(streamingDataList);
|
||||
|
||||
qDebug() << "Hash count: " << appDataList.count() ;
|
||||
dataParserOut->createFileDataList(appDataList,fullStaticDataFolderName + hashFilename);
|
||||
qDebug() << "UpdateController threadID " << QThread::currentThreadId();
|
||||
qDebug() <<"Calculate time " << timer.elapsed();
|
||||
}
|
||||
|
||||
void UpdateController::calculateStreamingHash()
|
||||
{
|
||||
streamingDataList.clear();
|
||||
streamingDataList = calculateHash(QDir::currentPath() + streamingAssetsPath,"");
|
||||
std::sort(streamingDataList.begin(),streamingDataList.end());
|
||||
hashCalculator->calculateHashes(QDir::currentPath() + streamingAssetsPath,"");
|
||||
streamingDataList = *hashCalculator->getHashList();
|
||||
dataParserOut->createFileDataList(streamingDataList,streamingHashFilename);
|
||||
}
|
||||
|
||||
@@ -45,7 +55,6 @@ QList<FileData> UpdateController::calculateHash(const QString& path,const QStrin
|
||||
}
|
||||
|
||||
QList<FileData> *hashes = new QList<FileData>;
|
||||
QString fullSize = Tools::convertFileSize(getDirectorySize(path),false);
|
||||
quint64 currentSize = 0;
|
||||
|
||||
QStringList filter;
|
||||
@@ -82,9 +91,9 @@ QList<FileData> UpdateController::calculateHash(const QString& path,const QStrin
|
||||
|
||||
currentSize += fileInfo.size();
|
||||
|
||||
emit sigSendHashInfo(fullSize,Tools::convertFileSize(currentSize,false));
|
||||
|
||||
quint64 fileSize = file.size(); //буффер для хэширования крупных файлов
|
||||
const quint64 bufferSize = 10240;
|
||||
const quint64 bufferSize = 1024;
|
||||
|
||||
if(fileInfo.isHidden()) continue;
|
||||
if(ignoreName != "" && fileInfo.path().contains(ignoreName)) continue;
|
||||
@@ -115,24 +124,6 @@ QList<FileData> UpdateController::calculateHash(const QString& path,const QStrin
|
||||
return *hashes;
|
||||
}
|
||||
|
||||
quint64 UpdateController::getDirectorySize(const QString& path)
|
||||
{
|
||||
quint64 totalSize = 0;
|
||||
QDirIterator iterator(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
QFileInfo fileInfo = iterator.fileInfo();
|
||||
if (fileInfo.isFile())
|
||||
{
|
||||
totalSize += fileInfo.size();
|
||||
}
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
|
||||
QListIterator<FileData> serverIterator(*fileSendList);
|
||||
@@ -155,8 +146,7 @@ void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
}
|
||||
|
||||
calculateCommonHash();
|
||||
sendSystem->sendFinish();
|
||||
|
||||
sendSystem->sendPacketType(PacketType::RECALCULATE_DOCS);
|
||||
emit sigUpdateComplete(true);
|
||||
}
|
||||
catch (...)
|
||||
@@ -166,6 +156,11 @@ void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
|
||||
}
|
||||
|
||||
FastHashCalculator *UpdateController::getHashCalculator() const
|
||||
{
|
||||
return hashCalculator;
|
||||
}
|
||||
|
||||
|
||||
UpdateController::~UpdateController()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Core/sendsystem.h"
|
||||
#include "Core/versioncontainer.h"
|
||||
#include "fasthashcalculator.h"
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamAttribute>
|
||||
@@ -34,19 +35,21 @@ public:
|
||||
void updateFilesOnServer(QList<FileData> *fileSendList);
|
||||
void checkCanUpdate();
|
||||
|
||||
FastHashCalculator *getHashCalculator() const;
|
||||
|
||||
signals:
|
||||
void sigUpdateComplete(bool flag);
|
||||
void sigSendHashInfo(QString fullSize,QString current);
|
||||
|
||||
private:
|
||||
SendSystem *sendSystem;
|
||||
DataParserOutput * dataParserOut;
|
||||
FastHashCalculator* hashCalculator;
|
||||
QString applicationFolderPath;
|
||||
VersionContainer *versionContainer;
|
||||
QList<FileData> appDataList;
|
||||
QList<FileData> streamingDataList;
|
||||
|
||||
QList<FileData> calculateHash(const QString& path,const QString& ignoreName);
|
||||
quint64 getDirectorySize(const QString &path);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -95,9 +95,10 @@ ServerSettings *DataParser::getClientSettings()
|
||||
return settings;
|
||||
}
|
||||
|
||||
void DataParser::xmlParser(const QByteArray& array)
|
||||
bool DataParser::xmlParser(const QByteArray& array)
|
||||
{
|
||||
QXmlStreamReader xmlReader(array);
|
||||
bool result = false;
|
||||
|
||||
xmlReader.readNext();
|
||||
|
||||
@@ -135,6 +136,7 @@ void DataParser::xmlParser(const QByteArray& array)
|
||||
if (value == "UNCHANGEABLE")
|
||||
{
|
||||
//версию нельзя изменять
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (value == "CHANGEABLE")
|
||||
@@ -247,4 +249,5 @@ void DataParser::xmlParser(const QByteArray& array)
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <QObject>
|
||||
#include <QDomDocument>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <Data/FileData.h>
|
||||
#include <Data/Datas.h>
|
||||
#include <Data/FileData.h>
|
||||
#include <Core/tools.h>
|
||||
@@ -22,7 +21,7 @@ public:
|
||||
|
||||
void initialize(PostProcessorSystem *postProcessSystem);
|
||||
ServerSettings* getClientSettings();
|
||||
void xmlParser(const QByteArray& array);
|
||||
bool xmlParser(const QByteArray& array);
|
||||
private:
|
||||
PostProcessorSystem *postProcessSystem;
|
||||
};
|
||||
|
||||
@@ -77,7 +77,6 @@ QByteArray DataParserOutput::xmlAnswer(const QList<SXmlAnswerTag>& listTag, cons
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
void DataParserOutput::createFileDataList(const QList<FileData>& fileDataList,const QString& filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
@@ -129,7 +128,6 @@ void DataParserOutput::createAuthMessage(ClientAutorization *auth)
|
||||
void DataParserOutput::createServerSettings(ServerSettings* serverSettings)
|
||||
{
|
||||
QFile file(settingsName);
|
||||
|
||||
file.open(QIODevice::WriteOnly);
|
||||
|
||||
QXmlStreamWriter xmlWriter(&file);
|
||||
@@ -144,9 +142,9 @@ void DataParserOutput::createServerSettings(ServerSettings* serverSettings)
|
||||
xmlWriter.writeAttribute("Port",serverSettings->Port);
|
||||
xmlWriter.writeAttribute("Language","RUS");
|
||||
xmlWriter.writeAttribute("AutoStart",QString::number(false));
|
||||
xmlWriter.writeAttribute("DestPortMath","18003");
|
||||
xmlWriter.writeAttribute("LocalPortMath","18004");
|
||||
xmlWriter.writeAttribute("UseMathModel",QString::number(serverSettings->mathModelUse));
|
||||
//xmlWriter.writeAttribute("DestPortMath","18003");
|
||||
//xmlWriter.writeAttribute("LocalPortMath","18004");
|
||||
//xmlWriter.writeAttribute("UseMathModel",QString::number(serverSettings->mathModelUse));
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
|
||||
127
Core/fasthashcalculator.cpp
Normal file
127
Core/fasthashcalculator.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
#include "fasthashcalculator.h"
|
||||
#include <QtConcurrent>
|
||||
|
||||
|
||||
FastHashCalculator::FastHashCalculator(QObject *parent) : QObject(parent)
|
||||
{
|
||||
hashList = new QList<FileData>();
|
||||
}
|
||||
void FastHashCalculator::calculateHashes(const QString& path, const QString& ignoreName)
|
||||
{
|
||||
hashList->clear();
|
||||
currentSize = 0;
|
||||
if(!QDir(path).exists()){
|
||||
QDir().mkdir(path);
|
||||
}
|
||||
|
||||
QString hashString;
|
||||
QStringList filter;
|
||||
filter << "*";
|
||||
QList<FileData> *folders = new QList<FileData>;
|
||||
fullSize = Tools::convertFileSize(getDirectorySize(path),false);
|
||||
|
||||
//только папки
|
||||
QDirIterator dirIterator(path,filter, QDir::AllEntries, QDirIterator::Subdirectories);
|
||||
|
||||
while (dirIterator.hasNext())
|
||||
{
|
||||
QFileInfo fileInfo(dirIterator.next());
|
||||
FileData currentFolder;
|
||||
if(fileInfo.isDir() && !fileInfo.fileName().startsWith(".") && fileInfo.fileName() != "RRJLoader")
|
||||
{
|
||||
currentFolder.path = Tools::createLocalPath(fileInfo.absoluteFilePath());
|
||||
currentFolder.hash = "FOLDER";
|
||||
|
||||
if(!folders->contains(currentFolder))
|
||||
{
|
||||
folders->push_back(currentFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//только файлы
|
||||
QDirIterator fileIterator(path,filter,QDir::Files | QDir::NoDotAndDotDot,QDirIterator::Subdirectories);
|
||||
|
||||
QList<QString> files;
|
||||
files.clear();
|
||||
|
||||
while(fileIterator.hasNext())
|
||||
{
|
||||
fileIterator.next();
|
||||
QFileInfo fileInfo = fileIterator.fileInfo();
|
||||
QString path = fileInfo.absoluteFilePath();
|
||||
|
||||
if (fileInfo.isHidden()) continue;
|
||||
if (!fileInfo.isFile()) continue;
|
||||
if (fileInfo.fileName().contains(".meta")) continue;
|
||||
if (ignoreName != "" && fileInfo.path().contains(ignoreName)) continue;
|
||||
|
||||
files.append(path);
|
||||
}
|
||||
|
||||
QtConcurrent::map(files, [this](const QString &filePath)
|
||||
{
|
||||
QByteArray hash = calculateFileHashOptimized(filePath);
|
||||
QMutexLocker locker(&_mutex);
|
||||
FileData currentFile;
|
||||
QString hashName;
|
||||
|
||||
currentFile.path = Tools::createLocalPath(filePath);
|
||||
currentFile.hash = hash.toHex();
|
||||
|
||||
hashList->append(currentFile);
|
||||
}).waitForFinished();
|
||||
|
||||
hashList->append(*folders);
|
||||
emit finished();
|
||||
}
|
||||
|
||||
QByteArray FastHashCalculator::calculateFileHashOptimized(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) return QByteArray();
|
||||
|
||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||
const qint64 bufferSize = 2048; // 2MB
|
||||
quint64 completeBytes = 0;
|
||||
QByteArray buffer;
|
||||
buffer.resize(bufferSize);
|
||||
|
||||
while (!file.atEnd()) {
|
||||
qint64 bytesRead = file.read(buffer.data(), bufferSize);
|
||||
hash.addData(buffer.constData(), bytesRead);
|
||||
completeBytes += bytesRead;
|
||||
}
|
||||
|
||||
hashCounterDisplay(completeBytes);
|
||||
return hash.result();
|
||||
}
|
||||
|
||||
void FastHashCalculator::hashCounterDisplay(quint64 size)
|
||||
{
|
||||
currentSize += size;
|
||||
emit sigSendHashInfo(fullSize,Tools::convertFileSize(currentSize,false));
|
||||
}
|
||||
|
||||
quint64 FastHashCalculator::getDirectorySize(const QString& path)
|
||||
{
|
||||
quint64 totalSize = 0;
|
||||
QDirIterator iterator(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
QFileInfo fileInfo = iterator.fileInfo();
|
||||
if (fileInfo.isFile())
|
||||
{
|
||||
totalSize += fileInfo.size();
|
||||
}
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
QList<FileData> *FastHashCalculator::getHashList() const
|
||||
{
|
||||
return hashList;
|
||||
}
|
||||
38
Core/fasthashcalculator.h
Normal file
38
Core/fasthashcalculator.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef FASTHASHCALCULATOR_H
|
||||
#define FASTHASHCALCULATOR_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
#include <QDirIterator>
|
||||
#include <Data/FileData.h>
|
||||
#include "tools.h"
|
||||
|
||||
|
||||
class FastHashCalculator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FastHashCalculator(QObject *parent = nullptr);
|
||||
void calculateHashes(const QString& path, const QString& ignoreName);
|
||||
QList<FileData> *getHashList() const;
|
||||
|
||||
signals:
|
||||
void sigSendHashInfo(QString fullSize,QString current);
|
||||
void finished();
|
||||
|
||||
private:
|
||||
QByteArray calculateFileHashOptimized(const QString &filePath);
|
||||
void calculateSingleHash(const QString &filePath);
|
||||
|
||||
QList<FileData>* hashList;
|
||||
QMutex _mutex;
|
||||
QString fullSize;
|
||||
quint64 currentSize;
|
||||
|
||||
quint64 getDirectorySize(const QString &path);
|
||||
void hashCounterDisplay(quint64 size);
|
||||
};
|
||||
|
||||
#endif // FASTHASHCALCULATOR_H
|
||||
@@ -25,6 +25,7 @@ void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<Fil
|
||||
{
|
||||
if(!serverStreamingHash->contains(item))
|
||||
{
|
||||
if (item.path.contains("docs.xml")) continue; //фильтр на docs
|
||||
files->append(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
countSend = 0;
|
||||
}
|
||||
|
||||
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem)
|
||||
void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem,Client *client)
|
||||
{
|
||||
this->versionContainer = versionContainer;
|
||||
this->postProcessorSystem = postProcessorSystem;
|
||||
this->dataParser = dataParser;
|
||||
this->client = client;
|
||||
}
|
||||
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
@@ -38,7 +39,8 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
stream.startTransaction();
|
||||
stream >> packetType;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
if(!stream.commitTransaction())
|
||||
{
|
||||
emit sigSendDebugLog(Tools::getTime() + " CLIENT: packetType - FAIL commitTransaction");
|
||||
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
@@ -205,15 +207,8 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
}
|
||||
|
||||
if (packetType ==PacketType::TYPE_FINISH) //для повторного создания хэша после загрузки
|
||||
{
|
||||
postProcessorSystem->calculateCommonHash();
|
||||
|
||||
emit sigLoadComplete();
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
if(packetType == PacketType::TYPE_NEEDUPDATE){ //нужно обновление
|
||||
if(packetType == PacketType::TYPE_NEEDUPDATE)
|
||||
{ //нужно обновление
|
||||
|
||||
bool flag = false;
|
||||
quint64 size = 0;
|
||||
@@ -251,10 +246,9 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
if(packetType == PacketType::HASH_READY)
|
||||
{
|
||||
emit sigCheckUpdate();
|
||||
//mainWindow->checkUpdate();
|
||||
}
|
||||
|
||||
if(packetType == PacketType::HASH_CALCULATE_START)
|
||||
if(packetType == PacketType::RECALCULATE_HASH)
|
||||
{
|
||||
emit sigdRecalculateHashOnServerState();
|
||||
}
|
||||
@@ -269,6 +263,22 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
emit sigAnimationActivated(false);
|
||||
}
|
||||
|
||||
if (packetType == PacketType::TYPE_XMLANSWER_DOCS_CHANGED) //на случай общего обновления
|
||||
{
|
||||
if (client->getIsLoggedIn())
|
||||
{
|
||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||
}
|
||||
}
|
||||
|
||||
if (packetType == PacketType::UPDATE_FILE_COMPLETE)
|
||||
{
|
||||
postProcessorSystem->calculateCommonHash();
|
||||
emit sigLoadComplete();
|
||||
emit sigSendPacketType(PacketType::GET_DOCS);
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QThread>
|
||||
#include <Core\tools.h>
|
||||
#include <Core\versioncontainer.h>
|
||||
#include <Data/Client.h>
|
||||
#include <Data\streamingversiondata.h>
|
||||
#include <Core\hashcomparer.h>
|
||||
|
||||
@@ -20,7 +21,7 @@ class RecognizeSystem : public QObject
|
||||
public:
|
||||
explicit RecognizeSystem(QObject *parent = 0);
|
||||
~RecognizeSystem(){};
|
||||
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem);
|
||||
void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem,Client *client);
|
||||
void recognize(QTcpSocket *socket);
|
||||
signals:
|
||||
void sigUpdateBytesAvailable();
|
||||
@@ -30,6 +31,10 @@ signals:
|
||||
void sigAnimationActivated(bool flag);
|
||||
void sigCheckUpdate();
|
||||
void sigdRecalculateHashOnServerState();
|
||||
void sigSendPacketType(PacketType packetType);
|
||||
void sigSendPacketTypeWithDelay(PacketType packetType,int delay);
|
||||
void sigSendToInlineLog(QString message);
|
||||
void sigCallUpdateList();
|
||||
|
||||
private:
|
||||
VersionContainer *versionContainer;
|
||||
@@ -38,6 +43,7 @@ private:
|
||||
PacketType packetType;
|
||||
QString filePath;
|
||||
QByteArray tmpBlock;
|
||||
Client *client;
|
||||
|
||||
qint64 sizeReceiveData;
|
||||
qint64 fileSize;
|
||||
|
||||
@@ -157,16 +157,6 @@ void SendSystem::sendXMLAnswer(const QByteArray& array)
|
||||
qDebug() << "Send XML answer in byte";
|
||||
}
|
||||
|
||||
void SendSystem::sendFinish()
|
||||
{
|
||||
socket->waitForReadyRead(100);
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
stream << PacketType::TYPE_FINISH;
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendPacketType(PacketType packetType)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
@@ -175,12 +165,47 @@ void SendSystem::sendPacketType(PacketType packetType)
|
||||
stream << packetType;
|
||||
}
|
||||
|
||||
void SendSystem::sendPacketTypeWithDelay(PacketType packetType,int delay)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
socket->waitForReadyRead(delay);
|
||||
stream << packetType;
|
||||
}
|
||||
void SendSystem::sendCheckHash()
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
QString fullPath = Tools::createSendFullPath(staticDataFolderName + hashFilename);
|
||||
|
||||
sendFileBlock(staticDataFolderName + hashFilename);
|
||||
quint64 fileSize = 0;
|
||||
int countSend = 0;
|
||||
|
||||
|
||||
QFile file(fullPath); //Открываем файл для чтения
|
||||
QFileInfo fileInfo(file);
|
||||
|
||||
fileSize = fileInfo.size();
|
||||
|
||||
stream << PacketType::SEND_HASH; //Отправляем тип блока
|
||||
stream << fileSize;
|
||||
|
||||
socket->waitForReadyRead(20);
|
||||
//socket->waitForBytesWritten();
|
||||
|
||||
if(file.open(QFile::ReadOnly)){
|
||||
while(!file.atEnd()){
|
||||
QByteArray data = file.read(readSize);
|
||||
stream << data;
|
||||
socket->waitForBytesWritten(20);
|
||||
countSend++;
|
||||
}
|
||||
|
||||
qDebug() << Tools::getTime() << "count end Final: " << countSend;
|
||||
}
|
||||
|
||||
file.close();
|
||||
countSend = 0;
|
||||
|
||||
socket->waitForReadyRead(2000);
|
||||
stream << PacketType::TYPE_CHECK_VERSION;
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
void sendCheckHash();
|
||||
void sendPacketType(PacketType packetType);
|
||||
~SendSystem(){};
|
||||
void sendPacketTypeWithDelay(PacketType packetType, int delay);
|
||||
signals:
|
||||
void sigSend();
|
||||
QByteArray sigGetXmlAnswer(QString);
|
||||
|
||||
@@ -47,7 +47,6 @@ void TCPClient::setConnect(ServerSettings *serverSettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TCPClient::setDisconnect()
|
||||
{
|
||||
socket->disconnect();
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void initialize(RecognizeSystem *recognize,SendSystem *sendSystem);
|
||||
void setConnect(ServerSettings *serverSettings);
|
||||
~TCPClient(){};
|
||||
|
||||
void setDisconnect();
|
||||
bool getIsConnected() const;
|
||||
|
||||
signals:
|
||||
@@ -43,8 +43,6 @@ private:
|
||||
QTcpSocket *socket;
|
||||
RecognizeSystem *recognizeSystem;
|
||||
bool isConnected;
|
||||
|
||||
void setDisconnect();
|
||||
};
|
||||
|
||||
#endif // TCPCLIENT_H
|
||||
|
||||
@@ -12,12 +12,12 @@ QString Tools::getTime()
|
||||
|
||||
QString Tools::createLocalPath(QString path)
|
||||
{
|
||||
qDebug() << "Full path: " << path;
|
||||
//qDebug() << "Full path: " << path;
|
||||
qint8 pos = path.indexOf("Application");
|
||||
|
||||
QString localPath = path.remove(0,--pos);
|
||||
|
||||
qDebug() << "Local path: " << localPath;
|
||||
//qDebug() << "Local path: " << localPath;
|
||||
return localPath;
|
||||
}
|
||||
|
||||
|
||||
10
Core/tools.h
10
Core/tools.h
@@ -39,13 +39,16 @@ enum PacketType{
|
||||
TYPE_COMMAND = 3,
|
||||
TYPE_FOLDER = 4,
|
||||
TYPE_DELETE = 5,
|
||||
TYPE_FINISH = 6,
|
||||
UPDATE_FILE_COMPLETE = 6,
|
||||
TYPE_NEEDUPDATE = 7,
|
||||
TYPE_XMLANSWER = 8,
|
||||
TYPE_QT = 9,
|
||||
TYPE_DISABLE = 11,
|
||||
TYPE_UPDATE = 12,
|
||||
TYPE_CHECK_VERSION = 13,
|
||||
UPDATE_DOCS_COMPLETE = 22,
|
||||
|
||||
TYPE_XMLANSWER_DOCS_CHANGED = 132,
|
||||
|
||||
HASH_READY = 150,
|
||||
CHANGE_DATA_VERSION = 151,
|
||||
@@ -53,7 +56,10 @@ enum PacketType{
|
||||
DELETE_DATA_VERSION = 153,
|
||||
BUSY = 154,
|
||||
FREE = 155,
|
||||
HASH_CALCULATE_START = 156
|
||||
RECALCULATE_HASH = 156,
|
||||
RECALCULATE_DOCS = 157,
|
||||
GET_DOCS = 158,
|
||||
SEND_HASH = 159
|
||||
|
||||
};
|
||||
|
||||
|
||||
105
Data/Client.h
Normal file
105
Data/Client.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QTcpSocket>
|
||||
|
||||
class Client
|
||||
{
|
||||
|
||||
public:
|
||||
Client():
|
||||
login(""),
|
||||
ready(false)
|
||||
{ };
|
||||
~Client(){};
|
||||
|
||||
public:
|
||||
QString getFullName()
|
||||
{
|
||||
return fullName;
|
||||
};
|
||||
|
||||
void setLogin(QString login)
|
||||
{
|
||||
this->login = login;
|
||||
isLoggedIn = true;
|
||||
fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
|
||||
}
|
||||
QString getLogin()
|
||||
{
|
||||
return login;
|
||||
}
|
||||
|
||||
QString getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
QString getPort()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
bool getReady()
|
||||
{
|
||||
return ready;
|
||||
}
|
||||
|
||||
void setReady(bool ready)
|
||||
{
|
||||
this->ready = ready;
|
||||
}
|
||||
|
||||
bool operator == (Client* right)
|
||||
{
|
||||
return this->address == right->address;
|
||||
}
|
||||
|
||||
bool getIsLoggedIn()
|
||||
{
|
||||
return isLoggedIn;
|
||||
}
|
||||
|
||||
void setIsLoggedIn(bool value)
|
||||
{
|
||||
isLoggedIn = value;
|
||||
}
|
||||
|
||||
QString getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(QString value)
|
||||
{
|
||||
id = value;
|
||||
}
|
||||
|
||||
QByteArray getClientHash()
|
||||
{
|
||||
return clientHash;
|
||||
}
|
||||
void setClientHash(const QByteArray &value)
|
||||
{
|
||||
clientHash = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QString name;
|
||||
QString address;
|
||||
QString port;
|
||||
QString fullName;
|
||||
QString id;
|
||||
|
||||
QString login;
|
||||
bool ready;
|
||||
bool isLoggedIn;
|
||||
QByteArray clientHash;
|
||||
|
||||
};
|
||||
|
||||
#endif // CLIENT_H
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
QString Language;
|
||||
QString LocalVersionName;
|
||||
StreamingVersionData versionData;
|
||||
bool isAutoStart;
|
||||
bool isAutoStart = false;
|
||||
bool mathModelUse;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
QT += core gui
|
||||
QT += network
|
||||
QT += xml
|
||||
QT += concurrent
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
@@ -19,6 +18,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += \
|
||||
Core/dataparseroutput.cpp \
|
||||
Core/fasthashcalculator.cpp \
|
||||
Core/notifycontroller.cpp \
|
||||
Core/postprocessorsystem.cpp \
|
||||
Core/sendsystem.cpp \
|
||||
@@ -46,6 +46,7 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
Core/dataparseroutput.h \
|
||||
Core/fasthashcalculator.h \
|
||||
Core/notifycontroller.h \
|
||||
Core/postprocessorsystem.h \
|
||||
Core/versioncontainer.h \
|
||||
@@ -58,6 +59,7 @@ HEADERS += \
|
||||
Core\tcpclient.h\
|
||||
Core\tools.h\
|
||||
Core\hashcomparer.h \
|
||||
Data/Client.h \
|
||||
Data/monitorInfo.h \
|
||||
Data/streamingversiondata.h \
|
||||
Data\FileData.h\
|
||||
@@ -85,6 +87,9 @@ FORMS += \
|
||||
TRANSLATIONS = QtLanguage_ru.ts\
|
||||
QtLanguage_eng.ts
|
||||
|
||||
#TEMPLATE = subdirs
|
||||
#SUBDIRS += Unit-tests\
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
|
||||
8935
StaticData/clientHash.xml
Normal file
8935
StaticData/clientHash.xml
Normal file
File diff suppressed because it is too large
Load Diff
2
StaticData/displayData.xml
Normal file
2
StaticData/displayData.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
<DisplayInfo DisplaysID="0;"/>
|
||||
8915
StaticData/serverHash.xml
Normal file
8915
StaticData/serverHash.xml
Normal file
File diff suppressed because it is too large
Load Diff
5
StaticData/settings.xml
Normal file
5
StaticData/settings.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ServerSettingsContainer>
|
||||
<ServerSettings Address="192.168.100.83" Port="6000" Language="RUS" AutoStart="0"/>
|
||||
<VersionData Version="base" isChangable="96"/>
|
||||
</ServerSettingsContainer>
|
||||
8730
StaticData/streamingHash.xml
Normal file
8730
StaticData/streamingHash.xml
Normal file
File diff suppressed because it is too large
Load Diff
2
StaticData/temp.xml
Normal file
2
StaticData/temp.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ClientNotify Code="DISABLE"/>
|
||||
@@ -26,7 +26,7 @@ void CommonButtonGroupWidget::updateProgressBar(float value)
|
||||
void CommonButtonGroupWidget::loadCompleteState()
|
||||
{
|
||||
show();
|
||||
ui->updateButton->setEnabled(false);
|
||||
ui->updateButton->hide();
|
||||
ui->startButton->setEnabled(true);
|
||||
ui->loadingProgressBar->setValue(100);
|
||||
ui->startButton->show();
|
||||
@@ -66,6 +66,8 @@ void CommonButtonGroupWidget::showProgressBar(bool flag)
|
||||
|
||||
void CommonButtonGroupWidget::needUpdateState(bool flag)
|
||||
{
|
||||
show();
|
||||
ui->loadingProgressBar->hide();
|
||||
ui->startButton->hide();
|
||||
ui->updateButton->setEnabled(flag);
|
||||
ui->updateButton->show();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "entrywidget.h"
|
||||
#include "ui_entrywidget.h"
|
||||
|
||||
#include <bits/functional_hash.h>
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
EntryWidget::EntryWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::EntryWidget)
|
||||
@@ -34,7 +38,9 @@ ClientAutorization* EntryWidget::getAuthData()
|
||||
QString username = ui->loginInputField->text();
|
||||
QString password = ui->passwordInputField->text();
|
||||
data->Login = username;
|
||||
data->Password = password;
|
||||
|
||||
QByteArray md5Hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
|
||||
data->Password = QString(md5Hash);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Core/tools.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
UpdateNotifyWidget::UpdateNotifyWidget(QWidget *) :
|
||||
ui(new Ui::UpdateNotifyWidget)
|
||||
@@ -37,15 +38,18 @@ void UpdateNotifyWidget::addToList(FileData fileData)
|
||||
void UpdateNotifyWidget::showTryChangeBase()
|
||||
{
|
||||
QString path = QDir::currentPath() + streamingAssetsPath;
|
||||
QString link = "<a href=\""+ path + "\"style=\"color:white;\">папку</a>";
|
||||
QString link = "<a href=\""+ path + "\"style=\"color:lightblue; text-decoration: underline;\">папку</a>";
|
||||
|
||||
ui->labelsLayout->addWidget(createLabel(tr("Данные изменения нельзя выгрузить на сервер, так как версия сервера не изменяема \n")));
|
||||
ui->labelsLayout->addWidget(createLabel(tr("Чтобы выгрузить на сервер нужно:")));
|
||||
ui->labelsLayout->addWidget(createLabel(tr("1. Скопировать измененные или созданные файлы в временную папку")));
|
||||
QLabel *labelStorage = new QLabel;
|
||||
QString link2 = "<a href=\""+ path + "\"style=\"color:white;\">тут</a>";
|
||||
QString link2 = "<a href=\""+ path + "\"style=\"color:lightblue; text-decoration: underline;\">тут</a>";
|
||||
labelStorage->setText(tr("Файлы можно найти в ") + link2);
|
||||
labelStorage->setTextFormat(Qt::RichText);
|
||||
labelStorage->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
labelStorage->setOpenExternalLinks(true);
|
||||
|
||||
ui->labelsLayout->addWidget(labelStorage);
|
||||
ui->labelsLayout->addWidget(createLabel(tr("2. Нажать Отменить изменения и дождатся окончания операции")));
|
||||
ui->labelsLayout->addWidget(createLabel(tr("3. Изменить версию сервера на изменяемую")));
|
||||
@@ -55,6 +59,8 @@ void UpdateNotifyWidget::showTryChangeBase()
|
||||
QLabel *linkLabel = new QLabel;
|
||||
linkLabel->setText(tr("5. Скопировать файлы из временной папки в эту ") + link);
|
||||
linkLabel->setOpenExternalLinks(true);
|
||||
linkLabel->setTextFormat(Qt::RichText);
|
||||
linkLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
|
||||
ui->labelsLayout->addWidget(linkLabel);
|
||||
ui->labelsLayout->addWidget(createLabel(tr("6.Перезапустить клиент и выгрузить изменения на сервер")));
|
||||
@@ -117,6 +123,11 @@ void UpdateNotifyWidget::on_startWithCurrentChangesButton_clicked()
|
||||
emit sigStartUnityClient();
|
||||
}
|
||||
|
||||
void UpdateNotifyWidget::closeWindow()
|
||||
{
|
||||
on_closeButton_clicked();
|
||||
}
|
||||
|
||||
void UpdateNotifyWidget::setUpdateState()
|
||||
{
|
||||
ui->undoChangesButton->show();
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
void showWithFill();
|
||||
void showTryChangeBase();
|
||||
void setVersionContainer(VersionContainer *versionContainer);
|
||||
void closeWindow();
|
||||
signals:
|
||||
void sigLoadToServerBehaviour();
|
||||
void sigUndoCurrentChanges();
|
||||
|
||||
@@ -4,7 +4,7 @@ CoreManager::CoreManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
isRecovery(false)
|
||||
{
|
||||
client = new TCPClient;
|
||||
tcpClient = new TCPClient;
|
||||
dataParser = new DataParser;
|
||||
dataParserOutput = new DataParserOutput;
|
||||
updateController = new UpdateController;
|
||||
@@ -16,6 +16,7 @@ CoreManager::CoreManager(QObject *parent) :
|
||||
versionContainer = new VersionContainer;
|
||||
resourceManager = new ResourceManager;
|
||||
postProcessorSystem = new PostProcessorSystem;
|
||||
client = new Client;
|
||||
}
|
||||
|
||||
void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
@@ -23,7 +24,7 @@ void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
this->workerThread = workerThread;
|
||||
this->widgetManager = widgetManager;
|
||||
|
||||
client->moveToThread(workerThread);
|
||||
tcpClient->moveToThread(workerThread);
|
||||
dataParser->moveToThread(workerThread);
|
||||
dataParserOutput->moveToThread(workerThread);
|
||||
sendSystem->moveToThread(workerThread);
|
||||
@@ -31,11 +32,8 @@ void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
recognizeSystem->moveToThread(workerThread);
|
||||
postProcessorSystem->moveToThread(workerThread);
|
||||
hashComparer->moveToThread(workerThread);
|
||||
// versionContainer->moveToThread(workerThread); //проверить работоспособность
|
||||
// resourceManager->moveToThread(workerThread); //проверить работоспособность
|
||||
|
||||
workerThread->start();
|
||||
//workerThread->setPriority(QThread::HighestPriority);
|
||||
|
||||
binding();
|
||||
initializeSystems();
|
||||
@@ -46,6 +44,7 @@ void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
|
||||
|
||||
void CoreManager::start()
|
||||
{
|
||||
saveServerSettingsWithConnect();
|
||||
checkAppAvailable();
|
||||
}
|
||||
|
||||
@@ -64,14 +63,15 @@ void CoreManager::binding()
|
||||
{
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnimationActivated,widgetManager,&WidgetManager::slotActivateLoadAnimation,Qt::AutoConnection);
|
||||
|
||||
connect(this,&CoreManager::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendCommand,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigInitializeClient,tcpClient,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSetConnect,tcpClient,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendCheckUpdate,sendSystem,&SendSystem::sendCheckHash,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
|
||||
connect(this,&CoreManager::sigSendUpdateToServer,updateController,&UpdateController::checkCanUpdate,Qt::AutoConnection);
|
||||
connect(this,&CoreManager::sigGetConnected,client,&TCPClient::getIsConnected);
|
||||
connect(this,&CoreManager::sigGetConnected,tcpClient,&TCPClient::getIsConnected);
|
||||
connect(this,&CoreManager::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
|
||||
|
||||
connect(this,&CoreManager::sigSetLoadSettings,widgetManager,&WidgetManager::slotSetLoadSettings,Qt::AutoConnection);
|
||||
@@ -79,7 +79,7 @@ void CoreManager::binding()
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigCallUpdateList,this,&CoreManager::callUpdateList,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigSocketDisabled,this,&CoreManager::lostConnection,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigServerBlocked,this,&CoreManager::serverBlocked,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas,Qt::AutoConnection); // ОПАСНОСТЬ
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigSaveLoginData,this,&CoreManager::checkLoginResult,Qt::AutoConnection);
|
||||
|
||||
connect(versionContainer,&VersionContainer::sigSetServerVersion,this,&CoreManager::setServerVersion,Qt::AutoConnection);
|
||||
@@ -89,19 +89,23 @@ void CoreManager::binding()
|
||||
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&CoreManager::checkNeedUpdate,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigCheckUpdate,this,&CoreManager::checkUpdate,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigdRecalculateHashOnServerState,this,&CoreManager::recalculateState,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSendPacketType,this,&CoreManager::sendPacketType,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSendPacketTypeWithDelay,sendSystem,&SendSystem::sendPacketTypeWithDelay,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSendToInlineLog,this,&CoreManager::setInlineDebug,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigCallUpdateList,this,&CoreManager::callUpdateList,Qt::AutoConnection);
|
||||
|
||||
connect(hashComparer,&HashComparer::sigCallCheck,this,&CoreManager::checkUpdate);
|
||||
connect(hashComparer,&HashComparer::sigHaveDelta,this,&CoreManager::checkUpdateInfo);
|
||||
|
||||
connect(updateController,&UpdateController::sigUpdateComplete,widgetManager,&WidgetManager::setCompeteState,Qt::AutoConnection);//ОПАСНОСТЬ
|
||||
connect(updateController,&UpdateController::sigSendHashInfo,widgetManager->getMainWindow(),&MainWindow::updateInitInformation,Qt::AutoConnection);
|
||||
connect(updateController,&UpdateController::sigUpdateComplete,widgetManager,&WidgetManager::setCompeteState,Qt::AutoConnection);
|
||||
connect(updateController->getHashCalculator(),&FastHashCalculator::sigSendHashInfo,widgetManager->getMainWindow(),&MainWindow::updateInitInformation,Qt::AutoConnection);
|
||||
|
||||
connect(client,&TCPClient::sigConnectionState,widgetManager,&WidgetManager::setConnectionState,Qt::AutoConnection);//ОПАСНОСТЬ
|
||||
connect(client,&TCPClient::sigServerDisconnect,widgetManager,&WidgetManager::setServerDisconnectState,Qt::AutoConnection);//ОПАСНОСТЬ
|
||||
connect(tcpClient,&TCPClient::sigConnectionState,widgetManager,&WidgetManager::setConnectionState,Qt::AutoConnection);
|
||||
connect(tcpClient,&TCPClient::sigServerDisconnect,widgetManager,&WidgetManager::setServerDisconnectState,Qt::AutoConnection);
|
||||
|
||||
connect(sendSystem,&SendSystem::sigSend,this,&CoreManager::calcUpdateProgress,Qt::AutoConnection);
|
||||
|
||||
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParserOutput,&DataParserOutput::xmlAnswer_notify,Qt::DirectConnection);//ОПАСНОСТЬ
|
||||
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParserOutput,&DataParserOutput::xmlAnswer_notify,Qt::DirectConnection);
|
||||
}
|
||||
|
||||
void CoreManager::initializeSystems()
|
||||
@@ -111,7 +115,7 @@ void CoreManager::initializeSystems()
|
||||
hashComparer->initialize(versionContainer,widgetManager->getUpdateWidget());
|
||||
postProcessorSystem->initialize(dataParserOutput,hashComparer,versionContainer,updateController);
|
||||
dataParser->initialize(postProcessorSystem);
|
||||
recognizeSystem->initialize(dataParser,versionContainer,postProcessorSystem);
|
||||
recognizeSystem->initialize(dataParser,versionContainer,postProcessorSystem,client);
|
||||
resourceManager->painting();
|
||||
|
||||
emit sigCalculateHash();
|
||||
@@ -163,6 +167,7 @@ void CoreManager::callUpdateList()
|
||||
void CoreManager::lostConnection()
|
||||
{
|
||||
widgetManager->setLostConnectionState();
|
||||
client->setIsLoggedIn(false);
|
||||
}
|
||||
|
||||
void CoreManager::serverBlocked()
|
||||
@@ -183,6 +188,7 @@ void CoreManager::setLocalVersion()
|
||||
version->setIsChangeable(currentSettings->versionData.getIsChangeable());
|
||||
|
||||
versionContainer->setLocalVersionData(version);
|
||||
widgetManager->getMainWindow()->setClientVersionName(versionContainer->getLocalVersion());
|
||||
}
|
||||
|
||||
void CoreManager::checkLoginResult(ServerAuthorization *auth)
|
||||
@@ -195,16 +201,19 @@ void CoreManager::checkLoginResult(ServerAuthorization *auth)
|
||||
setLocalVersion();
|
||||
widgetManager->setLoginSuccess();
|
||||
widgetManager->getMainWindow()->setClientVersionName(versionContainer->getLocalVersion());
|
||||
client->setLogin(auth->ClientName);
|
||||
client->setIsLoggedIn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
widgetManager->setLoginFailed();
|
||||
client->setIsLoggedIn(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreManager::tryLogin()
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
if (!tcpClient->getIsConnected())
|
||||
{
|
||||
widgetManager->getMainWindow()->showConnectionEmpty();
|
||||
return;
|
||||
@@ -220,13 +229,18 @@ void CoreManager::checkUpdate()
|
||||
{
|
||||
widgetManager->activateLoadingAnimation(true);
|
||||
emit sigSendCheckUpdate();
|
||||
widgetManager->getMainWindow()->setInlineDebug(tr("Проверка обновлений..."));
|
||||
setInlineDebug(tr("Проверка обновлений..."));
|
||||
}
|
||||
|
||||
void CoreManager::recalculateState()
|
||||
{
|
||||
widgetManager->activateLoadingAnimation(true);
|
||||
widgetManager->getMainWindow()->setInlineDebug(tr("Пересчет хэша на сервере..."));
|
||||
setInlineDebug(tr("Пересчет хэша на сервере..."));
|
||||
}
|
||||
|
||||
void CoreManager::setInlineDebug(QString text)
|
||||
{
|
||||
widgetManager->getMainWindow()->setInlineDebug(text);
|
||||
}
|
||||
|
||||
void CoreManager::checkAccessType(const QString& accessType)
|
||||
@@ -322,11 +336,9 @@ void CoreManager::undoCurrentChanges()
|
||||
isRecovery = true;
|
||||
widgetManager->setUndoCurrentChangesState();
|
||||
emit sigSendCheckUpdate();
|
||||
emit sigSendCommand(PacketType::TYPE_UPDATE);
|
||||
emit sigSendPacketType(PacketType::TYPE_UPDATE);
|
||||
//тут был таймер
|
||||
isRecovery = false;
|
||||
|
||||
widgetManager->activateLoadingAnimation(false);
|
||||
}
|
||||
|
||||
void CoreManager::startOffline()
|
||||
@@ -338,6 +350,11 @@ void CoreManager::startOffline()
|
||||
startUnityClient();
|
||||
}
|
||||
|
||||
void CoreManager::sendPacketType(PacketType packetType)
|
||||
{
|
||||
emit sigSendPacketType(packetType);
|
||||
}
|
||||
|
||||
void CoreManager::saveServerSettingsWithConnect()
|
||||
{
|
||||
widgetManager->activateLoadingAnimation(true);
|
||||
@@ -348,17 +365,17 @@ void CoreManager::saveServerSettingsWithConnect()
|
||||
settings->LocalVersionName = dataParser->getClientSettings()->LocalVersionName;
|
||||
dataParserOutput->createServerSettings(settings);
|
||||
|
||||
if(client->getIsConnected())
|
||||
if(tcpClient->getIsConnected())
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
tcpClient->setDisconnect();
|
||||
entryWidget->showLoginWidget(true);
|
||||
widgetManager->getMainWindow()->showOfflineButton(true);
|
||||
widgetManager->activateLoadingAnimation(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
emit sigSetConnect(settings);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreManager::checkAppAvailable()
|
||||
{
|
||||
@@ -384,7 +401,7 @@ void CoreManager::setLanguage(const QString& language)
|
||||
void CoreManager::exit()
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
client->disconnect();
|
||||
tcpClient->disconnect();
|
||||
|
||||
workerThread->quit();
|
||||
workerThread->wait();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Core/hashcomparer.h>
|
||||
#include <Core/versioncontainer.h>
|
||||
#include <widgetmanager.h>
|
||||
#include <Data/Client.h>
|
||||
|
||||
#include <UI/resourcemanager.h>
|
||||
|
||||
@@ -39,6 +40,7 @@ public:
|
||||
void startUnityClient();
|
||||
void tryLogin();
|
||||
void startOffline();
|
||||
void sendPacketType(PacketType packetType);
|
||||
|
||||
void saveServerSettingsWithConnect();
|
||||
|
||||
@@ -50,7 +52,7 @@ public:
|
||||
void recalculateState();
|
||||
signals:
|
||||
void sigInitializeClient(RecognizeSystem *recognize,SendSystem *sendSystem);
|
||||
void sigSendCommand(PacketType packetType);
|
||||
void sigSendPacketType(PacketType packetType);
|
||||
void sigSendXMLAnswer(QString answer);
|
||||
void sigSetConnect(ServerSettings* serverSettings);
|
||||
void sigCalculateHash();
|
||||
@@ -59,11 +61,12 @@ signals:
|
||||
bool sigGetConnected();
|
||||
void sigSendUpdateToServer();
|
||||
|
||||
|
||||
void sigSetLoadSettings(ServerSettings *serverSettings);
|
||||
|
||||
private:
|
||||
QTranslator translator;
|
||||
TCPClient *client;
|
||||
TCPClient *tcpClient;
|
||||
DataParser *dataParser;
|
||||
DataParserOutput *dataParserOutput;
|
||||
UpdateController *updateController;
|
||||
@@ -75,6 +78,7 @@ private:
|
||||
VersionContainer *versionContainer;
|
||||
ResourceManager *resourceManager;
|
||||
PostProcessorSystem *postProcessorSystem;
|
||||
Client *client;
|
||||
|
||||
WidgetManager *widgetManager;
|
||||
|
||||
@@ -101,6 +105,7 @@ private:
|
||||
void checkNeedUpdate(bool flag, quint64 size, quint64 fileCount, quint64 deleteCount);
|
||||
void checkUpdate();
|
||||
|
||||
void setInlineDebug(QString text);
|
||||
};
|
||||
|
||||
#endif // COREMANAGER_H
|
||||
|
||||
2
mathModelConfig.xml
Normal file
2
mathModelConfig.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MathModelSettings SendIP="10.100.7.255" SendPortMath="18004" ListenIP="10.100.7.9" LocalPortMath="18003" />
|
||||
2
path.txt
Normal file
2
path.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
D:/QT/Projects/RRJClient/path.txt
|
||||
D:/QT/Projects/RRJClient/Application/RRJLoader/RRJ_Data/StreamingAssets
|
||||
@@ -106,6 +106,7 @@ void WidgetManager::setNeedUpdateState(quint64 size, quint64 fileCount,quint64 d
|
||||
result = tr("Файлов к удалению: ") + QString::number(deleteCount);
|
||||
}
|
||||
|
||||
updateWidget->closeWindow();
|
||||
mainWindow->setNeedUpdateState(result);
|
||||
commonButtonGroupWidget->needUpdateState(true);
|
||||
waitAnimationWidget->hideWithStop();
|
||||
@@ -157,10 +158,11 @@ void WidgetManager::setServerDisconnectState()
|
||||
|
||||
void WidgetManager::setUndoCurrentChangesState()
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
mainWindow->undoCurrentChanges();
|
||||
updateWidget->hide();
|
||||
commonButtonGroupWidget->showProgressBar(false);
|
||||
waitAnimationWidget->showWithPlay();
|
||||
//waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void WidgetManager::showMainFrame(bool flag)
|
||||
|
||||
Reference in New Issue
Block a user