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!(
    /// SFKeychainSavePanel is a panel and sheet interface used to create a keychain using the NSSavePanel UI.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/securityinterface/sfkeychainsavepanel?language=objc)
    #[unsafe(super(NSSavePanel, NSPanel, NSWindow, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFKeychainSavePanel;
);

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

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

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

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

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

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

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

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

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

impl SFKeychainSavePanel {
    extern_methods!(
        /// Returns a global instance of SFKeychainSavePanel object.
        #[unsafe(method(sharedKeychainSavePanel))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedKeychainSavePanel(
            mtm: MainThreadMarker,
        ) -> Option<Retained<SFKeychainSavePanel>>;

        /// Displays a keychain save panel.
        ///
        /// Parameter `path`: The path to where the keychain is created (nil for ~/Library/Keychains).
        ///
        /// Parameter `name`: The keychain name to be automatically filled out in the NSSave panel.
        ///
        /// Returns: a result code returned by NSSavePanel's runModalForDirectory method.
        ///
        /// # Safety
        ///
        /// - `path` might not allow `None`.
        /// - `name` might not allow `None`.
        #[unsafe(method(runModalForDirectory:file:))]
        #[unsafe(method_family = none)]
        pub unsafe fn runModalForDirectory_file(
            &self,
            path: Option<&NSString>,
            name: Option<&NSString>,
        ) -> NSInteger;

        /// Specifies the password for the keychain that will be created.
        ///
        /// Parameter `The`: password string object.
        ///
        /// # Safety
        ///
        /// `password` might not allow `None`.
        #[unsafe(method(setPassword:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPassword(&self, password: Option<&NSString>);

        #[cfg(feature = "objc2-security")]
        /// Returns the keychain created by the SFKeychainSavePanel.
        ///
        /// Returns: The keychain object.
        #[unsafe(method(keychain))]
        #[unsafe(method_family = none)]
        pub unsafe fn keychain(&self) -> Option<Retained<SecKeychain>>;

        /// Returns the last error encountered by SFKeychainSavePanel.
        ///
        /// Returns: The error object.
        #[unsafe(method(error))]
        #[unsafe(method_family = none)]
        pub unsafe fn error(&self) -> Option<Retained<NSError>>;

        /// Displays a keychain save panel as a sheet.
        ///
        /// Parameter `path`: The path to where the keychain is created (nil for ~/Library/Keychains).
        ///
        /// Parameter `name`: The keychain name to be automatically filled out in the NSSave panel.
        ///
        /// Parameter `docWindow`: The panel in which the save sheet slides down; acting as a document modal window. If docWindow is nil, the behavior defaults to a standalone modal window.
        ///
        /// Parameter `delegate`: Delegate object in which didEndSelector is a method.
        ///
        /// Parameter `didEndSelector`: The didEndSelector method is optional. If implemented by the delegate, this method is invoked after the modal session has ended, but before dismissing the same panel. didEndSelector may dismiss the keychain panel itself; otherwise it will be dismissed on return from the method. didEndSelector should have the following signature:
        /// - (void)createPanelDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void  *)contextInfo;
        ///
        /// Parameter `contextInfo`: Client-defined context pointer.
        ///
        /// # Safety
        ///
        /// - `path` might not allow `None`.
        /// - `name` might not allow `None`.
        /// - `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.
        #[unsafe(method(beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo(
            &self,
            path: Option<&NSString>,
            name: Option<&NSString>,
            doc_window: Option<&NSWindow>,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
        );
    );
}

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

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