objc2_home_kit/generated/
HMHomeManager.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
8use crate::*;
9
10/// The home data authorization status of the client process.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhomemanagerauthorizationstatus?language=objc)
13// NS_OPTIONS
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct HMHomeManagerAuthorizationStatus(pub NSUInteger);
17bitflags::bitflags! {
18    impl HMHomeManagerAuthorizationStatus: NSUInteger {
19        #[doc(alias = "HMHomeManagerAuthorizationStatusDetermined")]
20        const Determined = 1<<0;
21        #[doc(alias = "HMHomeManagerAuthorizationStatusRestricted")]
22        const Restricted = 1<<1;
23        #[doc(alias = "HMHomeManagerAuthorizationStatusAuthorized")]
24        const Authorized = 1<<2;
25    }
26}
27
28unsafe impl Encode for HMHomeManagerAuthorizationStatus {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for HMHomeManagerAuthorizationStatus {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// Manages collection of one or more homes.
38    ///
39    ///
40    /// This class is responsible for managing a collection of homes.
41    ///
42    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhomemanager?language=objc)
43    #[unsafe(super(NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    pub struct HMHomeManager;
46);
47
48unsafe impl Send for HMHomeManager {}
49
50unsafe impl Sync for HMHomeManager {}
51
52extern_conformance!(
53    unsafe impl NSObjectProtocol for HMHomeManager {}
54);
55
56impl HMHomeManager {
57    extern_methods!(
58        #[unsafe(method(init))]
59        #[unsafe(method_family = init)]
60        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
61
62        /// Delegate that receives updates on the collection of homes.
63        #[unsafe(method(delegate))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn delegate(
66            &self,
67        ) -> Option<Retained<ProtocolObject<dyn HMHomeManagerDelegate>>>;
68
69        /// This is a [weak property][objc2::topics::weak_property].
70        /// Setter for [`delegate`][Self::delegate].
71        #[unsafe(method(setDelegate:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setDelegate(
74            &self,
75            delegate: Option<&ProtocolObject<dyn HMHomeManagerDelegate>>,
76        );
77
78        /// The current authorization status of the application.
79        ///
80        /// The authorization is managed by the system, there is no need to explicitly request authorization.
81        #[unsafe(method(authorizationStatus))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn authorizationStatus(&self) -> HMHomeManagerAuthorizationStatus;
84
85        #[cfg(feature = "HMHome")]
86        /// The primary home for this collection.
87        #[deprecated = "No longer supported."]
88        #[unsafe(method(primaryHome))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn primaryHome(&self) -> Option<Retained<HMHome>>;
91
92        #[cfg(feature = "HMHome")]
93        /// Array of HMHome objects that represents the homes associated with the home manager.
94        ///
95        ///
96        /// When a new home manager is created, this array is initialized as an empty array. It is
97        /// not guaranteed to be filled with the list of homes, represented as HMHome objects,
98        /// until the homeManagerDidUpdateHomes: delegate method has been invoked.
99        #[unsafe(method(homes))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn homes(&self) -> Retained<NSArray<HMHome>>;
102
103        #[cfg(all(feature = "HMHome", feature = "block2"))]
104        /// This method is used to change the primary home.
105        ///
106        ///
107        /// Parameter `home`: New primary home.
108        ///
109        ///
110        /// Parameter `completion`: Block that is invoked once the request is processed.
111        /// The NSError provides more information on the status of the request, error
112        /// will be nil on success.
113        #[deprecated = "No longer supported."]
114        #[unsafe(method(updatePrimaryHome:completionHandler:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn updatePrimaryHome_completionHandler(
117            &self,
118            home: &HMHome,
119            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
120        );
121
122        #[cfg(all(feature = "HMHome", feature = "block2"))]
123        /// Adds a new home to the collection.
124        ///
125        ///
126        /// Parameter `homeName`: Name of the  home to create and add to the collection.
127        ///
128        ///
129        /// Parameter `completion`: Block that is invoked once the request is processed.
130        /// The NSError provides more information on the status of the request, error
131        /// will be nil on success.
132        #[unsafe(method(addHomeWithName:completionHandler:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn addHomeWithName_completionHandler(
135            &self,
136            home_name: &NSString,
137            completion: &block2::DynBlock<dyn Fn(*mut HMHome, *mut NSError)>,
138        );
139
140        #[cfg(all(feature = "HMHome", feature = "block2"))]
141        /// Removes an existing home from the collection.
142        ///
143        ///
144        /// Parameter `home`: Home object that needs to be removed from the collection.
145        ///
146        ///
147        /// Parameter `completion`: Block that is invoked once the request is processed.
148        /// The NSError provides more information on the status of the request, error
149        /// will be nil on success.
150        #[unsafe(method(removeHome:completionHandler:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn removeHome_completionHandler(
153            &self,
154            home: &HMHome,
155            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
156        );
157    );
158}
159
160/// Methods declared on superclass `NSObject`.
161impl HMHomeManager {
162    extern_methods!(
163        #[unsafe(method(new))]
164        #[unsafe(method_family = new)]
165        pub unsafe fn new() -> Retained<Self>;
166    );
167}
168
169extern_protocol!(
170    /// This delegate receives updates on homes being managed via the home manager.
171    ///
172    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhomemanagerdelegate?language=objc)
173    pub unsafe trait HMHomeManagerDelegate: NSObjectProtocol {
174        /// Informs the delegate a change in authorization status has occurred.
175        ///
176        ///
177        /// Parameter `manager`: Sender of this message.
178        ///
179        /// Parameter `status`: The updated authorization status.
180        #[optional]
181        #[unsafe(method(homeManager:didUpdateAuthorizationStatus:))]
182        #[unsafe(method_family = none)]
183        unsafe fn homeManager_didUpdateAuthorizationStatus(
184            &self,
185            manager: &HMHomeManager,
186            status: HMHomeManagerAuthorizationStatus,
187        );
188
189        /// Informs the delegate when homes configured by the user have been detected by the system.
190        ///
191        ///
192        /// This delegate method is also invoked to inform an application of significant changes
193        /// to the home configuration. Applications should use this as a cue to invalidate their
194        /// current references to HomeKit objects and refresh their views with the new list of homes.
195        ///
196        ///
197        /// Parameter `manager`: Sender of this message.
198        #[optional]
199        #[unsafe(method(homeManagerDidUpdateHomes:))]
200        #[unsafe(method_family = none)]
201        unsafe fn homeManagerDidUpdateHomes(&self, manager: &HMHomeManager);
202
203        /// Informs the delegate when the primary home is modified.
204        ///
205        ///
206        /// Parameter `manager`: Sender of this message.
207        #[optional]
208        #[unsafe(method(homeManagerDidUpdatePrimaryHome:))]
209        #[unsafe(method_family = none)]
210        unsafe fn homeManagerDidUpdatePrimaryHome(&self, manager: &HMHomeManager);
211
212        #[cfg(feature = "HMHome")]
213        /// Informs the delegate when a new home is added.
214        ///
215        ///
216        /// Parameter `manager`: Sender of this message.
217        ///
218        ///
219        /// Parameter `home`: New home that was added.
220        #[optional]
221        #[unsafe(method(homeManager:didAddHome:))]
222        #[unsafe(method_family = none)]
223        unsafe fn homeManager_didAddHome(&self, manager: &HMHomeManager, home: &HMHome);
224
225        #[cfg(feature = "HMHome")]
226        /// Informs the delegate when an existing home is removed.
227        ///
228        ///
229        /// Parameter `manager`: Sender of this message.
230        ///
231        ///
232        /// Parameter `home`: Home that was removed.
233        #[optional]
234        #[unsafe(method(homeManager:didRemoveHome:))]
235        #[unsafe(method_family = none)]
236        unsafe fn homeManager_didRemoveHome(&self, manager: &HMHomeManager, home: &HMHome);
237
238        #[cfg(feature = "HMAddAccessoryRequest")]
239        /// Informs the delegate an accessory needs to be added to the home by using one of the
240        /// HMAccessorySetupPayload factory methods on the request parameter.
241        ///
242        ///
243        /// Parameter `manager`: Sender of this message.
244        ///
245        ///
246        /// Parameter `request`: Information for the add accessory request.
247        #[optional]
248        #[unsafe(method(homeManager:didReceiveAddAccessoryRequest:))]
249        #[unsafe(method_family = none)]
250        unsafe fn homeManager_didReceiveAddAccessoryRequest(
251            &self,
252            manager: &HMHomeManager,
253            request: &HMAddAccessoryRequest,
254        );
255    }
256);