diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index edc7f427853e..17d5cec271b8 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -570,3 +570,5 @@ enum WindowsTarget { extension WindowsTargetExt on int { WindowsTarget get windowsVersion => getWindowsTarget(this); } + +const kCheckSoftwareUpdateFinish = 'check_software_update_finish'; \ No newline at end of file diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index dee990af4c2d..90fa67dedde1 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -664,9 +664,17 @@ class _DesktopHomePageState extends State void initState() { super.initState(); if (!bind.isCustomClient()) { + platformFFI.registerEventHandler( + kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish, + (Map evt) async { + if (evt['url'] is String) { + setState(() { + updateUrl = evt['url']; + }); + } + }); Timer(const Duration(seconds: 1), () async { - updateUrl = await bind.mainGetSoftwareUpdateUrl(); - if (updateUrl.isNotEmpty) setState(() {}); + bind.mainGetSoftwareUpdateUrl(); }); } _updateTimer = periodic_immediate(const Duration(seconds: 1), () async { @@ -824,6 +832,10 @@ class _DesktopHomePageState extends State _uniLinksSubscription?.cancel(); Get.delete(tag: 'stop-service'); _updateTimer?.cancel(); + if (!bind.isCustomClient()) { + platformFFI.unregisterEventHandler( + kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish); + } super.dispose(); } diff --git a/flutter/lib/mobile/pages/connection_page.dart b/flutter/lib/mobile/pages/connection_page.dart index c6e812389264..181f36e58cc6 100644 --- a/flutter/lib/mobile/pages/connection_page.dart +++ b/flutter/lib/mobile/pages/connection_page.dart @@ -70,9 +70,17 @@ class _ConnectionPageState extends State { } if (isAndroid) { if (!bind.isCustomClient()) { + platformFFI.registerEventHandler( + kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish, + (Map evt) async { + if (evt['url'] is String) { + setState(() { + _updateUrl = evt['url']; + }); + } + }); Timer(const Duration(seconds: 1), () async { - _updateUrl = await bind.mainGetSoftwareUpdateUrl(); - if (_updateUrl.isNotEmpty) setState(() {}); + bind.mainGetSoftwareUpdateUrl(); }); } } @@ -353,6 +361,10 @@ class _ConnectionPageState extends State { if (Get.isRegistered()) { Get.delete(); } + if (!bind.isCustomClient()) { + platformFFI.unregisterEventHandler( + kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish); + } super.dispose(); } } diff --git a/flutter/lib/web/bridge.dart b/flutter/lib/web/bridge.dart index d28e0c26abf7..6e758dae438c 100644 --- a/flutter/lib/web/bridge.dart +++ b/flutter/lib/web/bridge.dart @@ -608,7 +608,7 @@ class RustdeskImpl { Future sessionElevateDirect( {required UuidValue sessionId, dynamic hint}) { - throw UnimplementedError(); + return Future(() => js.context.callMethod('setByName', ['elevate_direct'])); } Future sessionElevateWithLogon( @@ -618,7 +618,7 @@ class RustdeskImpl { dynamic hint}) { return Future(() => js.context.callMethod('setByName', [ 'elevate_with_logon', - jsonEncode({username, password}) + jsonEncode({'username': username, 'password': password}) ])); } @@ -1063,7 +1063,7 @@ class RustdeskImpl { () => js.context.callMethod('getByName', ['option', 'last_remote_id'])); } - Future mainGetSoftwareUpdateUrl({dynamic hint}) { + Future mainGetSoftwareUpdateUrl({dynamic hint}) { throw UnimplementedError(); } diff --git a/src/common.rs b/src/common.rs index 8911f99376c3..991ec0dabe05 100644 --- a/src/common.rs +++ b/src/common.rs @@ -828,7 +828,16 @@ async fn check_software_update_() -> hbb_common::ResultType<()> { let response_url = latest_release_response.url().to_string(); if get_version_number(&latest_release_version) > get_version_number(crate::VERSION) { - *SOFTWARE_UPDATE_URL.lock().unwrap() = response_url; + #[cfg(feature = "flutter")] + { + let mut m = HashMap::new(); + m.insert("name", "check_software_update_finish"); + m.insert("url", &response_url); + if let Ok(data) = serde_json::to_string(&m) { + let _ = crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, data); + } + } + *SOFTWARE_UPDATE_URL.lock().unwrap() = response_url; } Ok(()) } diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 72b0e5b37b42..020bc98aa920 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -61,7 +61,6 @@ fn initialize(app_dir: &str, custom_client_config: &str) { scrap::mediacodec::check_mediacodec(); crate::common::test_rendezvous_server(); crate::common::test_nat_type(); - crate::common::check_software_update(); } #[cfg(target_os = "ios")] { @@ -1376,11 +1375,10 @@ pub fn main_get_last_remote_id() -> String { LocalConfig::get_remote_id() } -pub fn main_get_software_update_url() -> String { +pub fn main_get_software_update_url() { if get_local_option("enable-check-update".to_string()) != "N" { crate::common::check_software_update(); } - crate::common::SOFTWARE_UPDATE_URL.lock().unwrap().clone() } pub fn main_get_home_dir() -> String { diff --git a/src/lang/it.rs b/src/lang/it.rs index 008fb3b3518f..a07df2da9227 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -369,7 +369,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Stop session recording", "Ferma registrazione sessione"), ("Enable recording session", "Abilita registrazione sessione"), ("Enable LAN discovery", "Abilita rilevamento LAN"), - ("Deny LAN discovery", "Nega rilevamento LAN"), + ("Deny LAN discovery", "Disabilita rilevamento LAN"), ("Write a message", "Scrivi un messaggio"), ("Prompt", "Richiedi"), ("Please wait for confirmation of UAC...", "Attendi la conferma dell'UAC..."), @@ -532,7 +532,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("HSV Color", "Colore HSV"), ("Installation Successful!", "Installazione completata"), ("Installation failed!", "Installazione fallita"), - ("Reverse mouse wheel", "Rotella mouse inversa"), + ("Reverse mouse wheel", "Funzione rotellina mouse inversa"), ("{} sessions", "{} sessioni"), ("scam_title", "Potresti essere stato TRUFFATO!"), ("scam_text1", "Se sei al telefono con qualcuno che NON conosci NON DI TUA FIDUCIA che ti ha chiesto di usare RustDesk e di avviare il servizio, non procedere e riattacca subito."), @@ -632,7 +632,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("About RustDesk", "Info su RustDesk"), ("Send clipboard keystrokes", "Invia sequenze tasti appunti"), ("network_error_tip", "Controlla la connessione di rete, quindi seleziona 'Riprova'."), - ("Unlock with PIN", "Sblocca con PIN"), + ("Unlock with PIN", "Abilita sblocco con PIN"), ("Requires at least {} characters", "Richiede almeno {} caratteri"), ("Wrong PIN", "PIN errato"), ("Set PIN", "Imposta PIN"), @@ -644,7 +644,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Parent directory", "Cartella principale"), ("Resume", "Riprendi"), ("Invalid file name", "Nome file non valido"), - ("one-way-file-transfer-tip", "Il trasferimento file unidirezionale è abilitato sul lato controllato."), + ("one-way-file-transfer-tip", "Sul lato controllato è abilitato il trasferimento file unidirezionale."), ("Authentication Required", "Richiesta autenticazione"), ("Authenticate", "Autentica"), ].iter().cloned().collect(); diff --git a/src/main.rs b/src/main.rs index 44ace8a76e56..f295363aa90e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,6 @@ fn main() { } common::test_rendezvous_server(); common::test_nat_type(); - #[cfg(target_os = "android")] - crate::common::check_software_update(); common::global_clean(); }