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