objc2_io_bluetooth/generated/objc2/OBEXSession.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7use objc2::__framework_prelude::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/opaqueprivobexsessiondata?language=objc)
12#[repr(C)]
13#[derive(Debug)]
14pub struct OpaquePrivOBEXSessionData {
15 inner: [u8; 0],
16 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
17}
18
19unsafe impl RefEncode for OpaquePrivOBEXSessionData {
20 const ENCODING_REF: Encoding =
21 Encoding::Pointer(&Encoding::Struct("OpaquePrivOBEXSessionData", &[]));
22}
23
24/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/privobexsessiondataref?language=objc)
25pub type PrivOBEXSessionDataRef = *mut OpaquePrivOBEXSessionData;
26
27/// Pass these types in the OBEXTransportEvent, and then pass the struct on to the session object once you
28/// have filled it out. This is how you can communicate with the session when events happen - if data is
29/// received, the type will be 'kOBEXTransportEventTypeDataReceived'. if an error has occurred on your transport,
30/// like the remote target died, you can send a status event with a non-zero value. Since session objects will
31/// receive this status code on their event handlers, you should try to pass a useful status/error code, such as
32/// an IOReturn value.
33///
34/// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/obextransporteventtype?language=objc)
35pub type OBEXTransportEventType = u32;
36
37/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/obextransporteventtypes?language=objc)
38#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct OBEXTransportEventTypes(pub c_uint);
41impl OBEXTransportEventTypes {
42 #[doc(alias = "kOBEXTransportEventTypeDataReceived")]
43 pub const DataReceived: Self = Self(0x44617441);
44 #[doc(alias = "kOBEXTransportEventTypeStatus")]
45 pub const Status: Self = Self(0x53746154);
46}
47
48unsafe impl Encode for OBEXTransportEventTypes {
49 const ENCODING: Encoding = c_uint::ENCODING;
50}
51
52unsafe impl RefEncode for OBEXTransportEventTypes {
53 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
54}
55
56/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/obextransportevent?language=objc)
57#[cfg(feature = "OBEX")]
58#[repr(C)]
59#[derive(Clone, Copy, Debug, PartialEq)]
60pub struct OBEXTransportEvent {
61 pub r#type: OBEXTransportEventType,
62 pub status: OBEXError,
63 pub dataPtr: *mut c_void,
64 pub dataLength: usize,
65}
66
67#[cfg(feature = "OBEX")]
68unsafe impl Encode for OBEXTransportEvent {
69 const ENCODING: Encoding = Encoding::Struct(
70 "OBEXTransportEvent",
71 &[
72 <OBEXTransportEventType>::ENCODING,
73 <OBEXError>::ENCODING,
74 <*mut c_void>::ENCODING,
75 <usize>::ENCODING,
76 ],
77 );
78}
79
80#[cfg(feature = "OBEX")]
81unsafe impl RefEncode for OBEXTransportEvent {
82 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
83}
84
85extern_class!(
86 /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/obexsession?language=objc)
87 #[unsafe(super(NSObject))]
88 #[derive(Debug, PartialEq, Eq, Hash)]
89 pub struct OBEXSession;
90);
91
92extern_conformance!(
93 unsafe impl NSObjectProtocol for OBEXSession {}
94);
95
96impl OBEXSession {
97 extern_methods!(
98 #[cfg(feature = "OBEX")]
99 /// Initiate an OBEX connection to a device. Causes underlying transport (Bluetooth, et al) to attempt to connect
100 /// to a remote device. After success, an OBEX connect packet is sent to establish the OBEX Connection.
101 ///
102 /// Parameter `inFlags`: OBEX connect flags. See OBEX.h for possibilities.
103 ///
104 /// Parameter `inMaxPacketLength`: Maximum packet size you want to support. May be negotiated down, depending on
105 /// target device.
106 ///
107 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use the
108 /// provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
109 ///
110 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
111 ///
112 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
113 /// Selector in your target object MUST have the following signature, or it
114 /// will not be called properly (look for error messages in Console.app):
115 ///
116 /// - (void)OBEXConnectHandler:(const OBEXSessionEvent*)inSessionEvent;
117 ///
118 ///
119 /// Parameter `inTarget`: A VALID target object for the selector.
120 ///
121 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
122 /// OBEXSessionEvent struct. nil is, of course, OK here.
123 ///
124 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
125 ///
126 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
127 /// transport. You will receive a response to your command on your selector. If you have already established an OBEX
128 /// connection and you call this again you will get an 'kOBEXSessionAlreadyConnectedError' as a result.
129 #[unsafe(method(OBEXConnect:maxPacketLength:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn OBEXConnect_maxPacketLength_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
132 &self,
133 in_flags: OBEXFlags,
134 in_max_packet_length: OBEXMaxPacketLength,
135 in_optional_headers: *mut c_void,
136 in_optional_headers_length: usize,
137 in_selector: Option<Sel>,
138 in_target: Option<&AnyObject>,
139 in_user_ref_con: *mut c_void,
140 ) -> OBEXError;
141
142 #[cfg(feature = "OBEX")]
143 /// Send an OBEX Disconnect command to the session's target. THIS DOES NOT necessarily close the underlying transport
144 /// connection. Deleting the session will ensure that closure.
145 ///
146 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
147 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
148 ///
149 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
150 ///
151 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
152 /// Selector in your target object MUST have the following signature, or it
153 /// will not be called properly (look for error messages in Console.app):
154 ///
155 /// - (void)OBEXDisconnectHandler:(const OBEXSessionEvent*)inSessionEvent;
156 ///
157 ///
158 /// Parameter `inTarget`: A VALID target object for the selector.
159 ///
160 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
161 /// OBEXSessionEvent struct. nil is, of course, OK here.
162 ///
163 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
164 ///
165 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
166 /// transport. You will receive a response to your command on your selector.
167 /// Be careful not to exceed the max packet length in your optional headers, or your command will be rejected.
168 /// It is recommended that you call getMaxPacketLength on your session before issuing this command so
169 /// you know how much data the session's target will accept in a single transaction.
170 #[unsafe(method(OBEXDisconnect:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn OBEXDisconnect_optionalHeadersLength_eventSelector_selectorTarget_refCon(
173 &self,
174 in_optional_headers: *mut c_void,
175 in_optional_headers_length: usize,
176 in_selector: Option<Sel>,
177 in_target: Option<&AnyObject>,
178 in_user_ref_con: *mut c_void,
179 ) -> OBEXError;
180
181 #[cfg(feature = "OBEX")]
182 /// Send an OBEX Put command to the session's target.
183 ///
184 /// Parameter `isFinalChunk`: Specify if this request is complete in one shot - that all the headers you are
185 /// supplying will fit in the negotiated max packet length.
186 ///
187 /// Parameter `inHeadersData`: Can be NULL. Ptr to some data you want to send as your headers, such as Length,
188 /// Name, etc. Use the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void)
189 /// for convenience.
190 ///
191 /// Parameter `inHeadersDataLength`: Length of data in ptr passed in above.
192 ///
193 /// Parameter `inBodyData`: Can be NULL. Ptr to some data you want to send as your BODY header. Do not construct a
194 /// real OBEX header here, it will be done for you - just pass a pointer to your
195 /// data, we'll do the rest. HOWEVER, be aware that some overhead (3 bytes) will be added
196 /// to the data in constructing the BODY header for you.
197 ///
198 /// Parameter `inBodyDataLength`: Length of data in ptr passed in above.
199 ///
200 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
201 /// Selector in your target object MUST have the following signature, or it
202 /// will not be called properly (look for error messages in Console.app):
203 ///
204 /// - (void)OBEXPutHandler:(const OBEXSessionEvent*)inSessionEvent;
205 ///
206 ///
207 /// Parameter `inTarget`: A VALID target object for the selector.
208 ///
209 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
210 /// OBEXSessionEvent struct. nil is, of course, OK here.
211 ///
212 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
213 ///
214 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
215 /// transport. You will receive a response to your command on your selector.
216 #[unsafe(method(OBEXPut:headersData:headersDataLength:bodyData:bodyDataLength:eventSelector:selectorTarget:refCon:))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn OBEXPut_headersData_headersDataLength_bodyData_bodyDataLength_eventSelector_selectorTarget_refCon(
219 &self,
220 is_final_chunk: Boolean,
221 in_headers_data: *mut c_void,
222 in_headers_data_length: usize,
223 in_body_data: *mut c_void,
224 in_body_data_length: usize,
225 in_selector: Option<Sel>,
226 in_target: Option<&AnyObject>,
227 in_user_ref_con: *mut c_void,
228 ) -> OBEXError;
229
230 #[cfg(feature = "OBEX")]
231 /// Send an OBEX Get command to the session's target.
232 ///
233 /// Parameter `isFinalChunk`: Specify if this request is complete in one shot - that all the headers you are
234 /// supplying will fit in the negotiated max packet length.
235 ///
236 /// Parameter `inHeadersData`: Can be NULL. Ptr to some data you want to send as your headers, such as Length,
237 /// Name, etc. Use the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void)
238 /// for your convenience.
239 ///
240 /// Parameter `inHeadersDataLength`: Length of data in ptr passed in above.
241 ///
242 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
243 /// Selector in your target object MUST have the following signature, or it
244 /// will not be called properly (look for error messages in Console.app):
245 ///
246 /// - (void)OBEXGetHandler:(const OBEXSessionEvent*)inSessionEvent;
247 ///
248 ///
249 /// Parameter `inTarget`: A VALID target object for the selector.
250 ///
251 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
252 /// OBEXSessionEvent struct. nil is, of course, OK here.
253 ///
254 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
255 ///
256 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
257 /// transport. You will receive a response to your command on your selector.
258 #[unsafe(method(OBEXGet:headers:headersLength:eventSelector:selectorTarget:refCon:))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn OBEXGet_headers_headersLength_eventSelector_selectorTarget_refCon(
261 &self,
262 is_final_chunk: Boolean,
263 in_headers: *mut c_void,
264 in_headers_length: usize,
265 in_selector: Option<Sel>,
266 in_target: Option<&AnyObject>,
267 in_user_ref_con: *mut c_void,
268 ) -> OBEXError;
269
270 #[cfg(feature = "OBEX")]
271 /// Send an OBEX Abort command to the session's target.
272 ///
273 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
274 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
275 ///
276 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
277 ///
278 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
279 /// Selector in your target object MUST have the following signature, or it
280 /// will not be called properly (look for error messages in Console.app):
281 ///
282 /// - (void)OBEXAbortHandler:(const OBEXSessionEvent*)inSessionEvent;
283 ///
284 ///
285 /// Parameter `inTarget`: A VALID target object for the selector.
286 ///
287 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
288 /// OBEXSessionEvent struct. nil is, of course, OK here.
289 ///
290 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
291 ///
292 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
293 /// transport. You will receive a response to your command on your selector.
294 #[unsafe(method(OBEXAbort:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn OBEXAbort_optionalHeadersLength_eventSelector_selectorTarget_refCon(
297 &self,
298 in_optional_headers: *mut c_void,
299 in_optional_headers_length: usize,
300 in_selector: Option<Sel>,
301 in_target: Option<&AnyObject>,
302 in_user_ref_con: *mut c_void,
303 ) -> OBEXError;
304
305 #[cfg(feature = "OBEX")]
306 /// Send an OBEX SetPath command to the session's target.
307 ///
308 /// Parameter `inFlags`: OBEX setpath flags. See OBEX.h for possibilities.
309 ///
310 /// Parameter `inConstants`: OBEX setpath constants. See OBEX.h for possibilities.
311 ///
312 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
313 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
314 ///
315 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
316 ///
317 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
318 /// Selector in your target object MUST have the following signature, or it
319 /// will not be called properly (look for error messages in Console.app):
320 ///
321 /// - (void)OBEXSetPathHandler:(const OBEXSessionEvent*)inSessionEvent;
322 ///
323 ///
324 /// Parameter `inTarget`: A VALID target object for the selector.
325 ///
326 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
327 /// OBEXSessionEvent struct. nil is, of course, OK here.
328 ///
329 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
330 ///
331 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
332 /// transport. You will receive a response to your command on your selector.
333 #[unsafe(method(OBEXSetPath:constants:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn OBEXSetPath_constants_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
336 &self,
337 in_flags: OBEXFlags,
338 in_constants: OBEXConstants,
339 in_optional_headers: *mut c_void,
340 in_optional_headers_length: usize,
341 in_selector: Option<Sel>,
342 in_target: Option<&AnyObject>,
343 in_user_ref_con: *mut c_void,
344 ) -> OBEXError;
345
346 #[cfg(feature = "OBEX")]
347 /// Send a connect response to a session's target.
348 ///
349 /// Parameter `inFlags`: OBEX connect flags. See OBEX.h for possibilities.
350 ///
351 /// Parameter `inConstants`: OBEX connect constants. See OBEX.h for possibilities.
352 ///
353 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
354 /// lower than the max packet size the client has reported to you in the connect command
355 /// you received from it.
356 ///
357 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
358 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
359 ///
360 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
361 ///
362 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
363 /// Selector in your target object MUST have the following signature, or it
364 /// will not be called properly (look for error messages in Console.app):
365 ///
366 /// - (void)OBEXConnectResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
367 ///
368 ///
369 /// Parameter `inTarget`: A VALID target object for the selector.
370 ///
371 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
372 /// OBEXSessionEvent struct. nil is, of course, OK here.
373 ///
374 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
375 ///
376 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
377 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
378 #[unsafe(method(OBEXConnectResponse:flags:maxPacketLength:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn OBEXConnectResponse_flags_maxPacketLength_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
381 &self,
382 in_response_op_code: OBEXOpCode,
383 in_flags: OBEXFlags,
384 in_max_packet_length: OBEXMaxPacketLength,
385 in_optional_headers: *mut c_void,
386 in_optional_headers_length: usize,
387 in_selector: Option<Sel>,
388 in_target: Option<&AnyObject>,
389 in_user_ref_con: *mut c_void,
390 ) -> OBEXError;
391
392 #[cfg(feature = "OBEX")]
393 /// Send a disconnect response to a session's target.
394 ///
395 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
396 /// lower than the max packet size the client has reported to you in the connect command
397 /// you received from it.
398 ///
399 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
400 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
401 ///
402 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
403 ///
404 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
405 /// Selector in your target object MUST have the following signature, or it
406 /// will not be called properly (look for error messages in Console.app):
407 ///
408 /// - (void)OBEXDisconnectResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
409 ///
410 ///
411 /// Parameter `inTarget`: A VALID target object for the selector.
412 ///
413 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
414 /// OBEXSessionEvent struct. nil is, of course, OK here.
415 ///
416 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
417 ///
418 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
419 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
420 #[unsafe(method(OBEXDisconnectResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
421 #[unsafe(method_family = none)]
422 pub unsafe fn OBEXDisconnectResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
423 &self,
424 in_response_op_code: OBEXOpCode,
425 in_optional_headers: *mut c_void,
426 in_optional_headers_length: usize,
427 in_selector: Option<Sel>,
428 in_target: Option<&AnyObject>,
429 in_user_ref_con: *mut c_void,
430 ) -> OBEXError;
431
432 #[cfg(feature = "OBEX")]
433 /// Send a put response to a session's target.
434 ///
435 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
436 /// lower than the max packet size the client has reported to you in the connect command
437 /// you received from it.
438 ///
439 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
440 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
441 ///
442 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
443 ///
444 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
445 /// Selector in your target object MUST have the following signature, or it
446 /// will not be called properly (look for error messages in Console.app):
447 ///
448 /// - (void)OBEXPutResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
449 ///
450 ///
451 /// Parameter `inTarget`: A VALID target object for the selector.
452 ///
453 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
454 /// OBEXSessionEvent struct. nil is, of course, OK here.
455 ///
456 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
457 ///
458 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
459 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
460 #[unsafe(method(OBEXPutResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn OBEXPutResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
463 &self,
464 in_response_op_code: OBEXOpCode,
465 in_optional_headers: *mut c_void,
466 in_optional_headers_length: usize,
467 in_selector: Option<Sel>,
468 in_target: Option<&AnyObject>,
469 in_user_ref_con: *mut c_void,
470 ) -> OBEXError;
471
472 #[cfg(feature = "OBEX")]
473 /// Send a get response to a session's target.
474 ///
475 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
476 /// lower than the max packet size the client has reported to you in the connect command
477 /// you received from it.
478 ///
479 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
480 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
481 ///
482 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
483 ///
484 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
485 /// Selector in your target object MUST have the following signature, or it
486 /// will not be called properly (look for error messages in Console.app):
487 ///
488 /// - (void)OBEXGetResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
489 ///
490 ///
491 /// Parameter `inTarget`: A VALID target object for the selector.
492 ///
493 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
494 /// OBEXSessionEvent struct. nil is, of course, OK here.
495 ///
496 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
497 ///
498 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
499 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
500 #[unsafe(method(OBEXGetResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
501 #[unsafe(method_family = none)]
502 pub unsafe fn OBEXGetResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
503 &self,
504 in_response_op_code: OBEXOpCode,
505 in_optional_headers: *mut c_void,
506 in_optional_headers_length: usize,
507 in_selector: Option<Sel>,
508 in_target: Option<&AnyObject>,
509 in_user_ref_con: *mut c_void,
510 ) -> OBEXError;
511
512 #[cfg(feature = "OBEX")]
513 /// Send a abort response to a session's target.
514 ///
515 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
516 /// lower than the max packet size the client has reported to you in the connect command
517 /// you received from it.
518 ///
519 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
520 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
521 ///
522 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
523 ///
524 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
525 /// Selector in your target object MUST have the following signature, or it
526 /// will not be called properly (look for error messages in Console.app):
527 ///
528 /// - (void)OBEXAbortResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
529 ///
530 ///
531 /// Parameter `inTarget`: A VALID target object for the selector.
532 ///
533 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
534 /// OBEXSessionEvent struct. nil is, of course, OK here.
535 ///
536 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
537 ///
538 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
539 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
540 #[unsafe(method(OBEXAbortResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
541 #[unsafe(method_family = none)]
542 pub unsafe fn OBEXAbortResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
543 &self,
544 in_response_op_code: OBEXOpCode,
545 in_optional_headers: *mut c_void,
546 in_optional_headers_length: usize,
547 in_selector: Option<Sel>,
548 in_target: Option<&AnyObject>,
549 in_user_ref_con: *mut c_void,
550 ) -> OBEXError;
551
552 #[cfg(feature = "OBEX")]
553 /// Send a set path response to a session's target.
554 ///
555 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
556 /// lower than the max packet size the client has reported to you in the connect command
557 /// you received from it.
558 ///
559 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
560 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
561 ///
562 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
563 ///
564 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
565 /// Selector in your target object MUST have the following signature, or it
566 /// will not be called properly (look for error messages in Console.app):
567 ///
568 /// - (void)OBEXSetPathResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
569 ///
570 ///
571 /// Parameter `inTarget`: A VALID target object for the selector.
572 ///
573 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
574 /// OBEXSessionEvent struct. nil is, of course, OK here.
575 ///
576 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
577 ///
578 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
579 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
580 #[unsafe(method(OBEXSetPathResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
581 #[unsafe(method_family = none)]
582 pub unsafe fn OBEXSetPathResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
583 &self,
584 in_response_op_code: OBEXOpCode,
585 in_optional_headers: *mut c_void,
586 in_optional_headers_length: usize,
587 in_selector: Option<Sel>,
588 in_target: Option<&AnyObject>,
589 in_user_ref_con: *mut c_void,
590 ) -> OBEXError;
591
592 #[cfg(feature = "OBEX")]
593 /// Determine the maximum amount of data you can send in a particular command as an OBEX client session.
594 ///
595 /// Parameter `inOpCode`: The opcode you are interested in sending (as a client).
596 ///
597 /// Returns: The maximum amount of data a particular packet can handle, after accounting for any command overhead.
598 ///
599 /// Each OBEX Command has a certain amount of overhead. Since the negotiated max packet length does
600 /// not indicate what the maximum data amount you can send in a particular command's packet, you can
601 /// use this function to determine how much data to provide in optional headers or body data headers.
602 #[unsafe(method(getAvailableCommandPayloadLength:))]
603 #[unsafe(method_family = none)]
604 pub unsafe fn getAvailableCommandPayloadLength(
605 &self,
606 in_op_code: OBEXOpCode,
607 ) -> OBEXMaxPacketLength;
608
609 #[cfg(feature = "OBEX")]
610 /// Determine the maximum amount of data you can send in a particular command response as an OBEX server session.
611 ///
612 /// Parameter `inOpCode`: The opcode you are interested in responding to (as a server).
613 ///
614 /// Returns: The maximum amount of data a particular packet can handle, after accounting for any command response overhead.
615 ///
616 /// Each OBEX Command response has a certain amount of overhead. Since the negotiated max packet length does
617 /// not indicate what the maximum data amount you can send in a particular response's packet, you can
618 /// use this function to determine how much data to provide in optional headers or body data headers.
619 #[unsafe(method(getAvailableCommandResponsePayloadLength:))]
620 #[unsafe(method_family = none)]
621 pub unsafe fn getAvailableCommandResponsePayloadLength(
622 &self,
623 in_op_code: OBEXOpCode,
624 ) -> OBEXMaxPacketLength;
625
626 #[cfg(feature = "OBEX")]
627 /// Gets current max packet length.
628 ///
629 /// Returns: Max packet length.
630 ///
631 /// This value *could* change before and after a connect command has been sent or a connect
632 /// command response has been received, since the recipient could negotiate a lower max packet size.
633 #[unsafe(method(getMaxPacketLength))]
634 #[unsafe(method_family = none)]
635 pub unsafe fn getMaxPacketLength(&self) -> OBEXMaxPacketLength;
636
637 /// Has a successful connect packet been sent and received? This API tells you so.
638 ///
639 /// Returns: True or false, we are OBEX-connected to another OBEX entity.
640 ///
641 /// A "transport" connection may exist (such as a Bluetooth baseband connection), but the OBEX connection
642 /// may not be established over that transport. If it has been, this function returns true.
643 #[unsafe(method(hasOpenOBEXConnection))]
644 #[unsafe(method_family = none)]
645 pub unsafe fn hasOpenOBEXConnection(&self) -> bool;
646
647 #[cfg(feature = "OBEX")]
648 /// Sets the C-API callback used when the session recieves data.
649 ///
650 /// Parameter `inEventCallback`: Function to callback. Should be non-NULL, unless you are attempting to clear the
651 /// callback, but doing that doesn't make much sense.
652 ///
653 /// This is really not intended for client sessions. Only subclasses would really be interested in using this. They
654 /// should set these when their subclass object is created, because otherwise they will have no way of receiving
655 /// the initial command data packet. This is a partner to setEventRefCon, described below.
656 #[unsafe(method(setEventCallback:))]
657 #[unsafe(method_family = none)]
658 pub unsafe fn setEventCallback(&self, in_event_callback: OBEXSessionEventCallback);
659
660 /// Sets the C-API callback refCon used when the session recieves data.
661 ///
662 /// Parameter `inRefCon`: User's refCon that will get passed when their event callback is invoked.
663 ///
664 /// This is really not intended for client sessions. Only subclasses would really be interested in using this. They
665 /// should set these when their subclass object is created, because otherwise they will have no context in their
666 /// callback.
667 #[unsafe(method(setEventRefCon:))]
668 #[unsafe(method_family = none)]
669 pub unsafe fn setEventRefCon(&self, in_ref_con: *mut c_void);
670
671 /// Allow you to set a selector to be called when events occur on the OBEX session.
672 ///
673 /// Parameter `inEventSelector`: Selector to call on the target.
674 ///
675 /// Parameter `inEventSelectorTarget`: Target to be called with the selector.
676 ///
677 /// Parameter `inUserRefCon`: User's refCon that will get passed when their event callback is invoked.
678 ///
679 /// Really not needed to be used, since the event selector will get set when an OBEX command is sent out.
680 #[unsafe(method(setEventSelector:target:refCon:))]
681 #[unsafe(method_family = none)]
682 pub unsafe fn setEventSelector_target_refCon(
683 &self,
684 in_event_selector: Option<Sel>,
685 in_event_selector_target: Option<&AnyObject>,
686 in_user_ref_con: *mut c_void,
687 );
688
689 #[cfg(feature = "OBEX")]
690 /// Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is
691 /// received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch
692 /// the data. If you do not handle this case, your server session will not work, guaranteed.
693 ///
694 /// Parameter `event`: New event received from the transport.
695 ///
696 /// Tranport subclasses must call this for OBEX server sessions to work!
697 #[unsafe(method(serverHandleIncomingData:))]
698 #[unsafe(method_family = none)]
699 pub unsafe fn serverHandleIncomingData(&self, event: *mut OBEXTransportEvent);
700
701 #[cfg(feature = "OBEX")]
702 /// Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is
703 /// received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch
704 /// the data. If you do not handle this case, your server session will not work, guaranteed.
705 ///
706 /// Parameter `event`: New event received from the transport.
707 ///
708 /// Tranport subclasses must call this for OBEX client sessions to work!
709 #[unsafe(method(clientHandleIncomingData:))]
710 #[unsafe(method_family = none)]
711 pub unsafe fn clientHandleIncomingData(&self, event: *mut OBEXTransportEvent);
712
713 #[cfg(feature = "OBEX")]
714 /// You must override this to send data over your transport. This does nothing by default, it will
715 /// return a kOBEXUnsupportedError.
716 ///
717 /// Parameter `inDataToSend`: Data to shove over the transport to a remote OBEX session.
718 ///
719 /// Parameter `inDataLength`: Length of data passed in.
720 ///
721 /// Returns: Return whether or not the transport could send the data or not. If you are successful, return kOBEXSuccess,
722 /// otherwise an interesting error code.
723 ///
724 /// Tranport subclasses must override this! When called you should send the data over the transport to
725 /// the remote session.
726 #[unsafe(method(sendDataToTransport:dataLength:))]
727 #[unsafe(method_family = none)]
728 pub unsafe fn sendDataToTransport_dataLength(
729 &self,
730 in_data_to_send: *mut c_void,
731 in_data_length: usize,
732 ) -> OBEXError;
733
734 #[cfg(feature = "OBEX")]
735 /// Opens a transport connection to a device. A Bluetooth connection is one example of a transport.
736 ///
737 /// Parameter `inSelector`: Selector to call for success, failure or timeout.
738 ///
739 /// Parameter `inTarget`: Target on which to call the selector.
740 ///
741 /// Parameter `inUserRefCon`: Caller's reference constant.
742 ///
743 /// Returns: Should return kOBEXSuccess ( 0 ) on success, otherwise an error code.
744 ///
745 /// Tranport subclasses must override this! when called you should attempt to open your transport
746 /// connection, and if you are successful, return kOBEXSuccess, otherwise an interesting error code.
747 #[unsafe(method(openTransportConnection:selectorTarget:refCon:))]
748 #[unsafe(method_family = none)]
749 pub unsafe fn openTransportConnection_selectorTarget_refCon(
750 &self,
751 in_selector: Option<Sel>,
752 in_target: Option<&AnyObject>,
753 in_user_ref_con: *mut c_void,
754 ) -> OBEXError;
755
756 /// You must override this - it will be called periodically to determine if a transport connection is open or not.
757 ///
758 /// Returns: Return whether or not the transport connection is still open.
759 ///
760 /// Tranport subclasses must override this! When called you simply return if the transport connection is still
761 /// open or not.
762 #[unsafe(method(hasOpenTransportConnection))]
763 #[unsafe(method_family = none)]
764 pub unsafe fn hasOpenTransportConnection(&self) -> Boolean;
765
766 #[cfg(feature = "OBEX")]
767 /// You must override this - it will be called when the transport connection should be shutdown.
768 ///
769 /// Returns: Return whether or not the transport connection was closed successfully or not. Return OBEXSuccess ( 0 ) on
770 /// success, otherwise an error code.
771 ///
772 /// Tranport subclasses must override this! When called you should take whatever steps are necessary to
773 /// actually close down the transport connection.
774 #[unsafe(method(closeTransportConnection))]
775 #[unsafe(method_family = none)]
776 pub unsafe fn closeTransportConnection(&self) -> OBEXError;
777 );
778}
779
780/// Methods declared on superclass `NSObject`.
781impl OBEXSession {
782 extern_methods!(
783 #[unsafe(method(init))]
784 #[unsafe(method_family = init)]
785 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
786
787 #[unsafe(method(new))]
788 #[unsafe(method_family = new)]
789 pub unsafe fn new() -> Retained<Self>;
790 );
791}