mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: change version
This commit is contained in:
@@ -107,6 +107,12 @@ QList<FileData> UpdateController::calculateHash(QString path,QString ignoreName)
|
||||
return *hashes;
|
||||
}
|
||||
|
||||
void UpdateController::checkCanUpdate()
|
||||
{
|
||||
QByteArray checkUpdate = dataParser->xmlAnswer_notify("CANCHANGE");
|
||||
sendSystem->sendXMLAnswer(checkUpdate);
|
||||
}
|
||||
|
||||
void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
|
||||
QListIterator<FileData> serverIterator(*fileSendList);
|
||||
@@ -122,7 +128,7 @@ void UpdateController::updateFilesOnServer(QList<FileData> *fileSendList){
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fullPath = Tools::createReceiveFullPath(data.path,versionContainer->getLocalVersionData());
|
||||
QString fullPath = Tools::createReceiveFullPath(data.path,versionContainer->getServerVersionData());
|
||||
sendSystem->sendFileBlockWithVersion(fullPath,data.path);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
|
||||
void updateFilesOnServer(QList<FileData> *fileSendList);
|
||||
|
||||
void checkCanUpdate();
|
||||
signals:
|
||||
void sigUpdateComplete(bool flag);
|
||||
private:
|
||||
|
||||
@@ -8,11 +8,17 @@ DataParser::DataParser(QObject *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
void DataParser::initialize(RecognizeSystem *recognizeSystem,NotifyController *notifyController)
|
||||
void DataParser::initialize(RecognizeSystem *recognizeSystem,
|
||||
NotifyController *notifyController,
|
||||
UpdateController *updateController,
|
||||
HashComparer *hashComparer)
|
||||
{
|
||||
this->recognizeSystem = recognizeSystem;
|
||||
this->notifyController = notifyController;
|
||||
this->hashComparer = hashComparer;
|
||||
|
||||
connect(this,&DataParser::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection);
|
||||
connect(this,&DataParser::sigUpdateFilesOnServer,updateController,&UpdateController::updateFilesOnServer,Qt::AutoConnection);
|
||||
}
|
||||
|
||||
void DataParser::createFileDataList(QList<FileData> fileDataList,QString filename)
|
||||
@@ -428,6 +434,17 @@ void DataParser::xmlParser(QByteArray array)
|
||||
{
|
||||
emit sigNotify(tr("Такое имя уже существет"));
|
||||
}
|
||||
|
||||
if (value == "UNCHANGEABLE")
|
||||
{
|
||||
emit sigNotify(tr("Нельзя выгружать в базовую версию"));
|
||||
emit recognizeSystem->sigShowUpdateList();
|
||||
}
|
||||
|
||||
if (value == "CHANGEABLE")
|
||||
{
|
||||
emit sigUpdateFilesOnServer(hashComparer->getFilesForUpdate());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,16 +487,21 @@ void DataParser::xmlParser(QByteArray array)
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Version")
|
||||
if (name == "Version")
|
||||
{
|
||||
serverVersion->setName(value);
|
||||
}
|
||||
|
||||
if(name == "Created")
|
||||
if (name == "Created")
|
||||
{
|
||||
serverVersion->setCreateData(QDateTime::fromString(value));
|
||||
}
|
||||
|
||||
if (name == "isChangeable")
|
||||
{
|
||||
serverVersion->setIsChangeable(value.toInt());
|
||||
}
|
||||
|
||||
}
|
||||
recognizeSystem->setServerVersion(serverVersion);
|
||||
}
|
||||
@@ -506,6 +528,10 @@ void DataParser::xmlParser(QByteArray array)
|
||||
data->setName(value);
|
||||
else if(name == "Created")
|
||||
data->setCreateData(QDateTime::fromString(value));
|
||||
else if(name == "isChangeable")
|
||||
{
|
||||
data->setIsChangeable(value.toInt());
|
||||
}
|
||||
}
|
||||
|
||||
serverStreamingVersionDataList->append(data);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
class RecognizeSystem;
|
||||
class NotifyController;
|
||||
class UpdateController;
|
||||
class HashComparer;
|
||||
|
||||
class DataParser : public QObject
|
||||
{
|
||||
@@ -23,7 +25,11 @@ class DataParser : public QObject
|
||||
|
||||
public:
|
||||
explicit DataParser(QObject *parent = 0);
|
||||
void initialize(RecognizeSystem *recognizeSystem,NotifyController *notifyController);
|
||||
void initialize(RecognizeSystem *recognizeSystem,
|
||||
NotifyController *notifyController,
|
||||
UpdateController *updateController,
|
||||
HashComparer *hashComparer);
|
||||
|
||||
~DataParser();
|
||||
ServerSettings* getServerSettings();
|
||||
void createServerSettings(ServerSettings* serverSettings);
|
||||
@@ -41,6 +47,7 @@ public:
|
||||
|
||||
signals:
|
||||
void sigNotify(QString notify);
|
||||
void sigUpdateFilesOnServer(QList<FileData> *fileSendList);
|
||||
public slots:
|
||||
QByteArray xmlAnswer_notify(QString code);
|
||||
|
||||
@@ -51,6 +58,7 @@ private:
|
||||
ClientAutorization *authPassCache;
|
||||
RecognizeSystem *recognizeSystem;
|
||||
NotifyController *notifyController;
|
||||
HashComparer *hashComparer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,
|
||||
connect(this,&RecognizeSystem::sigServerBlocked,mainWindow,&MainWindow::serverBlocked);
|
||||
connect(this,&RecognizeSystem::sigShowServerList,mainWindow,&MainWindow::showServerListWidget);
|
||||
connect(this,&RecognizeSystem::sigAnimationActivated,mainWindow,&MainWindow::activateLoadingAnimation,Qt::AutoConnection);
|
||||
connect(this,&RecognizeSystem::sigShowUpdateList,mainWindow,&MainWindow::showUpdateInfo,Qt::AutoConnection);
|
||||
}
|
||||
|
||||
void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
|
||||
@@ -48,6 +48,7 @@ signals:
|
||||
void sigStartCompare();
|
||||
void sigShowServerList(QList<StreamingVersionData*> *serverDatas);
|
||||
void sigAnimationActivated(bool flag);
|
||||
void sigShowUpdateList();
|
||||
|
||||
private:
|
||||
QList<QString> *folderList;
|
||||
|
||||
@@ -71,7 +71,7 @@ void SendSystem::sendFileBlock(QString path)
|
||||
while(!file.atEnd()){
|
||||
QByteArray data = file.read(1025*250);
|
||||
stream << data;
|
||||
socket->waitForBytesWritten();
|
||||
socket->waitForBytesWritten(20);
|
||||
countSend++;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath)
|
||||
while(!file.atEnd()){
|
||||
QByteArray data = file.read(1025*250);
|
||||
stream << data;
|
||||
socket->waitForBytesWritten();
|
||||
socket->waitForBytesWritten(10);
|
||||
countSend++;
|
||||
}
|
||||
|
||||
@@ -217,16 +217,6 @@ void SendSystem::sendCheckHash()
|
||||
|
||||
socket->waitForReadyRead(2000);
|
||||
stream << PacketType::TYPE_CHECK_VERSION;
|
||||
//socket->waitForReadyRead(1000);
|
||||
|
||||
// else if(command == "update")
|
||||
// {
|
||||
// qDebug() << ("Update started");
|
||||
// stream << PacketType::TYPE_COMMAND;
|
||||
// stream << command;
|
||||
// socket->waitForReadyRead(1000);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
SendSystem::~SendSystem()
|
||||
|
||||
Reference in New Issue
Block a user