From 644da37a4f02550209455ae28cfb5725db4f68b8 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 9 Jun 2023 22:02:25 +0800 Subject: [PATCH] refactor tray uninstall service --- src/platform/linux.rs | 2 +- src/platform/macos.rs | 2 +- src/platform/windows.rs | 2 +- src/tray.rs | 4 +--- src/ui_interface.rs | 3 ++- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 0981b674d..c0feada73 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -1144,7 +1144,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool { if show_new_window { run_me_with(2); } - std::process::exit(0); + true } pub fn install_service() -> bool { diff --git a/src/platform/macos.rs b/src/platform/macos.rs index fe0987bff..4e2253cd9 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -182,7 +182,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool { false } -pub fn uninstall(show_new_window: bool) -> bool { +pub fn uninstall_service(show_new_window: bool) -> bool { // to-do: do together with win/linux about refactory start/stop service if !is_installed_daemon(false) { return false; diff --git a/src/platform/windows.rs b/src/platform/windows.rs index df783b781..0ca1d4d73 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -2171,7 +2171,7 @@ pub fn uninstall_service(show_new_window: bool) -> bool { return true; } run_after_run_cmds(!show_new_window); - std::process::exit(0); + true } pub fn install_service() -> bool { diff --git a/src/tray.rs b/src/tray.rs index 0cf7d48a4..2aa3a85e5 100644 --- a/src/tray.rs +++ b/src/tray.rs @@ -91,10 +91,8 @@ pub fn make_tray() -> hbb_common::ResultType<()> { if let Ok(event) = menu_channel.try_recv() { if event.id == quit_i.id() { - #[cfg(target_os = "macos")] - crate::platform::macos::uninstall(false); - #[cfg(not(target_os = "macos"))] crate::platform::uninstall_service(false); + *control_flow = ControlFlow::Exit; } else if event.id == open_i.id() { open_func(); } diff --git a/src/ui_interface.rs b/src/ui_interface.rs index cb3d0c9cb..ec2c23bd9 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -274,7 +274,7 @@ pub fn set_option(key: String, value: String) { #[cfg(target_os = "macos")] { let is_stop = value == "Y"; - if is_stop && crate::platform::macos::uninstall(true) { + if is_stop && crate::platform::macos::uninstall_service(true) { return; } } @@ -283,6 +283,7 @@ pub fn set_option(key: String, value: String) { if crate::platform::is_installed() { if value == "Y" { if crate::platform::uninstall_service(true) { + std::process::exit(0); return; } } else {