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