objc2_io_bluetooth_ui/generated/objc2/
IOBluetoothPairingController.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 handle pairing with a bluetooth device.  This
17    /// class will handle connecting to the Bluetooth Daemon for the purposes of searches, and displaying the results.
18    /// When necessary this class will display a sheet asking the user for a PIN code.  This window will not return
19    /// anything to the caller if it is canceled or if pairing occurs.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetoothui/iobluetoothpairingcontroller?language=objc)
22    #[unsafe(super(NSWindowController, NSResponder, NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct IOBluetoothPairingController;
25);
26
27extern_conformance!(
28    unsafe impl NSCoding for IOBluetoothPairingController {}
29);
30
31extern_conformance!(
32    unsafe impl NSObjectProtocol for IOBluetoothPairingController {}
33);
34
35extern_conformance!(
36    unsafe impl NSSeguePerforming for IOBluetoothPairingController {}
37);
38
39impl IOBluetoothPairingController {
40    extern_methods!(
41        /// Method call to instantiate a new IOBluetoothPairingController object.
42        ///
43        /// Returns: An IOBluetoothPairingController instance.  Call runPanelWithAttributes
44        ///
45        /// Success - a new instance of the Pairing Controller
46        /// Failure    - nil
47        #[unsafe(method(pairingController))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn pairingController(
50            mtm: MainThreadMarker,
51        ) -> Option<Retained<IOBluetoothPairingController>>;
52
53        /// Runs the pairing panel in a modal session to allow the user to select a Bluetooth device.
54        ///
55        /// The controller will use the panel attributes to filter what devices the user sees.  The allowed UUIDs
56        /// will be used to validate the selection the user makes.  Only when a selection has been validated (or
57        /// the panel cancelled) and the device paired, will this method return.
58        ///
59        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
60        ///
61        /// Returns: Returns kIOBluetoothUISuccess if a successful, validated device selection was made by the user and
62        /// that device successfully paired.
63        /// Returns kIOBluetoothUIUserCanceledErr if the user cancelled the panel.  These return values are the
64        /// same as NSRunStoppedResponse and NSRunAbortedResponse respectively.  They are the standard values
65        /// used in a modal session.
66        #[unsafe(method(runModal))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn runModal(&self) -> c_int;
69
70        /// Returns an NSArray of the devices that were paired.
71        ///
72        /// There will only be results if the panel has been run, the user has successfully made a selection, that
73        /// selection has been validated and the selected device paired.  If kIOBluetoothUISuccess was returned for
74        /// the session, there should be valid results.  Currently only a single device is allowed to be selected,
75        /// so the results array will only contain one object.  However in the future multiple selection may be supported.
76        ///
77        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
78        ///
79        /// Returns: Returns an NSArray of IOBluetoothDevice objects of devices that were paired.  If the user cancelled
80        /// the panel, nil will be returned.
81        #[unsafe(method(getResults))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn getResults(&self) -> Option<Retained<NSArray>>;
84
85        #[cfg(feature = "IOBluetoothUIUserLib")]
86        /// Sets the option bits that control the panel's behavior.
87        ///
88        /// The pairing controller options control the behavior of the panel.  Currently
89        /// kIOBluetoothServiceBrowserControllerOptionsAutoStartInquiry is the only supported option.
90        /// In the future more options will be added to control things like whether the connection to
91        /// the device is closed when the controller is finished or if multiple selection is allowed.
92        ///
93        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
94        ///
95        /// Parameter `options`: Options to control the panel's behavior.
96        #[unsafe(method(setOptions:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setOptions(&self, options: IOBluetoothServiceBrowserControllerOptions);
99
100        #[cfg(feature = "IOBluetoothUIUserLib")]
101        /// Returns the option bits that control the panel's behavior.
102        ///
103        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
104        ///
105        /// Returns: Returns the option bits set by setOptions:
106        #[unsafe(method(getOptions))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn getOptions(&self) -> IOBluetoothServiceBrowserControllerOptions;
109
110        #[cfg(feature = "objc2-io-bluetooth")]
111        /// Sets the search attributes that control the panel's search/inquiry behavior.
112        ///
113        /// The device search attributes control the inquiry behavior of the panel.  They allow only devices
114        /// that match the specified attributes (i.e. class of device) to be displayed to the user.  Note that
115        /// this only covers attributes returned in an inquiry result and not actual SDP services on the device.
116        ///
117        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
118        ///
119        /// Parameter `searchAttributes`: Attributes to control the panel's inquiry behavior.
120        ///
121        /// # Safety
122        ///
123        /// `search_attributes` must be a valid pointer.
124        #[unsafe(method(setSearchAttributes:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn setSearchAttributes(
127            &self,
128            search_attributes: *const IOBluetoothDeviceSearchAttributes,
129        );
130
131        #[cfg(feature = "objc2-io-bluetooth")]
132        /// Returns the search attributes that control the panel's search/inquiry behavior.
133        ///
134        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
135        ///
136        /// Returns: Returns the search attributes set by setSearchAttributes:
137        ///
138        /// # Safety
139        ///
140        /// The returned struct field 4 struct field 2 Array TODO.
141        #[unsafe(method(getSearchAttributes))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn getSearchAttributes(&self) -> *const IOBluetoothDeviceSearchAttributes;
144
145        #[cfg(feature = "objc2-io-bluetooth")]
146        /// Adds a UUID to the list of UUIDs that are used to validate the user's selection.
147        ///
148        /// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
149        /// addAllowedUUIDArray:.  Each call to those methods essentially adds a filter that the
150        /// selected device gets validated with.  If any of the filters match, the device is considered
151        /// valid.  If they all fail, the device is not valid and the user is presented with an
152        /// error code that the device does not support the required services.  The UUID passed to
153        /// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
154        /// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
155        /// present.
156        ///
157        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
158        ///
159        /// Parameter `allowedUUID`: UUID that a device may contain to be selected
160        ///
161        /// # Safety
162        ///
163        /// `allowed_uuid` might not allow `None`.
164        #[unsafe(method(addAllowedUUID:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn addAllowedUUID(&self, allowed_uuid: Option<&IOBluetoothSDPUUID>);
167
168        /// Adds an array of UUIDs to the list of UUIDs that are used to validate the user's selection.
169        ///
170        /// The user's device selection gets validated against the UUIDs passed to -addAllowedUUID:
171        /// addAllowedUUIDArray:.  Each call to those methods essentially adds a filter that the
172        /// selected device gets validated with.  If any of the filters match, the device is considered
173        /// valid.  If they all fail, the device is not valid and the user is presented with an
174        /// error code that the device does not support the required services.  The UUID passed to
175        /// -addAllowedUUID: is the only UUID that must be present in the device's SDP service records.
176        /// Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be
177        /// present.
178        ///
179        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
180        ///
181        /// Parameter `allowedUUIDArray`: An NSArray of UUIDs that all must be present in a device for it to be selectable.
182        ///
183        /// # Safety
184        ///
185        /// - `allowed_uuid_array` generic should be of the correct type.
186        /// - `allowed_uuid_array` might not allow `None`.
187        #[unsafe(method(addAllowedUUIDArray:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn addAllowedUUIDArray(&self, allowed_uuid_array: Option<&NSArray>);
190
191        /// Resets the controller back to the default state where it will accept any device the user selects.
192        ///
193        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
194        #[unsafe(method(clearAllowedUUIDs))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn clearAllowedUUIDs(&self);
197
198        /// Sets the title of the panel when not run as a sheet.
199        ///
200        /// The panel title should be localized for best user experience.
201        ///
202        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
203        ///
204        /// Parameter `windowTitle`: Title of the device selector panel.
205        ///
206        /// # Safety
207        ///
208        /// `window_title` might not allow `None`.
209        #[unsafe(method(setTitle:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn setTitle(&self, window_title: Option<&NSString>);
212
213        /// Returns the title of the device selector panel (i.e. what was set in -setTitle:).
214        ///
215        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
216        ///
217        /// Returns: Returns the title of the device selector panel.
218        #[unsafe(method(getTitle))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn getTitle(&self) -> Option<Retained<NSString>>;
221
222        /// Sets the description text that appears in the device selector panel.
223        ///
224        /// The description text should be localized for best user experience.
225        ///
226        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
227        ///
228        /// Parameter `descriptionText`: String that appears in the description section of the device selector panel.
229        ///
230        /// # Safety
231        ///
232        /// `description_text` might not allow `None`.
233        #[unsafe(method(setDescriptionText:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setDescriptionText(&self, description_text: Option<&NSString>);
236
237        /// Returns the description text that appears in the device selector panel (i.e. what was set in -setDescriptionText:).
238        ///
239        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
240        ///
241        /// Returns: Returns the description text of the device selector panel.
242        #[unsafe(method(getDescriptionText))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn getDescriptionText(&self) -> Option<Retained<NSString>>;
245
246        /// Sets the title of the default/select button in the device selector panel.
247        ///
248        /// The prompt text should be localized for best user experience.
249        ///
250        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
251        ///
252        /// Parameter `prompt`: String that appears in the default/select button in the device selector panel.
253        ///
254        /// # Safety
255        ///
256        /// `prompt` might not allow `None`.
257        #[unsafe(method(setPrompt:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn setPrompt(&self, prompt: Option<&NSString>);
260
261        /// Returns the title of the default/select button in the device selector panel (i.e. what was set in -setPrompt:).
262        ///
263        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
264        ///
265        /// Returns: Returns the default button title of the device selector panel.
266        #[unsafe(method(getPrompt))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn getPrompt(&self) -> Option<Retained<NSString>>;
269    );
270}
271
272/// Methods declared on superclass `NSWindowController`.
273impl IOBluetoothPairingController {
274    extern_methods!(
275        #[unsafe(method(initWithWindow:))]
276        #[unsafe(method_family = init)]
277        pub unsafe fn initWithWindow(
278            this: Allocated<Self>,
279            window: Option<&NSWindow>,
280        ) -> Retained<Self>;
281
282        /// # Safety
283        ///
284        /// `coder` possibly has further requirements.
285        #[unsafe(method(initWithCoder:))]
286        #[unsafe(method_family = init)]
287        pub unsafe fn initWithCoder(
288            this: Allocated<Self>,
289            coder: &NSCoder,
290        ) -> Option<Retained<Self>>;
291
292        #[unsafe(method(initWithWindowNibName:))]
293        #[unsafe(method_family = init)]
294        pub unsafe fn initWithWindowNibName(
295            this: Allocated<Self>,
296            window_nib_name: &NSNibName,
297        ) -> Retained<Self>;
298
299        /// # Safety
300        ///
301        /// `owner` should be of the correct type.
302        #[unsafe(method(initWithWindowNibName:owner:))]
303        #[unsafe(method_family = init)]
304        pub unsafe fn initWithWindowNibName_owner(
305            this: Allocated<Self>,
306            window_nib_name: &NSNibName,
307            owner: &AnyObject,
308        ) -> Retained<Self>;
309
310        /// # Safety
311        ///
312        /// `owner` should be of the correct type.
313        #[unsafe(method(initWithWindowNibPath:owner:))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn initWithWindowNibPath_owner(
316            this: Allocated<Self>,
317            window_nib_path: &NSString,
318            owner: &AnyObject,
319        ) -> Retained<Self>;
320    );
321}
322
323/// Methods declared on superclass `NSResponder`.
324impl IOBluetoothPairingController {
325    extern_methods!(
326        #[unsafe(method(init))]
327        #[unsafe(method_family = init)]
328        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
329    );
330}
331
332/// Methods declared on superclass `NSObject`.
333impl IOBluetoothPairingController {
334    extern_methods!(
335        #[unsafe(method(new))]
336        #[unsafe(method_family = new)]
337        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
338    );
339}