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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
//! 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_app_kit::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-io-bluetooth")]
use objc2_io_bluetooth::*;
use crate::*;
extern_class!(
/// A NSWindowController subclass to display a window to initiate pairing to other bluetooth devices.
///
/// Implementation of a window controller to return a NSArray of selected bluetooth devices. This
/// class will handle connecting to the Bluetooth Daemon for the purposes of searches, and displaying
/// the results. This controller will return a NSArray of IOBluetoothDevice objects to the user.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetoothui/iobluetoothdeviceselectorcontroller?language=objc)
#[unsafe(super(NSWindowController, NSResponder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct IOBluetoothDeviceSelectorController;
);
extern_conformance!(
unsafe impl NSCoding for IOBluetoothDeviceSelectorController {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for IOBluetoothDeviceSelectorController {}
);
extern_conformance!(
unsafe impl NSSeguePerforming for IOBluetoothDeviceSelectorController {}
);
impl IOBluetoothDeviceSelectorController {
extern_methods!(
/// Method call to instantiate a new IOBluetoothDeviceSelectorController object.
///
/// Returns: Success - a new instance of the device selector Controller
/// Failure - nil
#[unsafe(method(deviceSelector))]
#[unsafe(method_family = none)]
pub unsafe fn deviceSelector(
mtm: MainThreadMarker,
) -> Option<Retained<IOBluetoothDeviceSelectorController>>;
/// Runs the device selector panel in a modal session to allow the user to select a Bluetooth device.
///
/// The controller will use the panel attributes to filter what devices the user sees. The allowed UUIDs
/// will be used to validate the selection the user makes. Only when a selection has been validated (or
/// the panel cancelled), will this method return.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns kIOBluetoothUISuccess if a successful, validated device selection was made by the user.
/// Returns kIOBluetoothUIUserCanceledErr if the user cancelled the panel. These return values are the
/// same as NSRunStoppedResponse and NSRunAbortedResponse respectively. They are the standard values
/// used in a modal session.
#[unsafe(method(runModal))]
#[unsafe(method_family = none)]
pub unsafe fn runModal(&self) -> c_int;
/// Runs the device selector panel as a sheet on the target window.
///
/// This function works the same way as -[NSApplication beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:].
/// The didEndSelector has a similar prototype as in NSApplication except that the first argument is the
/// IOBluetoothDeviceSelectorController object instead of the window:
/// -(void)sheetDidEnd:(IOBluetoothDeviceSelectorController *)controller returnCode:(int)returnCode contextInfo:(void *)contextInfo.
/// The returnCode parameter will either be kIOBluetoothUISuccess or kIOBluetoothUIUserCancelledErr as described in
/// -runModal.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `sheetWindow`: NSWindow to attach the device selector panel to as a sheet.
///
/// Parameter `modalDelegate`: Delegate object that gets sent the didEndSelector when the sheet modal session is finished.
///
/// Parameter `didEndSelector`: Selector sent to the modalDelegate when the sheet modal session is finished.
///
/// Parameter `contextInfo`: User-definied value passed to the modalDelegate in the didEndSelector.
///
/// Returns: Returns kIOReturnSuccess if the sheet modal session was started.
///
/// # Safety
///
/// - `sheet_window` might not allow `None`.
/// - `modal_delegate` should be of the correct type.
/// - `modal_delegate` might not allow `None`.
/// - `did_end_selector` must be a valid selector.
/// - `context_info` must be a valid pointer.
#[unsafe(method(beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:))]
#[unsafe(method_family = none)]
pub unsafe fn beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo(
&self,
sheet_window: Option<&NSWindow>,
modal_delegate: Option<&AnyObject>,
did_end_selector: Option<Sel>,
context_info: *mut c_void,
) -> IOReturn;
/// Returns the result of the user's selection.
///
/// There will only be results if the panel has been run, the user has successfully made a selection and that
/// selection has been validated. If kIOBluetoothUISuccess was returned for the session, there should be valid
/// results. Currently only a single device is allowed to be selected, so the results array will only contain
/// one object. However in the future multiple selection will be supported.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns an NSArray of IOBluetoothDevice objects corresponding to the user's selection. If the user cancelled
/// the panel, nil will be returned.
#[unsafe(method(getResults))]
#[unsafe(method_family = none)]
pub unsafe fn getResults(&self) -> Option<Retained<NSArray>>;
#[cfg(feature = "IOBluetoothUIUserLib")]
/// Sets the option bits that control the panel's behavior.
///
/// The service browser controller options control the behavior of the panel. Currently
/// kIOBluetoothServiceBrowserControllerOptionsAutoStartInquiry is the only supported option.
/// In the future more options will be added to control things like whether the connection to
/// the device is closed when the controller is finished or if multiple selection is allowed.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `options`: Options to control the panel's behavior.
#[unsafe(method(setOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn setOptions(&self, options: IOBluetoothServiceBrowserControllerOptions);
#[cfg(feature = "IOBluetoothUIUserLib")]
/// Returns the option bits that control the panel's behavior.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns the option bits set by setOptions:
#[unsafe(method(getOptions))]
#[unsafe(method_family = none)]
pub unsafe fn getOptions(&self) -> IOBluetoothServiceBrowserControllerOptions;
#[cfg(feature = "objc2-io-bluetooth")]
/// Sets the search attributes that control the panel's search/inquiry behavior.
///
/// The device search attributes control the inquiry behavior of the panel. They allow only devices
/// that match the specified attributes (i.e. class of device) to be displayed to the user. Note that
/// this only covers attributes returned in an inquiry result and not actual SDP services on the device.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `searchAttributes`: Attributes to control the panel's inquiry behavior.
///
/// # Safety
///
/// `search_attributes` must be a valid pointer.
#[unsafe(method(setSearchAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn setSearchAttributes(
&self,
search_attributes: *const IOBluetoothDeviceSearchAttributes,
);
#[cfg(feature = "objc2-io-bluetooth")]
/// Returns the search attributes that control the panel's search/inquiry behavior.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns the search attributes set by setSearchAttributes:
///
/// # Safety
///
/// The returned struct field 4 struct field 2 Array TODO.
#[unsafe(method(getSearchAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn getSearchAttributes(&self) -> *const IOBluetoothDeviceSearchAttributes;
#[cfg(feature = "objc2-io-bluetooth")]
/// Adds a UUID to the list of UUIDs that are used to validate the user's selection.
///
/// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
/// addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the
/// selected device gets validated with. If any of the filters match, the device is considered
/// valid. If they all fail, the device is not valid and the user is presented with an
/// error code that the device does not support the required services. The UUID passed to
/// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
/// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
/// present.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `allowedUUID`: UUID that a device may contain to be selected
///
/// # Safety
///
/// `allowed_uuid` might not allow `None`.
#[unsafe(method(addAllowedUUID:))]
#[unsafe(method_family = none)]
pub unsafe fn addAllowedUUID(&self, allowed_uuid: Option<&IOBluetoothSDPUUID>);
/// Adds an array of UUIDs to the list of UUIDs that are used to validate the user's selection.
///
/// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
/// addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the
/// selected device gets validated with. If any of the filters match, the device is considered
/// valid. If they all fail, the device is not valid and the user is presented with an
/// error code that the device does not support the required services. The UUID passed to
/// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
/// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
/// present.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `allowedUUIDArray`: An NSArray of UUIDs that all must be present in a device for it to be selectable.
///
/// # Safety
///
/// - `allowed_uuid_array` generic should be of the correct type.
/// - `allowed_uuid_array` might not allow `None`.
#[unsafe(method(addAllowedUUIDArray:))]
#[unsafe(method_family = none)]
pub unsafe fn addAllowedUUIDArray(&self, allowed_uuid_array: Option<&NSArray>);
/// Resets the controller back to the default state where it will accept any device the user selects.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
#[unsafe(method(clearAllowedUUIDs))]
#[unsafe(method_family = none)]
pub unsafe fn clearAllowedUUIDs(&self);
/// Sets the title of the panel when not run as a sheet.
///
/// The panel title should be localized for best user experience.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `windowTitle`: Title of the device selector panel.
///
/// # Safety
///
/// `window_title` might not allow `None`.
#[unsafe(method(setTitle:))]
#[unsafe(method_family = none)]
pub unsafe fn setTitle(&self, window_title: Option<&NSString>);
/// Returns the title of the device selector panel (i.e. what was set in -setTitle:).
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns the title of the device selector panel.
#[unsafe(method(getTitle))]
#[unsafe(method_family = none)]
pub unsafe fn getTitle(&self) -> Option<Retained<NSString>>;
/// Sets the header text that appears in the device selector panel.
///
/// The description text should be localized for best user experience.
///
/// NOTE: This method is only available in Mac OS X 10.9 or later.
///
/// Parameter `headerText`: String that appears in the description section of the device selector panel.
///
/// # Safety
///
/// `header_text` might not allow `None`.
#[unsafe(method(setHeader:))]
#[unsafe(method_family = none)]
pub unsafe fn setHeader(&self, header_text: Option<&NSString>);
/// Returns the header text that appears in the device selector panel (i.e. what was set in -setHeader:).
///
/// NOTE: This method is only available in Mac OS X 10.9 or later.
///
/// Returns: Returns the header text of the device selector panel.
#[unsafe(method(getHeader))]
#[unsafe(method_family = none)]
pub unsafe fn getHeader(&self) -> Option<Retained<NSString>>;
/// Sets the description text that appears in the device selector panel.
///
/// The description text should be localized for best user experience.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `descriptionText`: String that appears in the description section of the device selector panel.
///
/// # Safety
///
/// `description_text` might not allow `None`.
#[unsafe(method(setDescriptionText:))]
#[unsafe(method_family = none)]
pub unsafe fn setDescriptionText(&self, description_text: Option<&NSString>);
/// Returns the description text that appears in the device selector panel (i.e. what was set in -setDescriptionText:).
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns the description text of the device selector panel.
#[unsafe(method(getDescriptionText))]
#[unsafe(method_family = none)]
pub unsafe fn getDescriptionText(&self) -> Option<Retained<NSString>>;
/// Sets the title of the default/select button in the device selector panel.
///
/// The prompt text should be localized for best user experience.
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Parameter `prompt`: String that appears in the default/select button in the device selector panel.
///
/// # Safety
///
/// `prompt` might not allow `None`.
#[unsafe(method(setPrompt:))]
#[unsafe(method_family = none)]
pub unsafe fn setPrompt(&self, prompt: Option<&NSString>);
/// Returns the title of the default/select button in the device selector panel (i.e. what was set in -setPrompt:).
///
/// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
///
/// Returns: Returns the default button title of the device selector panel.
#[unsafe(method(getPrompt))]
#[unsafe(method_family = none)]
pub unsafe fn getPrompt(&self) -> Option<Retained<NSString>>;
/// Sets the title of the default/cancel button in the device selector panel.
///
/// The prompt text should be localized for best user experience.
///
/// NOTE: This method is only available in Mac OS X 10.9 or later.
///
/// Parameter `prompt`: String that appears in the default/cancel button in the device selector panel.
///
/// # Safety
///
/// `prompt` might not allow `None`.
#[unsafe(method(setCancel:))]
#[unsafe(method_family = none)]
pub unsafe fn setCancel(&self, prompt: Option<&NSString>);
/// Returns the title of the default/cancel button in the device selector panel (i.e. what was set in -setPrompt:).
///
/// NOTE: This method is only available in Mac OS X 10.9 or later.
///
/// Returns: Returns the default cancel button title of the device selector panel.
#[unsafe(method(getCancel))]
#[unsafe(method_family = none)]
pub unsafe fn getCancel(&self) -> Option<Retained<NSString>>;
);
}
/// Methods declared on superclass `NSWindowController`.
impl IOBluetoothDeviceSelectorController {
extern_methods!(
#[unsafe(method(initWithWindow:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithWindow(
this: Allocated<Self>,
window: Option<&NSWindow>,
) -> Retained<Self>;
/// # Safety
///
/// `coder` possibly has further requirements.
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[unsafe(method(initWithWindowNibName:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithWindowNibName(
this: Allocated<Self>,
window_nib_name: &NSNibName,
) -> Retained<Self>;
/// # Safety
///
/// `owner` should be of the correct type.
#[unsafe(method(initWithWindowNibName:owner:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithWindowNibName_owner(
this: Allocated<Self>,
window_nib_name: &NSNibName,
owner: &AnyObject,
) -> Retained<Self>;
/// # Safety
///
/// `owner` should be of the correct type.
#[unsafe(method(initWithWindowNibPath:owner:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithWindowNibPath_owner(
this: Allocated<Self>,
window_nib_path: &NSString,
owner: &AnyObject,
) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSResponder`.
impl IOBluetoothDeviceSelectorController {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl IOBluetoothDeviceSelectorController {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}