mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 14:07:28 +08:00
try AssociatedBundleIdentifiers per https://developer.apple.com/documentation/servicemanagement/updating-helper-executables-from-earlier-versions-of-macos#Respond-to-changes-in-System-Settings
This commit is contained in:
Submodule libs/hbb_common updated: 57c8a23ab9...bb2d6fa6bd
@@ -25,7 +25,7 @@ use hbb_common::{
|
||||
};
|
||||
use include_dir::{include_dir, Dir};
|
||||
use objc::rc::autoreleasepool;
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
use objc::{class, msg_send, runtime::Object, sel, sel_impl};
|
||||
use scrap::{libc::c_void, quartz::ffi::*};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@@ -171,6 +171,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
|
||||
let agent = format!("{}_server.plist", crate::get_full_name());
|
||||
let agent_plist_file = format!("/Library/LaunchAgents/{}", agent);
|
||||
if !prompt {
|
||||
// in macos 13, there is new way to check if they are running or enabled, https://developer.apple.com/documentation/servicemanagement/updating-helper-executables-from-earlier-versions-of-macos#Respond-to-changes-in-System-Settings
|
||||
if !std::path::Path::new(&format!("/Library/LaunchDaemons/{}", daemon)).exists() {
|
||||
return false;
|
||||
}
|
||||
@@ -296,6 +297,9 @@ fn update_daemon_agent(agent_plist_file: String, update_source_dir: String, sync
|
||||
fn correct_app_name(s: &str) -> String {
|
||||
let s = s.replace("rustdesk", &crate::get_app_name().to_lowercase());
|
||||
let s = s.replace("RustDesk", &crate::get_app_name());
|
||||
if let Some(bundleid) = get_bundle_id() {
|
||||
let s = s.replace("com.carriez.rustdesk", &bundleid);
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
@@ -1052,3 +1056,27 @@ impl WakeLock {
|
||||
.ok_or(anyhow!("no AwakeHandle"))?
|
||||
}
|
||||
}
|
||||
|
||||
fn get_bundle_id() -> Option<String> {
|
||||
unsafe {
|
||||
let bundle: id = msg_send![class!(NSBundle), mainBundle];
|
||||
if bundle.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let bundle_id: id = msg_send![bundle, bundleIdentifier];
|
||||
if bundle_id.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let c_str: *const std::os::raw::c_char = msg_send![bundle_id, UTF8String];
|
||||
if c_str.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let bundle_id_str = std::ffi::CStr::from_ptr(c_str)
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
Some(bundle_id_str)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.carriez.RustDesk_server</string>
|
||||
|
||||
<key>AssociatedBundleIdentifiers</key>
|
||||
<string>com.carriez.rustdesk</string>
|
||||
|
||||
<key>LimitLoadToSessionType</key>
|
||||
<array>
|
||||
<string>LoginWindow</string>
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.carriez.RustDesk_service</string>
|
||||
|
||||
<key>AssociatedBundleIdentifiers</key>
|
||||
<string>com.carriez.rustdesk</string>
|
||||
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>ThrottleInterval</key>
|
||||
|
||||
Reference in New Issue
Block a user