objc2-media-setup 0.3.2

Bindings to the MediaSetup 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_foundation::*;
#[cfg(feature = "objc2-ui-kit")]
use objc2_ui_kit::*;

use crate::*;

/// A window that presents a Media Setup configuration view.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/mspresentationanchor?language=objc)
#[cfg(feature = "objc2-ui-kit")]
pub type MSPresentationAnchor = UIWindow;

extern_protocol!(
    /// A protocol that provides media setup display information to the system.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/msauthenticationpresentationcontext?language=objc)
    pub unsafe trait MSAuthenticationPresentationContext: NSObjectProtocol {
        #[cfg(feature = "objc2-ui-kit")]
        /// A window that presents the system’s HomePod configuration view to the user.
        ///
        /// - Returns: The interface element in your app that the system uses to display
        /// HomePod configuration information.
        #[unsafe(method(presentationAnchor))]
        #[unsafe(method_family = none)]
        unsafe fn presentationAnchor(
            &self,
            mtm: MainThreadMarker,
        ) -> Option<Retained<MSPresentationAnchor>>;
    }
);

extern_class!(
    /// An object that manages the transfer of configuration information between
    /// your app, the system, your media service, and HomePod speakers.
    ///
    /// An `MSSetupSession` object guides the user through connecting HomePod
    /// speakers in their home to your media service. When your iOS app calls
    /// ``MSSetupSession/startWithError:``, the session displays a setup view in the
    /// window you provide in
    /// ``MSAuthenticationPresentationContext/presentationAnchor``. The session
    /// embeds your app icon and the ``MSServiceAccount/serviceName`` you provide
    /// into this setup view.
    ///
    /// ![A wireframe showing the setup view Media Setup displays to the user, with
    /// callouts indicating where your app’s icon and your media service’s name
    /// appear.](mssetupsession-1)
    ///
    /// After the user confirms the setup by tapping the “Use in Home” button, the
    /// system requests an OAuth 2.0 token from your authentication service and shares
    /// the token with HomePod speakers in the user’s home.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/mssetupsession?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MSSetupSession;
);

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

impl MSSetupSession {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "MSServiceAccount")]
        /// Creates a new session.
        ///
        /// - Parameters:
        /// - serviceAccount: The streaming media service account to set up on a
        /// HomePod.
        ///
        /// - Returns:
        /// Returns `true` if it successfully presents; otherwise, `false`.
        ///
        /// This method presents user with options to add a service to the home.
        #[unsafe(method(initWithServiceAccount:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithServiceAccount(
            this: Allocated<Self>,
            service_account: &MSServiceAccount,
        ) -> Retained<Self>;

        /// Initiates the service configuration process.
        ///
        /// This method sends the account details of the streaming media service to the user’s HomePod speakers.
        #[unsafe(method(startWithError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn startWithError(&self) -> Result<(), Retained<NSError>>;

        /// A delegate that provides media setup display information to the system.
        #[unsafe(method(presentationContext))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentationContext(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn MSAuthenticationPresentationContext>>>;

        /// Setter for [`presentationContext`][Self::presentationContext].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setPresentationContext:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPresentationContext(
            &self,
            presentation_context: Option<&ProtocolObject<dyn MSAuthenticationPresentationContext>>,
        );

        #[cfg(feature = "MSServiceAccount")]
        /// The streaming media service account for the session to configure.
        #[unsafe(method(account))]
        #[unsafe(method_family = none)]
        pub unsafe fn account(&self) -> Retained<MSServiceAccount>;
    );
}