nm_rs/auto/device_wifi_p2p.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5#![allow(deprecated)]
6
7use crate::{ffi,Device,Object,WifiP2PPeer};
8use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
9use std::{boxed::Box as Box_,pin::Pin};
10
11glib::wrapper! {
12 ///
13 ///
14 /// ## Properties
15 ///
16 ///
17 /// #### `peers`
18 /// List of all Wi-Fi P2P peers the device can see.
19 ///
20 /// Readable
21 /// <details><summary><h4>Device</h4></summary>
22 ///
23 ///
24 /// #### `active-connection`
25 /// The #NMActiveConnection object that "owns" this device during activation.
26 ///
27 /// Readable
28 ///
29 ///
30 /// #### `autoconnect`
31 /// Whether the device can auto-activate a connection.
32 ///
33 /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
34 ///
35 /// Readable | Writeable
36 ///
37 ///
38 /// #### `available-connections`
39 /// The available connections of the device
40 ///
41 /// Readable
42 ///
43 ///
44 /// #### `capabilities`
45 /// The capabilities of the device.
46 ///
47 /// Readable
48 ///
49 ///
50 /// #### `device-type`
51 /// The numeric type of the device.
52 ///
53 /// Readable
54 ///
55 ///
56 /// #### `dhcp4-config`
57 /// The IPv4 #NMDhcpConfig of the device.
58 ///
59 /// Readable
60 ///
61 ///
62 /// #### `dhcp6-config`
63 /// The IPv6 #NMDhcpConfig of the device.
64 ///
65 /// Readable
66 ///
67 ///
68 /// #### `driver`
69 /// The driver of the device.
70 ///
71 /// Readable
72 ///
73 ///
74 /// #### `driver-version`
75 /// The version of the device driver.
76 ///
77 /// Readable
78 ///
79 ///
80 /// #### `firmware-missing`
81 /// When [`true`] indicates the device is likely missing firmware required
82 /// for its operation.
83 ///
84 /// Readable
85 ///
86 ///
87 /// #### `firmware-version`
88 /// The firmware version of the device.
89 ///
90 /// Readable
91 ///
92 ///
93 /// #### `hw-address`
94 /// The hardware address of the device.
95 ///
96 /// Readable
97 ///
98 ///
99 /// #### `interface`
100 /// The interface of the device.
101 ///
102 /// Readable
103 ///
104 ///
105 /// #### `interface-flags`
106 /// The interface flags.
107 ///
108 /// Readable
109 ///
110 ///
111 /// #### `ip-interface`
112 /// The IP interface of the device which should be used for all IP-related
113 /// operations like addressing and routing.
114 ///
115 /// Readable
116 ///
117 ///
118 /// #### `ip4-config`
119 /// The #NMIP4Config of the device.
120 ///
121 /// Readable
122 ///
123 ///
124 /// #### `ip4-connectivity`
125 /// The IPv4 connectivity state of the device.
126 ///
127 /// Readable
128 ///
129 ///
130 /// #### `ip6-config`
131 /// The IPv6 #NMIPConfig of the device.
132 ///
133 /// Readable
134 ///
135 ///
136 /// #### `ip6-connectivity`
137 /// The IPv6 connectivity state of the device.
138 ///
139 /// Readable
140 ///
141 ///
142 /// #### `lldp-neighbors`
143 /// The LLDP neighbors.
144 ///
145 /// Readable
146 ///
147 ///
148 /// #### `managed`
149 /// Whether the device is managed by NetworkManager.
150 ///
151 /// Readable
152 ///
153 ///
154 /// #### `metered`
155 /// Whether the device is metered.
156 ///
157 /// Readable
158 ///
159 ///
160 /// #### `mtu`
161 /// The MTU of the device.
162 ///
163 /// Readable
164 ///
165 ///
166 /// #### `nm-plugin-missing`
167 /// When [`true`] indicates that the NetworkManager plugin for the device
168 /// is not installed.
169 ///
170 /// Readable
171 ///
172 ///
173 /// #### `path`
174 /// The device path as exposed by the udev property ID_PATH.
175 ///
176 /// The string is backslash escaped (C escaping) for invalid
177 /// characters. The escaping can be reverted with g_strcompress(),
178 /// however the result may not be valid UTF-8.
179 ///
180 /// Readable
181 ///
182 ///
183 /// #### `physical-port-id`
184 /// The physical port ID of the device. (See
185 /// nm_device_get_physical_port_id().)
186 ///
187 /// Readable
188 ///
189 ///
190 /// #### `ports`
191 /// The port devices of the controller device. For devices that cannot be
192 /// controllers this is likely to be always empty.
193 ///
194 /// Readable
195 ///
196 ///
197 /// #### `product`
198 /// The product string of the device.
199 ///
200 /// Readable
201 ///
202 ///
203 /// #### `real`
204 /// Whether the device is real or is a placeholder device that could
205 /// be created automatically by NetworkManager if one of its
206 /// #NMDevice:available-connections was activated.
207 ///
208 /// Readable
209 ///
210 ///
211 /// #### `state`
212 /// The state of the device.
213 ///
214 /// Readable
215 ///
216 ///
217 /// #### `state-reason`
218 /// The reason for the device state.
219 ///
220 /// Readable
221 ///
222 ///
223 /// #### `udi`
224 /// An operating-system specific device hardware identifier; this is not
225 /// unique to a specific hardware device across reboots or hotplugs. It
226 /// is an opaque string which for some device types (Bluetooth, Modem)
227 /// contains an identifier provided by the underlying hardware service daemon
228 /// such as Bluez or ModemManager, and clients can use this property to
229 /// request more information about the device from those services.
230 ///
231 /// Readable
232 ///
233 ///
234 /// #### `vendor`
235 /// The vendor string of the device.
236 ///
237 /// Readable
238 /// </details>
239 /// <details><summary><h4>Object</h4></summary>
240 ///
241 ///
242 /// #### `client`
243 /// The NMClient instance as returned by nm_object_get_client().
244 ///
245 /// When an NMObject gets removed from the NMClient cache,
246 /// the NMObject:path property stays unchanged, but this client
247 /// instance gets reset to [`None`]. You can use this property to
248 /// track removal of the object from the cache.
249 ///
250 /// Readable
251 ///
252 ///
253 /// #### `path`
254 /// The D-Bus object path.
255 ///
256 /// The D-Bus path of an object instance never changes, even if the object
257 /// gets removed from the cache. To see whether the object is still in the
258 /// cache, check NMObject:client.
259 ///
260 /// Readable
261 /// </details>
262 ///
263 /// ## Signals
264 ///
265 ///
266 /// #### `peer-added`
267 /// Notifies that a #NMWifiP2PPeer is added to the Wi-Fi P2P device.
268 ///
269 ///
270 ///
271 ///
272 /// #### `peer-removed`
273 /// Notifies that a #NMWifiP2PPeer is removed from the Wi-Fi P2P device.
274 ///
275 ///
276 /// <details><summary><h4>Device</h4></summary>
277 ///
278 ///
279 /// #### `state-changed`
280 /// Notifies the state change of a #NMDevice.
281 ///
282 ///
283 /// </details>
284 ///
285 /// # Implements
286 ///
287 /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
288 #[doc(alias = "NMDeviceWifiP2P")]
289 pub struct DeviceWifiP2P(Object<ffi::NMDeviceWifiP2P, ffi::NMDeviceWifiP2PClass>) @extends Device, Object;
290
291 match fn {
292 type_ => || ffi::nm_device_wifi_p2p_get_type(),
293 }
294}
295
296impl DeviceWifiP2P {
297 // rustdoc-stripper-ignore-next
298 /// Creates a new builder-pattern struct instance to construct [`DeviceWifiP2P`] objects.
299 ///
300 /// This method returns an instance of [`DeviceWifiP2PBuilder`](crate::builders::DeviceWifiP2PBuilder) which can be used to create [`DeviceWifiP2P`] objects.
301 pub fn builder() -> DeviceWifiP2PBuilder {
302 DeviceWifiP2PBuilder::new()
303 }
304
305
306 /// Gets the actual hardware (MAC) address of the #NMDeviceWifiP2P
307 ///
308 /// # Deprecated since 1.24
309 ///
310 /// Use nm_device_get_hw_address() instead.
311 ///
312 /// # Returns
313 ///
314 /// the actual hardware address. This is the internal string used by the
315 /// device, and must not be modified.
316 #[cfg_attr(feature = "v1_24", deprecated = "Since 1.24")]
317 #[allow(deprecated)]
318 #[doc(alias = "nm_device_wifi_p2p_get_hw_address")]
319 #[doc(alias = "get_hw_address")]
320 pub fn hw_address(&self) -> glib::GString {
321 unsafe {
322 from_glib_none(ffi::nm_device_wifi_p2p_get_hw_address(self.to_glib_none().0))
323 }
324 }
325
326 /// Gets a #NMWifiP2PPeer by path.
327 /// ## `path`
328 /// the object path of the peer
329 ///
330 /// # Returns
331 ///
332 /// the peer or [`None`] if none is found.
333 #[cfg(feature = "v1_42")]
334 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
335 #[doc(alias = "nm_device_wifi_p2p_get_peer_by_path")]
336 #[doc(alias = "get_peer_by_path")]
337 pub fn peer_by_path(&self, path: &str) -> WifiP2PPeer {
338 unsafe {
339 from_glib_none(ffi::nm_device_wifi_p2p_get_peer_by_path(self.to_glib_none().0, path.to_glib_none().0))
340 }
341 }
342
343 /// Gets all the found peers of the #NMDeviceWifiP2P.
344 ///
345 /// # Returns
346 ///
347 /// a #GPtrArray containing all the
348 /// found #NMWifiP2PPeers.
349 /// The returned array is owned by the client and should not be modified.
350 #[doc(alias = "nm_device_wifi_p2p_get_peers")]
351 #[doc(alias = "get_peers")]
352 pub fn peers(&self) -> Vec<WifiP2PPeer> {
353 unsafe {
354 FromGlibPtrContainer::from_glib_none(ffi::nm_device_wifi_p2p_get_peers(self.to_glib_none().0))
355 }
356 }
357
358 //#[doc(alias = "nm_device_wifi_p2p_start_find")]
359 //pub fn start_find<P: FnOnce(Result<(), glib::Error>) + 'static>(&self, options: /*Ignored*/Option<&glib::Variant>, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
360 // unsafe { TODO: call ffi:nm_device_wifi_p2p_start_find() }
361 //}
362
363 //
364 //pub fn start_find_future(&self, options: /*Ignored*/Option<&glib::Variant>) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
365
366 //let options = options.map(ToOwned::to_owned);
367 //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
368 // obj.start_find(
369 // options.as_ref().map(::std::borrow::Borrow::borrow),
370 // Some(cancellable),
371 // move |res| {
372 // send.resolve(res);
373 // },
374 // );
375 //}))
376 //}
377
378 /// Request NM to stop any ongoing find operation for Wi-Fi P2P peers on @self.
379 /// ## `cancellable`
380 /// a #GCancellable, or [`None`]
381 /// ## `callback`
382 /// a #GAsyncReadyCallback, or [`None`]
383 #[doc(alias = "nm_device_wifi_p2p_stop_find")]
384 pub fn stop_find<P: FnOnce(Result<(), glib::Error>) + 'static>(&self, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
385
386 let main_context = glib::MainContext::ref_thread_default();
387 let is_main_context_owner = main_context.is_owner();
388 let has_acquired_main_context = (!is_main_context_owner)
389 .then(|| main_context.acquire().ok())
390 .flatten();
391 assert!(
392 is_main_context_owner || has_acquired_main_context.is_some(),
393 "Async operations only allowed if the thread is owning the MainContext"
394 );
395
396 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::new(glib::thread_guard::ThreadGuard::new(callback));
397 unsafe extern "C" fn stop_find_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(_source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer) {
398 let mut error = std::ptr::null_mut();
399 ffi::nm_device_wifi_p2p_stop_find_finish(_source_object as *mut _, res, &mut error);
400 let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) };
401 let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
402 let callback: P = callback.into_inner();
403 callback(result);
404 }
405 let callback = stop_find_trampoline::<P>;
406 unsafe {
407 ffi::nm_device_wifi_p2p_stop_find(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _);
408 }
409 }
410
411
412 pub fn stop_find_future(&self) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
413
414 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
415 obj.stop_find(
416 Some(cancellable),
417 move |res| {
418 send.resolve(res);
419 },
420 );
421 }))
422 }
423
424 //#[cfg(feature = "v1_16")]
425 //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
426 //#[doc(alias = "peer-added")]
427 //pub fn connect_peer_added<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
428 // Ignored peer: GObject.Object
429 //}
430
431 //#[cfg(feature = "v1_16")]
432 //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
433 //#[doc(alias = "peer-removed")]
434 //pub fn connect_peer_removed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
435 // Ignored peer: GObject.Object
436 //}
437
438 #[cfg(feature = "v1_16")]
439 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
440 #[doc(alias = "peers")]
441 pub fn connect_peers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
442 unsafe extern "C" fn notify_peers_trampoline<F: Fn(&DeviceWifiP2P) + 'static>(this: *mut ffi::NMDeviceWifiP2P, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
443 let f: &F = &*(f as *const F);
444 f(&from_glib_borrow(this))
445 }
446 unsafe {
447 let f: Box_<F> = Box_::new(f);
448 connect_raw(self.as_ptr() as *mut _, c"notify::peers".as_ptr() as *const _,
449 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_peers_trampoline::<F> as *const ())), Box_::into_raw(f))
450 }
451 }
452}
453
454// rustdoc-stripper-ignore-next
455 /// A [builder-pattern] type to construct [`DeviceWifiP2P`] objects.
456 ///
457 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
458#[must_use = "The builder must be built to be used"]
459pub struct DeviceWifiP2PBuilder {
460 builder: glib::object::ObjectBuilder<'static, DeviceWifiP2P>,
461 }
462
463 impl DeviceWifiP2PBuilder {
464 fn new() -> Self {
465 Self { builder: glib::object::Object::builder() }
466 }
467
468 /// Whether the device can auto-activate a connection.
469 ///
470 /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
471 pub fn autoconnect(self, autoconnect: bool) -> Self {
472 Self { builder: self.builder.property("autoconnect", autoconnect), }
473 }
474
475 // rustdoc-stripper-ignore-next
476 /// Build the [`DeviceWifiP2P`].
477 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
478 pub fn build(self) -> DeviceWifiP2P {
479assert_initialized_main_thread!();
480 self.builder.build() }
481}