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