mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge branch 'rustdesk:master' into master
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use hbb_common::log;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use hbb_common::platform::register_breakdown_handler;
|
||||
|
||||
/// shared by flutter and sciter main function
|
||||
///
|
||||
@@ -38,10 +40,11 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
register_breakdown_handler();
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
crate::platform::linux::register_breakdown_handler();
|
||||
let (k, v) = ("LIBGL_ALWAYS_SOFTWARE", "true");
|
||||
if !hbb_common::config::Config::get_option("allow-always-software-render").is_empty() {
|
||||
std::env::set_var(k, v);
|
||||
@@ -54,11 +57,6 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
return core_main_invoke_new_connection(std::env::args());
|
||||
}
|
||||
let click_setup = cfg!(windows) && args.is_empty() && crate::common::is_setup(&arg_exe);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
{
|
||||
_is_quick_support =
|
||||
cfg!(windows) && args.is_empty() && arg_exe.to_lowercase().ends_with("qs.exe");
|
||||
}
|
||||
if click_setup {
|
||||
args.push("--install".to_owned());
|
||||
flutter_args.push("--install".to_string());
|
||||
@@ -70,6 +68,14 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
println!("{}", crate::VERSION);
|
||||
return None;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
_is_quick_support |= !crate::platform::is_installed()
|
||||
&& args.is_empty()
|
||||
&& (arg_exe.to_lowercase().ends_with("qs.exe")
|
||||
|| (!click_setup && crate::platform::is_elevated(None).unwrap_or(false)));
|
||||
crate::portable_service::client::set_quick_support(_is_quick_support);
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
use hbb_common::env_logger::*;
|
||||
@@ -106,7 +112,8 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
&& !_is_elevate
|
||||
&& !_is_run_as_system
|
||||
{
|
||||
if let Err(e) = crate::portable_service::client::start_portable_service() {
|
||||
use crate::portable_service::client;
|
||||
if let Err(e) = client::start_portable_service(client::StartPara::Direct) {
|
||||
log::error!("Failed to start portable service:{:?}", e);
|
||||
}
|
||||
}
|
||||
@@ -160,9 +167,6 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
#[cfg(feature = "with_rc")]
|
||||
hbb_common::allow_err!(crate::rc::extract_resources(&args[1]));
|
||||
return None;
|
||||
} else if args[0] == "--tray" {
|
||||
crate::tray::start_tray();
|
||||
return None;
|
||||
} else if args[0] == "--portable-service" {
|
||||
crate::platform::elevate_or_run_as_system(
|
||||
click_setup,
|
||||
@@ -179,34 +183,24 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
std::fs::remove_file(&args[1]).ok();
|
||||
return None;
|
||||
}
|
||||
} else if args[0] == "--tray" {
|
||||
crate::tray::start_tray();
|
||||
return None;
|
||||
} else if args[0] == "--service" {
|
||||
log::info!("start --service");
|
||||
crate::start_os_service();
|
||||
return None;
|
||||
} else if args[0] == "--server" {
|
||||
log::info!("start --server with user {}", crate::username());
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
{
|
||||
crate::start_server(true);
|
||||
return None;
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
std::thread::spawn(move || crate::start_server(true));
|
||||
crate::platform::macos::hide_dock();
|
||||
crate::tray::make_tray();
|
||||
return None;
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let handler = std::thread::spawn(move || crate::start_server(true));
|
||||
// Show the tray in linux only when current user is a normal user
|
||||
// [Note]
|
||||
// As for GNOME, the tray cannot be shown in user's status bar.
|
||||
// As for KDE, the tray can be shown without user's theme.
|
||||
if !crate::platform::is_root() {
|
||||
crate::tray::start_tray();
|
||||
}
|
||||
crate::tray::start_tray();
|
||||
// prevent server exit when encountering errors from tray
|
||||
hbb_common::allow_err!(handler.join());
|
||||
}
|
||||
@@ -247,11 +241,7 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
} else if args[0] == "--cm" {
|
||||
// call connection manager to establish connections
|
||||
// meanwhile, return true to call flutter window to show control panel
|
||||
#[cfg(feature = "flutter")]
|
||||
crate::flutter::connection_manager::start_listen_ipc_thread();
|
||||
crate::ui_interface::start_option_status_sync();
|
||||
#[cfg(target_os = "macos")]
|
||||
crate::platform::macos::hide_dock();
|
||||
}
|
||||
}
|
||||
//_async_logger_holder.map(|x| x.flush());
|
||||
@@ -297,18 +287,37 @@ fn import_config(path: &str) {
|
||||
fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<String>> {
|
||||
args.position(|element| {
|
||||
return element == "--connect";
|
||||
})
|
||||
.unwrap();
|
||||
})?;
|
||||
let peer_id = args.next().unwrap_or("".to_string());
|
||||
if peer_id.is_empty() {
|
||||
eprintln!("please provide a valid peer id");
|
||||
return None;
|
||||
}
|
||||
let mut switch_uuid = None;
|
||||
while let Some(item) = args.next() {
|
||||
if item == "--switch_uuid" {
|
||||
switch_uuid = args.next();
|
||||
}
|
||||
}
|
||||
let mut param_array = vec![];
|
||||
if switch_uuid.is_some() {
|
||||
let switch_uuid = switch_uuid.map_or("".to_string(), |p| format!("switch_uuid={}", p));
|
||||
param_array.push(switch_uuid);
|
||||
}
|
||||
|
||||
let params = param_array.join("&");
|
||||
let params_flag = if params.is_empty() { "" } else { "?" };
|
||||
#[allow(unused)]
|
||||
let uni_links = format!(
|
||||
"rustdesk://connection/new/{}{}{}",
|
||||
peer_id, params_flag, params
|
||||
);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
use crate::dbus::invoke_new_connection;
|
||||
|
||||
match invoke_new_connection(peer_id) {
|
||||
match invoke_new_connection(uni_links) {
|
||||
Ok(()) => {
|
||||
return None;
|
||||
}
|
||||
@@ -322,16 +331,21 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winapi::um::winuser::WM_USER;
|
||||
let uni_links = format!("rustdesk://connection/new/{}", peer_id);
|
||||
let res = crate::platform::send_message_to_hnwd(
|
||||
"FLUTTER_RUNNER_WIN32_WINDOW",
|
||||
"RustDesk",
|
||||
(WM_USER + 2) as _, // referred from unilinks desktop pub
|
||||
uni_links.as_str(),
|
||||
true,
|
||||
false,
|
||||
);
|
||||
return if res { None } else { Some(Vec::new()) };
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
return Some(Vec::new());
|
||||
{
|
||||
return if let Err(_) = crate::ipc::send_url_scheme(uni_links) {
|
||||
Some(Vec::new())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user