Add a smoothed bytes-per-second readout to the CDlgFileSend title, refreshed about every 200 ms during transfer (e.g. "发送文件 - 5.3M/s"). The base title is captured on the first progress frame and the speed suffix applied through Unicode APIs (GetWindowTextW / SetWindowTextW), so the whole title stays correct on non-Chinese systems where the ANSI message path would misdecode GBK as the system ACP. Also add the missing "接收文件 (V2)" translation (en_US "Receive File (V2)", zh_TW "接收檔案 (V2)"), so the V2 receive title no longer falls back to raw Chinese on non-Chinese systems. Co-Authored-By: deepseek-v4-pro
78 lines
2.7 KiB
C++
78 lines
2.7 KiB
C++
#pragma once
|
||
|
||
#include "IOCPServer.h"
|
||
#include "afxdialogex.h"
|
||
#include <resource.h>
|
||
#include"file_upload.h"
|
||
#include "2015RemoteDlg.h"
|
||
|
||
#define WM_UPDATEFILEPROGRESS (WM_USER + 0x100)
|
||
#define WM_FINISHFILESEND (WM_USER + 0x101)
|
||
|
||
// 协议无关的进度信息结构(支持 V1 和 V2)
|
||
struct FileProgressInfo {
|
||
uint32_t fileIndex;
|
||
uint32_t totalFiles;
|
||
uint64_t fileSize;
|
||
uint64_t offset;
|
||
uint64_t dataLength;
|
||
uint64_t nameLength;
|
||
|
||
// 从 V1 包构造
|
||
FileProgressInfo(const FileChunkPacket* pkt) :
|
||
fileIndex(pkt->fileIndex), totalFiles(pkt->totalNum),
|
||
fileSize(pkt->fileSize), offset(pkt->offset),
|
||
dataLength(pkt->dataLength), nameLength(pkt->nameLength) {}
|
||
|
||
// 从 V2 包构造
|
||
FileProgressInfo(const FileChunkPacketV2* pkt) :
|
||
fileIndex(pkt->fileIndex), totalFiles(pkt->totalFiles),
|
||
fileSize(pkt->fileSize), offset(pkt->offset),
|
||
dataLength(pkt->dataLength), nameLength(pkt->nameLength) {}
|
||
};
|
||
|
||
// CDlgFileSend 对话框
|
||
|
||
class CDlgFileSend : public DialogBase
|
||
{
|
||
DECLARE_DYNAMIC(CDlgFileSend)
|
||
CMy2015RemoteDlg* m_pParent = nullptr;
|
||
|
||
public:
|
||
CDlgFileSend(CMy2015RemoteDlg* pParent = NULL, Server* IOCPServer = NULL,
|
||
CONTEXT_OBJECT* ContextObject = NULL, BOOL sendFile = TRUE);
|
||
virtual ~CDlgFileSend();
|
||
void OnReceiveComplete(void);
|
||
void UpdateProgress(CString file, const FileProgressInfo& info);
|
||
void FinishFileSend(BOOL succeed);
|
||
|
||
BOOL m_bIsSending;
|
||
BOOL m_bKeepConnection = FALSE; // V2传输完成后不断开主连接
|
||
BOOL m_bTargetOffline = FALSE; // C2C目标已离线,已发送取消包
|
||
enum { IDD = IDD_DIALOG_FILESEND };
|
||
|
||
// 传输速度统计(用于标题实时显示速度,如 "发送文件 - 5.3M/s")
|
||
CStringW m_strBaseTitle; // 标题基础部分("发送文件"/"接收文件 (V2)" 等,Unicode),首帧进度时捕获
|
||
bool m_bBaseTitleCaptured = false;
|
||
uint64_t m_ullTotalBytes = 0; // 累计传输字节
|
||
uint64_t m_ullLastBytes = 0;
|
||
ULONGLONG m_ullLastTick = 0; // 上次速度采样时刻 (ms)
|
||
double m_dSpeedBps = 0.0; // 平滑后的速度 (B/s)
|
||
|
||
protected:
|
||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||
|
||
DECLARE_MESSAGE_MAP()
|
||
|
||
afx_msg LRESULT OnUpdateFileProgress(WPARAM wParam, LPARAM lParam);
|
||
afx_msg LRESULT OnFinishFileSend(WPARAM wParam, LPARAM lParam);
|
||
|
||
void UpdateTitleWithSpeed(uint64_t dataLength); // 累计字节并周期性刷新标题速度
|
||
|
||
public:
|
||
CProgressCtrl m_Progress;
|
||
virtual BOOL OnInitDialog();
|
||
afx_msg void OnClose();
|
||
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
||
};
|