Skip to content

Commit

Permalink
Replace objc with objc2 to fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Jan 14, 2025
1 parent 9649e07 commit 406405f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 41 deletions.
33 changes: 4 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mullvad-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ simple-signal = "1.1"
talpid-dbus = { path = "../talpid-dbus" }

[target.'cfg(target_os="macos")'.dependencies]
objc = { version = "0.2.7", features = ["exception", "verify_message"] }
objc2 = { version = "0.5.2", features = ["exception"] }

[target.'cfg(windows)'.dependencies]
ctrlc = "3.0"
Expand Down
28 changes: 17 additions & 11 deletions mullvad-daemon/src/macos_launch_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
//! must be checked so that the user can be directed to approve the launch
//! daemon in the system settings.
use objc::{class, msg_send, sel, sel_impl};
use libc::c_longlong;
use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode};
use std::ffi::CStr;

type Id = *mut objc::runtime::Object;
type Id = *mut AnyObject;

// Framework that contains `SMAppService`.
#[link(name = "ServiceManagement", kind = "framework")]
Expand All @@ -18,18 +19,23 @@ extern "C" {}
#[repr(C)]
#[derive(Debug)]
struct NSOperatingSystemVersion {
major_version: libc::c_longlong,
minor_version: libc::c_longlong,
patch_version: libc::c_longlong,
major_version: c_longlong,
minor_version: c_longlong,
patch_version: c_longlong,
}

/// Implement Objective-C type encoding for the struct. Allows the `objc` crate
/// Implement Objective-C type encoding for the struct. Allows the `objc2` crate
/// to perform function signature matching before performing calls into the Objective-C
/// runtime. This is needed to be able to enable the `verify_message` feature on `objc`.
unsafe impl objc::Encode for NSOperatingSystemVersion {
fn encode() -> objc::Encoding {
unsafe { objc::Encoding::from_str("{?=qqq}") }
}
/// runtime.
unsafe impl Encode for NSOperatingSystemVersion {
const ENCODING: Encoding = Encoding::Struct(
"NSOperatingSystemVersion",
&[Encoding::LongLong, Encoding::LongLong, Encoding::LongLong],
);
}

unsafe impl RefEncode for NSOperatingSystemVersion {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Authorization status of the Mullvad daemon.
Expand Down

0 comments on commit 406405f

Please sign in to comment.