Feature: File copy/paste support in remote control

This commit is contained in:
yuanyuanxiang
2025-10-25 16:13:18 +08:00
parent 2855af1932
commit ea4472445d
23 changed files with 339 additions and 24 deletions

View File

@@ -192,6 +192,9 @@ enum {
TOKEN_UNINSTALL = 63, // ж<><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TOKEN_PRIVATESCREEN = 64, // <20><>˽<EFBFBD><CBBD>Ļ
TOKEN_MACHINE_MANAGE = 65, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMMAND_GET_FOLDER = 66, // <20><>ȡĿ¼
COMMAND_GET_FILE = 67, // <20><>ȡ<EFBFBD>ļ<EFBFBD>
COMMAND_SEND_FILE = 68, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤

34
common/file_upload.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include <string>
#include <vector>
#pragma pack(push, 1)
struct FileChunkPacket
{
unsigned char cmd; // COMMAND_SEND_FILE
uint32_t fileIndex; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
uint32_t totalNum; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
uint64_t fileSize; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
uint64_t offset; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>е<EFBFBD>ƫ<EFBFBD><C6AB>
uint64_t dataLength; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
uint64_t nameLength; // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD> '\0'<27><>
};
#pragma pack(pop)
int InitFileUpload(const std::string hmac, int chunkSizeKb = 64, int sendDurationMs = 50);
int UninitFileUpload();
std::vector<std::string> GetClipboardFiles();
bool GetCurrentFolderPath(std::string& outDir);
typedef bool (*OnTransform)(void* user, FileChunkPacket* chunk, unsigned char* data, int size);
typedef void (*OnFinish)(void* user);
int FileBatchTransferWorker(const std::vector<std::string>& files, const std::string& targetDir,
void* user, OnTransform f, OnFinish finish, const std::string& hash, const std::string& hmac);
int RecvFileChunk(char* buf, size_t len, void* user, OnFinish f, const std::string& hash, const std::string& hmac);

View File

@@ -114,7 +114,11 @@ public:
}
cv.notify_one();
if (workerThread.joinable()) {
workerThread.join();
try {
workerThread.join();
} catch (const std::system_error& e) {
printf("Join failed: %s [%d]\n", e.what(), e.code().value());
}
}
for (int i = 0; threadRun && i++ < 1000; Sleep(1));
}