feat: insert core entry before launching flutter

This commit is contained in:
SoLongAndThanksForAllThePizza
2022-05-30 16:16:20 +08:00
parent 3a1bbc260b
commit 7cd0940661
4 changed files with 55 additions and 4 deletions

13
src/core_main.rs Normal file
View File

@@ -0,0 +1,13 @@
/// Main entry of the RustDesk Core.
/// Return true if the app should continue running with UI(possibly Flutter), false if the app should exit.
pub fn core_main() -> bool {
let args = std::env::args().collect::<Vec<_>>();
// TODO: implement core_main()
if args.len() > 1 {
if args[1] == "--cm" {
// For test purpose only, this should stop any new window from popping up when a new connection is established.
return false;
}
}
true
}

View File

@@ -52,6 +52,13 @@ fn initialize(app_dir: &str) {
}
}
/// FFI for rustdesk core's main entry.
/// 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()
}
pub fn start_event_stream(s: StreamSink<String>) -> ResultType<()> {
let _ = flutter::EVENT_STREAM.write().unwrap().insert(s);
Ok(())

View File

@@ -28,6 +28,11 @@ pub mod flutter;
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
pub mod flutter_ffi;
use common::*;
#[cfg(all(
not(any(target_os = "android", target_os = "ios")),
feature = "flutter"
))]
pub mod core_main;
#[cfg(feature = "cli")]
pub mod cli;
#[cfg(all(windows, feature = "hbbs"))]