diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 5f4d30e35..f0fb00c2b 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1523,6 +1523,11 @@ bool checkArguments() { } String? id = kBootArgs.length < connectIndex + 1 ? null : kBootArgs[connectIndex + 1]; + String? password = + kBootArgs.length < connectIndex + 2 ? null : kBootArgs[connectIndex + 2]; + if (password != null && password.startsWith("--")) { + password = null; + } final switchUuidIndex = kBootArgs.indexOf("--switch_uuid"); String? switchUuid = kBootArgs.length < switchUuidIndex + 1 ? null @@ -1536,7 +1541,8 @@ bool checkArguments() { kBootArgs.removeAt(connectIndex); // fallback to peer id Future.delayed(Duration.zero, () { - rustDeskWinManager.newRemoteDesktop(id, switch_uuid: switchUuid); + rustDeskWinManager.newRemoteDesktop(id, + password: password, switch_uuid: switchUuid); }); return true; } diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 2b1999b42..aea073ace 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -25,19 +25,20 @@ import '../../utils/image.dart'; import '../widgets/remote_toolbar.dart'; import '../widgets/kb_layout_type_chooser.dart'; -bool _isCustomCursorInited = false; final SimpleWrapper _firstEnterImage = SimpleWrapper(false); class RemotePage extends StatefulWidget { RemotePage({ Key? key, required this.id, + required this.password, required this.menubarState, this.switchUuid, this.forceRelay, }) : super(key: key); final String id; + final String? password; final MenubarState menubarState; final String? switchUuid; final bool? forceRelay; @@ -113,6 +114,7 @@ class _RemotePageState extends State }); _ffi.start( widget.id, + password: widget.password, switchUuid: widget.switchUuid, forceRelay: widget.forceRelay, ); diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart index 1d39b715c..f7bb85a37 100644 --- a/flutter/lib/desktop/pages/remote_tab_page.dart +++ b/flutter/lib/desktop/pages/remote_tab_page.dart @@ -23,9 +23,6 @@ import '../../models/platform_model.dart'; class _MenuTheme { static const Color blueColor = MyTheme.button; - static const Color hoverBlueColor = MyTheme.accent; - static const Color redColor = Colors.redAccent; - static const Color hoverRedColor = Colors.red; // kMinInteractiveDimension static const double height = 20.0; static const double dividerHeight = 12.0; @@ -71,6 +68,7 @@ class _ConnectionTabPageState extends State { page: RemotePage( key: ValueKey(peerId), id: peerId, + password: params['password'], menubarState: _menubarState, switchUuid: params['switch_uuid'], forceRelay: params['forceRelay'], @@ -106,6 +104,7 @@ class _ConnectionTabPageState extends State { page: RemotePage( key: ValueKey(id), id: id, + password: args['password'], menubarState: _menubarState, switchUuid: switchUuid, forceRelay: args['forceRelay'], diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index f7ccc4a13..1cc059ce0 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1,12 +1,9 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:ffi' hide Size; import 'dart:io'; import 'dart:math'; -import 'dart:typed_data'; import 'dart:ui' as ui; -import 'package:ffi/ffi.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hbb/consts.dart'; @@ -1534,6 +1531,7 @@ class FFI { {bool isFileTransfer = false, bool isPortForward = false, String? switchUuid, + String? password, bool? forceRelay}) { assert(!(isFileTransfer && isPortForward), 'more than one connect type'); if (isFileTransfer) { @@ -1550,11 +1548,13 @@ class FFI { } // ignore: unused_local_variable final addRes = bind.sessionAddSync( - id: id, - isFileTransfer: isFileTransfer, - isPortForward: isPortForward, - switchUuid: switchUuid ?? "", - forceRelay: forceRelay ?? false); + id: id, + isFileTransfer: isFileTransfer, + isPortForward: isPortForward, + switchUuid: switchUuid ?? "", + forceRelay: forceRelay ?? false, + password: password ?? "", + ); final stream = bind.sessionStart(id: id); final cb = ffiModel.startEventListener(id); () async { diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart index 864659a66..1aec57680 100644 --- a/flutter/lib/utils/multi_window_manager.dart +++ b/flutter/lib/utils/multi_window_manager.dart @@ -43,12 +43,14 @@ class RustDeskMultiWindowManager { Future newRemoteDesktop( String remoteId, { + String? password, String? switch_uuid, bool? forceRelay, }) async { var params = { "type": WindowType.RemoteDesktop.index, "id": remoteId, + "password": password, "forceRelay": forceRelay }; if (switch_uuid != null) { diff --git a/src/flutter.rs b/src/flutter.rs index 2262df660..089daff5c 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -420,7 +420,14 @@ impl InvokeUiSession for FlutterHandler { // unused in flutter // TEST flutter fn confirm_delete_files(&self, _id: i32, _i: i32, _name: String) {} - fn override_file_confirm(&self, id: i32, file_num: i32, to: String, is_upload: bool, is_identical: bool) { + fn override_file_confirm( + &self, + id: i32, + file_num: i32, + to: String, + is_upload: bool, + is_identical: bool, + ) { self.push_event( "override_file_confirm", vec![ @@ -428,7 +435,7 @@ impl InvokeUiSession for FlutterHandler { ("file_num", &file_num.to_string()), ("read_path", &to), ("is_upload", &is_upload.to_string()), - ("is_identical", &is_identical.to_string()) + ("is_identical", &is_identical.to_string()), ], ); } @@ -632,12 +639,14 @@ pub fn session_add( is_port_forward: bool, switch_uuid: &str, force_relay: bool, + password: String, ) -> ResultType<()> { let session_id = get_session_id(id.to_owned()); LocalConfig::set_remote_id(&session_id); let session: Session = Session { id: session_id.clone(), + password, server_keyboard_enabled: Arc::new(RwLock::new(true)), server_file_transfer_enabled: Arc::new(RwLock::new(true)), server_clipboard_enabled: Arc::new(RwLock::new(true)), diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 2a3baad95..a3e8c38f2 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -87,6 +87,7 @@ pub fn session_add_sync( is_port_forward: bool, switch_uuid: String, force_relay: bool, + password: String, ) -> SyncReturn { if let Err(e) = session_add( &id, @@ -94,6 +95,7 @@ pub fn session_add_sync( is_port_forward, &switch_uuid, force_relay, + password, ) { SyncReturn(format!("Failed to add session with id {}, {}", &id, e)) } else {