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        #[unsafe(method(publishedServiceRecordWithDictionary:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn publishedServiceRecordWithDictionary(
90            service_dict: Option<&NSDictionary>,
91        ) -> Option<Retained<Self>>;
92
93        /// Removes the service from the local SDP server.
94        ///
95        /// Returns: Returns kIOReturnSuccess if successful.
96        #[unsafe(method(removeServiceRecord))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn removeServiceRecord(&self) -> IOReturn;
99
100        #[cfg(all(
101            feature = "IOBluetoothDevice",
102            feature = "IOBluetoothObject",
103            feature = "objc2-foundation"
104        ))]
105        /// Returns an IOBluetoothSDPServiceRecord * with the attributes specified in the provided service dictionary. Provide
106        /// a pointer to an IOBlueotothDevice if you wish to associate the record to a specific IOBluetoothDevice.
107        ///
108        /// Returns: Returns an IOBluetoothSDPServiceRecord * with the attributes specified in the provided dictionary.
109        #[unsafe(method(withServiceDictionary:device:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn withServiceDictionary_device(
112            service_dict: Option<&NSDictionary>,
113            device: Option<&IOBluetoothDevice>,
114        ) -> Option<Retained<Self>>;
115
116        #[cfg(all(
117            feature = "IOBluetoothDevice",
118            feature = "IOBluetoothObject",
119            feature = "objc2-foundation"
120        ))]
121        /// Returns an initialized IOBluetoothSDPServiceRecord * with the attributes specified in the provided service dictionary. Provide
122        /// a pointer to an IOBlueotothDevice if you wish to associate the record to a specific IOBluetoothDevice.
123        ///
124        /// Returns: Returns an initialized IOBluetoothSDPServiceRecord * with the attributes specified in the provided dictionary.
125        #[unsafe(method(initWithServiceDictionary:device:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithServiceDictionary_device(
128            this: Allocated<Self>,
129            service_dict: Option<&NSDictionary>,
130            device: Option<&IOBluetoothDevice>,
131        ) -> Option<Retained<Self>>;
132
133        #[cfg(feature = "IOBluetoothUserLib")]
134        /// Method call to convert an IOBluetoothSDPServiceRecordRef into an IOBluetoothSDPServiceRecord *.
135        ///
136        /// Parameter `sdpServiceRecordRef`: IOBluetoothSDPServiceRecordRef for which an IOBluetoothSDPServiceRecord * is desired.
137        ///
138        /// Returns: Returns the IOBluetoothSDPServiceRecord * for the given IOBluetoothSDPServiceRecordRef.
139        #[unsafe(method(withSDPServiceRecordRef:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn withSDPServiceRecordRef(
142            sdp_service_record_ref: Option<&IOBluetoothSDPServiceRecordRef>,
143        ) -> Option<Retained<Self>>;
144
145        #[cfg(feature = "IOBluetoothUserLib")]
146        /// Returns an IOBluetoothSDPServiceRecordRef representation of the target IOBluetoothSDPServiceRecord object.
147        ///
148        /// Returns: Returns an IOBluetoothSDPServiceRecordRef representation of the target IOBluetoothSDPServiceRecord object.
149        #[unsafe(method(getSDPServiceRecordRef))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn getSDPServiceRecordRef(
152            &self,
153        ) -> Option<Retained<IOBluetoothSDPServiceRecordRef>>;
154
155        #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
156        /// Returns the IOBluetoothDevice that the target service belongs to.
157        ///
158        /// If the service is a local service (i.e. one the current host is vending out), then nil is returned.
159        ///
160        /// Returns: Returns the IOBluetoothDevice that the target service belongs to.  If the service is one the local host
161        /// is vending, then nil is returned.
162        #[unsafe(method(device))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn device(&self) -> Option<Retained<IOBluetoothDevice>>;
165
166        #[cfg(all(feature = "IOBluetoothDevice", feature = "IOBluetoothObject"))]
167        #[deprecated]
168        #[unsafe(method(getDevice))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn getDevice(&self) -> Option<Retained<IOBluetoothDevice>>;
171
172        #[cfg(feature = "objc2-foundation")]
173        /// Returns an NSDictionary containing the attributes for the service.
174        ///
175        /// The attribute dictionary is keyed off of the attribute id represented as an NSNumber.  The values
176        /// in the NSDictionary are IOBluetoothSDPDataElement objects representing the data element for the
177        /// given attribute.
178        ///
179        /// Returns: Returns an NSDictionary containing the attributes for the target service.
180        #[unsafe(method(attributes))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn attributes(&self) -> Retained<NSDictionary>;
183
184        #[cfg(feature = "objc2-foundation")]
185        #[deprecated]
186        #[unsafe(method(getAttributes))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn getAttributes(&self) -> Option<Retained<NSDictionary>>;
189
190        #[cfg(all(feature = "Bluetooth", feature = "IOBluetoothSDPDataElement"))]
191        /// Returns the data element for the given attribute ID in the target service.
192        ///
193        /// Parameter `attributeID`: The attribute ID of the desired attribute.
194        ///
195        /// Returns: Returns the data element for the given attribute ID in the target service.  If the service does not
196        /// contain an attribute with the given ID, then nil is returned.
197        #[unsafe(method(getAttributeDataElement:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn getAttributeDataElement(
200            &self,
201            attribute_id: BluetoothSDPServiceAttributeID,
202        ) -> Option<Retained<IOBluetoothSDPDataElement>>;
203
204        #[cfg(feature = "objc2-foundation")]
205        /// Returns the name of the service.
206        ///
207        /// This is currently implemented to simply return the attribute with an id of 0x0100.  In
208        /// the future, it will be extended to allow name localization based on the user's chosen
209        /// language or other languages.
210        ///
211        /// Returns: Returns the name of the target service.
212        #[unsafe(method(getServiceName))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn getServiceName(&self) -> Option<Retained<NSString>>;
215
216        #[cfg(feature = "Bluetooth")]
217        /// Allows the discovery of the RFCOMM channel ID assigned to the service.
218        ///
219        /// This method will search through the ProtoclDescriptorList attribute to find an entry
220        /// with the RFCOMM UUID (UUID16: 0x0003).  If one is found, it gets the second element of
221        /// the data element sequence and sets the rfcommChannelID pointer to it.  The channel ID
222        /// only gets set when kIOReturnSuccess is returned.
223        ///
224        /// Parameter `rfcommChannelID`: A pointer to the location that will get the found RFCOMM channel ID.
225        ///
226        /// Returns: Returns kIOReturnSuccess if the channel ID is found.
227        #[unsafe(method(getRFCOMMChannelID:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn getRFCOMMChannelID(
230            &self,
231            rfcomm_channel_id: *mut BluetoothRFCOMMChannelID,
232        ) -> IOReturn;
233
234        #[cfg(feature = "Bluetooth")]
235        /// Allows the discovery of the L2CAP PSM assigned to the service.
236        ///
237        /// This method will search through the ProtoclDescriptorList attribute to find an entry
238        /// with the L2CAP UUID (UUID16: 0x0100).  If one is found, it gets the second element of
239        /// the data element sequence and sets the outPSM pointer to it.  The PSM value
240        /// only gets set when kIOReturnSuccess is returned.
241        ///
242        /// Parameter `outPSM`: A pointer to the location that will get the found L2CAP PSM.
243        ///
244        /// Returns: Returns kIOReturnSuccess if the PSM is found.
245        #[unsafe(method(getL2CAPPSM:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn getL2CAPPSM(&self, out_psm: *mut BluetoothL2CAPPSM) -> IOReturn;
248
249        #[cfg(feature = "Bluetooth")]
250        /// Allows the discovery of the service record handle assigned to the service.
251        ///
252        /// This method will search through the attributes to find the one representing the
253        /// service record handle.  If one is found the outServiceRecordHandle param is set
254        /// with the value.  The outServiceRecordHandle value only gets set when kIOReturnSuccess
255        /// is returned.
256        ///
257        /// Parameter `outServiceRecordHandle`: A pointer to the location that will get the found service record handle.
258        ///
259        /// Returns: Returns kIOReturnSuccess if the service record handle is found.
260        #[unsafe(method(getServiceRecordHandle:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn getServiceRecordHandle(
263            &self,
264            out_service_record_handle: *mut BluetoothSDPServiceRecordHandle,
265        ) -> IOReturn;
266
267        #[cfg(feature = "Bluetooth")]
268        /// Returns TRUE the UUID16 is found in the target service.
269        ///
270        /// NOTE: This method is only available in Mac OS X 10.7 or later.
271        ///
272        /// Parameter `uuid16`: A BluetoothSDPUUID16 to search for in the target service.
273        ///
274        /// Returns: Returns TRUE if the UUID16 is present in the service.
275        #[unsafe(method(matchesUUID16:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn matchesUUID16(&self, uuid16: BluetoothSDPUUID16) -> bool;
278
279        #[cfg(feature = "objc2-foundation")]
280        /// Returns TRUE if ALL of the UUIDs in the given array is found in the target service.
281        ///
282        /// The given array should contain IOBluetoothSDPUUID objects.  It only returns TRUE if all of
283        /// the UUIDs are found.  This method is like hasServiceFromArray: except that it requires that
284        /// all UUIDs match instead of any of them matching.
285        ///
286        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
287        ///
288        /// Parameter `array`: An NSArray of IOBluetoothSDPUUID objects to search for in the target service.
289        ///
290        /// Returns: Returns TRUE if all of the given UUIDs are present in the service.
291        #[unsafe(method(matchesUUIDArray:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn matchesUUIDArray(&self, uuid_array: Option<&NSArray>) -> bool;
294
295        #[cfg(feature = "objc2-foundation")]
296        /// Returns TRUE any of the UUID arrays in the search array match the target service.
297        ///
298        /// The given array should contain NSArray objects.  Each sub-NSArray should contain
299        /// IOBluetoothSDPUUID objects.  In turn, each sub-NSArray gets passed to -matchesUUIDArray:
300        /// If any of those returns TRUE, then the search stops and TRUE is returned.
301        /// Essentially the master NSArray contains the OR operations and each sub-array contains
302        /// the AND operations.
303        ///
304        /// NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.
305        ///
306        /// Parameter `array`: An NSArray of NSArrays of IOBluetoothSDPUUID objects.
307        ///
308        /// Returns: Returns TRUE if any of the UUID arrays match.
309        #[unsafe(method(matchesSearchArray:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn matchesSearchArray(&self, search_array: Option<&NSArray>) -> bool;
312
313        #[cfg(feature = "objc2-foundation")]
314        /// Returns TRUE if any one of the UUIDs in the given array is found in the target service.
315        ///
316        /// The given array should contain IOBluetoothSDPUUID objects.  It is currently implemented
317        /// such that it returns TRUE if any of the UUIDs are found.  However in the future, it is likely
318        /// that this will change to more closely match the functionality in the SDP spec so that it only
319        /// returns TRUE if all of the given UUIDs are present.  That way, both AND and OR comparisons
320        /// can be implemented.  Please make a note of this potential change.
321        ///
322        /// Parameter `array`: An NSArray of IOBluetoothSDPUUID objects to search for in the target service.
323        ///
324        /// Returns: Returns TRUE if any of the given UUIDs are present in the service.
325        #[unsafe(method(hasServiceFromArray:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn hasServiceFromArray(&self, array: Option<&NSArray>) -> bool;
328
329        #[cfg(feature = "objc2-foundation")]
330        /// Returns a sorted array of SDP attributes
331        ///
332        /// This method will walk all the elements of the service record and return an array of
333        /// IOBluetoothSDPServiceAttribute objects sorted by attributeID
334        ///
335        /// Returns: Returns a sorted array of SDP attributes
336        #[unsafe(method(sortedAttributes))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn sortedAttributes(&self) -> Retained<NSArray>;
339    );
340}
341
342/// Methods declared on superclass `NSObject`.
343impl IOBluetoothSDPServiceRecord {
344    extern_methods!(
345        #[unsafe(method(init))]
346        #[unsafe(method_family = init)]
347        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
348
349        #[unsafe(method(new))]
350        #[unsafe(method_family = new)]
351        pub unsafe fn new() -> Retained<Self>;
352    );
353}