From 25f37577c3248c1e20607b6c450bff99e82397b1 Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 16 May 2023 16:19:06 +0800 Subject: [PATCH] refactor elevate on macOS Signed-off-by: fufesou --- src/plugin/manager.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/plugin/manager.rs b/src/plugin/manager.rs index 981ef456e..9fd4dfceb 100644 --- a/src/plugin/manager.rs +++ b/src/plugin/manager.rs @@ -186,6 +186,19 @@ fn elevate_install( crate::platform::elevate(args) } +#[cfg(target_os = "macos")] +fn elevate_install( + plugin_id: &str, + plugin_url: &str, + same_plugin_exists: bool, +) -> ResultType { + let mut args = vec!["--plugin-install", plugin_id]; + if !same_plugin_exists { + args.push(&plugin_url); + } + crate::platform::elevate(args, "RustDesk wants to install then plugin") +} + #[inline] #[cfg(target_os = "windows")] fn elevate_uninstall(plugin_id: &str) -> ResultType { @@ -193,11 +206,20 @@ fn elevate_uninstall(plugin_id: &str) -> ResultType { } #[inline] -#[cfg(any(target_os = "linux", target_os = "macos"))] -fn elevate_install(plugin_id: &str) -> ResultType { +#[cfg(target_os = "linux")] +fn elevate_uninstall(plugin_id: &str) -> ResultType { crate::platform::elevate(vec!["--plugin-uninstall", plugin_id]) } +#[inline] +#[cfg(target_os = "macos")] +fn elevate_uninstall(plugin_id: &str) -> ResultType { + crate::platform::elevate( + vec!["--plugin-uninstall", plugin_id], + "RustDesk wants to uninstall the plugin", + ) +} + pub fn install_plugin(id: &str) -> ResultType<()> { match PLUGIN_INFO.lock().unwrap().get(id) { Some(plugin) => {