objc2_media_setup/generated/
MSSetupSession.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-ui-kit")]
8use objc2_ui_kit::*;
9
10use crate::*;
11
12/// A window that presents a Media Setup configuration view.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/mspresentationanchor?language=objc)
15#[cfg(feature = "objc2-ui-kit")]
16pub type MSPresentationAnchor = UIWindow;
17
18extern_protocol!(
19    /// A protocol that provides media setup display information to the system.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/msauthenticationpresentationcontext?language=objc)
22    pub unsafe trait MSAuthenticationPresentationContext: NSObjectProtocol {
23        #[cfg(feature = "objc2-ui-kit")]
24        /// A window that presents the system’s HomePod configuration view to the user.
25        ///
26        /// - Returns: The interface element in your app that the system uses to display
27        /// HomePod configuration information.
28        #[unsafe(method(presentationAnchor))]
29        #[unsafe(method_family = none)]
30        unsafe fn presentationAnchor(
31            &self,
32            mtm: MainThreadMarker,
33        ) -> Option<Retained<MSPresentationAnchor>>;
34    }
35);
36
37extern_class!(
38    /// An object that manages the transfer of configuration information between
39    /// your app, the system, your media service, and HomePod speakers.
40    ///
41    /// An `MSSetupSession` object guides the user through connecting HomePod
42    /// speakers in their home to your media service. When your iOS app calls
43    /// ``MSSetupSession/startWithError:``, the session displays a setup view in the
44    /// window you provide in
45    /// ``MSAuthenticationPresentationContext/presentationAnchor``. The session
46    /// embeds your app icon and the ``MSServiceAccount/serviceName`` you provide
47    /// into this setup view.
48    ///
49    /// ![A wireframe showing the setup view Media Setup displays to the user, with
50    /// callouts indicating where your app’s icon and your media service’s name
51    /// appear.](mssetupsession-1)
52    ///
53    /// After the user confirms the setup by tapping the “Use in Home” button, the
54    /// system requests an OAuth 2.0 token from your authentication service and shares
55    /// the token with HomePod speakers in the user’s home.
56    ///
57    /// See also [Apple's documentation](https://developer.apple.com/documentation/mediasetup/mssetupsession?language=objc)
58    #[unsafe(super(NSObject))]
59    #[derive(Debug, PartialEq, Eq, Hash)]
60    pub struct MSSetupSession;
61);
62
63extern_conformance!(
64    unsafe impl NSObjectProtocol for MSSetupSession {}
65);
66
67impl MSSetupSession {
68    extern_methods!(
69        #[unsafe(method(init))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
72
73        #[unsafe(method(new))]
74        #[unsafe(method_family = new)]
75        pub unsafe fn new() -> Retained<Self>;
76
77        #[cfg(feature = "MSServiceAccount")]
78        /// Creates a new session.
79        ///
80        /// - Parameters:
81        /// - serviceAccount: The streaming media service account to set up on a
82        /// HomePod.
83        ///
84        /// - Returns:
85        /// Returns `true` if it successfully presents; otherwise, `false`.
86        ///
87        /// This method presents user with options to add a service to the home.
88        #[unsafe(method(initWithServiceAccount:))]
89        #[unsafe(method_family = init)]
90        pub unsafe fn initWithServiceAccount(
91            this: Allocated<Self>,
92            service_account: &MSServiceAccount,
93        ) -> Retained<Self>;
94
95        /// Initiates the service configuration process.
96        ///
97        /// This method sends the account details of the streaming media service to the user’s HomePod speakers.
98        #[unsafe(method(startWithError:_))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn startWithError(&self) -> Result<(), Retained<NSError>>;
101
102        /// A delegate that provides media setup display information to the system.
103        #[unsafe(method(presentationContext))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn presentationContext(
106            &self,
107        ) -> Option<Retained<ProtocolObject<dyn MSAuthenticationPresentationContext>>>;
108
109        /// Setter for [`presentationContext`][Self::presentationContext].
110        ///
111        /// This is a [weak property][objc2::topics::weak_property].
112        #[unsafe(method(setPresentationContext:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setPresentationContext(
115            &self,
116            presentation_context: Option<&ProtocolObject<dyn MSAuthenticationPresentationContext>>,
117        );
118
119        #[cfg(feature = "MSServiceAccount")]
120        /// The streaming media service account for the session to configure.
121        #[unsafe(method(account))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn account(&self) -> Retained<MSServiceAccount>;
124    );
125}