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!(
    /// SFCertificatePanel is a panel and sheet interface that displays one or more certificates.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfcertificatepanel?language=objc)
    #[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFCertificatePanel;
);

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

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

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

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

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

extern_conformance!(
    unsafe impl NSMenuItemValidation for SFCertificatePanel {}
);

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

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

extern_conformance!(
    unsafe impl NSUserInterfaceValidations for SFCertificatePanel {}
);

impl SFCertificatePanel {
    extern_methods!(
        /// Returns a shared instance of SFCertificatePanel.
        ///
        /// If your application can display multiple SFCertificatePanels at once,
        /// you should allocate (alloc) and initialize (init) separate object instances instead of using this class method.
        #[unsafe(method(sharedCertificatePanel))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedCertificatePanel(
            mtm: MainThreadMarker,
        ) -> Option<Retained<SFCertificatePanel>>;

        #[cfg(feature = "objc2-security")]
        /// Displays a certificate chain in a modal panel, returning NSOKButton when dismissed.
        /// This method is preferred over runModalForCertificates, since the SecTrustRef parameter lets you
        /// specify policies that determine whether the certificate is valid within your application's context.
        ///
        /// Parameter `trust`: A trust reference which contains the certificates to display.
        ///
        /// Parameter `showGroup`: Specifies whether additional certificates (other than the leaf certificate) are displayed.
        ///
        /// # Safety
        ///
        /// `trust` might not allow `None`.
        #[unsafe(method(runModalForTrust:showGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn runModalForTrust_showGroup(
            &self,
            trust: Option<&SecTrust>,
            show_group: bool,
        ) -> NSInteger;

        /// Displays one or more specified certificates in a modal panel, returning NSOKButton when dismissed.
        ///
        /// Parameter `certificates`: The certificates to display.
        /// Pass a NSArray containing one or more SecCertificateRef instances in this parameter.
        /// The leaf certificate is assumed to be at index 0; the order of additional certificates in the array is not critical.
        ///
        /// Parameter `showGroup`: Specifies whether additional certificates (other than the leaf certificate) are displayed.
        /// To show only a single certificate, specify only one SecCertificateRef in the array and set showGroup to NO.
        ///
        /// # Safety
        ///
        /// - `certificates` generic should be of the correct type.
        /// - `certificates` might not allow `None`.
        #[unsafe(method(runModalForCertificates:showGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn runModalForCertificates_showGroup(
            &self,
            certificates: Option<&NSArray>,
            show_group: bool,
        ) -> NSInteger;

        #[cfg(feature = "objc2-security")]
        /// Displays a certificate chain in a modal sheet.
        /// This is the preferred sheet method for SFCertificatePanel, since the SecTrustRef parameter lets you
        /// specify policies that determine whether the certificate is valid within your application's context.
        ///
        /// Parameter `docWindow`: The parent window to which the sheet is attached.
        ///
        /// Parameter `modalDelegate`: The object whose didEndSelector method will be called when the sheet is dismissed.
        ///
        /// Parameter `didEndSelector`: This method is called when the sheet is dismissed.
        ///
        /// Parameter `contextInfo`: Client-defined contextual data which will be passed to the didEndSelector method.
        ///
        /// Parameter `trust`: A trust reference which contains the certificates to display.
        ///
        /// Parameter `showGroup`: Specifies whether additional certificates (other than the leaf certificate) are displayed.
        ///
        /// The didEndSelector method should have the following signature:
        /// - (void)certificateSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
        ///
        /// # Safety
        ///
        /// - `doc_window` might not allow `None`.
        /// - `delegate` should be of the correct type.
        /// - `delegate` might not allow `None`.
        /// - `did_end_selector` must be a valid selector.
        /// - `context_info` must be a valid pointer.
        /// - `trust` might not allow `None`.
        #[unsafe(method(beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:trust:showGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginSheetForWindow_modalDelegate_didEndSelector_contextInfo_trust_showGroup(
            &self,
            doc_window: Option<&NSWindow>,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
            trust: Option<&SecTrust>,
            show_group: bool,
        );

        /// Displays one or more specified certificates in a modal sheet.
        ///
        /// Parameter `docWindow`: The parent window to which the sheet is attached.
        ///
        /// Parameter `modalDelegate`: The object whose didEndSelector method will be called when the sheet is dismissed.
        ///
        /// Parameter `didEndSelector`: This method is called when the sheet is dismissed.
        ///
        /// Parameter `contextInfo`: Client-defined contextual data which will be passed to the didEndSelector method.
        ///
        /// Parameter `certificates`: The certificates to display.
        /// Pass a NSArray containing one or more SecCertificateRef instances in this parameter.
        ///
        /// Parameter `showGroup`: Specifies whether additional certificates (other than the leaf certificate) are displayed.
        ///
        /// The didEndSelector method should have the following signature:
        /// - (void)certificateSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
        ///
        /// # Safety
        ///
        /// - `doc_window` might not allow `None`.
        /// - `delegate` should be of the correct type.
        /// - `delegate` might not allow `None`.
        /// - `did_end_selector` must be a valid selector.
        /// - `context_info` must be a valid pointer.
        /// - `certificates` generic should be of the correct type.
        /// - `certificates` might not allow `None`.
        #[unsafe(method(beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:certificates:showGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginSheetForWindow_modalDelegate_didEndSelector_contextInfo_certificates_showGroup(
            &self,
            doc_window: Option<&NSWindow>,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
            certificates: Option<&NSArray>,
            show_group: bool,
        );

        /// Specifies one or more policies that apply to the displayed certificates.
        ///
        /// Parameter `policies`: The policies to use when evaluating the certificates' 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 SFCertificatePanel 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 certificates.
        ///
        /// This method returns an autoreleased NSArray containing one or more SecPolicyRef instances, as set by a previous setPolicies: call.
        #[unsafe(method(policies))]
        #[unsafe(method_family = none)]
        pub unsafe fn policies(&self) -> Option<Retained<NSArray>>;

        /// Customizes the title of the default button.
        ///
        /// Parameter `title`: The new title for the default button.
        ///
        /// # Safety
        ///
        /// `title` might not allow `None`.
        #[unsafe(method(setDefaultButtonTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDefaultButtonTitle(&self, title: Option<&NSString>);

        /// Customizes the title of the alternate button.
        ///
        /// Parameter `title`: The new title for the alternate button. If title is set to nil, the button will not be shown.
        ///
        /// # Safety
        ///
        /// `title` might not allow `None`.
        #[unsafe(method(setAlternateButtonTitle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAlternateButtonTitle(&self, title: Option<&NSString>);

        #[unsafe(method(setShowsHelp:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsHelp(&self, shows_help: bool);

        #[unsafe(method(showsHelp))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsHelp(&self) -> bool;

        /// # Safety
        ///
        /// `anchor` might not allow `None`.
        #[unsafe(method(setHelpAnchor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHelpAnchor(&self, anchor: Option<&NSString>);

        #[unsafe(method(helpAnchor))]
        #[unsafe(method_family = none)]
        pub unsafe fn helpAnchor(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "SFCertificateView")]
        #[unsafe(method(certificateView))]
        #[unsafe(method_family = none)]
        pub unsafe fn certificateView(&self) -> Option<Retained<SFCertificateView>>;
    );
}

/// Methods declared on superclass `NSWindow`.
impl SFCertificatePanel {
    extern_methods!(
        #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContentRect_styleMask_backing_defer(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
        ) -> Retained<Self>;

        #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
            screen: Option<&NSScreen>,
        ) -> Retained<Self>;

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

        /// Convenience method for creating an autoreleased titled window with the given contentViewController. A basic NSWindow with the following attributes is made: titled, closable, resizable, miniaturizable. The window's title is automatically bound to the contentViewController's title. The size of the window can easily be controlled by utilizing autolayout and applying size constraints to the view (or its subviews). The window has isReleasedWhenClosed set to NO, and it must be explicitly retained to keep the window instance alive. To have it automatically be freed when it is closed, do the following: [window retain] and [window setReleasedWhenClosed:YES].
        #[unsafe(method(windowWithContentViewController:))]
        #[unsafe(method_family = none)]
        pub unsafe fn windowWithContentViewController(
            content_view_controller: &NSViewController,
        ) -> Retained<Self>;
    );
}

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

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

mod private_NSObjectSFCertificatePanelDelegate {
    pub trait Sealed {}
}

/// Category "SFCertificatePanelDelegate" on [`NSObject`].
#[doc(alias = "SFCertificatePanelDelegate")]
pub unsafe trait NSObjectSFCertificatePanelDelegate:
    ClassType + Sized + private_NSObjectSFCertificatePanelDelegate::Sealed
{
    extern_methods!(
        /// # Safety
        ///
        /// `sender` might not allow `None`.
        #[unsafe(method(certificatePanelShowHelp:))]
        #[unsafe(method_family = none)]
        unsafe fn certificatePanelShowHelp(&self, sender: Option<&SFCertificatePanel>) -> bool;
    );
}

impl private_NSObjectSFCertificatePanelDelegate::Sealed for NSObject {}
unsafe impl NSObjectSFCertificatePanelDelegate for NSObject {}