objc2-security-interface 0.3.2

Bindings to the SecurityInterface framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_app_kit::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-security")]
use objc2_security::*;

use crate::*;

extern_class!(
    /// SFCertificateView is a NSView that displays the contents of a certificate.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfcertificateview?language=objc)
    #[unsafe(super(NSVisualEffectView, NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFCertificateView;
);

extern_conformance!(
    unsafe impl NSAccessibility for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSAppearanceCustomization for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSCoding for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSDraggingDestination for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for SFCertificateView {}
);

extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for SFCertificateView {}
);

impl SFCertificateView {
    extern_methods!(
        #[cfg(feature = "objc2-security")]
        /// Specifies the certificate that's displayed in the view.
        ///
        /// Parameter `certificate`: The new certificate for the view.
        ///
        /// # Safety
        ///
        /// `certificate` might not allow `None`.
        #[unsafe(method(setCertificate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCertificate(&self, certificate: Option<&SecCertificate>);

        #[cfg(feature = "objc2-security")]
        /// Returns the certificate currently displayed in the view.
        #[unsafe(method(certificate))]
        #[unsafe(method_family = none)]
        pub unsafe fn certificate(&self) -> Option<Retained<SecCertificate>>;

        /// Specifies one or more policies that apply to the displayed certificate.
        ///
        /// Parameter `policies`: The policies to use when evaluating this certificate's status.
        /// You can pass either a SecPolicyRef or a NSArray (containing one or more SecPolicyRef instances) in this parameter.
        /// If policies is set to nil, the Apple X.509 Basic Policy will be used.
        ///
        /// Applications will typically display a SFCertificateView in the context of a specific usage, such as SSL or S/MIME.
        /// You should set only the policy references which apply to your intended usage.
        ///
        /// # Safety
        ///
        /// - `policies` should be of the correct type.
        /// - `policies` might not allow `None`.
        #[unsafe(method(setPolicies:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPolicies(&self, policies: Option<&AnyObject>);

        /// Returns an array of policies used to evaluate the status of the displayed certificate.
        ///
        /// This method returns an autoreleased NSArray containing one or more SecPolicyRef instances, as set by a previous
        /// setPolicies: call. The array will always contain at least one item (the Apple X.509 Basic Policy).
        #[unsafe(method(policies))]
        #[unsafe(method_family = none)]
        pub unsafe fn policies(&self) -> Option<Retained<NSArray>>;

        /// Specifies whether the user can edit the certificate's trust settings.
        ///
        /// Parameter `editable`: Pass YES if the trust settings should be editable.
        #[unsafe(method(setEditableTrust:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEditableTrust(&self, editable: bool);

        /// Indicates if the view allows the user to edit the certificate's trust.
        #[unsafe(method(isEditable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEditable(&self) -> bool;

        /// Specifies whether the user can see the certificate's trust settings.
        ///
        /// Parameter `display`: Pass YES to display the trust settings, or NO to hide them.
        ///
        /// Certificate trust settings are not displayed by default.
        /// To show the certificate's trust settings, you must explicitly set the display value to YES.
        #[unsafe(method(setDisplayTrust:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisplayTrust(&self, display: bool);

        /// Indicates if the view currently shows the certificate's trust settings.
        #[unsafe(method(isTrustDisplayed))]
        #[unsafe(method_family = none)]
        pub unsafe fn isTrustDisplayed(&self) -> bool;

        /// Saves the user's current trust settings for the displayed certificate.
        ///
        /// If trust settings are not editable, this method effectively does nothing.
        /// You can use SecTrustGetUserTrust (see
        /// <Security
        /// /SecTrust.h>) to subsequently retrieve the trust settings.
        #[unsafe(method(saveTrustSettings))]
        #[unsafe(method_family = none)]
        pub unsafe fn saveTrustSettings(&self);

        /// Specifies whether the user can see the certificate's entire contents.
        ///
        /// Parameter `display`: Pass YES to display the certificate's details, or NO to hide them.
        ///
        /// For behavioral compatibility with Panther, certificate details are displayed by default.
        /// To hide the details of a certificate, you must explicitly set the display value to NO.
        #[unsafe(method(setDisplayDetails:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDisplayDetails(&self, display: bool);

        /// Indicates if the view currently shows the certificate's details.
        #[unsafe(method(detailsDisplayed))]
        #[unsafe(method_family = none)]
        pub unsafe fn detailsDisplayed(&self) -> bool;

        /// Specifies whether the certificate details subview is disclosed (i.e. the triangle is turned down).
        ///
        /// Parameter `disclosed`: Pass YES to disclose the certificate details subview, or NO to collapse it.
        ///
        /// By default, the certificate details subview is not disclosed.
        /// Note that changing the disclosure state of a line item does not affect whether the item itself is shown;
        /// use setDisplayDetails: to cause it to be displayed or hidden.
        #[unsafe(method(setDetailsDisclosed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDetailsDisclosed(&self, disclosed: bool);

        /// Indicates if the view currently discloses the certificate's details.
        #[unsafe(method(detailsDisclosed))]
        #[unsafe(method_family = none)]
        pub unsafe fn detailsDisclosed(&self) -> bool;

        /// Specifies whether the trust policy settings are disclosed (i.e. the triangle is turned down).
        ///
        /// Parameter `disclosed`: Pass YES to disclose the trust policies subview, or NO to collapse it.
        ///
        /// By default, the trust policies subview is not disclosed.
        /// Note that changing the disclosure state of a line item does not affect whether the item itself is shown;
        /// use setDisplayTrust: to cause it to be displayed or hidden.
        #[unsafe(method(setPoliciesDisclosed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPoliciesDisclosed(&self, disclosed: bool);

        /// Indicates if the view currently discloses the trust policy settings.
        #[unsafe(method(policiesDisclosed))]
        #[unsafe(method_family = none)]
        pub unsafe fn policiesDisclosed(&self) -> bool;
    );
}

/// Methods declared on superclass `NSView`.
impl SFCertificateView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
impl SFCertificateView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl SFCertificateView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfcertificateviewdisclosurestatedidchange?language=objc)
    pub static SFCertificateViewDisclosureStateDidChange: Option<&'static NSString>;
}