diff --git a/flutter/lib/desktop/pages/port_forward_page.dart b/flutter/lib/desktop/pages/port_forward_page.dart index 126365a1a..167c2b20c 100644 --- a/flutter/lib/desktop/pages/port_forward_page.dart +++ b/flutter/lib/desktop/pages/port_forward_page.dart @@ -49,7 +49,10 @@ class _PortForwardPageState extends State void initState() { super.initState(); _ffi = FFI(); - _ffi.start(widget.id, isPortForward: true, forceRelay: widget.forceRelay); + _ffi.start(widget.id, + isPortForward: true, + forceRelay: widget.forceRelay, + isRdp: widget.isRDP); Get.put(_ffi, tag: 'pf_${widget.id}'); if (!Platform.isLinux) { Wakelock.enable(); diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index e36b8d390..e94452bd7 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1597,6 +1597,7 @@ class FFI { void start(String id, {bool isFileTransfer = false, bool isPortForward = false, + bool isRdp = false, String? switchUuid, String? password, bool? forceRelay}) { @@ -1619,6 +1620,7 @@ class FFI { id: id, isFileTransfer: isFileTransfer, isPortForward: isPortForward, + isRdp: isRdp, switchUuid: switchUuid ?? "", forceRelay: forceRelay ?? false, password: password ?? "", diff --git a/src/flutter.rs b/src/flutter.rs index 9062b5031..db7d466ef 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -505,7 +505,7 @@ impl InvokeUiSession for FlutterHandler { match hook { SessionHook::OnSessionRgba(cb) => { cb(key.to_owned(), rgba); - }, + } } } // If the current rgba is not fetched by flutter, i.e., is valid. @@ -688,6 +688,7 @@ pub fn session_add( id: &str, is_file_transfer: bool, is_port_forward: bool, + is_rdp: bool, switch_uuid: &str, force_relay: bool, password: String, @@ -704,11 +705,14 @@ pub fn session_add( ..Default::default() }; - // TODO rdp let conn_type = if is_file_transfer { ConnType::FILE_TRANSFER } else if is_port_forward { - ConnType::PORT_FORWARD + if is_rdp { + ConnType::RDP + } else { + ConnType::PORT_FORWARD + } } else { ConnType::DEFAULT_CONN }; @@ -725,7 +729,11 @@ pub fn session_add( .unwrap() .initialize(session_id, conn_type, switch_uuid, force_relay); - if let Some(same_id_session) = SESSIONS.write().unwrap().insert(id.to_owned(), session.clone()) { + if let Some(same_id_session) = SESSIONS + .write() + .unwrap() + .insert(id.to_owned(), session.clone()) + { same_id_session.close(); } @@ -1068,4 +1076,4 @@ unsafe extern "C" fn get_rgba() {} #[derive(Clone)] pub enum SessionHook { OnSessionRgba(fn(String, &mut scrap::ImageRgb)), -} \ No newline at end of file +} diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 4424a3bdb..9aadca1bc 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -76,6 +76,7 @@ pub fn session_add_sync( id: String, is_file_transfer: bool, is_port_forward: bool, + is_rdp: bool, switch_uuid: String, force_relay: bool, password: String, @@ -84,6 +85,7 @@ pub fn session_add_sync( &id, is_file_transfer, is_port_forward, + is_rdp, &switch_uuid, force_relay, password, diff --git a/src/port_forward.rs b/src/port_forward.rs index 028875fa3..62ba7b41c 100644 --- a/src/port_forward.rs +++ b/src/port_forward.rs @@ -92,6 +92,7 @@ pub async fn listen( break; } Some(Data::NewRDP) => { + println!("receive run_rdp from ui_receiver"); run_rdp(addr.port()); } _ => {} diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 8a6a30803..a804484a0 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -88,11 +88,11 @@ impl Session { } pub fn is_port_forward(&self) -> bool { - self.lc + let conn_type = self.lc .read() .unwrap() - .conn_type - .eq(&ConnType::PORT_FORWARD) + .conn_type; + conn_type == ConnType::PORT_FORWARD || conn_type == ConnType::RDP } #[cfg(not(any(target_os = "android", target_os = "ios")))]