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