objc2_core_wlan/generated/CWWiFiClient.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11 /// Receive Wi-Fi event notifications.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/corewlan/cweventdelegate?language=objc)
14 pub unsafe trait CWEventDelegate {
15 /// Invoked if the connection to the Wi-Fi subsystem is temporarily interrupted.
16 ///
17 ///
18 /// All event notifications for which the Wi-Fi client has registered will be automatically re-registered if
19 /// the connection is interrupted.
20 /// The Wi-Fi client should re-sync any local state which is updated as a result of Wi-Fi event notifications.
21 #[optional]
22 #[unsafe(method(clientConnectionInterrupted))]
23 #[unsafe(method_family = none)]
24 unsafe fn clientConnectionInterrupted(&self);
25
26 /// Invoked if the connection to the Wi-Fi subsystem is permanently invalidated.
27 #[optional]
28 #[unsafe(method(clientConnectionInvalidated))]
29 #[unsafe(method_family = none)]
30 unsafe fn clientConnectionInvalidated(&self);
31
32 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
33 ///
34 ///
35 /// Invoked when the Wi-Fi power state changes.
36 ///
37 ///
38 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypePowerDidChange event type
39 /// to register for power event notifications.
40 /// Use -[CWInterface powerOn] to query the current Wi-Fi power state.
41 #[optional]
42 #[unsafe(method(powerStateDidChangeForWiFiInterfaceWithName:))]
43 #[unsafe(method_family = none)]
44 unsafe fn powerStateDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
45
46 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
47 ///
48 ///
49 /// Invoked when the current SSID changes.
50 ///
51 ///
52 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeSSIDDidChange event type
53 /// to register for SSID event notifications.
54 /// Use -[CWInterface ssidData] or -[CWInterface ssid] to query the current SSID.
55 #[optional]
56 #[unsafe(method(ssidDidChangeForWiFiInterfaceWithName:))]
57 #[unsafe(method_family = none)]
58 unsafe fn ssidDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
59
60 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
61 ///
62 ///
63 /// Invoked when the current BSSID changes.
64 ///
65 ///
66 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeBSSIDDidChange event type
67 /// to register for BSSID event notifications.
68 /// Use -[CWInterface bssid] to query the current BSSID.
69 #[optional]
70 #[unsafe(method(bssidDidChangeForWiFiInterfaceWithName:))]
71 #[unsafe(method_family = none)]
72 unsafe fn bssidDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
73
74 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
75 ///
76 ///
77 /// Invoked when the currently adopted country code changes.
78 ///
79 ///
80 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeCountryCodeDidChange event type
81 /// to register for country code event notifications.
82 /// Use -[CWInterface countryCode] to query the currently adopted country code.
83 #[optional]
84 #[unsafe(method(countryCodeDidChangeForWiFiInterfaceWithName:))]
85 #[unsafe(method_family = none)]
86 unsafe fn countryCodeDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
87
88 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
89 ///
90 ///
91 /// Invoked when the Wi-Fi link state changes.
92 ///
93 ///
94 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeLinkDidChange event type
95 /// to register for link event notifications.
96 #[optional]
97 #[unsafe(method(linkDidChangeForWiFiInterfaceWithName:))]
98 #[unsafe(method_family = none)]
99 unsafe fn linkDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
100
101 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
102 ///
103 ///
104 /// Parameter `rssi`: The RSSI value for the currently associated network on the Wi-Fi interface.
105 ///
106 ///
107 /// Parameter `transmitRate`: The transmit rate for the currently associated network on the Wi-Fi interface.
108 ///
109 ///
110 /// Invoked when the Wi-Fi link quality changes.
111 ///
112 ///
113 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeLinkQualityDidChange event type
114 /// to register for link quality event notifications.
115 /// Use -[CWInterface rssiValue] and -[CWInterface transmitRate] to query the current RSSI and transmit rate, respectively.
116 #[optional]
117 #[unsafe(method(linkQualityDidChangeForWiFiInterfaceWithName:rssi:transmitRate:))]
118 #[unsafe(method_family = none)]
119 unsafe fn linkQualityDidChangeForWiFiInterfaceWithName_rssi_transmitRate(
120 &self,
121 interface_name: &NSString,
122 rssi: NSInteger,
123 transmit_rate: c_double,
124 );
125
126 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
127 ///
128 ///
129 /// Invoked when the Wi-Fi operating mode changes.
130 ///
131 ///
132 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeModeDidChange event type
133 /// to register for interface mode event notifications.
134 /// Use -[CWInterface interfaceMode] to query the current operating mode.
135 #[optional]
136 #[unsafe(method(modeDidChangeForWiFiInterfaceWithName:))]
137 #[unsafe(method_family = none)]
138 unsafe fn modeDidChangeForWiFiInterfaceWithName(&self, interface_name: &NSString);
139
140 /// Parameter `interfaceName`: The name of the Wi-Fi interface.
141 ///
142 ///
143 /// Invoked when the Wi-Fi interface scan cache is updated with new scan results.
144 ///
145 ///
146 /// Use -[CWWiFiClient startMonitoringEventWithType:error:] with the CWEventTypeScanCacheUpdated event type
147 /// to register for scan cache event notifications.
148 /// Use -[CWInterface cachedScanResults] to query scan cache results from the last scan.
149 #[optional]
150 #[unsafe(method(scanCacheUpdatedForWiFiInterfaceWithName:))]
151 #[unsafe(method_family = none)]
152 unsafe fn scanCacheUpdatedForWiFiInterfaceWithName(&self, interface_name: &NSString);
153 }
154);
155
156extern_class!(
157 /// The interface to the Wi-Fi subsystem on OS X.
158 ///
159 ///
160 /// Provides access to all Wi-Fi interfaces and allows Wi-Fi clients to setup event notifications.
161 ///
162 /// CWWiFiClient objects are heavy objects, therefore, clients of the CoreWLAN framework should use a single,
163 /// long-running instance rather than creating several short-lived instances.
164 /// For convenience, +[CWWiFiClient sharedWiFiClient] can be used to return a singleton instance.
165 ///
166 /// The CWWiFiClient object should be used to instantiate CWInterface objects rather than using a CWInterface
167 /// initializer directly.
168 ///
169 /// See also [Apple's documentation](https://developer.apple.com/documentation/corewlan/cwwificlient?language=objc)
170 #[unsafe(super(NSObject))]
171 #[derive(Debug, PartialEq, Eq, Hash)]
172 pub struct CWWiFiClient;
173);
174
175extern_conformance!(
176 unsafe impl NSObjectProtocol for CWWiFiClient {}
177);
178
179impl CWWiFiClient {
180 extern_methods!(
181 /// Sets the delegate to the specified object, which may implement CWWiFiEventDelegate protocol for Wi-Fi event handling.
182 ///
183 ///
184 /// Clients may register for specific Wi-Fi events using -[CWWiFiClient startMonitoringEventWithType:error:].
185 #[unsafe(method(delegate))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
188
189 /// This is a [weak property][objc2::topics::weak_property].
190 /// Setter for [`delegate`][Self::delegate].
191 #[unsafe(method(setDelegate:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
194
195 /// Returns the shared CWWiFiClient instance. There is a single shared instance per process.
196 #[unsafe(method(sharedWiFiClient))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn sharedWiFiClient() -> Retained<CWWiFiClient>;
199
200 /// Initializes a CWWiFiClient object.
201 #[unsafe(method(init))]
202 #[unsafe(method_family = init)]
203 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
204
205 #[cfg(feature = "CWInterface")]
206 /// Returns the CWInterface object for the default Wi-Fi interface.
207 #[unsafe(method(interface))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn interface(&self) -> Option<Retained<CWInterface>>;
210
211 /// Returns: An NSArray of NSString objects corresponding to Wi-Fi interface names.
212 ///
213 ///
214 /// Returns the list of available Wi-Fi interface names (e.g. "en0").
215 ///
216 ///
217 /// If no Wi-Fi interfaces are available, this method will return an empty array.
218 /// Returns nil if an error occurs.
219 #[unsafe(method(interfaceNames))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn interfaceNames(&self) -> Option<Retained<NSArray<NSString>>>;
222
223 #[deprecated = "Use -[CWWiFiClient interfaceNames] instead"]
224 #[unsafe(method(interfaceNames))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn interfaceNames_class() -> Option<Retained<NSArray<NSString>>>;
227
228 #[cfg(feature = "CWInterface")]
229 /// Parameter `interfaceName`: The name of an available Wi-Fi interface.
230 ///
231 ///
232 /// Get the CWInterface object bound to the Wi-Fi interface with a specific interface name.
233 ///
234 ///
235 /// Use +[CWWiFiClient interfaceNames] to get a list of available Wi-Fi interface names.
236 /// Returns a CWInterface object for the default Wi-Fi interface if no interface name is specified.
237 #[unsafe(method(interfaceWithName:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn interfaceWithName(
240 &self,
241 interface_name: Option<&NSString>,
242 ) -> Option<Retained<CWInterface>>;
243
244 #[cfg(feature = "CWInterface")]
245 /// Returns: An NSArray of CWInterface objects.
246 ///
247 ///
248 /// Returns all available Wi-Fi interfaces.
249 ///
250 ///
251 /// If no Wi-Fi interfaces are available, this method will return an empty array.
252 /// Returns nil if an error occurs.
253 #[unsafe(method(interfaces))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn interfaces(&self) -> Option<Retained<NSArray<CWInterface>>>;
256
257 #[cfg(feature = "CoreWLANTypes")]
258 /// Parameter `type`: A CWEventType value.
259 ///
260 ///
261 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
262 /// This parameter is optional.
263 ///
264 ///
265 /// Returns: Returns YES upon success, or NO if an error occurred.
266 ///
267 ///
268 /// Register for specific Wi-Fi event notifications.
269 #[unsafe(method(startMonitoringEventWithType:error:_))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn startMonitoringEventWithType_error(
272 &self,
273 r#type: CWEventType,
274 ) -> Result<(), Retained<NSError>>;
275
276 #[cfg(feature = "CoreWLANTypes")]
277 /// Parameter `type`: A CWEventType value.
278 ///
279 ///
280 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
281 /// This parameter is optional.
282 ///
283 ///
284 /// Returns: Returns YES upon success, or NO if an error occurred.
285 ///
286 ///
287 /// Unregister for specific Wi-Fi event notifications.
288 #[unsafe(method(stopMonitoringEventWithType:error:_))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn stopMonitoringEventWithType_error(
291 &self,
292 r#type: CWEventType,
293 ) -> Result<(), Retained<NSError>>;
294
295 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
296 /// This parameter is optional.
297 ///
298 ///
299 /// Returns: Returns YES upon success, or NO if an error occurred.
300 ///
301 ///
302 /// Unregister for all Wi-Fi event notifications.
303 #[unsafe(method(stopMonitoringAllEventsAndReturnError:_))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn stopMonitoringAllEventsAndReturnError(&self)
306 -> Result<(), Retained<NSError>>;
307 );
308}
309
310/// Methods declared on superclass `NSObject`.
311impl CWWiFiClient {
312 extern_methods!(
313 #[unsafe(method(new))]
314 #[unsafe(method_family = new)]
315 pub unsafe fn new() -> Retained<Self>;
316 );
317}