From efcaf4b970d45343e0b6a4437bccefd6ecd87a94 Mon Sep 17 00:00:00 2001 From: Huge_Black Date: Mon, 31 Mar 2025 09:33:37 +0800 Subject: [PATCH] remove "proxy" and run cargo fmt --- ffi/src/lib.rs | 2 +- ffi/src/sbservices.rs | 26 +++++++++----------------- idevice/src/lib.rs | 4 ++-- idevice/src/sbservices/mod.rs | 8 +++----- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index 96f6752..ced26b9 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -14,8 +14,8 @@ pub mod process_control; pub mod provider; pub mod remote_server; pub mod remotexpc; -pub mod usbmuxd; pub mod sbservices; +pub mod usbmuxd; pub mod util; pub use errors::*; diff --git a/ffi/src/sbservices.rs b/ffi/src/sbservices.rs index 4ac8d7f..b722897 100644 --- a/ffi/src/sbservices.rs +++ b/ffi/src/sbservices.rs @@ -1,4 +1,4 @@ -use std::ffi::{c_void, CStr}; +use std::ffi::{CStr, c_void}; use idevice::{IdeviceError, IdeviceService, sbservices::SpringBoardServicesClient}; @@ -13,7 +13,7 @@ pub struct SpringBoardServicesClientHandle(pub SpringBoardServicesClient); pub struct plist_t; #[unsafe(no_mangle)] -pub unsafe extern "C" fn springboard_services_proxy_connect_tcp( +pub unsafe extern "C" fn springboard_services_connect_tcp( provider: *mut TcpProviderHandle, client: *mut *mut SpringBoardServicesClientHandle, ) -> IdeviceErrorCode { @@ -53,7 +53,7 @@ pub unsafe extern "C" fn springboard_services_proxy_connect_tcp( } #[unsafe(no_mangle)] -pub unsafe extern "C" fn springboard_services_proxy_connect_usbmuxd( +pub unsafe extern "C" fn springboard_services_connect_usbmuxd( provider: *mut UsbmuxdProviderHandle, client: *mut *mut SpringBoardServicesClientHandle, ) -> IdeviceErrorCode { @@ -88,7 +88,7 @@ pub unsafe extern "C" fn springboard_services_proxy_connect_usbmuxd( } #[unsafe(no_mangle)] -pub unsafe extern "C" fn springboard_services_proxy_new( +pub unsafe extern "C" fn springboard_services_new( socket: *mut IdeviceHandle, client: *mut *mut SpringBoardServicesClientHandle, ) -> IdeviceErrorCode { @@ -116,7 +116,7 @@ pub unsafe extern "C" fn springboard_services_proxy_new( /// `client` must be a valid pointer to a handle allocated by this library /// `out_result` must be a valid, non-null pointer to a location where the result will be stored #[unsafe(no_mangle)] -pub unsafe extern "C" fn springboard_services_proxy_get_icon( +pub unsafe extern "C" fn springboard_services_get_icon( client: *mut SpringBoardServicesClientHandle, bundle_identifier: *const libc::c_char, out_result: *mut *mut c_void, @@ -128,16 +128,14 @@ pub unsafe extern "C" fn springboard_services_proxy_get_icon( } let client = unsafe { &mut *client }; - let name_cstr = unsafe { CStr::from_ptr(bundle_identifier) }; let bundle_id = match name_cstr.to_str() { Ok(s) => s.to_string(), Err(_) => return IdeviceErrorCode::InvalidArg, }; - let res: Result, IdeviceError> = RUNTIME.block_on(async { - client.0.get_icon_pngdata(bundle_id).await - }); + let res: Result, IdeviceError> = + RUNTIME.block_on(async { client.0.get_icon_pngdata(bundle_id).await }); match res { Ok(r) => { @@ -156,16 +154,10 @@ pub unsafe extern "C" fn springboard_services_proxy_get_icon( } } - - - - #[unsafe(no_mangle)] -pub unsafe extern "C" fn springboard_services_proxy_free( - handle: *mut SpringBoardServicesClientHandle, -) { +pub unsafe extern "C" fn springboard_services_free(handle: *mut SpringBoardServicesClientHandle) { if !handle.is_null() { - log::debug!("Freeing springboard_services_proxy_client"); + log::debug!("Freeing springboard_services_client"); let _ = unsafe { Box::from_raw(handle) }; } } diff --git a/idevice/src/lib.rs b/idevice/src/lib.rs index 5634823..3c6d03e 100644 --- a/idevice/src/lib.rs +++ b/idevice/src/lib.rs @@ -19,6 +19,8 @@ pub mod misagent; pub mod mounter; pub mod pairing_file; pub mod provider; +#[cfg(feature = "sbservices")] +pub mod sbservices; #[cfg(feature = "tunnel_tcp_stack")] pub mod tcp; #[cfg(feature = "tss")] @@ -30,8 +32,6 @@ pub mod usbmuxd; mod util; #[cfg(feature = "xpc")] pub mod xpc; -#[cfg(feature = "sbservices")] -pub mod sbservices; use log::{debug, error, trace}; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; diff --git a/idevice/src/sbservices/mod.rs b/idevice/src/sbservices/mod.rs index ed40723..52943e7 100644 --- a/idevice/src/sbservices/mod.rs +++ b/idevice/src/sbservices/mod.rs @@ -1,7 +1,7 @@ use crate::{lockdownd::LockdowndClient, Idevice, IdeviceError, IdeviceService}; pub struct SpringBoardServicesClient { - pub idevice: Idevice + pub idevice: Idevice, } impl IdeviceService for SpringBoardServicesClient { @@ -40,7 +40,7 @@ impl SpringBoardServicesClient { /// `bundle_identifier` - The identifier of the app to get icon pub async fn get_icon_pngdata( &mut self, - bundle_identifier: String + bundle_identifier: String, ) -> Result, IdeviceError> { let mut req = plist::Dictionary::new(); req.insert("command".into(), "getIconPNGData".into()); @@ -51,9 +51,7 @@ impl SpringBoardServicesClient { let mut res = self.idevice.read_plist().await?; match res.remove("pngData") { - Some(plist::Value::Data(res)) => { - Ok(res) - } + Some(plist::Value::Data(res)) => Ok(res), _ => Err(IdeviceError::UnexpectedResponse), } }