diff --git a/kordophoned/src/xpc/agent.rs b/kordophoned/src/xpc/agent.rs index 226f1b5..3260683 100644 --- a/kordophoned/src/xpc/agent.rs +++ b/kordophoned/src/xpc/agent.rs @@ -1,7 +1,5 @@ use crate::xpc::interface::SERVICE_NAME; -use kordophoned::daemon::settings::Settings; use kordophoned::daemon::{events::Event, signals::Signal, DaemonResult}; -use std::collections::HashMap; use std::ffi::CString; use std::os::raw::c_char; use std::ptr; @@ -15,7 +13,7 @@ pub(super) static LOG_TARGET: &str = "xpc"; /// Wrapper for raw XPC connection pointer to declare cross-thread usage. /// Safety: libxpc connections are reference-counted and may be used to send from other threads. #[derive(Copy, Clone)] -pub(super) struct XpcConn(pub xpc_sys::xpc_connection_t); +pub(crate) struct XpcConn(pub xpc_sys::xpc_connection_t); unsafe impl Send for XpcConn {} unsafe impl Sync for XpcConn {} @@ -110,19 +108,17 @@ impl XpcAgent { let method = super::util::dict_get_str(&map, "method").or_else(|| super::util::dict_get_str(&map, "type")).unwrap_or_else(|| "".to_string()); log::trace!(target: LOG_TARGET, "XPC request received: {}", method); let response = rt_conn.block_on(super::rpc::dispatch(&agent_conn, &conns_for_handler, client, &map)); - let reply = unsafe { xpc_sys::xpc_dictionary_create_reply(msg) }; + let reply = xpc_sys::xpc_dictionary_create_reply(msg); if !reply.is_null() { let payload = message_to_xpc_object(response); let apply_block = ConcreteBlock::new(move |key: *const c_char, value: xpc_sys::xpc_object_t| { - unsafe { xpc_sys::xpc_dictionary_set_value(reply, key, value); } + xpc_sys::xpc_dictionary_set_value(reply, key, value); }) .copy(); - unsafe { - xpc_sys::xpc_dictionary_apply(payload, apply_block.deref() as *const _ as *mut _); - xpc_sys::xpc_connection_send_message(client, reply); - xpc_sys::xpc_release(payload); - xpc_sys::xpc_release(reply); - } + xpc_sys::xpc_dictionary_apply(payload, apply_block.deref() as *const _ as *mut _); + xpc_sys::xpc_connection_send_message(client, reply); + xpc_sys::xpc_release(payload); + xpc_sys::xpc_release(reply); log::trace!(target: LOG_TARGET, "XPC reply sent for method: {}", method); } else { log::warn!(target: LOG_TARGET, "No reply port for method: {}", method);