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!(
    /// SFChooseIdentityPanel is a panel and sheet interface that allows a user to select an identity from a list.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfchooseidentitypanel?language=objc)
    #[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFChooseIdentityPanel;
);

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

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

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

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

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

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

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

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

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

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

        /// Displays a supplied list of identities in a modal panel, returning NSOKButton or NSCancelButton when dismissed.
        /// Use the -identity method to subsequently obtain the identity chosen by the user.
        ///
        /// Parameter `identities`: An array of SecIdentityRef objects, usually obtained from an identity search (see
        /// <Security
        /// /SecIdentitySearch.h>).
        ///
        /// Parameter `message`: Client-defined message string to display in the panel.
        ///
        /// # Safety
        ///
        /// - `identities` generic should be of the correct type.
        /// - `identities` might not allow `None`.
        /// - `message` might not allow `None`.
        #[unsafe(method(runModalForIdentities:message:))]
        #[unsafe(method_family = none)]
        pub unsafe fn runModalForIdentities_message(
            &self,
            identities: Option<&NSArray>,
            message: Option<&NSString>,
        ) -> NSInteger;

        /// Displays a sheet version of the SFChooseIdentityPanel. The didEndSelector returnCode will contain either NSOKButton or NSCancelButton.
        ///
        /// 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 `identities`: An array of SecIdentityRef objects, usually obtained from an identity search (see
        /// <Security
        /// /SecIdentitySearch.h>).
        ///
        /// Parameter `message`: Client-defined message string to display in the panel.
        ///
        /// The didEndSelector method should have the following signature:
        /// - (void)chooseIdentitySheetDidEnd:(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.
        /// - `identities` generic should be of the correct type.
        /// - `identities` might not allow `None`.
        /// - `message` might not allow `None`.
        #[unsafe(method(beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:identities:message:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginSheetForWindow_modalDelegate_didEndSelector_contextInfo_identities_message(
            &self,
            doc_window: Option<&NSWindow>,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
            identities: Option<&NSArray>,
            message: Option<&NSString>,
        );

        #[cfg(feature = "objc2-security")]
        /// Returns the identity that the user chose in the panel.
        #[unsafe(method(identity))]
        #[unsafe(method_family = none)]
        pub unsafe fn identity(&self) -> Option<Retained<SecIdentity>>;

        /// 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 SFChooseIdentityPanel 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>>;

        /// Sets the optional informative text displayed in the SFChooseIdentityPanel.
        ///
        /// Parameter `informativeText`: The informative text to display in the panel.
        ///
        /// Call this method to set the informative text to be displayed.
        ///
        /// # Safety
        ///
        /// `informative_text` might not allow `None`.
        #[unsafe(method(setInformativeText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInformativeText(&self, informative_text: Option<&NSString>);

        /// Returns the informative text currently displayed in the SFChooseIdentityPanel.
        #[unsafe(method(informativeText))]
        #[unsafe(method_family = none)]
        pub unsafe fn informativeText(&self) -> Option<Retained<NSString>>;

        /// Sets an optional domain in which the identity is to be used.
        ///
        /// Parameter `domainString`: A string containing a hostname, RFC822 name (email address), URL, or similar identifier.
        ///
        /// Call this method to associate a domain with the chosen identity.
        /// If the user chooses an identity and a domain has been set, an identity preference item will be created in the default keychain. Subsequently, calling SecIdentitySearchCreateWithPolicy and SecIdentitySearchCopyNext will return the preferred identity for this domain first.
        ///
        /// # Safety
        ///
        /// `domain_string` might not allow `None`.
        #[unsafe(method(setDomain:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDomain(&self, domain_string: Option<&NSString>);

        /// Returns the domain which will be associated with the chosen identity.
        #[unsafe(method(domain))]
        #[unsafe(method_family = none)]
        pub unsafe fn domain(&self) -> Option<Retained<NSString>>;
    );
}

/// Methods declared on superclass `NSWindow`.
impl SFChooseIdentityPanel {
    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 SFChooseIdentityPanel {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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

mod private_NSObjectSFChooseIdentityPanelDelegate {
    pub trait Sealed {}
}

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

impl private_NSObjectSFChooseIdentityPanelDelegate::Sealed for NSObject {}
unsafe impl NSObjectSFChooseIdentityPanelDelegate for NSObject {}