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 ///
130 /// # Safety
131 ///
132 /// - `in_optional_headers` must be a valid pointer.
133 /// - `in_selector` must be a valid selector.
134 /// - `in_target` should be of the correct type.
135 /// - `in_target` might not allow `None`.
136 /// - `in_user_ref_con` must be a valid pointer.
137 #[unsafe(method(OBEXConnect:maxPacketLength:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn OBEXConnect_maxPacketLength_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
140 &self,
141 in_flags: OBEXFlags,
142 in_max_packet_length: OBEXMaxPacketLength,
143 in_optional_headers: *mut c_void,
144 in_optional_headers_length: usize,
145 in_selector: Option<Sel>,
146 in_target: Option<&AnyObject>,
147 in_user_ref_con: *mut c_void,
148 ) -> OBEXError;
149
150 #[cfg(feature = "OBEX")]
151 /// Send an OBEX Disconnect command to the session's target. THIS DOES NOT necessarily close the underlying transport
152 /// connection. Deleting the session will ensure that closure.
153 ///
154 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
155 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
156 ///
157 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
158 ///
159 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
160 /// Selector in your target object MUST have the following signature, or it
161 /// will not be called properly (look for error messages in Console.app):
162 ///
163 /// - (void)OBEXDisconnectHandler:(const OBEXSessionEvent*)inSessionEvent;
164 ///
165 ///
166 /// Parameter `inTarget`: A VALID target object for the selector.
167 ///
168 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
169 /// OBEXSessionEvent struct. nil is, of course, OK here.
170 ///
171 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
172 ///
173 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
174 /// transport. You will receive a response to your command on your selector.
175 /// Be careful not to exceed the max packet length in your optional headers, or your command will be rejected.
176 /// It is recommended that you call getMaxPacketLength on your session before issuing this command so
177 /// you know how much data the session's target will accept in a single transaction.
178 ///
179 /// # Safety
180 ///
181 /// - `in_optional_headers` must be a valid pointer.
182 /// - `in_selector` must be a valid selector.
183 /// - `in_target` should be of the correct type.
184 /// - `in_target` might not allow `None`.
185 /// - `in_user_ref_con` must be a valid pointer.
186 #[unsafe(method(OBEXDisconnect:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn OBEXDisconnect_optionalHeadersLength_eventSelector_selectorTarget_refCon(
189 &self,
190 in_optional_headers: *mut c_void,
191 in_optional_headers_length: usize,
192 in_selector: Option<Sel>,
193 in_target: Option<&AnyObject>,
194 in_user_ref_con: *mut c_void,
195 ) -> OBEXError;
196
197 #[cfg(feature = "OBEX")]
198 /// Send an OBEX Put command to the session's target.
199 ///
200 /// Parameter `isFinalChunk`: Specify if this request is complete in one shot - that all the headers you are
201 /// supplying will fit in the negotiated max packet length.
202 ///
203 /// Parameter `inHeadersData`: Can be NULL. Ptr to some data you want to send as your headers, such as Length,
204 /// Name, etc. Use the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void)
205 /// for convenience.
206 ///
207 /// Parameter `inHeadersDataLength`: Length of data in ptr passed in above.
208 ///
209 /// Parameter `inBodyData`: Can be NULL. Ptr to some data you want to send as your BODY header. Do not construct a
210 /// real OBEX header here, it will be done for you - just pass a pointer to your
211 /// data, we'll do the rest. HOWEVER, be aware that some overhead (3 bytes) will be added
212 /// to the data in constructing the BODY header for you.
213 ///
214 /// Parameter `inBodyDataLength`: Length of data in ptr passed in above.
215 ///
216 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
217 /// Selector in your target object MUST have the following signature, or it
218 /// will not be called properly (look for error messages in Console.app):
219 ///
220 /// - (void)OBEXPutHandler:(const OBEXSessionEvent*)inSessionEvent;
221 ///
222 ///
223 /// Parameter `inTarget`: A VALID target object for the selector.
224 ///
225 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
226 /// OBEXSessionEvent struct. nil is, of course, OK here.
227 ///
228 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
229 ///
230 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
231 /// transport. You will receive a response to your command on your selector.
232 ///
233 /// # Safety
234 ///
235 /// - `in_headers_data` must be a valid pointer.
236 /// - `in_body_data` must be a valid pointer.
237 /// - `in_selector` must be a valid selector.
238 /// - `in_target` should be of the correct type.
239 /// - `in_target` might not allow `None`.
240 /// - `in_user_ref_con` must be a valid pointer.
241 #[unsafe(method(OBEXPut:headersData:headersDataLength:bodyData:bodyDataLength:eventSelector:selectorTarget:refCon:))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn OBEXPut_headersData_headersDataLength_bodyData_bodyDataLength_eventSelector_selectorTarget_refCon(
244 &self,
245 is_final_chunk: Boolean,
246 in_headers_data: *mut c_void,
247 in_headers_data_length: usize,
248 in_body_data: *mut c_void,
249 in_body_data_length: usize,
250 in_selector: Option<Sel>,
251 in_target: Option<&AnyObject>,
252 in_user_ref_con: *mut c_void,
253 ) -> OBEXError;
254
255 #[cfg(feature = "OBEX")]
256 /// Send an OBEX Get command to the session's target.
257 ///
258 /// Parameter `isFinalChunk`: Specify if this request is complete in one shot - that all the headers you are
259 /// supplying will fit in the negotiated max packet length.
260 ///
261 /// Parameter `inHeadersData`: Can be NULL. Ptr to some data you want to send as your headers, such as Length,
262 /// Name, etc. Use the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void)
263 /// for your convenience.
264 ///
265 /// Parameter `inHeadersDataLength`: Length of data in ptr passed in above.
266 ///
267 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
268 /// Selector in your target object MUST have the following signature, or it
269 /// will not be called properly (look for error messages in Console.app):
270 ///
271 /// - (void)OBEXGetHandler:(const OBEXSessionEvent*)inSessionEvent;
272 ///
273 ///
274 /// Parameter `inTarget`: A VALID target object for the selector.
275 ///
276 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
277 /// OBEXSessionEvent struct. nil is, of course, OK here.
278 ///
279 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
280 ///
281 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
282 /// transport. You will receive a response to your command on your selector.
283 ///
284 /// # Safety
285 ///
286 /// - `in_headers` must be a valid pointer.
287 /// - `in_selector` must be a valid selector.
288 /// - `in_target` should be of the correct type.
289 /// - `in_target` might not allow `None`.
290 /// - `in_user_ref_con` must be a valid pointer.
291 #[unsafe(method(OBEXGet:headers:headersLength:eventSelector:selectorTarget:refCon:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn OBEXGet_headers_headersLength_eventSelector_selectorTarget_refCon(
294 &self,
295 is_final_chunk: Boolean,
296 in_headers: *mut c_void,
297 in_headers_length: usize,
298 in_selector: Option<Sel>,
299 in_target: Option<&AnyObject>,
300 in_user_ref_con: *mut c_void,
301 ) -> OBEXError;
302
303 #[cfg(feature = "OBEX")]
304 /// Send an OBEX Abort command to the session's target.
305 ///
306 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
307 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
308 ///
309 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
310 ///
311 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
312 /// Selector in your target object MUST have the following signature, or it
313 /// will not be called properly (look for error messages in Console.app):
314 ///
315 /// - (void)OBEXAbortHandler:(const OBEXSessionEvent*)inSessionEvent;
316 ///
317 ///
318 /// Parameter `inTarget`: A VALID target object for the selector.
319 ///
320 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
321 /// OBEXSessionEvent struct. nil is, of course, OK here.
322 ///
323 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
324 ///
325 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
326 /// transport. You will receive a response to your command on your selector.
327 ///
328 /// # Safety
329 ///
330 /// - `in_optional_headers` must be a valid pointer.
331 /// - `in_selector` must be a valid selector.
332 /// - `in_target` should be of the correct type.
333 /// - `in_target` might not allow `None`.
334 /// - `in_user_ref_con` must be a valid pointer.
335 #[unsafe(method(OBEXAbort:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn OBEXAbort_optionalHeadersLength_eventSelector_selectorTarget_refCon(
338 &self,
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 an OBEX SetPath command to the session's target.
348 ///
349 /// Parameter `inFlags`: OBEX setpath flags. See OBEX.h for possibilities.
350 ///
351 /// Parameter `inConstants`: OBEX setpath constants. See OBEX.h for possibilities.
352 ///
353 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
354 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
355 ///
356 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
357 ///
358 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
359 /// Selector in your target object MUST have the following signature, or it
360 /// will not be called properly (look for error messages in Console.app):
361 ///
362 /// - (void)OBEXSetPathHandler:(const OBEXSessionEvent*)inSessionEvent;
363 ///
364 ///
365 /// Parameter `inTarget`: A VALID target object for the selector.
366 ///
367 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
368 /// OBEXSessionEvent struct. nil is, of course, OK here.
369 ///
370 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
371 ///
372 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
373 /// transport. You will receive a response to your command on your selector.
374 ///
375 /// # Safety
376 ///
377 /// - `in_optional_headers` must be a valid pointer.
378 /// - `in_selector` must be a valid selector.
379 /// - `in_target` should be of the correct type.
380 /// - `in_target` might not allow `None`.
381 /// - `in_user_ref_con` must be a valid pointer.
382 #[unsafe(method(OBEXSetPath:constants:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
383 #[unsafe(method_family = none)]
384 pub unsafe fn OBEXSetPath_constants_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
385 &self,
386 in_flags: OBEXFlags,
387 in_constants: OBEXConstants,
388 in_optional_headers: *mut c_void,
389 in_optional_headers_length: usize,
390 in_selector: Option<Sel>,
391 in_target: Option<&AnyObject>,
392 in_user_ref_con: *mut c_void,
393 ) -> OBEXError;
394
395 #[cfg(feature = "OBEX")]
396 /// Send a connect response to a session's target.
397 ///
398 /// Parameter `inFlags`: OBEX connect flags. See OBEX.h for possibilities.
399 ///
400 /// Parameter `inConstants`: OBEX connect constants. See OBEX.h for possibilities.
401 ///
402 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
403 /// lower than the max packet size the client has reported to you in the connect command
404 /// you received from it.
405 ///
406 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
407 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
408 ///
409 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
410 ///
411 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
412 /// Selector in your target object MUST have the following signature, or it
413 /// will not be called properly (look for error messages in Console.app):
414 ///
415 /// - (void)OBEXConnectResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
416 ///
417 ///
418 /// Parameter `inTarget`: A VALID target object for the selector.
419 ///
420 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
421 /// OBEXSessionEvent struct. nil is, of course, OK here.
422 ///
423 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
424 ///
425 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
426 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
427 ///
428 /// # Safety
429 ///
430 /// - `in_optional_headers` must be a valid pointer.
431 /// - `in_selector` must be a valid selector.
432 /// - `in_target` should be of the correct type.
433 /// - `in_target` might not allow `None`.
434 /// - `in_user_ref_con` must be a valid pointer.
435 #[unsafe(method(OBEXConnectResponse:flags:maxPacketLength:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn OBEXConnectResponse_flags_maxPacketLength_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
438 &self,
439 in_response_op_code: OBEXOpCode,
440 in_flags: OBEXFlags,
441 in_max_packet_length: OBEXMaxPacketLength,
442 in_optional_headers: *mut c_void,
443 in_optional_headers_length: usize,
444 in_selector: Option<Sel>,
445 in_target: Option<&AnyObject>,
446 in_user_ref_con: *mut c_void,
447 ) -> OBEXError;
448
449 #[cfg(feature = "OBEX")]
450 /// Send a disconnect response to a session's target.
451 ///
452 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
453 /// lower than the max packet size the client has reported to you in the connect command
454 /// you received from it.
455 ///
456 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
457 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
458 ///
459 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
460 ///
461 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
462 /// Selector in your target object MUST have the following signature, or it
463 /// will not be called properly (look for error messages in Console.app):
464 ///
465 /// - (void)OBEXDisconnectResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
466 ///
467 ///
468 /// Parameter `inTarget`: A VALID target object for the selector.
469 ///
470 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
471 /// OBEXSessionEvent struct. nil is, of course, OK here.
472 ///
473 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
474 ///
475 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
476 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
477 ///
478 /// # Safety
479 ///
480 /// - `in_optional_headers` must be a valid pointer.
481 /// - `in_selector` must be a valid selector.
482 /// - `in_target` should be of the correct type.
483 /// - `in_target` might not allow `None`.
484 /// - `in_user_ref_con` must be a valid pointer.
485 #[unsafe(method(OBEXDisconnectResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn OBEXDisconnectResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
488 &self,
489 in_response_op_code: OBEXOpCode,
490 in_optional_headers: *mut c_void,
491 in_optional_headers_length: usize,
492 in_selector: Option<Sel>,
493 in_target: Option<&AnyObject>,
494 in_user_ref_con: *mut c_void,
495 ) -> OBEXError;
496
497 #[cfg(feature = "OBEX")]
498 /// Send a put response to a session's target.
499 ///
500 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
501 /// lower than the max packet size the client has reported to you in the connect command
502 /// you received from it.
503 ///
504 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
505 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
506 ///
507 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
508 ///
509 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
510 /// Selector in your target object MUST have the following signature, or it
511 /// will not be called properly (look for error messages in Console.app):
512 ///
513 /// - (void)OBEXPutResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
514 ///
515 ///
516 /// Parameter `inTarget`: A VALID target object for the selector.
517 ///
518 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
519 /// OBEXSessionEvent struct. nil is, of course, OK here.
520 ///
521 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
522 ///
523 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
524 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
525 ///
526 /// # Safety
527 ///
528 /// - `in_optional_headers` must be a valid pointer.
529 /// - `in_selector` must be a valid selector.
530 /// - `in_target` should be of the correct type.
531 /// - `in_target` might not allow `None`.
532 /// - `in_user_ref_con` must be a valid pointer.
533 #[unsafe(method(OBEXPutResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
534 #[unsafe(method_family = none)]
535 pub unsafe fn OBEXPutResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
536 &self,
537 in_response_op_code: OBEXOpCode,
538 in_optional_headers: *mut c_void,
539 in_optional_headers_length: usize,
540 in_selector: Option<Sel>,
541 in_target: Option<&AnyObject>,
542 in_user_ref_con: *mut c_void,
543 ) -> OBEXError;
544
545 #[cfg(feature = "OBEX")]
546 /// Send a get response to a session's target.
547 ///
548 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
549 /// lower than the max packet size the client has reported to you in the connect command
550 /// you received from it.
551 ///
552 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
553 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
554 ///
555 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
556 ///
557 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
558 /// Selector in your target object MUST have the following signature, or it
559 /// will not be called properly (look for error messages in Console.app):
560 ///
561 /// - (void)OBEXGetResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
562 ///
563 ///
564 /// Parameter `inTarget`: A VALID target object for the selector.
565 ///
566 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
567 /// OBEXSessionEvent struct. nil is, of course, OK here.
568 ///
569 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
570 ///
571 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
572 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
573 ///
574 /// # Safety
575 ///
576 /// - `in_optional_headers` must be a valid pointer.
577 /// - `in_selector` must be a valid selector.
578 /// - `in_target` should be of the correct type.
579 /// - `in_target` might not allow `None`.
580 /// - `in_user_ref_con` must be a valid pointer.
581 #[unsafe(method(OBEXGetResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
582 #[unsafe(method_family = none)]
583 pub unsafe fn OBEXGetResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
584 &self,
585 in_response_op_code: OBEXOpCode,
586 in_optional_headers: *mut c_void,
587 in_optional_headers_length: usize,
588 in_selector: Option<Sel>,
589 in_target: Option<&AnyObject>,
590 in_user_ref_con: *mut c_void,
591 ) -> OBEXError;
592
593 #[cfg(feature = "OBEX")]
594 /// Send a abort response to a session's target.
595 ///
596 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
597 /// lower than the max packet size the client has reported to you in the connect command
598 /// you received from it.
599 ///
600 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
601 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
602 ///
603 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
604 ///
605 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
606 /// Selector in your target object MUST have the following signature, or it
607 /// will not be called properly (look for error messages in Console.app):
608 ///
609 /// - (void)OBEXAbortResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
610 ///
611 ///
612 /// Parameter `inTarget`: A VALID target object for the selector.
613 ///
614 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
615 /// OBEXSessionEvent struct. nil is, of course, OK here.
616 ///
617 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
618 ///
619 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
620 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
621 ///
622 /// # Safety
623 ///
624 /// - `in_optional_headers` must be a valid pointer.
625 /// - `in_selector` must be a valid selector.
626 /// - `in_target` should be of the correct type.
627 /// - `in_target` might not allow `None`.
628 /// - `in_user_ref_con` must be a valid pointer.
629 #[unsafe(method(OBEXAbortResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
630 #[unsafe(method_family = none)]
631 pub unsafe fn OBEXAbortResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
632 &self,
633 in_response_op_code: OBEXOpCode,
634 in_optional_headers: *mut c_void,
635 in_optional_headers_length: usize,
636 in_selector: Option<Sel>,
637 in_target: Option<&AnyObject>,
638 in_user_ref_con: *mut c_void,
639 ) -> OBEXError;
640
641 #[cfg(feature = "OBEX")]
642 /// Send a set path response to a session's target.
643 ///
644 /// Parameter `inMaxPacketLength`: Maximum packet size you want your OBEX session to communicate with. This MUST be
645 /// lower than the max packet size the client has reported to you in the connect command
646 /// you received from it.
647 ///
648 /// Parameter `inOptionalHeaders`: Can be NULL. Ptr to some data you want to send as your optional headers. Use
649 /// the provided header contruction kit in OBEX.h and OBEXHeadersToBytes(void) for convenience.
650 ///
651 /// Parameter `inOptionalHeadersLength`: Length of data in ptr passed in above.
652 ///
653 /// Parameter `inSelector`: A VALID selector to be called when something interesting happens due to this call.
654 /// Selector in your target object MUST have the following signature, or it
655 /// will not be called properly (look for error messages in Console.app):
656 ///
657 /// - (void)OBEXSetPathResponseHandler:(const OBEXSessionEvent*)inSessionEvent;
658 ///
659 ///
660 /// Parameter `inTarget`: A VALID target object for the selector.
661 ///
662 /// Parameter `inUserRefCon`: Whatever you want to pass here. It will be passed back to you in the refCon portion of the
663 /// OBEXSessionEvent struct. nil is, of course, OK here.
664 ///
665 /// Returns: An error code value on failure (see OBEX.h and IOReturn.h for possible return values). 0 (kOBEXSuccess) if successful.
666 ///
667 /// A NULL selector or target will result in an error. After return, the data passed in will have been sent over the
668 /// underlying OBEX transport. You will receive any responses to your command response on your selector.
669 ///
670 /// # Safety
671 ///
672 /// - `in_optional_headers` must be a valid pointer.
673 /// - `in_selector` must be a valid selector.
674 /// - `in_target` should be of the correct type.
675 /// - `in_target` might not allow `None`.
676 /// - `in_user_ref_con` must be a valid pointer.
677 #[unsafe(method(OBEXSetPathResponse:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:))]
678 #[unsafe(method_family = none)]
679 pub unsafe fn OBEXSetPathResponse_optionalHeaders_optionalHeadersLength_eventSelector_selectorTarget_refCon(
680 &self,
681 in_response_op_code: OBEXOpCode,
682 in_optional_headers: *mut c_void,
683 in_optional_headers_length: usize,
684 in_selector: Option<Sel>,
685 in_target: Option<&AnyObject>,
686 in_user_ref_con: *mut c_void,
687 ) -> OBEXError;
688
689 #[cfg(feature = "OBEX")]
690 /// Determine the maximum amount of data you can send in a particular command as an OBEX client session.
691 ///
692 /// Parameter `inOpCode`: The opcode you are interested in sending (as a client).
693 ///
694 /// Returns: The maximum amount of data a particular packet can handle, after accounting for any command overhead.
695 ///
696 /// Each OBEX Command has a certain amount of overhead. Since the negotiated max packet length does
697 /// not indicate what the maximum data amount you can send in a particular command's packet, you can
698 /// use this function to determine how much data to provide in optional headers or body data headers.
699 #[unsafe(method(getAvailableCommandPayloadLength:))]
700 #[unsafe(method_family = none)]
701 pub unsafe fn getAvailableCommandPayloadLength(
702 &self,
703 in_op_code: OBEXOpCode,
704 ) -> OBEXMaxPacketLength;
705
706 #[cfg(feature = "OBEX")]
707 /// Determine the maximum amount of data you can send in a particular command response as an OBEX server session.
708 ///
709 /// Parameter `inOpCode`: The opcode you are interested in responding to (as a server).
710 ///
711 /// Returns: The maximum amount of data a particular packet can handle, after accounting for any command response overhead.
712 ///
713 /// Each OBEX Command response has a certain amount of overhead. Since the negotiated max packet length does
714 /// not indicate what the maximum data amount you can send in a particular response's packet, you can
715 /// use this function to determine how much data to provide in optional headers or body data headers.
716 #[unsafe(method(getAvailableCommandResponsePayloadLength:))]
717 #[unsafe(method_family = none)]
718 pub unsafe fn getAvailableCommandResponsePayloadLength(
719 &self,
720 in_op_code: OBEXOpCode,
721 ) -> OBEXMaxPacketLength;
722
723 #[cfg(feature = "OBEX")]
724 /// Gets current max packet length.
725 ///
726 /// Returns: Max packet length.
727 ///
728 /// This value *could* change before and after a connect command has been sent or a connect
729 /// command response has been received, since the recipient could negotiate a lower max packet size.
730 #[unsafe(method(getMaxPacketLength))]
731 #[unsafe(method_family = none)]
732 pub unsafe fn getMaxPacketLength(&self) -> OBEXMaxPacketLength;
733
734 /// Has a successful connect packet been sent and received? This API tells you so.
735 ///
736 /// Returns: True or false, we are OBEX-connected to another OBEX entity.
737 ///
738 /// A "transport" connection may exist (such as a Bluetooth baseband connection), but the OBEX connection
739 /// may not be established over that transport. If it has been, this function returns true.
740 #[unsafe(method(hasOpenOBEXConnection))]
741 #[unsafe(method_family = none)]
742 pub unsafe fn hasOpenOBEXConnection(&self) -> bool;
743
744 #[cfg(feature = "OBEX")]
745 /// Sets the C-API callback used when the session recieves data.
746 ///
747 /// Parameter `inEventCallback`: Function to callback. Should be non-NULL, unless you are attempting to clear the
748 /// callback, but doing that doesn't make much sense.
749 ///
750 /// This is really not intended for client sessions. Only subclasses would really be interested in using this. They
751 /// should set these when their subclass object is created, because otherwise they will have no way of receiving
752 /// the initial command data packet. This is a partner to setEventRefCon, described below.
753 ///
754 /// # Safety
755 ///
756 /// `in_event_callback` must be implemented correctly.
757 #[unsafe(method(setEventCallback:))]
758 #[unsafe(method_family = none)]
759 pub unsafe fn setEventCallback(&self, in_event_callback: OBEXSessionEventCallback);
760
761 /// Sets the C-API callback refCon used when the session recieves data.
762 ///
763 /// Parameter `inRefCon`: User's refCon that will get passed when their event callback is invoked.
764 ///
765 /// This is really not intended for client sessions. Only subclasses would really be interested in using this. They
766 /// should set these when their subclass object is created, because otherwise they will have no context in their
767 /// callback.
768 ///
769 /// # Safety
770 ///
771 /// `in_ref_con` must be a valid pointer.
772 #[unsafe(method(setEventRefCon:))]
773 #[unsafe(method_family = none)]
774 pub unsafe fn setEventRefCon(&self, in_ref_con: *mut c_void);
775
776 /// Allow you to set a selector to be called when events occur on the OBEX session.
777 ///
778 /// Parameter `inEventSelector`: Selector to call on the target.
779 ///
780 /// Parameter `inEventSelectorTarget`: Target to be called with the selector.
781 ///
782 /// Parameter `inUserRefCon`: User's refCon that will get passed when their event callback is invoked.
783 ///
784 /// Really not needed to be used, since the event selector will get set when an OBEX command is sent out.
785 ///
786 /// # Safety
787 ///
788 /// - `in_event_selector` must be a valid selector.
789 /// - `in_event_selector_target` should be of the correct type.
790 /// - `in_event_selector_target` might not allow `None`.
791 /// - `in_user_ref_con` must be a valid pointer.
792 #[unsafe(method(setEventSelector:target:refCon:))]
793 #[unsafe(method_family = none)]
794 pub unsafe fn setEventSelector_target_refCon(
795 &self,
796 in_event_selector: Option<Sel>,
797 in_event_selector_target: Option<&AnyObject>,
798 in_user_ref_con: *mut c_void,
799 );
800
801 #[cfg(feature = "OBEX")]
802 /// Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is
803 /// received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch
804 /// the data. If you do not handle this case, your server session will not work, guaranteed.
805 ///
806 /// Parameter `event`: New event received from the transport.
807 ///
808 /// Tranport subclasses must call this for OBEX server sessions to work!
809 ///
810 /// # Safety
811 ///
812 /// `event` must be a valid pointer.
813 #[unsafe(method(serverHandleIncomingData:))]
814 #[unsafe(method_family = none)]
815 pub unsafe fn serverHandleIncomingData(&self, event: *mut OBEXTransportEvent);
816
817 #[cfg(feature = "OBEX")]
818 /// Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is
819 /// received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch
820 /// the data. If you do not handle this case, your server session will not work, guaranteed.
821 ///
822 /// Parameter `event`: New event received from the transport.
823 ///
824 /// Tranport subclasses must call this for OBEX client sessions to work!
825 ///
826 /// # Safety
827 ///
828 /// `event` must be a valid pointer.
829 #[unsafe(method(clientHandleIncomingData:))]
830 #[unsafe(method_family = none)]
831 pub unsafe fn clientHandleIncomingData(&self, event: *mut OBEXTransportEvent);
832
833 #[cfg(feature = "OBEX")]
834 /// You must override this to send data over your transport. This does nothing by default, it will
835 /// return a kOBEXUnsupportedError.
836 ///
837 /// Parameter `inDataToSend`: Data to shove over the transport to a remote OBEX session.
838 ///
839 /// Parameter `inDataLength`: Length of data passed in.
840 ///
841 /// Returns: Return whether or not the transport could send the data or not. If you are successful, return kOBEXSuccess,
842 /// otherwise an interesting error code.
843 ///
844 /// Tranport subclasses must override this! When called you should send the data over the transport to
845 /// the remote session.
846 ///
847 /// # Safety
848 ///
849 /// `in_data_to_send` must be a valid pointer.
850 #[unsafe(method(sendDataToTransport:dataLength:))]
851 #[unsafe(method_family = none)]
852 pub unsafe fn sendDataToTransport_dataLength(
853 &self,
854 in_data_to_send: *mut c_void,
855 in_data_length: usize,
856 ) -> OBEXError;
857
858 #[cfg(feature = "OBEX")]
859 /// Opens a transport connection to a device. A Bluetooth connection is one example of a transport.
860 ///
861 /// Parameter `inSelector`: Selector to call for success, failure or timeout.
862 ///
863 /// Parameter `inTarget`: Target on which to call the selector.
864 ///
865 /// Parameter `inUserRefCon`: Caller's reference constant.
866 ///
867 /// Returns: Should return kOBEXSuccess ( 0 ) on success, otherwise an error code.
868 ///
869 /// Tranport subclasses must override this! when called you should attempt to open your transport
870 /// connection, and if you are successful, return kOBEXSuccess, otherwise an interesting error code.
871 ///
872 /// # Safety
873 ///
874 /// - `in_selector` must be a valid selector.
875 /// - `in_target` should be of the correct type.
876 /// - `in_target` might not allow `None`.
877 /// - `in_user_ref_con` must be a valid pointer.
878 #[unsafe(method(openTransportConnection:selectorTarget:refCon:))]
879 #[unsafe(method_family = none)]
880 pub unsafe fn openTransportConnection_selectorTarget_refCon(
881 &self,
882 in_selector: Option<Sel>,
883 in_target: Option<&AnyObject>,
884 in_user_ref_con: *mut c_void,
885 ) -> OBEXError;
886
887 /// You must override this - it will be called periodically to determine if a transport connection is open or not.
888 ///
889 /// Returns: Return whether or not the transport connection is still open.
890 ///
891 /// Tranport subclasses must override this! When called you simply return if the transport connection is still
892 /// open or not.
893 #[unsafe(method(hasOpenTransportConnection))]
894 #[unsafe(method_family = none)]
895 pub unsafe fn hasOpenTransportConnection(&self) -> Boolean;
896
897 #[cfg(feature = "OBEX")]
898 /// You must override this - it will be called when the transport connection should be shutdown.
899 ///
900 /// Returns: Return whether or not the transport connection was closed successfully or not. Return OBEXSuccess ( 0 ) on
901 /// success, otherwise an error code.
902 ///
903 /// Tranport subclasses must override this! When called you should take whatever steps are necessary to
904 /// actually close down the transport connection.
905 #[unsafe(method(closeTransportConnection))]
906 #[unsafe(method_family = none)]
907 pub unsafe fn closeTransportConnection(&self) -> OBEXError;
908 );
909}
910
911/// Methods declared on superclass `NSObject`.
912impl OBEXSession {
913 extern_methods!(
914 #[unsafe(method(init))]
915 #[unsafe(method_family = init)]
916 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
917
918 #[unsafe(method(new))]
919 #[unsafe(method_family = new)]
920 pub unsafe fn new() -> Retained<Self>;
921 );
922}