From a6c1d2d486b46de571f422e9e771532504e0c1de Mon Sep 17 00:00:00 2001 From: rustdesk Date: Tue, 16 Apr 2024 18:42:35 +0800 Subject: [PATCH] customClientConfig in dart --- flutter/lib/models/native_model.dart | 4 +++- src/flutter_ffi.rs | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/flutter/lib/models/native_model.dart b/flutter/lib/models/native_model.dart index fe8fba732..d8e5aa1ee 100644 --- a/flutter/lib/models/native_model.dart +++ b/flutter/lib/models/native_model.dart @@ -198,7 +198,9 @@ class PlatformFFI { await _ffiBind.mainDeviceId(id: id); await _ffiBind.mainDeviceName(name: name); await _ffiBind.mainSetHomeDir(home: _homeDir); - await _ffiBind.mainInit(appDir: _dir); + final customClientConfig = ''; + await _ffiBind.mainInit( + appDir: _dir, customClientConfig: customClientConfig); } catch (e) { debugPrintStack(label: 'initialize failed: $e'); } diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index e27b4140e..dec4bc370 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -39,11 +39,15 @@ lazy_static::lazy_static! { static ref TEXTURE_RENDER_KEY: Arc = Arc::new(AtomicI32::new(0)); } -fn initialize(app_dir: &str) { +fn initialize(app_dir: &str, custom_client_config: &str) { flutter::async_tasks::start_flutter_async_runner(); *config::APP_DIR.write().unwrap() = app_dir.to_owned(); // core_main's load_custom_client does not work for flutter since it is only applied to its load_library in main.c - crate::load_custom_client(); + if custom_client_config.is_empty() { + crate::load_custom_client(); + } else { + crate::read_custom_client(custom_client_config); + } #[cfg(target_os = "android")] { // flexi_logger can't work when android_logger initialized. @@ -1275,8 +1279,8 @@ pub fn cm_get_clients_length() -> usize { crate::ui_cm_interface::get_clients_length() } -pub fn main_init(app_dir: String) { - initialize(&app_dir); +pub fn main_init(app_dir: String, custom_client_config: String) { + initialize(&app_dir, &custom_client_config); } pub fn main_device_id(id: String) { @@ -2122,10 +2126,7 @@ pub mod server_side { } #[no_mangle] - pub unsafe extern "system" fn Java_ffi_FFI_startService( - _env: JNIEnv, - _class: JClass, - ) { + pub unsafe extern "system" fn Java_ffi_FFI_startService(_env: JNIEnv, _class: JClass) { log::debug!("startService from jvm"); config::Config::set_option("stop-service".into(), "".into()); crate::rendezvous_mediator::RendezvousMediator::restart(); @@ -2151,10 +2152,7 @@ pub mod server_side { } #[no_mangle] - pub unsafe extern "system" fn Java_ffi_FFI_refreshScreen( - _env: JNIEnv, - _class: JClass, - ) { + pub unsafe extern "system" fn Java_ffi_FFI_refreshScreen(_env: JNIEnv, _class: JClass) { crate::server::video_service::refresh() } }