Merge pull request #1181 from Heap-Hop/flutter_desktop_merge_master_mobile

Flutter desktop merge master mobile
This commit is contained in:
RustDesk
2022-08-04 18:17:49 +08:00
committed by GitHub
29 changed files with 958 additions and 198 deletions

View File

@@ -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 {
@@ -396,6 +401,7 @@ pub fn main_get_sound_inputs() -> Vec<String> {
}
pub fn main_change_id(new_id: String) {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
change_id(new_id)
}
@@ -467,6 +473,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);
}
@@ -643,25 +650,6 @@ unsafe extern "C" fn get_by_name(name: *const c_char, arg: *const c_char) -> *co
// res = Session::get_option(arg);
// }
// }
"server_id" => {
res = ui_interface::get_id();
}
"temporary_password" => {
res = ui_interface::temporary_password();
}
"permanent_password" => {
res = ui_interface::permanent_password();
}
"connect_statue" => {
res = ONLINE
.lock()
.unwrap()
.values()
.max()
.unwrap_or(&0)
.clone()
.to_string();
}
// File Action
"get_home_dir" => {
res = fs::get_home_as_string();
@@ -682,6 +670,33 @@ unsafe extern "C" fn get_by_name(name: *const c_char, arg: *const c_char) -> *co
// }
// }
// Server Side
"local_option" => {
if let Ok(arg) = arg.to_str() {
res = LocalConfig::get_option(arg);
}
}
"langs" => {
res = crate::lang::LANGS.to_string();
}
"server_id" => {
res = ui_interface::get_id();
}
"temporary_password" => {
res = ui_interface::temporary_password();
}
"permanent_password" => {
res = ui_interface::permanent_password();
}
"connect_statue" => {
res = ONLINE
.lock()
.unwrap()
.values()
.max()
.unwrap_or(&0)
.clone()
.to_string();
}
#[cfg(not(any(target_os = "ios")))]
"clients_state" => {
res = get_clients_state();
@@ -861,9 +876,22 @@ unsafe extern "C" fn set_by_name(name: *const c_char, value: *const c_char) {
// }
// }
// }
"local_option" => {
if let Ok(m) = serde_json::from_str::<HashMap<String, String>>(value) {
if let Some(name) = m.get("name") {
if let Some(value) = m.get("value") {
LocalConfig::set_option(name.to_owned(), value.to_owned());
}
}
}
}
// "input_os_password" => {
// Session::input_os_password(value.to_owned(), true);
// }
"restart_remote_device" => {
// TODO
// Session::restart_remote_device();
}
// // File Action
// "read_remote_dir" => {
// if let Ok(m) = serde_json::from_str::<HashMap<String, String>>(value) {
@@ -1048,8 +1076,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" => {