mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
ref: link argument
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
#include "sendsystem.h"
|
||||
|
||||
SendSystem::SendSystem(QObject *) {}
|
||||
SendSystem::SendSystem(QObject *parent) :
|
||||
QObject(parent),
|
||||
socket(nullptr),
|
||||
readSize(1025*250){}
|
||||
|
||||
void SendSystem::setSocket(QTcpSocket *socket)
|
||||
{
|
||||
this->socket = socket;
|
||||
}
|
||||
|
||||
void SendSystem::xmlAnswer(QString message)
|
||||
void SendSystem::xmlAnswer(const QString& message)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -40,7 +43,7 @@ void SendSystem::sendClientAutorization()
|
||||
file.close();
|
||||
}
|
||||
|
||||
void SendSystem::sendFileBlock(QString path)
|
||||
void SendSystem::sendFileBlock(const QString& path)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -62,7 +65,7 @@ void SendSystem::sendFileBlock(QString path)
|
||||
|
||||
if(file.open(QFile::ReadOnly)){
|
||||
while(!file.atEnd()){
|
||||
QByteArray data = file.read(1025*250);
|
||||
QByteArray data = file.read(readSize);
|
||||
stream << data;
|
||||
socket->waitForBytesWritten(20);
|
||||
countSend++;
|
||||
@@ -74,13 +77,11 @@ void SendSystem::sendFileBlock(QString path)
|
||||
file.close();
|
||||
|
||||
emit sigSend();
|
||||
//qDebug() << "Transaction after send file: " << socket->isTransactionStarted();
|
||||
countSend = 0;
|
||||
//socket->waitForBytesWritten();
|
||||
socket->waitForReadyRead(20);
|
||||
}
|
||||
|
||||
void SendSystem::sendFolderBlock(QString path)
|
||||
void SendSystem::sendFolderBlock(const QString& path)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -91,11 +92,10 @@ void SendSystem::sendFolderBlock(QString path)
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath)
|
||||
void SendSystem::sendFileBlockWithVersion(const QString& localPath,const QString& serverPath)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
//QString fullPath = Tools::createLocalPath(localPath);
|
||||
quint64 fileSize = 0;
|
||||
int countSend = 0;
|
||||
|
||||
@@ -109,11 +109,10 @@ void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath)
|
||||
stream << serverPath << fileSize;
|
||||
|
||||
socket->waitForReadyRead(20);
|
||||
//socket->waitForBytesWritten();
|
||||
|
||||
if(file.open(QFile::ReadOnly)){
|
||||
while(!file.atEnd()){
|
||||
QByteArray data = file.read(1025*250);
|
||||
QByteArray data = file.read(readSize);
|
||||
stream << data;
|
||||
socket->waitForBytesWritten(10);
|
||||
countSend++;
|
||||
@@ -133,8 +132,7 @@ void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath)
|
||||
|
||||
void SendSystem::sendQTConnect()
|
||||
{
|
||||
//QString value = QString::number(PacketType::TYPE_QT);
|
||||
QByteArray container;
|
||||
QByteArray container; //TODO найти более компактное решение
|
||||
int numPackage = (int)PacketType::TYPE_QT;
|
||||
container.append(numPackage & 0x000000ff);
|
||||
container.append((numPackage >> 8) & 0x000000ff);
|
||||
@@ -145,7 +143,7 @@ void SendSystem::sendQTConnect()
|
||||
socket->waitForBytesWritten();
|
||||
}
|
||||
|
||||
void SendSystem::sendXMLAnswer(QByteArray array)
|
||||
void SendSystem::sendXMLAnswer(const QByteArray& array)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
@@ -189,19 +187,18 @@ void SendSystem::sendDeleteVersion(StreamingVersionData *streamingVersion)
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendCopyVersion(QString streamingVersion)
|
||||
void SendSystem::sendCopyVersion(const QString& versionName)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
stream << PacketType::COPY_VERSION;
|
||||
|
||||
stream << streamingVersion;
|
||||
stream << versionName;
|
||||
}
|
||||
|
||||
void SendSystem::sendPacketType(PacketType packetType)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
QByteArray data;
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
stream << packetType;
|
||||
@@ -210,7 +207,6 @@ void SendSystem::sendPacketType(PacketType packetType)
|
||||
void SendSystem::sendCheckHash()
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
QByteArray data;
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
|
||||
sendFileBlock(staticDataFolderName + hashFilename);
|
||||
@@ -218,8 +214,3 @@ void SendSystem::sendCheckHash()
|
||||
socket->waitForReadyRead(2000);
|
||||
stream << PacketType::TYPE_CHECK_VERSION;
|
||||
}
|
||||
|
||||
SendSystem::~SendSystem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user