diff --git a/src/client.rs b/src/client.rs index 478d81ce8..a05826c36 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1267,7 +1267,7 @@ impl LoginConfigHandler { /// Create a [`Message`] for login. fn create_login_msg(&self, password: Vec) -> Message { #[cfg(any(target_os = "android", target_os = "ios"))] - let my_id = Config::get_id_or(crate::common::MOBILE_INFO1.lock().unwrap().clone()); + let my_id = Config::get_id_or(crate::common::FLUTTER_INFO1.lock().unwrap().clone()); #[cfg(not(any(target_os = "android", target_os = "ios")))] let my_id = Config::get_id(); let mut lr = LoginRequest { diff --git a/src/common.rs b/src/common.rs index d2d1922ec..5af811c05 100644 --- a/src/common.rs +++ b/src/common.rs @@ -441,7 +441,7 @@ pub fn username() -> String { #[cfg(not(any(target_os = "android", target_os = "ios")))] return whoami::username().trim_end_matches('\0').to_owned(); #[cfg(any(target_os = "android", target_os = "ios"))] - return MOBILE_INFO2.lock().unwrap().clone(); + return FLUTTER_INFO2.lock().unwrap().clone(); } #[inline] diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 413e3cde3..84cc20e0a 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -19,12 +19,14 @@ use crate::flutter::connection_manager::{self, get_clients_length, get_clients_s use crate::flutter::{self, Session, SESSIONS}; use crate::start_server; use crate::ui_interface; +#[cfg(not(any(target_os = "android", target_os = "ios")))] +use crate::ui_interface::{change_id, check_connect_status, is_ok_change_id}; use crate::ui_interface::{ - change_id, check_connect_status, discover, forget_password, get_api_server, get_app_name, - get_async_job_status, get_connect_status, get_fav, get_id, get_lan_peers, get_license, - get_local_option, get_options, get_peer, get_peer_option, get_socks, get_sound_inputs, - get_uuid, get_version, has_rendezvous_service, is_ok_change_id, post_request, set_local_option, - set_options, set_peer_option, set_socks, store_fav, test_if_valid_server, using_public_server, + discover, forget_password, get_api_server, get_app_name, get_async_job_status, + get_connect_status, get_fav, get_id, get_lan_peers, get_license, get_local_option, get_options, + get_peer, get_peer_option, get_socks, get_sound_inputs, get_uuid, get_version, + has_rendezvous_service, post_request, set_local_option, set_options, set_peer_option, + set_socks, store_fav, test_if_valid_server, using_public_server, }; fn initialize(app_dir: &str) { @@ -67,7 +69,10 @@ fn initialize(app_dir: &str) { /// Return true if the app should continue running with UI(possibly Flutter), false if the app should exit. #[no_mangle] pub extern "C" fn rustdesk_core_main() -> bool { - crate::core_main::core_main() + #[cfg(not(any(target_os = "android", target_os = "ios")))] + return crate::core_main::core_main(); + #[cfg(any(target_os = "android", target_os = "ios"))] + false } pub enum EventToUI { @@ -390,6 +395,7 @@ pub fn main_get_sound_inputs() -> Vec { } pub fn main_change_id(new_id: String) { + #[cfg(not(any(target_os = "android", target_os = "ios")))] change_id(new_id) } @@ -461,6 +467,7 @@ pub fn main_get_connect_status() -> String { } pub fn main_check_connect_status() { + #[cfg(not(any(target_os = "android", target_os = "ios")))] check_connect_status(true); } @@ -1042,8 +1049,13 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) { crate::rendezvous_mediator::RendezvousMediator::restart(); } "start_service" => { - Config::set_option("stop-service".into(), "".into()); - start_server(false); + #[cfg(target_os = "android")] + { + Config::set_option("stop-service".into(), "".into()); + crate::rendezvous_mediator::RendezvousMediator::restart(); + } + #[cfg(not(target_os = "android"))] + std::thread::spawn(move || start_server(true)); } #[cfg(target_os = "android")] "close_conn" => { diff --git a/src/server/connection.rs b/src/server/connection.rs index fc38ec77f..383c5782b 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -5,7 +5,7 @@ use crate::clipboard_file::*; use crate::common::update_clipboard; use crate::video_service; #[cfg(any(target_os = "android", target_os = "ios"))] -use crate::{common::MOBILE_INFO2, flutter::connection_manager::start_channel}; +use crate::{common::FLUTTER_INFO2, flutter::connection_manager::start_channel}; use crate::{ipc, VERSION}; use hbb_common::{ config::Config, @@ -643,7 +643,7 @@ impl Connection { } #[cfg(target_os = "android")] { - pi.hostname = MOBILE_INFO2.lock().unwrap().clone(); + pi.hostname = FLUTTER_INFO2.lock().unwrap().clone(); pi.platform = "Android".into(); } #[cfg(feature = "hwcodec")] diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 7e08f9855..2aa4f36ec 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -32,10 +32,14 @@ lazy_static::lazy_static! { pub static ref UI_STATUS : Arc> = Arc::new(Mutex::new((0, false, 0, "".to_owned()))); pub static ref OPTIONS : Arc>> = Arc::new(Mutex::new(Config::get_options())); pub static ref ASYNC_JOB_STATUS : Arc> = Default::default(); - pub static ref SENDER : Mutex> = Mutex::new(check_connect_status(true)); pub static ref TEMPORARY_PASSWD : Arc> = Arc::new(Mutex::new("".to_owned())); } +#[cfg(not(any(target_os = "android", target_os = "ios")))] +lazy_static::lazy_static! { + pub static ref SENDER : Mutex> = Mutex::new(check_connect_status(true)); +} + pub fn recent_sessions_updated() -> bool { let mut childs = CHILDS.lock().unwrap(); if childs.0 { @@ -47,7 +51,10 @@ pub fn recent_sessions_updated() -> bool { } pub fn get_id() -> String { - ipc::get_id() + #[cfg(any(target_os = "android", target_os = "ios"))] + return Config::get_id(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] + return ipc::get_id(); } pub fn get_remote_id() -> String { @@ -132,7 +139,7 @@ pub fn get_license() -> String { pub fn get_option(key: String) -> String { #[cfg(any(target_os = "android", target_os = "ios"))] - return Config::get_option(arg); + return Config::get_option(&key); #[cfg(not(any(target_os = "android", target_os = "ios")))] return get_option_(&key); } @@ -243,13 +250,16 @@ pub fn get_sound_inputs() -> Vec { } pub fn set_options(m: HashMap) { - *OPTIONS.lock().unwrap() = m.clone(); - ipc::set_options(m).ok(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + *OPTIONS.lock().unwrap() = m.clone(); + ipc::set_options(m).ok(); + } } pub fn set_option(key: String, value: String) { #[cfg(any(target_os = "android", target_os = "ios"))] - Config::set_option(name.to_owned(), value.to_owned()); + Config::set_option(key, value); #[cfg(not(any(target_os = "android", target_os = "ios")))] { let mut options = OPTIONS.lock().unwrap(); @@ -277,20 +287,26 @@ pub fn install_path() -> String { } pub fn get_socks() -> Vec { - let s = ipc::get_socks(); - match s { - None => Vec::new(), - Some(s) => { - let mut v = Vec::new(); - v.push(s.proxy); - v.push(s.username); - v.push(s.password); - v + #[cfg(any(target_os = "android", target_os = "ios"))] + return Vec::new(); + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + let s = ipc::get_socks(); + match s { + None => Vec::new(), + Some(s) => { + let mut v = Vec::new(); + v.push(s.proxy); + v.push(s.username); + v.push(s.password); + v + } } } } pub fn set_socks(proxy: String, username: String, password: String) { + #[cfg(not(any(target_os = "android", target_os = "ios")))] ipc::set_socks(config::Socks5Server { proxy, username, @@ -357,6 +373,7 @@ pub fn get_mouse_time() -> f64 { return res; } +#[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn check_mouse_time() { let sender = SENDER.lock().unwrap(); allow_err!(sender.send(ipc::Data::MouseMoveTime(0)));