objc2_io_bluetooth_ui/generated/objc2/IOBluetoothDeviceSelectorController.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_app_kit::*;
7use objc2_foundation::*;
8#[cfg(feature = "objc2-io-bluetooth")]
9use objc2_io_bluetooth::*;
10
11use crate::*;
12
13extern_class!(
14 /// A NSWindowController subclass to display a window to initiate pairing to other bluetooth devices.
15 ///
16 /// Implementation of a window controller to return a NSArray of selected bluetooth devices. This
17 /// class will handle connecting to the Bluetooth Daemon for the purposes of searches, and displaying
18 /// the results. This controller will return a NSArray of IOBluetoothDevice objects to the user.
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetoothui/iobluetoothdeviceselectorcontroller?language=objc)
21 #[unsafe(super(NSWindowController, NSResponder, NSObject))]
22 #[derive(Debug, PartialEq, Eq, Hash)]
23 pub struct IOBluetoothDeviceSelectorController;
24);
25
26extern_conformance!(
27 unsafe impl NSCoding for IOBluetoothDeviceSelectorController {}
28);
29
30extern_conformance!(
31 unsafe impl NSObjectProtocol for IOBluetoothDeviceSelectorController {}
32);
33
34extern_conformance!(
35 unsafe impl NSSeguePerforming for IOBluetoothDeviceSelectorController {}
36);
37
38impl IOBluetoothDeviceSelectorController {
39 extern_methods!(
40 /// Method call to instantiate a new IOBluetoothDeviceSelectorController object.
41 ///
42 /// Returns: Success - a new instance of the device selector Controller
43 /// Failure - nil
44 #[unsafe(method(deviceSelector))]
45 #[unsafe(method_family = none)]
46 pub unsafe fn deviceSelector(
47 mtm: MainThreadMarker,
48 ) -> Option<Retained<IOBluetoothDeviceSelectorController>>;
49
50 /// Runs the device selector panel in a modal session to allow the user to select a Bluetooth device.
51 ///
52 /// The controller will use the panel attributes to filter what devices the user sees. The allowed UUIDs
53 /// will be used to validate the selection the user makes. Only when a selection has been validated (or
54 /// the panel cancelled), will this method return.
55 ///
56 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
57 ///
58 /// Returns: Returns kIOBluetoothUISuccess if a successful, validated device selection was made by the user.
59 /// Returns kIOBluetoothUIUserCanceledErr if the user cancelled the panel. These return values are the
60 /// same as NSRunStoppedResponse and NSRunAbortedResponse respectively. They are the standard values
61 /// used in a modal session.
62 #[unsafe(method(runModal))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn runModal(&self) -> c_int;
65
66 /// Runs the device selector panel as a sheet on the target window.
67 ///
68 /// This function works the same way as -[NSApplication beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:].
69 /// The didEndSelector has a similar prototype as in NSApplication except that the first argument is the
70 /// IOBluetoothDeviceSelectorController object instead of the window:
71 /// -(void)sheetDidEnd:(IOBluetoothDeviceSelectorController *)controller returnCode:(int)returnCode contextInfo:(void *)contextInfo.
72 /// The returnCode parameter will either be kIOBluetoothUISuccess or kIOBluetoothUIUserCancelledErr as described in
73 /// -runModal.
74 ///
75 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
76 ///
77 /// Parameter `sheetWindow`: NSWindow to attach the device selector panel to as a sheet.
78 ///
79 /// Parameter `modalDelegate`: Delegate object that gets sent the didEndSelector when the sheet modal session is finished.
80 ///
81 /// Parameter `didEndSelector`: Selector sent to the modalDelegate when the sheet modal session is finished.
82 ///
83 /// Parameter `contextInfo`: User-definied value passed to the modalDelegate in the didEndSelector.
84 ///
85 /// Returns: Returns kIOReturnSuccess if the sheet modal session was started.
86 ///
87 /// # Safety
88 ///
89 /// - `sheet_window` might not allow `None`.
90 /// - `modal_delegate` should be of the correct type.
91 /// - `modal_delegate` might not allow `None`.
92 /// - `did_end_selector` must be a valid selector.
93 /// - `context_info` must be a valid pointer.
94 #[unsafe(method(beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo(
97 &self,
98 sheet_window: Option<&NSWindow>,
99 modal_delegate: Option<&AnyObject>,
100 did_end_selector: Option<Sel>,
101 context_info: *mut c_void,
102 ) -> IOReturn;
103
104 /// Returns the result of the user's selection.
105 ///
106 /// There will only be results if the panel has been run, the user has successfully made a selection and that
107 /// selection has been validated. If kIOBluetoothUISuccess was returned for the session, there should be valid
108 /// results. Currently only a single device is allowed to be selected, so the results array will only contain
109 /// one object. However in the future multiple selection will be supported.
110 ///
111 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
112 ///
113 /// Returns: Returns an NSArray of IOBluetoothDevice objects corresponding to the user's selection. If the user cancelled
114 /// the panel, nil will be returned.
115 #[unsafe(method(getResults))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn getResults(&self) -> Option<Retained<NSArray>>;
118
119 #[cfg(feature = "IOBluetoothUIUserLib")]
120 /// Sets the option bits that control the panel's behavior.
121 ///
122 /// The service browser controller options control the behavior of the panel. Currently
123 /// kIOBluetoothServiceBrowserControllerOptionsAutoStartInquiry is the only supported option.
124 /// In the future more options will be added to control things like whether the connection to
125 /// the device is closed when the controller is finished or if multiple selection is allowed.
126 ///
127 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
128 ///
129 /// Parameter `options`: Options to control the panel's behavior.
130 #[unsafe(method(setOptions:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn setOptions(&self, options: IOBluetoothServiceBrowserControllerOptions);
133
134 #[cfg(feature = "IOBluetoothUIUserLib")]
135 /// Returns the option bits that control the panel's behavior.
136 ///
137 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
138 ///
139 /// Returns: Returns the option bits set by setOptions:
140 #[unsafe(method(getOptions))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn getOptions(&self) -> IOBluetoothServiceBrowserControllerOptions;
143
144 #[cfg(feature = "objc2-io-bluetooth")]
145 /// Sets the search attributes that control the panel's search/inquiry behavior.
146 ///
147 /// The device search attributes control the inquiry behavior of the panel. They allow only devices
148 /// that match the specified attributes (i.e. class of device) to be displayed to the user. Note that
149 /// this only covers attributes returned in an inquiry result and not actual SDP services on the device.
150 ///
151 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
152 ///
153 /// Parameter `searchAttributes`: Attributes to control the panel's inquiry behavior.
154 ///
155 /// # Safety
156 ///
157 /// `search_attributes` must be a valid pointer.
158 #[unsafe(method(setSearchAttributes:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn setSearchAttributes(
161 &self,
162 search_attributes: *const IOBluetoothDeviceSearchAttributes,
163 );
164
165 #[cfg(feature = "objc2-io-bluetooth")]
166 /// Returns the search attributes that control the panel's search/inquiry behavior.
167 ///
168 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
169 ///
170 /// Returns: Returns the search attributes set by setSearchAttributes:
171 ///
172 /// # Safety
173 ///
174 /// The returned struct field 4 struct field 2 Array TODO.
175 #[unsafe(method(getSearchAttributes))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn getSearchAttributes(&self) -> *const IOBluetoothDeviceSearchAttributes;
178
179 #[cfg(feature = "objc2-io-bluetooth")]
180 /// Adds a UUID to the list of UUIDs that are used to validate the user's selection.
181 ///
182 /// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
183 /// addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the
184 /// selected device gets validated with. If any of the filters match, the device is considered
185 /// valid. If they all fail, the device is not valid and the user is presented with an
186 /// error code that the device does not support the required services. The UUID passed to
187 /// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
188 /// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
189 /// present.
190 ///
191 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
192 ///
193 /// Parameter `allowedUUID`: UUID that a device may contain to be selected
194 ///
195 /// # Safety
196 ///
197 /// `allowed_uuid` might not allow `None`.
198 #[unsafe(method(addAllowedUUID:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn addAllowedUUID(&self, allowed_uuid: Option<&IOBluetoothSDPUUID>);
201
202 /// Adds an array of UUIDs to the list of UUIDs that are used to validate the user's selection.
203 ///
204 /// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
205 /// addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the
206 /// selected device gets validated with. If any of the filters match, the device is considered
207 /// valid. If they all fail, the device is not valid and the user is presented with an
208 /// error code that the device does not support the required services. The UUID passed to
209 /// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
210 /// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
211 /// present.
212 ///
213 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
214 ///
215 /// Parameter `allowedUUIDArray`: An NSArray of UUIDs that all must be present in a device for it to be selectable.
216 ///
217 /// # Safety
218 ///
219 /// - `allowed_uuid_array` generic should be of the correct type.
220 /// - `allowed_uuid_array` might not allow `None`.
221 #[unsafe(method(addAllowedUUIDArray:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn addAllowedUUIDArray(&self, allowed_uuid_array: Option<&NSArray>);
224
225 /// Resets the controller back to the default state where it will accept any device the user selects.
226 ///
227 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
228 #[unsafe(method(clearAllowedUUIDs))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn clearAllowedUUIDs(&self);
231
232 /// Sets the title of the panel when not run as a sheet.
233 ///
234 /// The panel title should be localized for best user experience.
235 ///
236 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
237 ///
238 /// Parameter `windowTitle`: Title of the device selector panel.
239 ///
240 /// # Safety
241 ///
242 /// `window_title` might not allow `None`.
243 #[unsafe(method(setTitle:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn setTitle(&self, window_title: Option<&NSString>);
246
247 /// Returns the title of the device selector panel (i.e. what was set in -setTitle:).
248 ///
249 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
250 ///
251 /// Returns: Returns the title of the device selector panel.
252 #[unsafe(method(getTitle))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn getTitle(&self) -> Option<Retained<NSString>>;
255
256 /// Sets the header text that appears in the device selector panel.
257 ///
258 /// The description text should be localized for best user experience.
259 ///
260 /// NOTE: This method is only available in Mac OS X 10.9 or later.
261 ///
262 /// Parameter `headerText`: String that appears in the description section of the device selector panel.
263 ///
264 /// # Safety
265 ///
266 /// `header_text` might not allow `None`.
267 #[unsafe(method(setHeader:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn setHeader(&self, header_text: Option<&NSString>);
270
271 /// Returns the header text that appears in the device selector panel (i.e. what was set in -setHeader:).
272 ///
273 /// NOTE: This method is only available in Mac OS X 10.9 or later.
274 ///
275 /// Returns: Returns the header text of the device selector panel.
276 #[unsafe(method(getHeader))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn getHeader(&self) -> Option<Retained<NSString>>;
279
280 /// Sets the description text that appears in the device selector panel.
281 ///
282 /// The description text should be localized for best user experience.
283 ///
284 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
285 ///
286 /// Parameter `descriptionText`: String that appears in the description section of the device selector panel.
287 ///
288 /// # Safety
289 ///
290 /// `description_text` might not allow `None`.
291 #[unsafe(method(setDescriptionText:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn setDescriptionText(&self, description_text: Option<&NSString>);
294
295 /// Returns the description text that appears in the device selector panel (i.e. what was set in -setDescriptionText:).
296 ///
297 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
298 ///
299 /// Returns: Returns the description text of the device selector panel.
300 #[unsafe(method(getDescriptionText))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn getDescriptionText(&self) -> Option<Retained<NSString>>;
303
304 /// Sets the title of the default/select button in the device selector panel.
305 ///
306 /// The prompt text should be localized for best user experience.
307 ///
308 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
309 ///
310 /// Parameter `prompt`: String that appears in the default/select button in the device selector panel.
311 ///
312 /// # Safety
313 ///
314 /// `prompt` might not allow `None`.
315 #[unsafe(method(setPrompt:))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn setPrompt(&self, prompt: Option<&NSString>);
318
319 /// Returns the title of the default/select button in the device selector panel (i.e. what was set in -setPrompt:).
320 ///
321 /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
322 ///
323 /// Returns: Returns the default button title of the device selector panel.
324 #[unsafe(method(getPrompt))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn getPrompt(&self) -> Option<Retained<NSString>>;
327
328 /// Sets the title of the default/cancel button in the device selector panel.
329 ///
330 /// The prompt text should be localized for best user experience.
331 ///
332 /// NOTE: This method is only available in Mac OS X 10.9 or later.
333 ///
334 /// Parameter `prompt`: String that appears in the default/cancel button in the device selector panel.
335 ///
336 /// # Safety
337 ///
338 /// `prompt` might not allow `None`.
339 #[unsafe(method(setCancel:))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn setCancel(&self, prompt: Option<&NSString>);
342
343 /// Returns the title of the default/cancel button in the device selector panel (i.e. what was set in -setPrompt:).
344 ///
345 /// NOTE: This method is only available in Mac OS X 10.9 or later.
346 ///
347 /// Returns: Returns the default cancel button title of the device selector panel.
348 #[unsafe(method(getCancel))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn getCancel(&self) -> Option<Retained<NSString>>;
351 );
352}
353
354/// Methods declared on superclass `NSWindowController`.
355impl IOBluetoothDeviceSelectorController {
356 extern_methods!(
357 #[unsafe(method(initWithWindow:))]
358 #[unsafe(method_family = init)]
359 pub unsafe fn initWithWindow(
360 this: Allocated<Self>,
361 window: Option<&NSWindow>,
362 ) -> Retained<Self>;
363
364 /// # Safety
365 ///
366 /// `coder` possibly has further requirements.
367 #[unsafe(method(initWithCoder:))]
368 #[unsafe(method_family = init)]
369 pub unsafe fn initWithCoder(
370 this: Allocated<Self>,
371 coder: &NSCoder,
372 ) -> Option<Retained<Self>>;
373
374 #[unsafe(method(initWithWindowNibName:))]
375 #[unsafe(method_family = init)]
376 pub unsafe fn initWithWindowNibName(
377 this: Allocated<Self>,
378 window_nib_name: &NSNibName,
379 ) -> Retained<Self>;
380
381 /// # Safety
382 ///
383 /// `owner` should be of the correct type.
384 #[unsafe(method(initWithWindowNibName:owner:))]
385 #[unsafe(method_family = init)]
386 pub unsafe fn initWithWindowNibName_owner(
387 this: Allocated<Self>,
388 window_nib_name: &NSNibName,
389 owner: &AnyObject,
390 ) -> Retained<Self>;
391
392 /// # Safety
393 ///
394 /// `owner` should be of the correct type.
395 #[unsafe(method(initWithWindowNibPath:owner:))]
396 #[unsafe(method_family = init)]
397 pub unsafe fn initWithWindowNibPath_owner(
398 this: Allocated<Self>,
399 window_nib_path: &NSString,
400 owner: &AnyObject,
401 ) -> Retained<Self>;
402 );
403}
404
405/// Methods declared on superclass `NSResponder`.
406impl IOBluetoothDeviceSelectorController {
407 extern_methods!(
408 #[unsafe(method(init))]
409 #[unsafe(method_family = init)]
410 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
411 );
412}
413
414/// Methods declared on superclass `NSObject`.
415impl IOBluetoothDeviceSelectorController {
416 extern_methods!(
417 #[unsafe(method(new))]
418 #[unsafe(method_family = new)]
419 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
420 );
421}