objc2_io_bluetooth/generated/objc2/
IOBluetoothSDPServiceRecord.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-foundation")]
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// An instance of this class represents a single SDP service record.
12    ///
13    /// As a service record, an instance of this class has an NSDictionary of service attributes.
14    /// It also has a link to the IOBluetoothDevice that the service belongs to.  The service
15    /// dictionary is keyed off of the attribute ID of each attribute represented as an NSNumber.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothsdpservicerecord?language=objc)
18    #[unsafe(super(NSObject))]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    pub struct IOBluetoothSDPServiceRecord;
21);
22
23#[cfg(feature = "objc2-foundation")]
24extern_conformance!(
25    unsafe impl NSCoding for IOBluetoothSDPServiceRecord {}
26);
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for IOBluetoothSDPServiceRecord {}
30);
31
32#[cfg(feature = "objc2-foundation")]
33extern_conformance!(
34    unsafe impl NSSecureCoding for IOBluetoothSDPServiceRecord {}
35);
36
37impl IOBluetoothSDPServiceRecord {
38    extern_methods!(
39        #[cfg(feature = "objc2-foundation")]
40        /// Adds a service to the local SDP server.
41        ///
42        /// Returns: Returns an IOBluetoothSDPServiceRecord * with the attributes specified in the provided dictionary.
43        ///
44        ///
45        /// Each entry in the dictionary representing the service contains the individual attributes.  Each
46        /// attribute in the dict is keyed by a string that must begin with a hex number representing the
47        /// attribute ID.  The key string may contain additional characters if desired as long as they
48        /// follow a space after the ID hex string.  The attribute value must follow the dictionary format
49        /// described by IOBluetoothSDPDataElement.  This dictionary format allows a service dict to be
50        /// created as a plist file and then loaded into the system rather than built up in code.  See the
51        /// example code for an example of how can be done.
52        ///
53        /// If the service record handle, L2CAP PSM or RFCOMM channel ID specified in the dictionary are in
54        /// use, an alternate one will be assigned.
55        ///
56        /// In addition to attributes that represent the service itself, additional attributes may be specified
57        /// that control the local behavior of the service.  To specify these local attributes, an additional
58        /// property titled "LocalAttributes" may be added to the root of the service dict.  The value of this
59        /// property must be a dictionary that contains the individual local attributes.
60        ///
61        /// Currently, only two local attributes are supported: "Persistent" and "TargetApplication".
62        ///
63        /// The "Persistent" local attribute must be either a boolean or number representing whether the service
64        /// should be persistent.  A persistent service will be saved off and restored any time the Bluetooth
65        /// hardware is present.  It will persist through reboots and can only be removed by calling
66        /// IOBluetoothRemoveServiceWithRecordHandle(void).  This attribute is optional.  By default, if no
67        /// "Persistent" local property is present,    the service will only exist temporarily.  It will
68        /// be removed either when IOBluetoothRemoveServiceWithRecordHandle(void) is called or when the client
69        /// application exits.
70        ///
71        /// The "TargetApplication" local attribute is used to specify an application to be launched when a
72        /// remote device attempts to connect to the service (by opening either an L2CAP or RFCOMM channel of
73        /// the type specified in the service).  This value must be a string representing the absolute path to
74        /// the target executable (not just the .app wrapper - i.e.
75        /// /System/Library/CoreServices/OBEXAgent.app/Contents/MacOS/OBEXAgent).  This attribute is optional.
76        /// If no "TargetApplication" local attribute is specified, no special action will take place when an
77        /// incoming connection to the service is created.  It is up to the client to be monitoring for the
78        /// connection and to do the right thing when one appears.
79        ///
80        /// The "LocalAttributes" property is optional.  If it is not specified, by default the created service
81        /// is transient and will be removed when the client exits.
82        ///
83        /// Additional local attributes to further control incoming services will be added in the future.
84        ///
85        ///
86        /// Parameter `serviceDict`: A dictionary containing the attributes for the new service
87        ///
88        /// # Safety
89        ///
90        /// - `service_dict` generic should be of the correct type.
91        /// - `service_dict` might not allow `None`.
92        #[unsafe(method(publishedServiceRecordWithDictionary:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn publishedServiceRecordWithDictionary(
95            service_dict: Option<&NSDictionary>,
96        ) -> Option<Retained<Self>>;
97
98        /// Removes the service from the local SDP server.
99        ///
100        /// Returns: Returns kIOReturnSuccess if successful.
101        #[unsafe(method(removeServiceRecord))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn removeServiceRecord(&self) -> IOReturn;
104
105        #[cfg(all(
106            feature = "IOBluetoothDevice",
107            feature = "IOBluetoothObject",
108            feature = "objc2-foundation"
109        ))]
110        /// Returns an IOBluetoothSDPServiceRecord * with the attributes specified in the provided service dictionary. Provide
111        /// a pointer to an IOBlueotothDevice if you wish to associate the record to a specific IOBluetoothDevice.
112        ///
113        /// Returns: Returns an IOBluetoothSDPServiceRecord * with the attributes specified in the provided dictionary.
114        ///
115        /// # Safety
116        ///
117        /// - `service_dict` generic should be of the correct type.
118        /// - `service_dict` might not allow `None`.
119        /// - `device` might not allow `None`.
120        #[unsafe(method(withServiceDictionary:device:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn withServiceDictionary_device(
123            service_dict: Option<&NSDictionary>,
124            device: Option<&IOBluetoothDevice>,
125        ) -> Option<Retained<Self>>;
126
127        #[cfg(all(
128            feature = "IOBluetoothDevice",
129            feature = "IOBluetoothObject",
130            feature = "objc2-foundation"
131        ))]
132        /// Returns an initialized IOBluetoothSDPServiceRecord * with the attributes specified in the provided service dictionary. Provide
133        /// a pointer to an IOBlueotothDevice if you wish to associate the record to a specific IOBluetoothDevice.
134        ///
135        /// Returns: Returns an initialized IOBluetoothSDPServiceRecord * with the attributes specified in the provided dictionary.
136        ///
137        /// # Safety
138        ///
139        /// - `service_dict` generic should be of the correct type.
140        /// - `service_dict` might not allow `None`.
141        /// - `device` might not allow `None`.
142        #[unsafe(method(initWithServiceDictionary:device:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithServiceDictionary_device(
145            this: Allocated<Self>,
146            service_dict: Option<&NSDictionary>,
147            device: Option<&IOBluetoothDevice>,
148        ) -> Option<Retained<Self>>;
149
150        #[cfg(feature = "IOBluetoothUserLib")]
151        /// Method call to convert an IOBluetoothSDPServiceRecordRef into an IOBluetoothSDPServiceRecord *.
152        ///
153        /// Parameter `sdpServiceRecordRef`: IOBluetoothSDPServiceRecordRef for which an IOBluetoothSDPServiceRecord * is desired.
154        ///
155        /// Returns: Returns the IOBluetoothSDPServiceRecord * for the given IOBluetoothSDPServiceRecordRef.
156        ///
157        /// # Safety
158        ///
159        /// `sdp_service_record_ref` might not allow `None`.
160        #[unsafe(method(withSDPServiceRecordRef:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn withSDPServiceRecordRef(
163            sdp_service_record_ref: Option<&IOBluetoothSDPServiceRecordRef>,
164        ) -> Option<Retained<Self>>;
165
166        #[cfg(feature = "IOBluetoothUserLib")]
167        /// Returns an IOBluetoothSDPServiceRecordRef representation of the target IOBluetoothSDPServiceRecord object.
168        ///
169        /// Returns: Returns an IOBluetoothSDPServiceRecordRef representation of the target IOBluetoothSDPServiceRecord object.
170        #[unsafe(method(getSDPServiceRecordRef))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn getSDPServiceRecordRef(
173            &self,
174        ) -> Option<Retained<IOBluetoothSDPServiceRecordRef>>;
175
176        #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
177        /// Returns the IOBluetoothDevice that the target service belongs to.
178        ///
179        /// If the service is a local service (i.e. one the current host is vending out), then nil is returned.
180        ///
181        /// Returns: Returns the IOBluetoothDevice that the target service belongs to.  If the service is one the local host
182        /// is vending, then nil is returned.
183        #[unsafe(method(device))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn device(&self) -> Option<Retained<IOBluetoothDevice>>;
186
187        #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
188        #[deprecated]
189        #[unsafe(method(getDevice))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn getDevice(&self) -> Option<Retained<IOBluetoothDevice>>;
192
193        #[cfg(feature = "objc2-foundation")]
194        /// Returns an NSDictionary containing the attributes for the service.
195        ///
196        /// The attribute dictionary is keyed off of the attribute id represented as an NSNumber.  The values
197        /// in the NSDictionary are IOBluetoothSDPDataElement objects representing the data element for the
198        /// given attribute.
199        ///
200        /// Returns: Returns an NSDictionary containing the attributes for the target service.
201        #[unsafe(method(attributes))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn attributes(&self) -> Retained<NSDictionary>;
204
205        #[cfg(feature = "objc2-foundation")]
206        #[deprecated]
207        #[unsafe(method(getAttributes))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn getAttributes(&self) -> Option<Retained<NSDictionary>>;
210
211        #[cfg(all(feature = "Bluetooth", feature = "IOBluetoothSDPDataElement"))]
212        /// Returns the data element for the given attribute ID in the target service.
213        ///
214        /// Parameter `attributeID`: The attribute ID of the desired attribute.
215        ///
216        /// Returns: Returns the data element for the given attribute ID in the target service.  If the service does not
217        /// contain an attribute with the given ID, then nil is returned.
218        #[unsafe(method(getAttributeDataElement:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn getAttributeDataElement(
221            &self,
222            attribute_id: BluetoothSDPServiceAttributeID,
223        ) -> Option<Retained<IOBluetoothSDPDataElement>>;
224
225        #[cfg(feature = "objc2-foundation")]
226        /// Returns the name of the service.
227        ///
228        /// This is currently implemented to simply return the attribute with an id of 0x0100.  In
229        /// the future, it will be extended to allow name localization based on the user's chosen
230        /// language or other languages.
231        ///
232        /// Returns: Returns the name of the target service.
233        #[unsafe(method(getServiceName))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn getServiceName(&self) -> Option<Retained<NSString>>;
236
237        #[cfg(feature = "Bluetooth")]
238        /// Allows the discovery of the RFCOMM channel ID assigned to the service.
239        ///
240        /// This method will search through the ProtoclDescriptorList attribute to find an entry
241        /// with the RFCOMM UUID (UUID16: 0x0003).  If one is found, it gets the second element of
242        /// the data element sequence and sets the rfcommChannelID pointer to it.  The channel ID
243        /// only gets set when kIOReturnSuccess is returned.
244        ///
245        /// Parameter `rfcommChannelID`: A pointer to the location that will get the found RFCOMM channel ID.
246        ///
247        /// Returns: Returns kIOReturnSuccess if the channel ID is found.
248        ///
249        /// # Safety
250        ///
251        /// `rfcomm_channel_id` must be a valid pointer.
252        #[unsafe(method(getRFCOMMChannelID:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn getRFCOMMChannelID(
255            &self,
256            rfcomm_channel_id: *mut BluetoothRFCOMMChannelID,
257        ) -> IOReturn;
258
259        #[cfg(feature = "Bluetooth")]
260        /// Allows the discovery of the L2CAP PSM assigned to the service.
261        ///
262        /// This method will search through the ProtoclDescriptorList attribute to find an entry
263        /// with the L2CAP UUID (UUID16: 0x0100).  If one is found, it gets the second element of
264        /// the data element sequence and sets the outPSM pointer to it.  The PSM value
265        /// only gets set when kIOReturnSuccess is returned.
266        ///
267        /// Parameter `outPSM`: A pointer to the location that will get the found L2CAP PSM.
268        ///
269        /// Returns: Returns kIOReturnSuccess if the PSM is found.
270        ///
271        /// # Safety
272        ///
273        /// `out_psm` must be a valid pointer.
274        #[unsafe(method(getL2CAPPSM:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn getL2CAPPSM(&self, out_psm: *mut BluetoothL2CAPPSM) -> IOReturn;
277
278        #[cfg(feature = "Bluetooth")]
279        /// Allows the discovery of the service record handle assigned to the service.
280        ///
281        /// This method will search through the attributes to find the one representing the
282        /// service record handle.  If one is found the outServiceRecordHandle param is set
283        /// with the value.  The outServiceRecordHandle value only gets set when kIOReturnSuccess
284        /// is returned.
285        ///
286        /// Parameter `outServiceRecordHandle`: A pointer to the location that will get the found service record handle.
287        ///
288        /// Returns: Returns kIOReturnSuccess if the service record handle is found.
289        ///
290        /// # Safety
291        ///
292        /// `out_service_record_handle` must be a valid pointer.
293        #[unsafe(method(getServiceRecordHandle:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn getServiceRecordHandle(
296            &self,
297            out_service_record_handle: *mut BluetoothSDPServiceRecordHandle,
298        ) -> IOReturn;
299
300        #[cfg(feature = "Bluetooth")]
301        /// Returns TRUE the UUID16 is found in the target service.
302        ///
303        /// NOTE: This method is only available in Mac OS X 10.7 or later.
304        ///
305        /// Parameter `uuid16`: A BluetoothSDPUUID16 to search for in the target service.
306        ///
307        /// Returns: Returns TRUE if the UUID16 is present in the service.
308        #[unsafe(method(matchesUUID16:))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn matchesUUID16(&self, uuid16: BluetoothSDPUUID16) -> bool;
311
312        #[cfg(feature = "objc2-foundation")]
313        /// Returns TRUE if ALL of the UUIDs in the given array is found in the target service.
314        ///
315        /// The given array should contain IOBluetoothSDPUUID objects.  It only returns TRUE if all of
316        /// the UUIDs are found.  This method is like hasServiceFromArray: except that it requires that
317        /// all UUIDs match instead of any of them matching.
318        ///
319        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
320        ///
321        /// Parameter `array`: An NSArray of IOBluetoothSDPUUID objects to search for in the target service.
322        ///
323        /// Returns: Returns TRUE if all of the given UUIDs are present in the service.
324        ///
325        /// # Safety
326        ///
327        /// - `uuid_array` generic should be of the correct type.
328        /// - `uuid_array` might not allow `None`.
329        #[unsafe(method(matchesUUIDArray:))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn matchesUUIDArray(&self, uuid_array: Option<&NSArray>) -> bool;
332
333        #[cfg(feature = "objc2-foundation")]
334        /// Returns TRUE any of the UUID arrays in the search array match the target service.
335        ///
336        /// The given array should contain NSArray objects.  Each sub-NSArray should contain
337        /// IOBluetoothSDPUUID objects.  In turn, each sub-NSArray gets passed to -matchesUUIDArray:
338        /// If any of those returns TRUE, then the search stops and TRUE is returned.
339        /// Essentially the master NSArray contains the OR operations and each sub-array contains
340        /// the AND operations.
341        ///
342        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
343        ///
344        /// Parameter `array`: An NSArray of NSArrays of IOBluetoothSDPUUID objects.
345        ///
346        /// Returns: Returns TRUE if any of the UUID arrays match.
347        ///
348        /// # Safety
349        ///
350        /// - `search_array` generic should be of the correct type.
351        /// - `search_array` might not allow `None`.
352        #[unsafe(method(matchesSearchArray:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn matchesSearchArray(&self, search_array: Option<&NSArray>) -> bool;
355
356        #[cfg(feature = "objc2-foundation")]
357        /// Returns TRUE if any one of the UUIDs in the given array is found in the target service.
358        ///
359        /// The given array should contain IOBluetoothSDPUUID objects.  It is currently implemented
360        /// such that it returns TRUE if any of the UUIDs are found.  However in the future, it is likely
361        /// that this will change to more closely match the functionality in the SDP spec so that it only
362        /// returns TRUE if all of the given UUIDs are present.  That way, both AND and OR comparisons
363        /// can be implemented.  Please make a note of this potential change.
364        ///
365        /// Parameter `array`: An NSArray of IOBluetoothSDPUUID objects to search for in the target service.
366        ///
367        /// Returns: Returns TRUE if any of the given UUIDs are present in the service.
368        ///
369        /// # Safety
370        ///
371        /// - `array` generic should be of the correct type.
372        /// - `array` might not allow `None`.
373        #[unsafe(method(hasServiceFromArray:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn hasServiceFromArray(&self, array: Option<&NSArray>) -> bool;
376
377        #[cfg(feature = "objc2-foundation")]
378        /// Returns a sorted array of SDP attributes
379        ///
380        /// This method will walk all the elements of the service record and return an array of
381        /// IOBluetoothSDPServiceAttribute objects sorted by attributeID
382        ///
383        /// Returns: Returns a sorted array of SDP attributes
384        #[unsafe(method(sortedAttributes))]
385        #[unsafe(method_family = none)]
386        pub unsafe fn sortedAttributes(&self) -> Retained<NSArray>;
387    );
388}
389
390/// Methods declared on superclass `NSObject`.
391impl IOBluetoothSDPServiceRecord {
392    extern_methods!(
393        #[unsafe(method(init))]
394        #[unsafe(method_family = init)]
395        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
396
397        #[unsafe(method(new))]
398        #[unsafe(method_family = new)]
399        pub unsafe fn new() -> Retained<Self>;
400    );
401}