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
//! 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 crate::*;
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothobexsession?language=objc)
#[unsafe(super(OBEXSession, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "OBEXSession")]
pub struct IOBluetoothOBEXSession;
);
#[cfg(all(feature = "IOBluetoothRFCOMMChannel", feature = "OBEXSession"))]
extern_conformance!(
unsafe impl IOBluetoothRFCOMMChannelDelegate for IOBluetoothOBEXSession {}
);
#[cfg(feature = "OBEXSession")]
extern_conformance!(
unsafe impl NSObjectProtocol for IOBluetoothOBEXSession {}
);
#[cfg(feature = "OBEXSession")]
impl IOBluetoothOBEXSession {
extern_methods!(
#[cfg(feature = "IOBluetoothSDPServiceRecord")]
/// Creates a Bluetooth-based OBEX Session using an SDP service record, typically obtained from a device/service
/// browser window controller.
///
/// Parameter `inSDPServiceRecord`: A valid SDP service record describing the service (and RFCOMM channel) you want to
/// connect to with Bluetooth/OBEX.
///
/// Returns: An OBEX session representing the device/rfcomm channel found in the service record. nil if we failed.
///
/// Note that this does NOT mean the transport connection was open. It will be opened when OBEXConnect is
/// invoked on the session object.
///
/// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
/// should be according to objc convention. This has been changed starting in Bluetooth version
/// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
/// it if you want to reference it later.
///
/// # Safety
///
/// `in_sdp_service_record` might not allow `None`.
#[unsafe(method(withSDPServiceRecord:))]
#[unsafe(method_family = none)]
pub unsafe fn withSDPServiceRecord(
in_sdp_service_record: Option<&IOBluetoothSDPServiceRecord>,
) -> Option<Retained<Self>>;
#[cfg(all(
feature = "Bluetooth",
feature = "IOBluetoothDevice",
feature = "IOBluetoothObject"
))]
/// Creates a Bluetooth-based OBEX Session using a Bluetooth device and a Bluetooth RFCOMM channel ID.
///
/// Parameter `inDevice`: A valid Bluetooth device describing which device you want to connect to
/// with Bluetooth/OBEX.
///
/// Parameter `inRFCOMMChannelID`: An RFCOMM Channel ID numbe that is available on the remote device. This channel will
/// be used when the transport connection is attempted.
///
/// Returns: An OBEX session representing the device/rfcomm channel found in the service record. nil if we failed.
///
/// Note that this does NOT mean the transport connection was open. It will be opened when OBEXConnect is
/// invoked on the session object.
///
/// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
/// should be according to objc convention. This has been changed starting in Bluetooth version
/// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
/// it if you want to reference it later.
///
/// # Safety
///
/// `in_device` might not allow `None`.
#[unsafe(method(withDevice:channelID:))]
#[unsafe(method_family = none)]
pub unsafe fn withDevice_channelID(
in_device: Option<&IOBluetoothDevice>,
in_rfcomm_channel_id: BluetoothRFCOMMChannelID,
) -> Option<Retained<Self>>;
#[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
/// Creates a Bluetooth-based OBEX Session using an incoming RFCOMM channel.
///
/// Parameter `inChannel`: The channel to use to create a connection to a device.
///
/// Parameter `inEventSelector`: The selector that gets called when an event occurs on the OBEX Session.
///
/// Parameter `inEventSelectorTarget`: The object that is used to call the above selector.
///
/// Parameter `inUserRefCon`: The reference constant. Pass whatever you wish - it will be returned to you in the selector.
///
/// Returns:
///
/// IMPORTANT NOTE* In Bluetooth framework version 1.0.0, the session returned will NOT be autoreleased as it
/// should be according to objc convention. This has been changed starting in Bluetooth version
/// 1.0.1 and later, so it WILL be autoreleased upon return, so you will need to retain
/// it if you want to reference it later.
///
/// # Safety
///
/// - `in_channel` might not allow `None`.
/// - `in_event_selector` must be a valid selector.
/// - `in_event_selector_target` should be of the correct type.
/// - `in_event_selector_target` might not allow `None`.
/// - `in_user_ref_con` must be a valid pointer.
#[unsafe(method(withIncomingRFCOMMChannel:eventSelector:selectorTarget:refCon:))]
#[unsafe(method_family = none)]
pub unsafe fn withIncomingRFCOMMChannel_eventSelector_selectorTarget_refCon(
in_channel: Option<&IOBluetoothRFCOMMChannel>,
in_event_selector: Option<Sel>,
in_event_selector_target: Option<&AnyObject>,
in_user_ref_con: *mut c_void,
) -> Option<Retained<Self>>;
#[cfg(feature = "IOBluetoothSDPServiceRecord")]
/// Initializes a Bluetooth-based OBEX Session using an SDP service record.
///
/// Parameter `inSDPServiceRecord`:
/// Returns:
///
/// # Safety
///
/// `in_sdp_service_record` might not allow `None`.
#[unsafe(method(initWithSDPServiceRecord:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithSDPServiceRecord(
this: Allocated<Self>,
in_sdp_service_record: Option<&IOBluetoothSDPServiceRecord>,
) -> Option<Retained<Self>>;
#[cfg(all(
feature = "Bluetooth",
feature = "IOBluetoothDevice",
feature = "IOBluetoothObject"
))]
/// Initializes a Bluetooth-based OBEX Session using a Bluetooth device.
///
/// Parameter `inDevice`: The bluetooth device on which to open the OBEXSession.
///
/// Parameter `inChannelID`: The RFCOMM channel ID to use when opening the connection.
///
/// Returns:
///
/// # Safety
///
/// `in_device` might not allow `None`.
#[unsafe(method(initWithDevice:channelID:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithDevice_channelID(
this: Allocated<Self>,
in_device: Option<&IOBluetoothDevice>,
in_channel_id: BluetoothRFCOMMChannelID,
) -> Option<Retained<Self>>;
#[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
/// Initializes a Bluetooth-based OBEX Session using an incoming RFCOMM channel.
///
/// Parameter `inChannelID`: RFCOMM channel ID of the desired channel to be used.
///
/// Parameter `inEventSelector`: The selector to be called when an event is received.
///
/// Parameter `inEventSelectorTarget`: The target object that get the selector message.
///
/// Parameter `refCon`: caller reference constant, pass whatever you want, it will be returned to you in the selector.
///
/// Returns:
///
/// # Safety
///
/// - `in_channel` might not allow `None`.
/// - `in_event_selector` must be a valid selector.
/// - `in_event_selector_target` should be of the correct type.
/// - `in_event_selector_target` might not allow `None`.
/// - `in_user_ref_con` must be a valid pointer.
#[unsafe(method(initWithIncomingRFCOMMChannel:eventSelector:selectorTarget:refCon:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithIncomingRFCOMMChannel_eventSelector_selectorTarget_refCon(
this: Allocated<Self>,
in_channel: Option<&IOBluetoothRFCOMMChannel>,
in_event_selector: Option<Sel>,
in_event_selector_target: Option<&AnyObject>,
in_user_ref_con: *mut c_void,
) -> Option<Retained<Self>>;
#[cfg(all(feature = "IOBluetoothObject", feature = "IOBluetoothRFCOMMChannel"))]
/// Get the Bluetooth RFCOMM channel being used by the session object.
///
/// Returns: A IOBluetoothRFCOMMChannel object.
///
/// This could potentially be nil even though you have a valid OBEX session, because the RFCOMM channel is
/// only valid when the session is connected.
#[unsafe(method(getRFCOMMChannel))]
#[unsafe(method_family = none)]
pub unsafe fn getRFCOMMChannel(&self) -> Option<Retained<IOBluetoothRFCOMMChannel>>;
#[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
/// Get the Bluetooth Device being used by the session object.
///
/// Returns: An IOBluetoothDevice object.
#[unsafe(method(getDevice))]
#[unsafe(method_family = none)]
pub unsafe fn getDevice(&self) -> Option<Retained<IOBluetoothDevice>>;
/// Sends the next block of data trough the rfcomm channel.
///
/// Returns:
/// Since a send in the rfcomm channel is broken in multiple write calls (this actually is true only if the size is grater
/// than the rfcomm MTU). Each write call is performed by sendBufferTroughChannel. This should never need to be overwritten.
#[unsafe(method(sendBufferTroughChannel))]
#[unsafe(method_family = none)]
pub unsafe fn sendBufferTroughChannel(&self) -> IOReturn;
/// If the transmission was stopeed due to the lack of buffers this call restarts it.
///
/// Returns:
/// If the transmission was stopeed due to the lack of buffers this call restarts it.
#[unsafe(method(restartTransmission))]
#[unsafe(method_family = none)]
pub unsafe fn restartTransmission(&self);
/// Tells whether the target device is a Mac by checking its service record.
///
/// Returns: TRUE only if device service record has Mac entry, FALSE for all else.
///
/// Tells whether the target device is a Mac by checking its service record.
#[unsafe(method(isSessionTargetAMac))]
#[unsafe(method_family = none)]
pub unsafe fn isSessionTargetAMac(&self) -> bool;
#[cfg(feature = "OBEX")]
/// An OBEXSession override. When this is called by the session baseclass, we will attempt to open the
/// transport connection. In our case, this would be an RFCOMM channel to another Bluetooth device.
///
/// Returns: Success or failure code.
///
/// Your selector should have the following signature:
///
/// -(void)transportConnectionSelector:(id)refcon status:(OBEXError)status;
///
/// Thus you could use it with openTransportConnection like this:
///
/// OBEXError error = [anOBEXSession openTransportConnection:
/// sel!( transportConnectionSelector:status: )
/// selectorTarget:self
/// refCon:anOBEXSession]; // or whatever you want to pass as a refCon...
///
/// Be sure to check the status code! Assume the connection was not opened unless status is kOBEXSuccess.
///
/// # Safety
///
/// - `in_selector` must be a valid selector.
/// - `in_target` should be of the correct type.
/// - `in_target` might not allow `None`.
/// - `in_user_ref_con` must be a valid pointer.
#[unsafe(method(openTransportConnection:selectorTarget:refCon:))]
#[unsafe(method_family = none)]
pub unsafe fn openTransportConnection_selectorTarget_refCon(
&self,
in_selector: Option<Sel>,
in_target: Option<&AnyObject>,
in_user_ref_con: *mut c_void,
) -> OBEXError;
/// An OBEXSession override. When this is called by the session baseclass, we will return whether or not we
/// have a transport connection established to another OBEX server/client. In our case we will tell whether
/// or not the RFCOMM channel to a remote device is still open.
///
/// Returns: True or false, whether there is already an open transport connection for this OBEX session.
#[unsafe(method(hasOpenTransportConnection))]
#[unsafe(method_family = none)]
pub unsafe fn hasOpenTransportConnection(&self) -> Boolean;
#[cfg(feature = "OBEX")]
/// An OBEXSession override. When this is called by the session baseclass, we will close the transport
/// connection if it is opened. In our case, it will be the RFCOMM channel that needs closing.
///
/// Returns: Success or failure code, describing whether the call succeeded in closing the transport connection successfully.
#[unsafe(method(closeTransportConnection))]
#[unsafe(method_family = none)]
pub unsafe fn closeTransportConnection(&self) -> OBEXError;
#[cfg(feature = "OBEX")]
/// An OBEXSession override. When this is called by the session baseclass, we will send the data we are given
/// over our transport connection. If none is open, we could try to open it, or just return an error. In our
/// case, it will be sent over the RFCOMM channel.
///
/// Returns: Success or failure code, describing whether the call succeeded in writing the data to the transport.
///
/// # Safety
///
/// `in_data_to_send` must be a valid pointer.
#[unsafe(method(sendDataToTransport:dataLength:))]
#[unsafe(method_family = none)]
pub unsafe fn sendDataToTransport_dataLength(
&self,
in_data_to_send: *mut c_void,
in_data_length: usize,
) -> OBEXError;
/// Allows you to set the selector to be used when a transport connection is opened, or fails to open.
///
/// Parameter `inEventSelector`: Selector to call on the target.
///
/// Parameter `inEventSelectorTarget`: Target to be called with the selector.
///
/// Parameter `inUserRefCon`: User's refCon that will get passed to them when their selector is invoked.
///
/// You do not need to call this on the session typically, unless you have subclassed the OBEXSession to
/// implement a new transport and that transport supports async opening of connections. If it does not support
/// async open, then using this is pointless.
///
/// # Safety
///
/// - `in_selector` must be a valid selector.
/// - `in_selector_target` should be of the correct type.
/// - `in_selector_target` might not allow `None`.
/// - `in_user_ref_con` must be a valid pointer.
#[unsafe(method(setOpenTransportConnectionAsyncSelector:target:refCon:))]
#[unsafe(method_family = none)]
pub unsafe fn setOpenTransportConnectionAsyncSelector_target_refCon(
&self,
in_selector: Option<Sel>,
in_selector_target: Option<&AnyObject>,
in_user_ref_con: *mut c_void,
);
#[cfg(all(feature = "OBEX", feature = "OBEXBluetooth"))]
/// For C API support. Allows you to set the callback to be invoked when the OBEX connection is actually opened.
///
/// Parameter `inCallback`: function to call on the target.
///
/// Parameter `inUserRefCon`: user's reference constant, will be returned on the callback.
///
/// # Safety
///
/// - `in_callback` must be implemented correctly.
/// - `in_user_ref_con` must be a valid pointer.
#[unsafe(method(setOBEXSessionOpenConnectionCallback:refCon:))]
#[unsafe(method_family = none)]
pub unsafe fn setOBEXSessionOpenConnectionCallback_refCon(
&self,
in_callback: IOBluetoothOBEXSessionOpenConnectionCallback,
in_user_ref_con: *mut c_void,
);
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "OBEXSession")]
impl IOBluetoothOBEXSession {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}