mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: loading base version
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "UpdateController.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
UpdateController::UpdateController(DataParser *parser,SendSystem *sendSystem, QObject *parent) :
|
||||
@@ -26,6 +25,11 @@ void UpdateController::calculateStreamingHash()
|
||||
dataParser->createFileDataList(appDataList,streamingHashFilename);
|
||||
}
|
||||
|
||||
void UpdateController::setServerVersion(StreamingVersionData *version)
|
||||
{
|
||||
serverVersion = version;
|
||||
}
|
||||
|
||||
QList<FileData> UpdateController::calculateHash(QString path)
|
||||
{
|
||||
qDebug() << "Try calculate";
|
||||
@@ -122,6 +126,11 @@ void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
|
||||
}
|
||||
|
||||
StreamingVersionData *UpdateController::getServerVersion() const
|
||||
{
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
|
||||
UpdateController::~UpdateController()
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Core\FileData.h"
|
||||
#include "Core\dataparser.h"
|
||||
#include "Core\tcpclient.h"
|
||||
#include "streamingversiondata.h"
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamAttribute>
|
||||
@@ -29,10 +30,13 @@ public:
|
||||
|
||||
void calculateCommonHash();
|
||||
void calculateStreamingHash();
|
||||
void setServerVersion(StreamingVersionData *version);
|
||||
~UpdateController();
|
||||
|
||||
void updateFilesOnServer(QList<FileData> *fileSendList);
|
||||
|
||||
StreamingVersionData *getServerVersion() const;
|
||||
|
||||
signals:
|
||||
void sigUpdateComplete(bool flag);
|
||||
private:
|
||||
@@ -41,6 +45,7 @@ private:
|
||||
QString applicationFolderPath;
|
||||
QList<FileData> appDataList;
|
||||
QList<FileData> streamingDataList;
|
||||
StreamingVersionData *serverVersion;
|
||||
|
||||
QList<FileData> calculateHash(QString path);
|
||||
};
|
||||
|
||||
@@ -13,14 +13,6 @@ DataParser::DataParser(QObject *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray DataParser::slotGetXmlAnswer(QString answerCode)
|
||||
{
|
||||
if(answerCode == "END"){
|
||||
return xmlAnswer_notify(answerCode);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DataParser::createFileDataList(QList<FileData> fileDataList,QString filename)
|
||||
{
|
||||
|
||||
|
||||
@@ -23,13 +23,12 @@ public:
|
||||
void createAuthMessage(ClientAutorization *auth);
|
||||
void createAuthData(ServerAuthorization *serverAuth);
|
||||
void createAuthDataOffline(QString username,QString pass);
|
||||
void addRunData(QList<int> displays);
|
||||
QByteArray xmlAnswer_notify(QString code);
|
||||
void addRunData(QList<int> displays);
|
||||
QByteArray xmlAnswer(QList<SXmlAnswerTag> listTag, QString elemUp1 = "", QString elemUp2 = "");
|
||||
|
||||
QList<FileData>* xmlFileDataParse(QByteArray array,QString filter);
|
||||
|
||||
public slots:
|
||||
QByteArray slotGetXmlAnswer(QString);
|
||||
QByteArray xmlAnswer_notify(QString code);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Core/recognizesystem.h"
|
||||
|
||||
#include "streamingversiondata.h"
|
||||
|
||||
#include <updatenotifywidget.h>
|
||||
|
||||
RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||
@@ -80,7 +82,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
continue;
|
||||
}
|
||||
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
filePath = Tools::createReceiveFullPath(filePath,updateController->getServerVersion());
|
||||
|
||||
QDir dir(filePath);
|
||||
if(!dir.exists()){
|
||||
@@ -115,7 +117,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
}
|
||||
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
filePath = Tools::createReceiveFullPath(filePath,updateController->getServerVersion());
|
||||
|
||||
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
emit sigSendDebugLog("CLIENT: filePath: " + filePath);
|
||||
@@ -198,7 +200,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
continue;
|
||||
}
|
||||
|
||||
filePath = Tools::createFullPath(filePath);
|
||||
filePath = Tools::createReceiveFullPath(filePath,updateController->getServerVersion());
|
||||
|
||||
QFileInfo fileInfo(filePath);
|
||||
|
||||
@@ -337,6 +339,28 @@ void RecognizeSystem::xmlParser(QByteArray array)
|
||||
emit sigSaveLoginData(serverAuth);
|
||||
}
|
||||
|
||||
if(xmlReader.name() == "VersionData")
|
||||
{
|
||||
StreamingVersionData *serverVersion = new StreamingVersionData;
|
||||
foreach(const QXmlStreamAttribute &attr,xmlReader.attributes())
|
||||
{
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Version")
|
||||
{
|
||||
serverVersion->setName(value);
|
||||
}
|
||||
|
||||
if(name == "Created")
|
||||
{
|
||||
serverVersion->setCreateData(QDateTime::fromString(value));
|
||||
}
|
||||
|
||||
}
|
||||
updateController->setServerVersion(serverVersion);
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,24 @@ SendSystem::SendSystem(QObject *)
|
||||
|
||||
}
|
||||
|
||||
void SendSystem::initialize(MainWindow *mainWindow,DataParser *dataParser)
|
||||
{
|
||||
connect(this,&SendSystem::sigSend,mainWindow,&MainWindow::updateProgress);
|
||||
connect(this,&SendSystem::sigGetXmlAnswer,dataParser,&DataParser::xmlAnswer_notify,Qt::DirectConnection); //МОЖЕТ ДАТУ ПАРСЕР В ВТОРОСТЕПЕННЫЙ ПОТОК?
|
||||
}
|
||||
|
||||
void SendSystem::setSocket(QTcpSocket *socket)
|
||||
{
|
||||
this->socket = socket;
|
||||
}
|
||||
|
||||
|
||||
void SendSystem:: sendDisable()
|
||||
void SendSystem::xmlAnswer(QString message)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
QByteArray data;
|
||||
data = emit sigGetXmlAnswer("DISABLE");
|
||||
data = emit sigGetXmlAnswer(message);
|
||||
|
||||
stream << PacketType::TYPE_XMLANSWER;
|
||||
stream << data;
|
||||
@@ -52,7 +57,7 @@ void SendSystem::sendFileBlock(QString path)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
QString fullPath = Tools::createFullPath(path);
|
||||
QString fullPath = Tools::createSendFullPath(path);
|
||||
quint64 fileSize = 0;
|
||||
int countSend = 0;
|
||||
|
||||
|
||||
@@ -4,12 +4,17 @@
|
||||
#include <QObject>
|
||||
#include <QTcpSocket>
|
||||
#include <QDataStream>
|
||||
#include <mainwindow.h>
|
||||
|
||||
class MainWindow;
|
||||
class DataParser;
|
||||
|
||||
class SendSystem :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SendSystem(QObject* parent = nullptr);
|
||||
void initialize(MainWindow *mainWindow,DataParser *dataParser);
|
||||
void setSocket(QTcpSocket *socket);
|
||||
void sendClientAutorization();
|
||||
void sendDisable();
|
||||
@@ -17,14 +22,19 @@ public:
|
||||
void sendFolderBlock(QString path);
|
||||
void sendQTConnect();
|
||||
void sendXMLAnswer(QByteArray array);
|
||||
~SendSystem();
|
||||
void sendFinish();
|
||||
|
||||
~SendSystem();
|
||||
|
||||
signals:
|
||||
void sigSend();
|
||||
QByteArray sigGetXmlAnswer(QString);
|
||||
|
||||
public slots:
|
||||
void xmlAnswer(QString message);
|
||||
private:
|
||||
QTcpSocket *socket;
|
||||
|
||||
};
|
||||
|
||||
#endif // SENDSYSTEM_H
|
||||
|
||||
60
Core/streamingversiondata.h
Normal file
60
Core/streamingversiondata.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef STREAMINGVERSIONDATA_H
|
||||
#define STREAMINGVERSIONDATA_H
|
||||
|
||||
#include <QObject>
|
||||
#include <qdatetime.h>
|
||||
|
||||
class StreamingVersionData
|
||||
{
|
||||
public:
|
||||
|
||||
StreamingVersionData(){}
|
||||
|
||||
StreamingVersionData(QString absoltePath,QString viewName,QDateTime data,qint32 size)
|
||||
{
|
||||
this->absolutePath = absoltePath;
|
||||
this->viewName = viewName;
|
||||
this->createData = data;
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
void setName(QString viewName)
|
||||
{
|
||||
this->viewName = viewName;
|
||||
}
|
||||
|
||||
void setCreateData(QDateTime data)
|
||||
{
|
||||
this->createData = data;
|
||||
}
|
||||
|
||||
~StreamingVersionData();
|
||||
|
||||
QString getAbsolutPath() const
|
||||
{
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
QString getViewName() const
|
||||
{
|
||||
return viewName;
|
||||
}
|
||||
|
||||
QDateTime getCreateData() const
|
||||
{
|
||||
return createData;
|
||||
}
|
||||
|
||||
qint32 getSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
private:
|
||||
QString absolutePath;
|
||||
QString viewName;
|
||||
QDateTime createData;
|
||||
qint32 size;
|
||||
};
|
||||
|
||||
#endif // STREAMINGVERSIONDATA_H
|
||||
@@ -24,7 +24,31 @@ QString Tools::createLocalPath(QString path)
|
||||
return localPath;
|
||||
}
|
||||
|
||||
QString Tools::createFullPath(QString path)
|
||||
QString Tools::createReceiveFullPath(QString path, StreamingVersionData *version)
|
||||
{
|
||||
QString fullPath;
|
||||
QString localPath;
|
||||
qint8 pos = path.indexOf("Application");
|
||||
|
||||
if(pos == -1)
|
||||
{
|
||||
pos = path.indexOf(version->getViewName());
|
||||
localPath = path.remove(0,pos + version->getViewName().length());
|
||||
localPath.prepend(streamingAssetsPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
localPath = path.remove(0,--pos);
|
||||
}
|
||||
|
||||
fullPath = QDir::currentPath() + localPath;
|
||||
qDebug() << "CLIENT: localPath" << localPath;
|
||||
|
||||
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
QString Tools::createSendFullPath(QString path)
|
||||
{
|
||||
QString fullPath;
|
||||
qint8 pos = path.indexOf("Application");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include "streamingversiondata.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
@@ -39,7 +41,8 @@ public:
|
||||
static void printTime();
|
||||
static QString getTime();
|
||||
static QString createLocalPath(QString path);
|
||||
static QString createFullPath(QString path);
|
||||
static QString createSendFullPath(QString path);
|
||||
static QString createReceiveFullPath(QString path,StreamingVersionData *version);
|
||||
static QString convertFileSize(quint64 fileSize);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user