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 /// Setter for [`delegate`][Self::delegate].
190 ///
191 /// This is a [weak property][objc2::topics::weak_property].
192 ///
193 /// # Safety
194 ///
195 /// `delegate` should be of the correct type.
196 #[unsafe(method(setDelegate:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);
199
200 /// Returns the shared CWWiFiClient instance. There is a single shared instance per process.
201 #[unsafe(method(sharedWiFiClient))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn sharedWiFiClient() -> Retained<CWWiFiClient>;
204
205 /// Initializes a CWWiFiClient object.
206 #[unsafe(method(init))]
207 #[unsafe(method_family = init)]
208 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
209
210 #[cfg(feature = "CWInterface")]
211 /// Returns the CWInterface object for the default Wi-Fi interface.
212 #[unsafe(method(interface))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn interface(&self) -> Option<Retained<CWInterface>>;
215
216 /// Returns: An NSArray of NSString objects corresponding to Wi-Fi interface names.
217 ///
218 ///
219 /// Returns the list of available Wi-Fi interface names (e.g. "en0").
220 ///
221 ///
222 /// If no Wi-Fi interfaces are available, this method will return an empty array.
223 /// Returns nil if an error occurs.
224 #[unsafe(method(interfaceNames))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn interfaceNames(&self) -> Option<Retained<NSArray<NSString>>>;
227
228 #[deprecated = "Use -[CWWiFiClient interfaceNames] instead"]
229 #[unsafe(method(interfaceNames))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn interfaceNames_class() -> Option<Retained<NSArray<NSString>>>;
232
233 #[cfg(feature = "CWInterface")]
234 /// Parameter `interfaceName`: The name of an available Wi-Fi interface.
235 ///
236 ///
237 /// Get the CWInterface object bound to the Wi-Fi interface with a specific interface name.
238 ///
239 ///
240 /// Use +[CWWiFiClient interfaceNames] to get a list of available Wi-Fi interface names.
241 /// Returns a CWInterface object for the default Wi-Fi interface if no interface name is specified.
242 #[unsafe(method(interfaceWithName:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn interfaceWithName(
245 &self,
246 interface_name: Option<&NSString>,
247 ) -> Option<Retained<CWInterface>>;
248
249 #[cfg(feature = "CWInterface")]
250 /// Returns: An NSArray of CWInterface objects.
251 ///
252 ///
253 /// Returns all available Wi-Fi interfaces.
254 ///
255 ///
256 /// If no Wi-Fi interfaces are available, this method will return an empty array.
257 /// Returns nil if an error occurs.
258 #[unsafe(method(interfaces))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn interfaces(&self) -> Option<Retained<NSArray<CWInterface>>>;
261
262 #[cfg(feature = "CoreWLANTypes")]
263 /// Parameter `type`: A CWEventType value.
264 ///
265 ///
266 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
267 /// This parameter is optional.
268 ///
269 ///
270 /// Returns: Returns YES upon success, or NO if an error occurred.
271 ///
272 ///
273 /// Register for specific Wi-Fi event notifications.
274 #[unsafe(method(startMonitoringEventWithType:error:_))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn startMonitoringEventWithType_error(
277 &self,
278 r#type: CWEventType,
279 ) -> Result<(), Retained<NSError>>;
280
281 #[cfg(feature = "CoreWLANTypes")]
282 /// Parameter `type`: A CWEventType value.
283 ///
284 ///
285 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
286 /// This parameter is optional.
287 ///
288 ///
289 /// Returns: Returns YES upon success, or NO if an error occurred.
290 ///
291 ///
292 /// Unregister for specific Wi-Fi event notifications.
293 #[unsafe(method(stopMonitoringEventWithType:error:_))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn stopMonitoringEventWithType_error(
296 &self,
297 r#type: CWEventType,
298 ) -> Result<(), Retained<NSError>>;
299
300 /// Parameter `error`: An NSError object passed by reference, which upon return will contain the error if an error occurs.
301 /// This parameter is optional.
302 ///
303 ///
304 /// Returns: Returns YES upon success, or NO if an error occurred.
305 ///
306 ///
307 /// Unregister for all Wi-Fi event notifications.
308 #[unsafe(method(stopMonitoringAllEventsAndReturnError:_))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn stopMonitoringAllEventsAndReturnError(&self)
311 -> Result<(), Retained<NSError>>;
312 );
313}
314
315/// Methods declared on superclass `NSObject`.
316impl CWWiFiClient {
317 extern_methods!(
318 #[unsafe(method(new))]
319 #[unsafe(method_family = new)]
320 pub unsafe fn new() -> Retained<Self>;
321 );
322}