fix: xp support code ver trans bug.
This commit is contained in:
@@ -8,15 +8,12 @@
|
|||||||
#include <LocalFile.h>
|
#include <LocalFile.h>
|
||||||
#include <Protocol.h>
|
#include <Protocol.h>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QFuture>
|
|
||||||
#include <QFutureWatcher>
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
class ClientCore : public QObject
|
class ClientCore : public QObject
|
||||||
|
|||||||
@@ -236,8 +236,6 @@ void FileTrans::fbtTransDone(QSharedPointer<FrameBuffer> frame)
|
|||||||
downTask_->state = TaskState::STATE_FINISH;
|
downTask_->state = TaskState::STATE_FINISH;
|
||||||
info.msg = QString(tr("recv file:%1 success.")).arg(downTask_->file.fileName());
|
info.msg = QString(tr("recv file:%1 success.")).arg(downTask_->file.fileName());
|
||||||
qInfo() << info.msg;
|
qInfo() << info.msg;
|
||||||
auto f = clientCore_->GetBuffer(info, FBT_CLI_CAN_DOWN, frame->fid);
|
|
||||||
ClientCore::syncInvoke(clientCore_, f);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCritical() << QString(tr("recv file:%1 done sigal, but file not opened.")).arg(info.msg);
|
qCritical() << QString(tr("recv file:%1 done sigal, but file not opened.")).arg(info.msg);
|
||||||
@@ -251,7 +249,7 @@ void FileTrans::fbtCanDown(QSharedPointer<FrameBuffer> frame)
|
|||||||
downTask_->permission = info.permissions;
|
downTask_->permission = info.permissions;
|
||||||
downTask_->totalSize = info.size;
|
downTask_->totalSize = info.size;
|
||||||
downTask_->tranSize = 0;
|
downTask_->tranSize = 0;
|
||||||
qDebug() << QString(tr("start trans file:%1.")).arg(info.fromPath);
|
qDebug() << QString(tr("Can Down trans file:%1.")).arg(info.fromPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTrans::fbtCanotDown(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtCanotDown(QSharedPointer<FrameBuffer> frame)
|
||||||
@@ -299,7 +297,7 @@ void FileTrans::fbtCanotSend(QSharedPointer<FrameBuffer> frame)
|
|||||||
void FileTrans::fbtCanSend(QSharedPointer<FrameBuffer> frame)
|
void FileTrans::fbtCanSend(QSharedPointer<FrameBuffer> frame)
|
||||||
{
|
{
|
||||||
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
|
||||||
qInfo() << QString(tr("start trans file:%1 to %2")).arg(info.fromPath, frame->fid);
|
qInfo() << QString(tr("Can Send start trans file:%1 to %2")).arg(info.fromPath, frame->fid);
|
||||||
SendFile(sendTask_);
|
SendFile(sendTask_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,12 +328,12 @@ void SendThread::run()
|
|||||||
{
|
{
|
||||||
// task's file shoule be already opened.
|
// task's file shoule be already opened.
|
||||||
isSuccess_ = true;
|
isSuccess_ = true;
|
||||||
|
bool invokeSuccess = false;
|
||||||
while (!task_->file.atEnd()) {
|
while (!task_->file.atEnd()) {
|
||||||
|
|
||||||
auto frame = QSharedPointer<FrameBuffer>::create();
|
auto frame = QSharedPointer<FrameBuffer>::create();
|
||||||
frame->tid = task_->task.remoteId;
|
frame->tid = task_->task.remoteId;
|
||||||
frame->type = FBT_CLI_FILE_BUFFER;
|
frame->type = FBT_CLI_FILE_BUFFER;
|
||||||
frame->call = [this](QSharedPointer<FrameBuffer> frame) { sendCall(frame); };
|
|
||||||
frame->data.resize(CHUNK_BUF_SIZE);
|
frame->data.resize(CHUNK_BUF_SIZE);
|
||||||
|
|
||||||
auto br = task_->file.read(frame->data.data(), CHUNK_BUF_SIZE);
|
auto br = task_->file.read(frame->data.data(), CHUNK_BUF_SIZE);
|
||||||
@@ -345,32 +343,14 @@ void SendThread::run()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
frame->data.resize(br);
|
frame->data.resize(br);
|
||||||
|
invokeSuccess = QMetaObject::invokeMethod(cliCore_, "SendFrame", Qt::BlockingQueuedConnection,
|
||||||
while (curSendCount_ >= MAX_SEND_TASK) {
|
Q_RETURN_ARG(bool, isSuccess_), Q_ARG(QSharedPointer<FrameBuffer>, frame));
|
||||||
QThread::msleep(1);
|
if (!invokeSuccess || !isSuccess_) {
|
||||||
// shoule add abort action mark.
|
|
||||||
}
|
|
||||||
|
|
||||||
// QMetaObject::invokeMethod(cliCore_, [this, frame] {
|
|
||||||
// frame->sendRet = cliCore_->Send(frame);
|
|
||||||
// if (frame->call) {
|
|
||||||
// frame->call(frame);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
++curSendCount_;
|
|
||||||
|
|
||||||
if (!isSuccess_) {
|
|
||||||
qCritical() << QString(tr("send to %1 file failed.")).arg(task_->task.remoteId);
|
qCritical() << QString(tr("send to %1 file failed.")).arg(task_->task.remoteId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
task_->tranSize += frame->data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (curSendCount_ > 0) {
|
|
||||||
QThread::msleep(1);
|
|
||||||
// shoule add abort action mark.
|
|
||||||
}
|
|
||||||
|
|
||||||
InfoMsg info;
|
InfoMsg info;
|
||||||
auto f = cliCore_->GetBuffer(info, FBT_CLI_TRANS_DONE, task_->task.remoteId);
|
auto f = cliCore_->GetBuffer(info, FBT_CLI_TRANS_DONE, task_->task.remoteId);
|
||||||
ClientCore::syncInvoke(cliCore_, f);
|
ClientCore::syncInvoke(cliCore_, f);
|
||||||
@@ -382,13 +362,3 @@ void SendThread::setTask(const QSharedPointer<DoTransTask>& task)
|
|||||||
{
|
{
|
||||||
task_ = task;
|
task_ = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendThread::sendCall(QSharedPointer<FrameBuffer> frame)
|
|
||||||
{
|
|
||||||
if (frame->sendRet) {
|
|
||||||
--curSendCount_;
|
|
||||||
task_->tranSize += frame->data.size();
|
|
||||||
} else {
|
|
||||||
isSuccess_ = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
void run() override;
|
void run() override;
|
||||||
void setTask(const QSharedPointer<DoTransTask>& task);
|
void setTask(const QSharedPointer<DoTransTask>& task);
|
||||||
void sendCall(QSharedPointer<FrameBuffer> frame);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isSuccess_{false};
|
bool isSuccess_{false};
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ int main(int argc, char* argv[])
|
|||||||
qRegisterMetaType<QSharedPointer<FrameBuffer>>("QSharedPointer<FrameBuffer>");
|
qRegisterMetaType<QSharedPointer<FrameBuffer>>("QSharedPointer<FrameBuffer>");
|
||||||
qRegisterMetaType<InfoClientVec>("InfoClientVec");
|
qRegisterMetaType<InfoClientVec>("InfoClientVec");
|
||||||
qRegisterMetaType<DirFileInfoVec>("DirFileInfoVec");
|
qRegisterMetaType<DirFileInfoVec>("DirFileInfoVec");
|
||||||
|
qRegisterMetaType<TransTask>("TransTask");
|
||||||
|
|
||||||
frelayGUI w;
|
frelayGUI w;
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ struct FrameBuffer {
|
|||||||
QString tid;
|
QString tid;
|
||||||
FrameBufferType type = FBT_NONE;
|
FrameBufferType type = FBT_NONE;
|
||||||
bool sendRet;
|
bool sendRet;
|
||||||
std::function<void(QSharedPointer<FrameBuffer>)> call{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Protocol
|
class Protocol
|
||||||
|
|||||||
Reference in New Issue
Block a user