ready: trans file ready code.

This commit is contained in:
2025-06-16 23:41:35 +08:00
parent 02d163ccb7
commit 33b8a37719
11 changed files with 169 additions and 58 deletions

View File

@@ -17,6 +17,8 @@ ClientCore.cpp
ClientCore.h
RemoteFile.h
RemoteFile.cpp
FileTrans.h
FileTrans.cpp
)
add_library(ClientCore STATIC ${SOURCES})

View File

@@ -1,4 +1,4 @@
#include "ClientCore.h"
#include "ClientCore.h"
#include <QDebug>
@@ -99,7 +99,7 @@ void ClientCore::UseFrame(QSharedPointer<FrameBuffer> frame)
break;
}
default:
qWarning() << QString(tr("unknown frame type: %1")).arg(frame->type);
frameCall_[static_cast<uint32_t>(frame->type)](frame);
break;
}
}
@@ -150,7 +150,7 @@ void ClientCore::SetRemoteID(const QString& id)
remoteID_ = id;
}
void ClientCore::SetFrameCall(FrameBufferType type, const std::function<void(FrameBuffer*)>& call)
void ClientCore::SetFrameCall(FrameBufferType type, const std::function<void(QSharedPointer<FrameBuffer>)>& call)
{
frameCall_[type] = call;
}

View File

@@ -1,4 +1,4 @@
#ifndef CLIENTCORE_H
#ifndef CLIENTCORE_H
#define CLIENTCORE_H
#include <InfoClient.h>
@@ -48,7 +48,7 @@ public:
void SetClientsCall(const std::function<void(const InfoClientVec& clients)>& call);
void SetPathCall(const std::function<void(const QString& path)>& call);
void SetFileCall(const std::function<void(const DirFileInfoVec& files)>& call);
void SetFrameCall(FrameBufferType type, const std::function<void(FrameBuffer*)>& call);
void SetFrameCall(FrameBufferType type, const std::function<void(QSharedPointer<FrameBuffer>)>& call);
void SetRemoteID(const QString& id);
QString GetRemoteID();
@@ -65,7 +65,7 @@ public:
std::function<void(const InfoClientVec& clients)> clientsCall_;
std::function<void(const DirFileInfoVec& files)> fileCall_;
std::array<std::function<void(FrameBuffer*)>, 256> frameCall_;
std::array<std::function<void(QSharedPointer<FrameBuffer>)>, 256> frameCall_;
};
#endif // CLIENTCORE_H

19
ClientCore/FileTrans.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "FileTrans.h"
FileTrans::FileTrans(ClientCore* clientCore) : clientCore_(clientCore)
{
}
void FileTrans::SetTasks(const QVector<TransTask>& tasks)
{
tasks_ = tasks;
}
void FileTrans::RegisterFrameCall()
{
clientCore_->SetFrameCall(FBT_CLI_REQ_SEND, [this](QSharedPointer<FrameBuffer> frame) { fbtReqSend(frame); });
}
void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
{
}

53
ClientCore/FileTrans.h Normal file
View File

@@ -0,0 +1,53 @@
#ifndef FILETRANS_H
#define FILETRANS_H
#include <QFile>
#include <QMap>
#include <QVector>
#include "ClientCore.h"
struct TransTask {
bool isUpload{false};
QString localId;
QString localPath;
QString localUUID;
QString remoteId;
QString remotePath;
QString remoteUUID;
};
enum class TaskState {
STATE_READY = 0,
STATE_RUNNING,
STATE_FAILED,
STATE_FINISH,
};
struct DoTransTask {
QFile file;
TaskState state;
TransTask task;
};
class FileTrans : public QObject
{
Q_OBJECT
public:
FileTrans(ClientCore* clientCore);
public:
void SetTasks(const QVector<TransTask>& tasks);
void RegisterFrameCall();
private:
void fbtReqSend(QSharedPointer<FrameBuffer> frame);
private:
DoTransTask downTask_;
QVector<TransTask> tasks_;
ClientCore* clientCore_;
QMap<QString, DoTransTask> upTasks_;
};
#endif