nm_rs/auto/
device_modem.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
6use crate::{ffi,Device,DeviceModemCapabilities,Object};
7use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    ///
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `apn`
17    ///  Readable
18    ///
19    ///
20    /// #### `current-capabilities`
21    ///  The generic family of access technologies the modem currently supports
22    /// without a firmware reload or reinitialization.
23    ///
24    /// Readable
25    ///
26    ///
27    /// #### `device-id`
28    ///  Readable
29    ///
30    ///
31    /// #### `modem-capabilities`
32    ///  The generic family of access technologies the modem supports.  Not all
33    /// capabilities are available at the same time however; some modems require
34    /// a firmware reload or other reinitialization to switch between eg
35    /// CDMA/EVDO and GSM/UMTS.
36    ///
37    /// Readable
38    ///
39    ///
40    /// #### `operator-code`
41    ///  Readable
42    /// <details><summary><h4>Device</h4></summary>
43    ///
44    ///
45    /// #### `active-connection`
46    ///  The #NMActiveConnection object that "owns" this device during activation.
47    ///
48    /// Readable
49    ///
50    ///
51    /// #### `autoconnect`
52    ///  Whether the device can auto-activate a connection.
53    ///
54    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
55    ///
56    /// Readable | Writeable
57    ///
58    ///
59    /// #### `available-connections`
60    ///  The available connections of the device
61    ///
62    /// Readable
63    ///
64    ///
65    /// #### `capabilities`
66    ///  The capabilities of the device.
67    ///
68    /// Readable
69    ///
70    ///
71    /// #### `device-type`
72    ///  The numeric type of the device.
73    ///
74    /// Readable
75    ///
76    ///
77    /// #### `dhcp4-config`
78    ///  The IPv4 #NMDhcpConfig of the device.
79    ///
80    /// Readable
81    ///
82    ///
83    /// #### `dhcp6-config`
84    ///  The IPv6 #NMDhcpConfig of the device.
85    ///
86    /// Readable
87    ///
88    ///
89    /// #### `driver`
90    ///  The driver of the device.
91    ///
92    /// Readable
93    ///
94    ///
95    /// #### `driver-version`
96    ///  The version of the device driver.
97    ///
98    /// Readable
99    ///
100    ///
101    /// #### `firmware-missing`
102    ///  When [`true`] indicates the device is likely missing firmware required
103    /// for its operation.
104    ///
105    /// Readable
106    ///
107    ///
108    /// #### `firmware-version`
109    ///  The firmware version of the device.
110    ///
111    /// Readable
112    ///
113    ///
114    /// #### `hw-address`
115    ///  The hardware address of the device.
116    ///
117    /// Readable
118    ///
119    ///
120    /// #### `interface`
121    ///  The interface of the device.
122    ///
123    /// Readable
124    ///
125    ///
126    /// #### `interface-flags`
127    ///  The interface flags.
128    ///
129    /// Readable
130    ///
131    ///
132    /// #### `ip-interface`
133    ///  The IP interface of the device which should be used for all IP-related
134    /// operations like addressing and routing.
135    ///
136    /// Readable
137    ///
138    ///
139    /// #### `ip4-config`
140    ///  The #NMIP4Config of the device.
141    ///
142    /// Readable
143    ///
144    ///
145    /// #### `ip4-connectivity`
146    ///  The IPv4 connectivity state of the device.
147    ///
148    /// Readable
149    ///
150    ///
151    /// #### `ip6-config`
152    ///  The IPv6 #NMIPConfig of the device.
153    ///
154    /// Readable
155    ///
156    ///
157    /// #### `ip6-connectivity`
158    ///  The IPv6 connectivity state of the device.
159    ///
160    /// Readable
161    ///
162    ///
163    /// #### `lldp-neighbors`
164    ///  The LLDP neighbors.
165    ///
166    /// Readable
167    ///
168    ///
169    /// #### `managed`
170    ///  Whether the device is managed by NetworkManager.
171    ///
172    /// Readable
173    ///
174    ///
175    /// #### `metered`
176    ///  Whether the device is metered.
177    ///
178    /// Readable
179    ///
180    ///
181    /// #### `mtu`
182    ///  The MTU of the device.
183    ///
184    /// Readable
185    ///
186    ///
187    /// #### `nm-plugin-missing`
188    ///  When [`true`] indicates that the NetworkManager plugin for the device
189    /// is not installed.
190    ///
191    /// Readable
192    ///
193    ///
194    /// #### `path`
195    ///  The device path as exposed by the udev property ID_PATH.
196    ///
197    /// The string is backslash escaped (C escaping) for invalid
198    /// characters. The escaping can be reverted with g_strcompress(),
199    /// however the result may not be valid UTF-8.
200    ///
201    /// Readable
202    ///
203    ///
204    /// #### `physical-port-id`
205    ///  The physical port ID of the device. (See
206    /// nm_device_get_physical_port_id().)
207    ///
208    /// Readable
209    ///
210    ///
211    /// #### `ports`
212    ///  The port devices of the controller device. For devices that cannot be
213    /// controllers this is likely to be always empty.
214    ///
215    /// Readable
216    ///
217    ///
218    /// #### `product`
219    ///  The product string of the device.
220    ///
221    /// Readable
222    ///
223    ///
224    /// #### `real`
225    ///  Whether the device is real or is a placeholder device that could
226    /// be created automatically by NetworkManager if one of its
227    /// #NMDevice:available-connections was activated.
228    ///
229    /// Readable
230    ///
231    ///
232    /// #### `state`
233    ///  The state of the device.
234    ///
235    /// Readable
236    ///
237    ///
238    /// #### `state-reason`
239    ///  The reason for the device state.
240    ///
241    /// Readable
242    ///
243    ///
244    /// #### `udi`
245    ///  An operating-system specific device hardware identifier; this is not
246    /// unique to a specific hardware device across reboots or hotplugs.  It
247    /// is an opaque string which for some device types (Bluetooth, Modem)
248    /// contains an identifier provided by the underlying hardware service daemon
249    /// such as Bluez or ModemManager, and clients can use this property to
250    /// request more information about the device from those services.
251    ///
252    /// Readable
253    ///
254    ///
255    /// #### `vendor`
256    ///  The vendor string of the device.
257    ///
258    /// Readable
259    /// </details>
260    /// <details><summary><h4>Object</h4></summary>
261    ///
262    ///
263    /// #### `client`
264    ///  The NMClient instance as returned by nm_object_get_client().
265    ///
266    /// When an NMObject gets removed from the NMClient cache,
267    /// the NMObject:path property stays unchanged, but this client
268    /// instance gets reset to [`None`]. You can use this property to
269    /// track removal of the object from the cache.
270    ///
271    /// Readable
272    ///
273    ///
274    /// #### `path`
275    ///  The D-Bus object path.
276    ///
277    /// The D-Bus path of an object instance never changes, even if the object
278    /// gets removed from the cache. To see whether the object is still in the
279    /// cache, check NMObject:client.
280    ///
281    /// Readable
282    /// </details>
283    ///
284    /// # Implements
285    ///
286    /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
287    #[doc(alias = "NMDeviceModem")]
288    pub struct DeviceModem(Object<ffi::NMDeviceModem, ffi::NMDeviceModemClass>) @extends Device, Object;
289
290    match fn {
291        type_ => || ffi::nm_device_modem_get_type(),
292    }
293}
294
295impl DeviceModem {
296            // rustdoc-stripper-ignore-next
297            /// Creates a new builder-pattern struct instance to construct [`DeviceModem`] objects.
298            ///
299            /// This method returns an instance of [`DeviceModemBuilder`](crate::builders::DeviceModemBuilder) which can be used to create [`DeviceModem`] objects.
300            pub fn builder() -> DeviceModemBuilder {
301                DeviceModemBuilder::new()
302            }
303        
304
305    /// The access point name the modem is connected to.
306    ///
307    /// # Returns
308    ///
309    /// the APN name or [`None`] if disconnected
310    #[cfg(feature = "v1_20")]
311    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
312    #[doc(alias = "nm_device_modem_get_apn")]
313    #[doc(alias = "get_apn")]
314    pub fn apn(&self) -> glib::GString {
315        unsafe {
316            from_glib_none(ffi::nm_device_modem_get_apn(self.to_glib_none().0))
317        }
318    }
319
320    /// Returns a bitfield of the generic access technology families the modem
321    /// supports without a firmware reload or reinitialization.  This value
322    /// represents the network types the modem can immediately connect to.
323    ///
324    /// # Returns
325    ///
326    /// the generic access technology families the modem supports without
327    /// a firmware reload or other reinitialization
328    #[doc(alias = "nm_device_modem_get_current_capabilities")]
329    #[doc(alias = "get_current_capabilities")]
330    #[doc(alias = "current-capabilities")]
331    pub fn current_capabilities(&self) -> DeviceModemCapabilities {
332        unsafe {
333            from_glib(ffi::nm_device_modem_get_current_capabilities(self.to_glib_none().0))
334        }
335    }
336
337    /// An identifier used by the modem backend (ModemManager) that aims to
338    /// uniquely identify the a device. Can be used to match a connection to a
339    /// particular device.
340    ///
341    /// # Returns
342    ///
343    /// a device-id string
344    #[cfg(feature = "v1_20")]
345    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
346    #[doc(alias = "nm_device_modem_get_device_id")]
347    #[doc(alias = "get_device_id")]
348    #[doc(alias = "device-id")]
349    pub fn device_id(&self) -> glib::GString {
350        unsafe {
351            from_glib_none(ffi::nm_device_modem_get_device_id(self.to_glib_none().0))
352        }
353    }
354
355    /// Returns a bitfield of the generic access technology families the modem
356    /// supports.  Not all capabilities are available concurrently however; some
357    /// may require a firmware reload or reinitialization.
358    ///
359    /// # Returns
360    ///
361    /// the generic access technology families the modem supports
362    #[doc(alias = "nm_device_modem_get_modem_capabilities")]
363    #[doc(alias = "get_modem_capabilities")]
364    #[doc(alias = "modem-capabilities")]
365    pub fn modem_capabilities(&self) -> DeviceModemCapabilities {
366        unsafe {
367            from_glib(ffi::nm_device_modem_get_modem_capabilities(self.to_glib_none().0))
368        }
369    }
370
371    /// The MCC and MNC (concatenated) of the network the modem is connected to.
372    ///
373    /// # Returns
374    ///
375    /// the operator code or [`None`] if disconnected or not a 3GPP modem.
376    #[cfg(feature = "v1_20")]
377    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
378    #[doc(alias = "nm_device_modem_get_operator_code")]
379    #[doc(alias = "get_operator_code")]
380    #[doc(alias = "operator-code")]
381    pub fn operator_code(&self) -> glib::GString {
382        unsafe {
383            from_glib_none(ffi::nm_device_modem_get_operator_code(self.to_glib_none().0))
384        }
385    }
386
387    #[cfg(feature = "v1_20")]
388    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
389    #[doc(alias = "apn")]
390    pub fn connect_apn_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
391        unsafe extern "C" fn notify_apn_trampoline<F: Fn(&DeviceModem) + 'static>(this: *mut ffi::NMDeviceModem, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
392            let f: &F = &*(f as *const F);
393            f(&from_glib_borrow(this))
394        }
395        unsafe {
396            let f: Box_<F> = Box_::new(f);
397            connect_raw(self.as_ptr() as *mut _, c"notify::apn".as_ptr() as *const _,
398                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_apn_trampoline::<F> as *const ())), Box_::into_raw(f))
399        }
400    }
401
402    #[doc(alias = "current-capabilities")]
403    pub fn connect_current_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
404        unsafe extern "C" fn notify_current_capabilities_trampoline<F: Fn(&DeviceModem) + 'static>(this: *mut ffi::NMDeviceModem, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
405            let f: &F = &*(f as *const F);
406            f(&from_glib_borrow(this))
407        }
408        unsafe {
409            let f: Box_<F> = Box_::new(f);
410            connect_raw(self.as_ptr() as *mut _, c"notify::current-capabilities".as_ptr() as *const _,
411                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_current_capabilities_trampoline::<F> as *const ())), Box_::into_raw(f))
412        }
413    }
414
415    #[cfg(feature = "v1_20")]
416    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
417    #[doc(alias = "device-id")]
418    pub fn connect_device_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
419        unsafe extern "C" fn notify_device_id_trampoline<F: Fn(&DeviceModem) + 'static>(this: *mut ffi::NMDeviceModem, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
420            let f: &F = &*(f as *const F);
421            f(&from_glib_borrow(this))
422        }
423        unsafe {
424            let f: Box_<F> = Box_::new(f);
425            connect_raw(self.as_ptr() as *mut _, c"notify::device-id".as_ptr() as *const _,
426                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_device_id_trampoline::<F> as *const ())), Box_::into_raw(f))
427        }
428    }
429
430    #[doc(alias = "modem-capabilities")]
431    pub fn connect_modem_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
432        unsafe extern "C" fn notify_modem_capabilities_trampoline<F: Fn(&DeviceModem) + 'static>(this: *mut ffi::NMDeviceModem, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
433            let f: &F = &*(f as *const F);
434            f(&from_glib_borrow(this))
435        }
436        unsafe {
437            let f: Box_<F> = Box_::new(f);
438            connect_raw(self.as_ptr() as *mut _, c"notify::modem-capabilities".as_ptr() as *const _,
439                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_modem_capabilities_trampoline::<F> as *const ())), Box_::into_raw(f))
440        }
441    }
442
443    #[cfg(feature = "v1_20")]
444    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
445    #[doc(alias = "operator-code")]
446    pub fn connect_operator_code_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
447        unsafe extern "C" fn notify_operator_code_trampoline<F: Fn(&DeviceModem) + 'static>(this: *mut ffi::NMDeviceModem, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
448            let f: &F = &*(f as *const F);
449            f(&from_glib_borrow(this))
450        }
451        unsafe {
452            let f: Box_<F> = Box_::new(f);
453            connect_raw(self.as_ptr() as *mut _, c"notify::operator-code".as_ptr() as *const _,
454                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_operator_code_trampoline::<F> as *const ())), Box_::into_raw(f))
455        }
456    }
457}
458
459// rustdoc-stripper-ignore-next
460        /// A [builder-pattern] type to construct [`DeviceModem`] objects.
461        ///
462        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
463#[must_use = "The builder must be built to be used"]
464pub struct DeviceModemBuilder {
465            builder: glib::object::ObjectBuilder<'static, DeviceModem>,
466        }
467
468        impl DeviceModemBuilder {
469        fn new() -> Self {
470            Self { builder: glib::object::Object::builder() }
471        }
472
473                            /// Whether the device can auto-activate a connection.
474                            ///
475                            /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
476                            pub fn autoconnect(self, autoconnect: bool) -> Self {
477                            Self { builder: self.builder.property("autoconnect", autoconnect), }
478                        }
479
480    // rustdoc-stripper-ignore-next
481    /// Build the [`DeviceModem`].
482    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
483    pub fn build(self) -> DeviceModem {
484assert_initialized_main_thread!();
485    self.builder.build() }
486}