objc2_io_bluetooth/generated/objc2/IOBluetoothDevicePair.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::*;
6
7use crate::*;
8
9extern_protocol!(
10 /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothdevicepairdelegate?language=objc)
11 pub unsafe trait IOBluetoothDevicePairDelegate: NSObjectProtocol {
12 /// Indicates that the pairing has started.
13 ///
14 /// Parameter `sender`: The IOBluetoothDevicePair object.
15 #[optional]
16 #[unsafe(method(devicePairingStarted:))]
17 #[unsafe(method_family = none)]
18 unsafe fn devicePairingStarted(&self, sender: Option<&AnyObject>);
19
20 /// Indicates to the delegate that the pairing object is making the device (baseband) connection.
21 ///
22 /// Parameter `sender`: The IOBluetoothDevicePair object.
23 #[optional]
24 #[unsafe(method(devicePairingConnecting:))]
25 #[unsafe(method_family = none)]
26 unsafe fn devicePairingConnecting(&self, sender: Option<&AnyObject>);
27
28 /// Indicates to the delegate that the pairing object is connected the device (baseband).
29 ///
30 /// Parameter `sender`: The IOBluetoothDevicePair object.
31 #[optional]
32 #[unsafe(method(devicePairingConnected:))]
33 #[unsafe(method_family = none)]
34 unsafe fn devicePairingConnected(&self, sender: Option<&AnyObject>);
35
36 /// Indicates to the delegate that the pairing object has made the device (baseband) connection and is
37 /// awaiting the PIN code (if specified) to be entered on the device. Thus, when you recieve this message,
38 /// you should display to the user that they should enter the PIN code on the device.
39 /// The method replyPINCode must be invoked in response and happen before the timeout period of the device.
40 ///
41 /// Parameter `sender`: The IOBluetoothDevicePair object.
42 #[optional]
43 #[unsafe(method(devicePairingPINCodeRequest:))]
44 #[unsafe(method_family = none)]
45 unsafe fn devicePairingPINCodeRequest(&self, sender: Option<&AnyObject>);
46
47 #[cfg(feature = "Bluetooth")]
48 /// Indicates to the delegate that the pairing object has made the device (baseband) connection and is
49 /// awaiting the a yes/no answer for the Simple Secure Pairing numeric comparison. Thus, when you recieve this message,
50 /// you should display to the user the numeric value and then accept the yes/no answer if it matches the value
51 /// on the other device.
52 /// The method replyUserConfirmation must be invoked in response and happen before the timeout period of the device.
53 ///
54 /// Parameter `sender`: The IOBluetoothDevicePair object.
55 ///
56 /// Parameter `numericValue`: Numeric value to be displayed.
57 #[optional]
58 #[unsafe(method(devicePairingUserConfirmationRequest:numericValue:))]
59 #[unsafe(method_family = none)]
60 unsafe fn devicePairingUserConfirmationRequest_numericValue(
61 &self,
62 sender: Option<&AnyObject>,
63 numeric_value: BluetoothNumericValue,
64 );
65
66 #[cfg(feature = "Bluetooth")]
67 /// Indicates to the delegate that the pairing object has made the device (baseband) connection and is
68 /// awaiting the passkey (if specified) to be entered on the device for the Secure Simple Pairing.
69 /// Thus, when you recieve this message, you should display to the user that they should enter
70 /// the passkey on the device.
71 ///
72 /// Parameter `sender`: The IOBluetoothDevicePair object.
73 ///
74 /// Parameter `passkey`: Passkey to be displayed.
75 #[optional]
76 #[unsafe(method(devicePairingUserPasskeyNotification:passkey:))]
77 #[unsafe(method_family = none)]
78 unsafe fn devicePairingUserPasskeyNotification_passkey(
79 &self,
80 sender: Option<&AnyObject>,
81 passkey: BluetoothPasskey,
82 );
83
84 /// Indicates to the delegate that the pairing object has fully completed the process. Can tell the delegate
85 /// when and error occurred during the attempt to pair with the device.
86 ///
87 /// The error passed to your delegate could be kBluetoothHCIErrorAuthenticationFailure,
88 /// kBluetoothHCIErrorLMPResponseTimeout, etc. See Bluetooth.h for all the possibilities.
89 ///
90 /// Parameter `sender`: The IOBluetoothDevicePair object.
91 ///
92 /// Parameter `error`: An IOReturn or Bluetooth error code.
93 #[optional]
94 #[unsafe(method(devicePairingFinished:error:))]
95 #[unsafe(method_family = none)]
96 unsafe fn devicePairingFinished_error(&self, sender: Option<&AnyObject>, error: IOReturn);
97
98 #[cfg(feature = "Bluetooth")]
99 /// Indicates to the delegate that the pairing object has fully completed the simple pairing process. Can tell the delegate
100 /// when and error occurred during the attempt to pair with the device.
101 ///
102 /// The status passed to your delegate could be BluetoothHCIEventStatus, etc. See Bluetooth.h for all the possibilities.
103 ///
104 /// Parameter `sender`: The IOBluetoothDevicePair object.
105 ///
106 /// Parameter `status`: A simple pairing complete error code.
107 #[optional]
108 #[unsafe(method(deviceSimplePairingComplete:status:))]
109 #[unsafe(method_family = none)]
110 unsafe fn deviceSimplePairingComplete_status(
111 &self,
112 sender: Option<&AnyObject>,
113 status: BluetoothHCIEventStatus,
114 );
115 }
116);
117
118extern_class!(
119 /// An instance of IOBluetoothDevicePair represents a pairing attempt to a remote Bluetooth device.
120 ///
121 /// Use the IOBluetoothDevicePair object to attempt to pair with any Bluetooth device. Once -start is invoked
122 /// on it, progress is returned to the delegate via the messages defined below. This object enables you to
123 /// pair with devices within your application without having to use the standard panels provided by the
124 /// IOBluetoothUI framework, allowing you to write custom UI to select devices, and still handle the ability
125 /// to perform device pairings.
126 ///
127 /// Of note is that this object MAY attempt to perform two low-level pairings, depending on the type of device
128 /// you are attempting to pair. This is inconsequential to your code, however, as it occurs automatically and
129 /// does not change the messaging.
130 ///
131 /// Once started, the pairing can be stopped. This will set the delegate to nil and then attempt to disconnect
132 /// from the device if already connected.
133 ///
134 /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothdevicepair?language=objc)
135 #[unsafe(super(NSObject))]
136 #[derive(Debug, PartialEq, Eq, Hash)]
137 pub struct IOBluetoothDevicePair;
138);
139
140extern_conformance!(
141 unsafe impl NSObjectProtocol for IOBluetoothDevicePair {}
142);
143
144impl IOBluetoothDevicePair {
145 extern_methods!(
146 #[unsafe(method(delegate))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
149
150 /// This is a [weak property][objc2::topics::weak_property].
151 /// Setter for [`delegate`][Self::delegate].
152 #[unsafe(method(setDelegate:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
155
156 #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
157 /// Creates an autorelease IOBluetoothDevicePair object with a device as the pairing target.
158 ///
159 /// Parameter `device`: An IOBluetoothDevice to attept to pair with. The device is retained.
160 ///
161 /// Returns: Returns an IOReturn or Bluetooth error code, if the pairing could not be started.
162 #[unsafe(method(pairWithDevice:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn pairWithDevice(device: Option<&IOBluetoothDevice>) -> Option<Retained<Self>>;
165
166 /// Kicks off the pairing with the device.
167 ///
168 /// Returns: Returns an IOReturn or Bluetooth error code, if the pairing could not be started.
169 #[unsafe(method(start))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn start(&self) -> IOReturn;
172
173 /// Stops the current pairing. Removes the delegate and disconnects if device was connected.
174 #[unsafe(method(stop))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn stop(&self);
177
178 #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
179 /// Get the IOBluetoothDevice being used by the object.
180 ///
181 /// Returns: device The IOBluetoothDevice object that the IOBluetoothDevicePair object is pairing with, as
182 /// specified in -setDevice: or pairWithDevice:
183 #[unsafe(method(device))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn device(&self) -> Option<Retained<IOBluetoothDevice>>;
186
187 #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
188 /// Set the device object to pair with. It is retained by the object.
189 ///
190 /// Parameter `device`: The IOBluetoothDevice object that the IOBluetoothDevicePair object with which to perform a pairing.
191 #[unsafe(method(setDevice:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn setDevice(&self, in_device: Option<&IOBluetoothDevice>);
194
195 #[cfg(feature = "Bluetooth")]
196 /// This is the required reply to the devicePairingPINCodeRequest delegate message.
197 /// Set the PIN code to use during pairing if required.
198 ///
199 /// Parameter `PINCodeSize`: The PIN code length in octets (8 bits).
200 ///
201 /// Parameter `PINcode`: PIN code for the device. Can be up to a maximum of 128 bits.
202 #[unsafe(method(replyPINCode:PINCode:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn replyPINCode_PINCode(
205 &self,
206 pin_code_size: ByteCount,
207 pin_code: *mut BluetoothPINCode,
208 );
209
210 /// This is the required reply to the devicePairingUserConfirmationRequest delegate message.
211 ///
212 /// Parameter `reply`: A yes/no answer provide by the user to the numeric comparison presented.
213 #[unsafe(method(replyUserConfirmation:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn replyUserConfirmation(&self, reply: bool);
216 );
217}
218
219/// Methods declared on superclass `NSObject`.
220impl IOBluetoothDevicePair {
221 extern_methods!(
222 #[unsafe(method(init))]
223 #[unsafe(method_family = init)]
224 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
225
226 #[unsafe(method(new))]
227 #[unsafe(method_family = new)]
228 pub unsafe fn new() -> Retained<Self>;
229 );
230}