fix: file transfer, show error, msgbox ()

* fix: file transfer, show error, msgbox

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: translation

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-09-18 19:29:35 +08:00 committed by GitHub
parent e5ec6957fe
commit d08c335fdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 88 additions and 15 deletions

@ -34,6 +34,7 @@ class JobID {
} }
typedef GetSessionID = SessionID Function(); typedef GetSessionID = SessionID Function();
typedef GetDialogManager = OverlayDialogManager? Function();
class FileModel { class FileModel {
final WeakReference<FFI> parent; final WeakReference<FFI> parent;
@ -45,13 +46,15 @@ class FileModel {
late final FileController remoteController; late final FileController remoteController;
late final GetSessionID getSessionID; late final GetSessionID getSessionID;
late final GetDialogManager getDialogManager;
SessionID get sessionId => getSessionID(); SessionID get sessionId => getSessionID();
late final FileDialogEventLoop evtLoop; late final FileDialogEventLoop evtLoop;
FileModel(this.parent) { FileModel(this.parent) {
getSessionID = () => parent.target!.sessionId; getSessionID = () => parent.target!.sessionId;
getDialogManager = () => parent.target?.dialogManager;
fileFetcher = FileFetcher(getSessionID); fileFetcher = FileFetcher(getSessionID);
jobController = JobController(getSessionID); jobController = JobController(getSessionID, getDialogManager);
localController = FileController( localController = FileController(
isLocal: true, isLocal: true,
getSessionID: getSessionID, getSessionID: getSessionID,
@ -736,14 +739,19 @@ class FileController {
} }
} }
const _kOneWayFileTransferError = 'one-way-file-transfer-tip';
class JobController { class JobController {
static final JobID jobID = JobID(); static final JobID jobID = JobID();
final jobTable = List<JobProgress>.empty(growable: true).obs; final jobTable = List<JobProgress>.empty(growable: true).obs;
final jobResultListener = JobResultListener<Map<String, dynamic>>(); final jobResultListener = JobResultListener<Map<String, dynamic>>();
final GetSessionID getSessionID; final GetSessionID getSessionID;
final GetDialogManager getDialogManager;
SessionID get sessionId => getSessionID(); SessionID get sessionId => getSessionID();
OverlayDialogManager? get alogManager => getDialogManager();
int _lastTimeShowMsgbox = DateTime.now().millisecondsSinceEpoch;
JobController(this.getSessionID); JobController(this.getSessionID, this.getDialogManager);
int getJob(int id) { int getJob(int id) {
return jobTable.indexWhere((element) => element.id == id); return jobTable.indexWhere((element) => element.id == id);
@ -882,6 +890,15 @@ class JobController {
} }
jobTable.refresh(); jobTable.refresh();
} }
if (err == _kOneWayFileTransferError) {
if (DateTime.now().millisecondsSinceEpoch - _lastTimeShowMsgbox > 3000) {
final dm = alogManager;
if (dm != null) {
_lastTimeShowMsgbox = DateTime.now().millisecondsSinceEpoch;
msgBox(sessionId, 'custom-nocancel', 'Error', err, '', dm);
}
}
}
debugPrint("jobError $evt"); debugPrint("jobError $evt");
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", "Възобновяване"), ("Resume", "Възобновяване"),
("Invalid file name", "Невалидно име за файл"), ("Invalid file name", "Невалидно име за файл"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "父目录"), ("Parent directory", "父目录"),
("Resume", "继续"), ("Resume", "继续"),
("Invalid file name", "无效文件名"), ("Invalid file name", "无效文件名"),
("one-way-file-transfer-tip", "被控端启用了单项文件传输"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Rodičovský adresář"), ("Parent directory", "Rodičovský adresář"),
("Resume", "Pokračovat"), ("Resume", "Pokračovat"),
("Invalid file name", "Nesprávný název souboru"), ("Invalid file name", "Nesprávný název souboru"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "mappe"), ("Parent directory", "mappe"),
("Resume", "Fortsæt"), ("Resume", "Fortsæt"),
("Invalid file name", "Ugyldigt filnavn"), ("Invalid file name", "Ugyldigt filnavn"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Übergeordnetes Verzeichnis"), ("Parent directory", "Übergeordnetes Verzeichnis"),
("Resume", "Fortsetzen"), ("Resume", "Fortsetzen"),
("Invalid file name", "Ungültiger Dateiname"), ("Invalid file name", "Ungültiger Dateiname"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -234,5 +234,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("About RustDesk", ""), ("About RustDesk", ""),
("network_error_tip", "Please check your network connection, then click retry."), ("network_error_tip", "Please check your network connection, then click retry."),
("enable-trusted-devices-tip", "Skip 2FA verification on trusted devices"), ("enable-trusted-devices-tip", "Skip 2FA verification on trusted devices"),
("one-way-file-transfer-tip", "One-way file transfer is enabled on the controlled side."),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Directorio superior"), ("Parent directory", "Directorio superior"),
("Resume", "Continuar"), ("Resume", "Continuar"),
("Invalid file name", "Nombre de archivo no válido"), ("Invalid file name", "Nombre de archivo no válido"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Cartella principale"), ("Parent directory", "Cartella principale"),
("Resume", "Riprendi"), ("Resume", "Riprendi"),
("Invalid file name", "Nome file non valido"), ("Invalid file name", "Nome file non valido"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "親ディレクトリ"), ("Parent directory", "親ディレクトリ"),
("Resume", "再開"), ("Resume", "再開"),
("Invalid file name", "無効なファイル名"), ("Invalid file name", "無効なファイル名"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Vecākdirektorijs"), ("Parent directory", "Vecākdirektorijs"),
("Resume", "Atsākt"), ("Resume", "Atsākt"),
("Invalid file name", "Nederīgs faila nosaukums"), ("Invalid file name", "Nederīgs faila nosaukums"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Hoofdmap"), ("Parent directory", "Hoofdmap"),
("Resume", "Hervatten"), ("Resume", "Hervatten"),
("Invalid file name", "Ongeldige bestandsnaam"), ("Invalid file name", "Ongeldige bestandsnaam"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Folder nadrzędny"), ("Parent directory", "Folder nadrzędny"),
("Resume", "Wznów"), ("Resume", "Wznów"),
("Invalid file name", "Nieprawidłowa nazwa pliku"), ("Invalid file name", "Nieprawidłowa nazwa pliku"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Diretório pai"), ("Parent directory", "Diretório pai"),
("Resume", "Continuar"), ("Resume", "Continuar"),
("Invalid file name", "Nome de arquivo inválido"), ("Invalid file name", "Nome de arquivo inválido"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Родительская директория"), ("Parent directory", "Родительская директория"),
("Resume", "Продолжить"), ("Resume", "Продолжить"),
("Invalid file name", "Неверное имя файла"), ("Invalid file name", "Неверное имя файла"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "Rodičovský adresár"), ("Parent directory", "Rodičovský adresár"),
("Resume", "Obnoviť"), ("Resume", "Obnoviť"),
("Invalid file name", "Nesprávny názov súboru"), ("Invalid file name", "Nesprávny názov súboru"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", "父目錄"), ("Parent directory", "父目錄"),
("Resume", "繼續"), ("Resume", "繼續"),
("Invalid file name", "無效文件名"), ("Invalid file name", "無效文件名"),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -644,5 +644,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Parent directory", ""), ("Parent directory", ""),
("Resume", ""), ("Resume", ""),
("Invalid file name", ""), ("Invalid file name", ""),
("one-way-file-transfer-tip", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

@ -2139,22 +2139,34 @@ impl Connection {
return true; return true;
} }
if crate::get_builtin_option(keys::OPTION_ONE_WAY_FILE_TRANSFER) == "Y" { if crate::get_builtin_option(keys::OPTION_ONE_WAY_FILE_TRANSFER) == "Y" {
match fa.union { let mut job_id = None;
Some(file_action::Union::Send(_)) match &fa.union {
| Some(file_action::Union::RemoveFile(_)) Some(file_action::Union::Send(s)) => {
| Some(file_action::Union::Rename(_)) job_id = Some(s.id);
| Some(file_action::Union::Create(_)) }
| Some(file_action::Union::RemoveDir(_)) => { Some(file_action::Union::RemoveFile(rf)) => {
job_id = Some(rf.id);
}
Some(file_action::Union::Rename(r)) => {
job_id = Some(r.id);
}
Some(file_action::Union::Create(c)) => {
job_id = Some(c.id);
}
Some(file_action::Union::RemoveDir(rd)) => {
job_id = Some(rd.id);
}
_ => {}
}
if let Some(job_id) = job_id {
self.send(fs::new_error( self.send(fs::new_error(
0, job_id,
"One-way file transfer is enabled on controlled side", "one-way-file-transfer-tip",
0, 0,
)) ))
.await; .await;
return true; return true;
} }
_ => {}
}
} }
match fa.union { match fa.union {
Some(file_action::Union::ReadDir(rd)) => { Some(file_action::Union::ReadDir(rd)) => {