objc2_io_bluetooth/generated/objc2/IOBluetoothOBEXSession.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_class!(
10 /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothobexsession?language=objc)
11 #[unsafe(super(OBEXSession, NSObject))]
12 #[derive(Debug, PartialEq, Eq, Hash)]
13 #[cfg(feature = "OBEXSession")]
14 pub struct IOBluetoothOBEXSession;
15);
16
17#[cfg(all(feature = "IOBluetoothRFCOMMChannel", feature = "OBEXSession"))]
18extern_conformance!(
19 unsafe impl IOBluetoothRFCOMMChannelDelegate for IOBluetoothOBEXSession {}
20);
21
22#[cfg(feature = "OBEXSession")]
23extern_conformance!(
24 unsafe impl NSObjectProtocol for IOBluetoothOBEXSession {}
25);
26
27#[cfg(feature = "OBEXSession")]
28impl IOBluetoothOBEXSession {
29 extern_methods!(
30 #[cfg(feature = "IOBluetoothSDPServiceRecord")]
31 /// Creates a Bluetooth-based OBEX Session using an SDP service record, typically obtained from a device/service
32 /// browser window controller.
33 ///
34 /// Parameter `inSDPServiceRecord`: A valid SDP service record describing the service (and RFCOMM channel) you want to
35 /// connect to with Bluetooth/OBEX.
36 ///
37 /// Returns: An OBEX session representing the device/rfcomm channel found in the service record. nil if we failed.
38 ///
39 /// Note that this does NOT mean the transport connection was open. It will be opened when OBEXConnect is
40 /// invoked on the session object.
41 ///
42 /// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
43 /// should be according to objc convention. This has been changed starting in Bluetooth version
44 /// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
45 /// it if you want to reference it later.
46 ///
47 /// # Safety
48 ///
49 /// `in_sdp_service_record` might not allow `None`.
50 #[unsafe(method(withSDPServiceRecord:))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn withSDPServiceRecord(
53 in_sdp_service_record: Option<&IOBluetoothSDPServiceRecord>,
54 ) -> Option<Retained<Self>>;
55
56 #[cfg(all(
57 feature = "Bluetooth",
58 feature = "IOBluetoothDevice",
59 feature = "IOBluetoothObject"
60 ))]
61 /// Creates a Bluetooth-based OBEX Session using a Bluetooth device and a Bluetooth RFCOMM channel ID.
62 ///
63 /// Parameter `inDevice`: A valid Bluetooth device describing which device you want to connect to
64 /// with Bluetooth/OBEX.
65 ///
66 /// Parameter `inRFCOMMChannelID`: An RFCOMM Channel ID numbe that is available on the remote device. This channel will
67 /// be used when the transport connection is attempted.
68 ///
69 /// Returns: An OBEX session representing the device/rfcomm channel found in the service record. nil if we failed.
70 ///
71 /// Note that this does NOT mean the transport connection was open. It will be opened when OBEXConnect is
72 /// invoked on the session object.
73 ///
74 /// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
75 /// should be according to objc convention. This has been changed starting in Bluetooth version
76 /// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
77 /// it if you want to reference it later.
78 ///
79 /// # Safety
80 ///
81 /// `in_device` might not allow `None`.
82 #[unsafe(method(withDevice:channelID:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn withDevice_channelID(
85 in_device: Option<&IOBluetoothDevice>,
86 in_rfcomm_channel_id: BluetoothRFCOMMChannelID,
87 ) -> Option<Retained<Self>>;
88
89 #[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
90 /// Creates a Bluetooth-based OBEX Session using an incoming RFCOMM channel.
91 ///
92 /// Parameter `inChannel`: The channel to use to create a connection to a device.
93 ///
94 /// Parameter `inEventSelector`: The selector that gets called when an event occurs on the OBEX Session.
95 ///
96 /// Parameter `inEventSelectorTarget`: The object that is used to call the above selector.
97 ///
98 /// Parameter `inUserRefCon`: The reference constant. Pass whatever you wish - it will be returned to you in the selector.
99 ///
100 /// Returns:
101 ///
102 /// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
103 /// should be according to objc convention. This has been changed starting in Bluetooth version
104 /// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
105 /// it if you want to reference it later.
106 ///
107 /// # Safety
108 ///
109 /// - `in_channel` might not allow `None`.
110 /// - `in_event_selector` must be a valid selector.
111 /// - `in_event_selector_target` should be of the correct type.
112 /// - `in_event_selector_target` might not allow `None`.
113 /// - `in_user_ref_con` must be a valid pointer.
114 #[unsafe(method(withIncomingRFCOMMChannel:eventSelector:selectorTarget:refCon:))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn withIncomingRFCOMMChannel_eventSelector_selectorTarget_refCon(
117 in_channel: Option<&IOBluetoothRFCOMMChannel>,
118 in_event_selector: Option<Sel>,
119 in_event_selector_target: Option<&AnyObject>,
120 in_user_ref_con: *mut c_void,
121 ) -> Option<Retained<Self>>;
122
123 #[cfg(feature = "IOBluetoothSDPServiceRecord")]
124 /// Initializes a Bluetooth-based OBEX Session using an SDP service record.
125 ///
126 /// Parameter `inSDPServiceRecord`:
127 /// Returns:
128 ///
129 /// # Safety
130 ///
131 /// `in_sdp_service_record` might not allow `None`.
132 #[unsafe(method(initWithSDPServiceRecord:))]
133 #[unsafe(method_family = init)]
134 pub unsafe fn initWithSDPServiceRecord(
135 this: Allocated<Self>,
136 in_sdp_service_record: Option<&IOBluetoothSDPServiceRecord>,
137 ) -> Option<Retained<Self>>;
138
139 #[cfg(all(
140 feature = "Bluetooth",
141 feature = "IOBluetoothDevice",
142 feature = "IOBluetoothObject"
143 ))]
144 /// Initializes a Bluetooth-based OBEX Session using a Bluetooth device.
145 ///
146 /// Parameter `inDevice`: The bluetooth device on which to open the OBEXSession.
147 ///
148 /// Parameter `inChannelID`: The RFCOMM channel ID to use when opening the connection.
149 ///
150 /// Returns:
151 ///
152 /// # Safety
153 ///
154 /// `in_device` might not allow `None`.
155 #[unsafe(method(initWithDevice:channelID:))]
156 #[unsafe(method_family = init)]
157 pub unsafe fn initWithDevice_channelID(
158 this: Allocated<Self>,
159 in_device: Option<&IOBluetoothDevice>,
160 in_channel_id: BluetoothRFCOMMChannelID,
161 ) -> Option<Retained<Self>>;
162
163 #[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
164 /// Initializes a Bluetooth-based OBEX Session using an incoming RFCOMM channel.
165 ///
166 /// Parameter `inChannelID`: RFCOMM channel ID of the desired channel to be used.
167 ///
168 /// Parameter `inEventSelector`: The selector to be called when an event is received.
169 ///
170 /// Parameter `inEventSelectorTarget`: The target object that get the selector message.
171 ///
172 /// Parameter `refCon`: caller reference constant, pass whatever you want, it will be returned to you in the selector.
173 ///
174 /// Returns:
175 ///
176 /// # Safety
177 ///
178 /// - `in_channel` might not allow `None`.
179 /// - `in_event_selector` must be a valid selector.
180 /// - `in_event_selector_target` should be of the correct type.
181 /// - `in_event_selector_target` might not allow `None`.
182 /// - `in_user_ref_con` must be a valid pointer.
183 #[unsafe(method(initWithIncomingRFCOMMChannel:eventSelector:selectorTarget:refCon:))]
184 #[unsafe(method_family = init)]
185 pub unsafe fn initWithIncomingRFCOMMChannel_eventSelector_selectorTarget_refCon(
186 this: Allocated<Self>,
187 in_channel: Option<&IOBluetoothRFCOMMChannel>,
188 in_event_selector: Option<Sel>,
189 in_event_selector_target: Option<&AnyObject>,
190 in_user_ref_con: *mut c_void,
191 ) -> Option<Retained<Self>>;
192
193 #[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
194 /// Get the Bluetooth RFCOMM channel being used by the session object.
195 ///
196 /// Returns: A IOBluetoothRFCOMMChannel object.
197 ///
198 /// This could potentially be nil even though you have a valid OBEX session, because the RFCOMM channel is
199 /// only valid when the session is connected.
200 #[unsafe(method(getRFCOMMChannel))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn getRFCOMMChannel(&self) -> Option<Retained<IOBluetoothRFCOMMChannel>>;
203
204 #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
205 /// Get the Bluetooth Device being used by the session object.
206 ///
207 /// Returns: An IOBluetoothDevice object.
208 #[unsafe(method(getDevice))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn getDevice(&self) -> Option<Retained<IOBluetoothDevice>>;
211
212 /// Sends the next block of data trough the rfcomm channel.
213 ///
214 /// Returns:
215 /// Since a send in the rfcomm channel is broken in multiple write calls (this actually is true only if the size is grater
216 /// than the rfcomm MTU). Each write call is performed by sendBufferTroughChannel. This should never need to be overwritten.
217 #[unsafe(method(sendBufferTroughChannel))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn sendBufferTroughChannel(&self) -> IOReturn;
220
221 /// If the transmission was stopeed due to the lack of buffers this call restarts it.
222 ///
223 /// Returns:
224 /// If the transmission was stopeed due to the lack of buffers this call restarts it.
225 #[unsafe(method(restartTransmission))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn restartTransmission(&self);
228
229 /// Tells whether the target device is a Mac by checking its service record.
230 ///
231 /// Returns: TRUE only if device service record has Mac entry, FALSE for all else.
232 ///
233 /// Tells whether the target device is a Mac by checking its service record.
234 #[unsafe(method(isSessionTargetAMac))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn isSessionTargetAMac(&self) -> bool;
237
238 #[cfg(feature = "OBEX")]
239 /// An OBEXSession override. When this is called by the session baseclass, we will attempt to open the
240 /// transport connection. In our case, this would be an RFCOMM channel to another Bluetooth device.
241 ///
242 /// Returns: Success or failure code.
243 ///
244 /// Your selector should have the following signature:
245 ///
246 /// -(void)transportConnectionSelector:(id)refcon status:(OBEXError)status;
247 ///
248 /// Thus you could use it with openTransportConnection like this:
249 ///
250 /// OBEXError error = [anOBEXSession openTransportConnection:
251 /// sel!( transportConnectionSelector:status: )
252 /// selectorTarget:self
253 /// refCon:anOBEXSession]; // or whatever you want to pass as a refCon...
254 ///
255 /// Be sure to check the status code! Assume the connection was not opened unless status is kOBEXSuccess.
256 ///
257 /// # Safety
258 ///
259 /// - `in_selector` must be a valid selector.
260 /// - `in_target` should be of the correct type.
261 /// - `in_target` might not allow `None`.
262 /// - `in_user_ref_con` must be a valid pointer.
263 #[unsafe(method(openTransportConnection:selectorTarget:refCon:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn openTransportConnection_selectorTarget_refCon(
266 &self,
267 in_selector: Option<Sel>,
268 in_target: Option<&AnyObject>,
269 in_user_ref_con: *mut c_void,
270 ) -> OBEXError;
271
272 /// An OBEXSession override. When this is called by the session baseclass, we will return whether or not we
273 /// have a transport connection established to another OBEX server/client. In our case we will tell whether
274 /// or not the RFCOMM channel to a remote device is still open.
275 ///
276 /// Returns: True or false, whether there is already an open transport connection for this OBEX session.
277 #[unsafe(method(hasOpenTransportConnection))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn hasOpenTransportConnection(&self) -> Boolean;
280
281 #[cfg(feature = "OBEX")]
282 /// An OBEXSession override. When this is called by the session baseclass, we will close the transport
283 /// connection if it is opened. In our case, it will be the RFCOMM channel that needs closing.
284 ///
285 /// Returns: Success or failure code, describing whether the call succeeded in closing the transport connection successfully.
286 #[unsafe(method(closeTransportConnection))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn closeTransportConnection(&self) -> OBEXError;
289
290 #[cfg(feature = "OBEX")]
291 /// An OBEXSession override. When this is called by the session baseclass, we will send the data we are given
292 /// over our transport connection. If none is open, we could try to open it, or just return an error. In our
293 /// case, it will be sent over the RFCOMM channel.
294 ///
295 /// Returns: Success or failure code, describing whether the call succeeded in writing the data to the transport.
296 ///
297 /// # Safety
298 ///
299 /// `in_data_to_send` must be a valid pointer.
300 #[unsafe(method(sendDataToTransport:dataLength:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn sendDataToTransport_dataLength(
303 &self,
304 in_data_to_send: *mut c_void,
305 in_data_length: usize,
306 ) -> OBEXError;
307
308 /// Allows you to set the selector to be used when a transport connection is opened, or fails to open.
309 ///
310 /// Parameter `inEventSelector`: Selector to call on the target.
311 ///
312 /// Parameter `inEventSelectorTarget`: Target to be called with the selector.
313 ///
314 /// Parameter `inUserRefCon`: User's refCon that will get passed to them when their selector is invoked.
315 ///
316 /// You do not need to call this on the session typically, unless you have subclassed the OBEXSession to
317 /// implement a new transport and that transport supports async opening of connections. If it does not support
318 /// async open, then using this is pointless.
319 ///
320 /// # Safety
321 ///
322 /// - `in_selector` must be a valid selector.
323 /// - `in_selector_target` should be of the correct type.
324 /// - `in_selector_target` might not allow `None`.
325 /// - `in_user_ref_con` must be a valid pointer.
326 #[unsafe(method(setOpenTransportConnectionAsyncSelector:target:refCon:))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn setOpenTransportConnectionAsyncSelector_target_refCon(
329 &self,
330 in_selector: Option<Sel>,
331 in_selector_target: Option<&AnyObject>,
332 in_user_ref_con: *mut c_void,
333 );
334
335 #[cfg(all(feature = "OBEX", feature = "OBEXBluetooth"))]
336 /// For C API support. Allows you to set the callback to be invoked when the OBEX connection is actually opened.
337 ///
338 /// Parameter `inCallback`: function to call on the target.
339 ///
340 /// Parameter `inUserRefCon`: user's reference constant, will be returned on the callback.
341 ///
342 /// # Safety
343 ///
344 /// - `in_callback` must be implemented correctly.
345 /// - `in_user_ref_con` must be a valid pointer.
346 #[unsafe(method(setOBEXSessionOpenConnectionCallback:refCon:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn setOBEXSessionOpenConnectionCallback_refCon(
349 &self,
350 in_callback: IOBluetoothOBEXSessionOpenConnectionCallback,
351 in_user_ref_con: *mut c_void,
352 );
353 );
354}
355
356/// Methods declared on superclass `NSObject`.
357#[cfg(feature = "OBEXSession")]
358impl IOBluetoothOBEXSession {
359 extern_methods!(
360 #[unsafe(method(init))]
361 #[unsafe(method_family = init)]
362 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
363
364 #[unsafe(method(new))]
365 #[unsafe(method_family = new)]
366 pub unsafe fn new() -> Retained<Self>;
367 );
368}