nm_rs/auto/
client.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
7#[cfg(feature = "v1_6")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
9use crate::DnsEntry;
10#[cfg(feature = "v1_38")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
12use crate::RadioFlags;
13use crate::{
14    ActiveConnection, ClientPermission, ClientPermissionResult, Connection, ConnectivityState,
15    Device, RemoteConnection, State, ffi,
16};
17#[cfg(feature = "v1_12")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
19use crate::{Checkpoint, CheckpointCreateFlags};
20#[cfg(feature = "v1_24")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
22use crate::{ClientInstanceFlags, Object, Ternary};
23#[cfg(feature = "v1_22")]
24#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
25use crate::{ManagerReloadFlags, Metered};
26use glib::{
27    GString,
28    object::ObjectType as _,
29    prelude::*,
30    signal::{SignalHandlerId, connect_raw},
31    translate::*,
32};
33use std::{boxed::Box as Box_, pin::Pin};
34
35#[cfg(feature = "gio_v2_22")]
36#[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_22")))]
37glib::wrapper! {
38    /// NMClient contains a cache of the objects of NetworkManager's D-Bus API.
39    /// It uses #GMainContext and #GDBusConnection for that and registers to
40    /// D-Bus signals. That means, when iterating the associated #GMainContext,
41    /// D-Bus signals gets processed and the #NMClient instance updates and
42    /// emits #GObject signals.
43    ///
44    /// ## Properties
45    ///
46    ///
47    /// #### `activating-connection`
48    ///  The #NMActiveConnection of the activating connection that is
49    /// likely to become the new #NMClient:primary-connection.
50    ///
51    /// Readable
52    ///
53    ///
54    /// #### `active-connections`
55    ///  The active connections.
56    ///
57    /// Readable
58    ///
59    ///
60    /// #### `all-devices`
61    ///  List of both real devices and device placeholders.
62    ///
63    /// Readable
64    ///
65    ///
66    /// #### `can-modify`
67    ///  If [`true`], adding and modifying connections is supported.
68    ///
69    /// Readable
70    ///
71    ///
72    /// #### `capabilities`
73    ///  The list of capabilities numbers as guint32 or [`None`] if
74    /// there are no capabilities. The numeric value correspond
75    /// to `NMCapability` enum.
76    ///
77    /// Readable
78    ///
79    ///
80    /// #### `checkpoints`
81    ///  The list of active checkpoints.
82    ///
83    /// Readable
84    ///
85    ///
86    /// #### `connections`
87    ///  The list of configured connections that are available to the user. (Note
88    /// that this differs from the underlying D-Bus property, which may also
89    /// contain the object paths of connections that the user does not have
90    /// permission to read the details of.)
91    ///
92    /// Readable
93    ///
94    ///
95    /// #### `connectivity`
96    ///  The network connectivity state.
97    ///
98    /// Readable
99    ///
100    ///
101    /// #### `connectivity-check-available`
102    ///  Readable
103    ///
104    ///
105    /// #### `connectivity-check-enabled`
106    ///  Readable | Writeable
107    ///
108    ///
109    /// #### `connectivity-check-uri`
110    ///  The used URI for connectivity checking.
111    ///
112    /// Readable
113    ///
114    ///
115    /// #### `dbus-connection`
116    ///  The #GDBusConnection to use.
117    ///
118    /// If this is not set during object construction, the D-Bus connection will
119    /// automatically be chosen during async/sync initalization via g_bus_get().
120    ///
121    /// Readable | Writeable | Construct Only
122    ///
123    ///
124    /// #### `dbus-name-owner`
125    ///  The name owner of the NetworkManager D-Bus service.
126    ///
127    /// Readable
128    ///
129    ///
130    /// #### `devices`
131    ///  List of real network devices.  Does not include placeholder devices.
132    ///
133    /// Readable
134    ///
135    ///
136    /// #### `dns-configuration`
137    ///  The current DNS configuration, represented as an array
138    /// of #NMDnsEntry objects.
139    ///
140    /// Readable
141    ///
142    ///
143    /// #### `dns-mode`
144    ///  The current DNS processing mode.
145    ///
146    /// Readable
147    ///
148    ///
149    /// #### `dns-rc-manager`
150    ///  The current resolv.conf management mode.
151    ///
152    /// Readable
153    ///
154    ///
155    /// #### `hostname`
156    ///  The machine hostname stored in persistent configuration. This can be
157    /// modified by calling nm_client_save_hostname().
158    ///
159    /// Readable
160    ///
161    ///
162    /// #### `instance-flags`
163    ///  #NMClientInstanceFlags for the instance. These affect behavior of #NMClient.
164    /// This is a construct property and you may only set most flags only during
165    /// construction.
166    ///
167    /// The flag [`ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS`][crate::ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS] can be toggled any time,
168    /// even after constructing the instance. Note that you may want to watch NMClient:permissions-state
169    /// property to know whether permissions are ready. Note that permissions are only fetched
170    /// when NMClient has a D-Bus name owner.
171    ///
172    /// The flags [`ClientInstanceFlags::INITIALIZED_GOOD`][crate::ClientInstanceFlags::INITIALIZED_GOOD] and [`ClientInstanceFlags::INITIALIZED_BAD`][crate::ClientInstanceFlags::INITIALIZED_BAD]
173    /// cannot be set, however they will be returned by the getter after initialization completes.
174    ///
175    /// Readable | Writeable | Construct
176    ///
177    ///
178    /// #### `metered`
179    ///  Whether the connectivity is metered.
180    ///
181    /// Readable
182    ///
183    ///
184    /// #### `networking-enabled`
185    ///  Whether networking is enabled.
186    ///
187    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
188    ///
189    /// Readable | Writeable
190    ///
191    ///
192    /// #### `nm-running`
193    ///  Whether the daemon is running.
194    ///
195    /// Readable
196    ///
197    ///
198    /// #### `permissions-state`
199    ///  The state of the cached permissions. The value [`Ternary::Default`][crate::Ternary::Default]
200    /// means that no permissions are yet received (or not yet requested).
201    /// [`Ternary::True`][crate::Ternary::True] means that permissions are received, cached and up
202    /// to date. [`Ternary::False`][crate::Ternary::False] means that permissions were received and are
203    /// cached, but in the meantime a "CheckPermissions" signal was received
204    /// that invalidated the cached permissions.
205    /// Note that NMClient will always emit a notify::permissions-state signal
206    /// when a "CheckPermissions" signal got received or after new permissions
207    /// got received (that is regardless whether the value of the permission state
208    /// actually changed). With this you can watch the permissions-state property
209    /// to know whether the permissions are ready. Note that while NMClient has
210    /// no D-Bus name owner, no permissions are fetched (and this property won't
211    /// change).
212    ///
213    /// Readable
214    ///
215    ///
216    /// #### `primary-connection`
217    ///  The #NMActiveConnection of the device with the default route;
218    /// see nm_client_get_primary_connection() for more details.
219    ///
220    /// Readable
221    ///
222    ///
223    /// #### `radio-flags`
224    ///  Flags for radio interfaces. See #NMRadioFlags.
225    ///
226    /// Readable
227    ///
228    ///
229    /// #### `startup`
230    ///  Whether the daemon is still starting up.
231    ///
232    /// Readable
233    ///
234    ///
235    /// #### `state`
236    ///  The current daemon state.
237    ///
238    /// Readable
239    ///
240    ///
241    /// #### `version`
242    ///  The NetworkManager version.
243    ///
244    /// Readable
245    ///
246    ///
247    /// #### `version-info`
248    ///  Expose version info and capabilities of NetworkManager. If non-empty,
249    /// the first element is NM_VERSION, which encodes the version of the
250    /// daemon as "(major << 16 | minor << 8 | micro)". The following elements
251    /// is a bitfields of `NMVersionInfoCapability`. If a bit is set, then
252    /// the running NetworkManager has the respective capability.
253    ///
254    /// Readable
255    ///
256    ///
257    /// #### `wimax-enabled`
258    ///  Whether WiMAX functionality is enabled.
259    ///
260    /// Readable | Writeable
261    ///
262    ///
263    /// #### `wimax-hardware-enabled`
264    ///  Whether the WiMAX hardware is enabled.
265    ///
266    /// Readable
267    ///
268    ///
269    /// #### `wireless-enabled`
270    ///  Whether wireless is enabled.
271    ///
272    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
273    ///
274    /// Readable | Writeable
275    ///
276    ///
277    /// #### `wireless-hardware-enabled`
278    ///  Whether the wireless hardware is enabled.
279    ///
280    /// Readable
281    ///
282    ///
283    /// #### `wwan-enabled`
284    ///  Whether WWAN functionality is enabled.
285    ///
286    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
287    ///
288    /// Readable | Writeable
289    ///
290    ///
291    /// #### `wwan-hardware-enabled`
292    ///  Whether the WWAN hardware is enabled.
293    ///
294    /// Readable
295    ///
296    /// ## Signals
297    ///
298    ///
299    /// #### `active-connection-added`
300    ///  Notifies that a #NMActiveConnection has been added.
301    ///
302    ///
303    ///
304    ///
305    /// #### `active-connection-removed`
306    ///  Notifies that a #NMActiveConnection has been removed.
307    ///
308    ///
309    ///
310    ///
311    /// #### `any-device-added`
312    ///  Notifies that a #NMDevice is added.  This signal is emitted for both
313    /// regular devices and placeholder devices.
314    ///
315    ///
316    ///
317    ///
318    /// #### `any-device-removed`
319    ///  Notifies that a #NMDevice is removed.  This signal is emitted for both
320    /// regular devices and placeholder devices.
321    ///
322    ///
323    ///
324    ///
325    /// #### `connection-added`
326    ///  Notifies that a #NMConnection has been added.
327    ///
328    ///
329    ///
330    ///
331    /// #### `connection-removed`
332    ///  Notifies that a #NMConnection has been removed.
333    ///
334    ///
335    ///
336    ///
337    /// #### `device-added`
338    ///  Notifies that a #NMDevice is added.  This signal is not emitted for
339    /// placeholder devices.
340    ///
341    ///
342    ///
343    ///
344    /// #### `device-removed`
345    ///  Notifies that a #NMDevice is removed.  This signal is not emitted for
346    /// placeholder devices.
347    ///
348    ///
349    ///
350    ///
351    /// #### `permission-changed`
352    ///  Notifies that a permission has changed
353    ///
354    ///
355    ///
356    /// # Implements
357    ///
358    /// [`trait@gio::prelude::AsyncInitableExt`], [`trait@gio::prelude::InitableExt`]
359    #[doc(alias = "NMClient")]
360    pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>) @implements gio::AsyncInitable, gio::Initable;
361
362    match fn {
363        type_ => || ffi::nm_client_get_type(),
364    }
365}
366
367#[cfg(not(any(feature = "gio_v2_22")))]
368#[cfg(feature = "gio_v2_22")]
369glib::wrapper! {
370    #[doc(alias = "NMClient")]
371    pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>) @implements gio::Initable;
372
373    match fn {
374        type_ => || ffi::nm_client_get_type(),
375    }
376}
377
378#[cfg(not(any(feature = "gio_v2_22")))]
379glib::wrapper! {
380    #[doc(alias = "NMClient")]
381    pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>);
382
383    match fn {
384        type_ => || ffi::nm_client_get_type(),
385    }
386}
387
388impl Client {
389    /// Creates a new #NMClient synchronously.
390    ///
391    /// Note that this will block until a NMClient instance is fully initialized.
392    /// This does nothing beside calling g_initable_new(). You are free to call
393    /// g_initable_new() or g_object_new()/g_initable_init() directly for more
394    /// control, to set GObject properties or get access to the NMClient instance
395    /// while it is still initializing.
396    ///
397    /// Using the synchronous initialization creates an #NMClient instance
398    /// that uses an internal #GMainContext. This context is invisible to the
399    /// user. This introduces an additional overhead that is payed not
400    /// only during object initialization, but for the entire lifetime of
401    /// this object.
402    /// Also, due to this internal #GMainContext, the events are no longer
403    /// in sync with other messages from #GDBusConnection (but all events
404    /// of the NMClient will themselves still be ordered).
405    /// For a serious program, you should therefore avoid these problems by
406    /// using g_async_initable_init_async() or nm_client_new_async() instead.
407    /// The sync initialization is still useful for simple scripts or interactive
408    /// testing for example via pygobject.
409    ///
410    /// Creating an #NMClient instance can only fail for two reasons. First, if you didn't
411    /// provide a [`CLIENT_DBUS_CONNECTION`][crate::CLIENT_DBUS_CONNECTION] and the call to g_bus_get()
412    /// fails. You can avoid that by using g_initable_new() directly and
413    /// set a D-Bus connection.
414    /// Second, if you cancelled the creation. If you do that, then note
415    /// that after the failure there might still be idle actions pending
416    /// which keep nm_client_get_main_context() alive. That means,
417    /// in that case you must continue iterating the context to avoid
418    /// leaks. See nm_client_get_context_busy_watcher().
419    ///
420    /// Creating an #NMClient instance when NetworkManager is not running
421    /// does not cause a failure.
422    /// ## `cancellable`
423    /// a #GCancellable, or [`None`]
424    ///
425    /// # Returns
426    ///
427    /// a new #NMClient or NULL on an error
428    #[doc(alias = "nm_client_new")]
429    pub fn new(cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<Client, glib::Error> {
430        assert_initialized_main_thread!();
431        unsafe {
432            let mut error = std::ptr::null_mut();
433            let ret =
434                ffi::nm_client_new(cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
435            if error.is_null() {
436                Ok(from_glib_full(ret))
437            } else {
438                Err(from_glib_full(error))
439            }
440        }
441    }
442
443    // rustdoc-stripper-ignore-next
444    /// Creates a new builder-pattern struct instance to construct [`Client`] objects.
445    ///
446    /// This method returns an instance of [`ClientBuilder`](crate::builders::ClientBuilder) which can be used to create [`Client`] objects.
447    pub fn builder() -> ClientBuilder {
448        ClientBuilder::new()
449    }
450
451    /// Asynchronously starts a connection to a particular network using the
452    /// configuration settings from @connection and the network device @device.
453    /// Certain connection types also take a "specific object" which is the object
454    /// path of a connection- specific object, like an #NMAccessPoint for Wi-Fi
455    /// connections, or an #NMWimaxNsp for WiMAX connections, to which you wish to
456    /// connect.  If the specific object is not given, NetworkManager can, in some
457    /// cases, automatically determine which network to connect to given the settings
458    /// in @connection.
459    ///
460    /// If @connection is not given for a device-based activation, NetworkManager
461    /// picks the best available connection for the device and activates it.
462    ///
463    /// Note that the callback is invoked when NetworkManager has started activating
464    /// the new connection, not when it finishes. You can use the returned
465    /// #NMActiveConnection object (in particular, #NMActiveConnection:state) to
466    /// track the activation to its completion.
467    /// ## `connection`
468    /// an #NMConnection
469    /// ## `device`
470    /// the #NMDevice
471    /// ## `specific_object`
472    /// the object path of a connection-type-specific
473    ///   object this activation should use. This parameter is currently ignored for
474    ///   wired and mobile broadband connections, and the value of [`None`] should be used
475    ///   (ie, no specific object).  For Wi-Fi or WiMAX connections, pass the object
476    ///   path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
477    ///   get using nm_object_get_path(), and which will be used to complete the
478    ///   details of the newly added connection.
479    /// ## `cancellable`
480    /// a #GCancellable, or [`None`]
481    /// ## `callback`
482    /// callback to be called when the activation has started
483    #[doc(alias = "nm_client_activate_connection_async")]
484    pub fn activate_connection_async<P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static>(
485        &self,
486        connection: Option<&impl IsA<Connection>>,
487        device: Option<&impl IsA<Device>>,
488        specific_object: Option<&str>,
489        cancellable: Option<&impl IsA<gio::Cancellable>>,
490        callback: P,
491    ) {
492        let main_context = glib::MainContext::ref_thread_default();
493        let is_main_context_owner = main_context.is_owner();
494        let has_acquired_main_context = (!is_main_context_owner)
495            .then(|| main_context.acquire().ok())
496            .flatten();
497        assert!(
498            is_main_context_owner || has_acquired_main_context.is_some(),
499            "Async operations only allowed if the thread is owning the MainContext"
500        );
501
502        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
503            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
504        unsafe extern "C" fn activate_connection_async_trampoline<
505            P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
506        >(
507            _source_object: *mut glib::gobject_ffi::GObject,
508            res: *mut gio::ffi::GAsyncResult,
509            user_data: glib::ffi::gpointer,
510        ) {
511            let mut error = std::ptr::null_mut();
512            let ret = ffi::nm_client_activate_connection_finish(
513                _source_object as *mut _,
514                res,
515                &mut error,
516            );
517            let result = if error.is_null() {
518                Ok(from_glib_full(ret))
519            } else {
520                Err(from_glib_full(error))
521            };
522            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
523                Box_::from_raw(user_data as *mut _);
524            let callback: P = callback.into_inner();
525            callback(result);
526        }
527        let callback = activate_connection_async_trampoline::<P>;
528        unsafe {
529            ffi::nm_client_activate_connection_async(
530                self.to_glib_none().0,
531                connection.map(|p| p.as_ref()).to_glib_none().0,
532                device.map(|p| p.as_ref()).to_glib_none().0,
533                specific_object.to_glib_none().0,
534                cancellable.map(|p| p.as_ref()).to_glib_none().0,
535                Some(callback),
536                Box_::into_raw(user_data) as *mut _,
537            );
538        }
539    }
540
541    pub fn activate_connection_future(
542        &self,
543        connection: Option<&(impl IsA<Connection> + Clone + 'static)>,
544        device: Option<&(impl IsA<Device> + Clone + 'static)>,
545        specific_object: Option<&str>,
546    ) -> Pin<Box_<dyn std::future::Future<Output = Result<ActiveConnection, glib::Error>> + 'static>>
547    {
548        let connection = connection.map(ToOwned::to_owned);
549        let device = device.map(ToOwned::to_owned);
550        let specific_object = specific_object.map(ToOwned::to_owned);
551        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
552            obj.activate_connection_async(
553                connection.as_ref().map(::std::borrow::Borrow::borrow),
554                device.as_ref().map(::std::borrow::Borrow::borrow),
555                specific_object.as_ref().map(::std::borrow::Borrow::borrow),
556                Some(cancellable),
557                move |res| {
558                    send.resolve(res);
559                },
560            );
561        }))
562    }
563
564    //#[cfg(feature = "v1_16")]
565    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
566    //#[doc(alias = "nm_client_add_and_activate_connection2")]
567    //pub fn add_and_activate_connection2<P: FnOnce(Result<(ActiveConnection, /*Ignored*/Option<glib::Variant>), glib::Error>) + 'static>(&self, partial: Option<&impl IsA<Connection>>, device: Option<&impl IsA<Device>>, specific_object: Option<&str>, options: /*Ignored*/&glib::Variant, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
568    //    unsafe { TODO: call ffi:nm_client_add_and_activate_connection2() }
569    //}
570
571    //
572    //#[cfg(feature = "v1_16")]
573    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
574    //pub fn add_and_activate_connection2_future(&self, partial: Option<&(impl IsA<Connection> + Clone + 'static)>, device: Option<&(impl IsA<Device> + Clone + 'static)>, specific_object: Option<&str>, options: /*Ignored*/&glib::Variant) -> Pin<Box_<dyn std::future::Future<Output = Result<(ActiveConnection, /*Ignored*/Option<glib::Variant>), glib::Error>> + 'static>> {
575
576    //let partial = partial.map(ToOwned::to_owned);
577    //let device = device.map(ToOwned::to_owned);
578    //let specific_object = specific_object.map(ToOwned::to_owned);
579    //let options = options.clone();
580    //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
581    //    obj.add_and_activate_connection2(
582    //        partial.as_ref().map(::std::borrow::Borrow::borrow),
583    //        device.as_ref().map(::std::borrow::Borrow::borrow),
584    //        specific_object.as_ref().map(::std::borrow::Borrow::borrow),
585    //        &options,
586    //        Some(cancellable),
587    //        move |res| {
588    //            send.resolve(res);
589    //        },
590    //    );
591    //}))
592    //}
593
594    /// Adds a new connection using the given details (if any) as a template,
595    /// automatically filling in missing settings with the capabilities of the given
596    /// device and specific object.  The new connection is then asynchronously
597    /// activated as with nm_client_activate_connection_async(). Cannot be used for
598    /// VPN connections at this time.
599    ///
600    /// Note that the callback is invoked when NetworkManager has started activating
601    /// the new connection, not when it finishes. You can used the returned
602    /// #NMActiveConnection object (in particular, #NMActiveConnection:state) to
603    /// track the activation to its completion.
604    /// ## `partial`
605    /// an #NMConnection to add; the connection may be
606    ///   partially filled (or even [`None`]) and will be completed by NetworkManager
607    ///   using the given @device and @specific_object before being added
608    /// ## `device`
609    /// the #NMDevice
610    /// ## `specific_object`
611    /// the object path of a connection-type-specific
612    ///   object this activation should use. This parameter is currently ignored for
613    ///   wired and mobile broadband connections, and the value of [`None`] should be used
614    ///   (ie, no specific object).  For Wi-Fi or WiMAX connections, pass the object
615    ///   path of a #NMAccessPoint or #NMWimaxNsp owned by @device, which you can
616    ///   get using nm_object_get_path(), and which will be used to complete the
617    ///   details of the newly added connection.
618    ///   If the variant is floating, it will be consumed.
619    /// ## `cancellable`
620    /// a #GCancellable, or [`None`]
621    /// ## `callback`
622    /// callback to be called when the activation has started
623    #[doc(alias = "nm_client_add_and_activate_connection_async")]
624    pub fn add_and_activate_connection_async<
625        P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
626    >(
627        &self,
628        partial: Option<&impl IsA<Connection>>,
629        device: Option<&impl IsA<Device>>,
630        specific_object: Option<&str>,
631        cancellable: Option<&impl IsA<gio::Cancellable>>,
632        callback: P,
633    ) {
634        let main_context = glib::MainContext::ref_thread_default();
635        let is_main_context_owner = main_context.is_owner();
636        let has_acquired_main_context = (!is_main_context_owner)
637            .then(|| main_context.acquire().ok())
638            .flatten();
639        assert!(
640            is_main_context_owner || has_acquired_main_context.is_some(),
641            "Async operations only allowed if the thread is owning the MainContext"
642        );
643
644        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
645            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
646        unsafe extern "C" fn add_and_activate_connection_async_trampoline<
647            P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
648        >(
649            _source_object: *mut glib::gobject_ffi::GObject,
650            res: *mut gio::ffi::GAsyncResult,
651            user_data: glib::ffi::gpointer,
652        ) {
653            let mut error = std::ptr::null_mut();
654            let ret = ffi::nm_client_add_and_activate_connection_finish(
655                _source_object as *mut _,
656                res,
657                &mut error,
658            );
659            let result = if error.is_null() {
660                Ok(from_glib_full(ret))
661            } else {
662                Err(from_glib_full(error))
663            };
664            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
665                Box_::from_raw(user_data as *mut _);
666            let callback: P = callback.into_inner();
667            callback(result);
668        }
669        let callback = add_and_activate_connection_async_trampoline::<P>;
670        unsafe {
671            ffi::nm_client_add_and_activate_connection_async(
672                self.to_glib_none().0,
673                partial.map(|p| p.as_ref()).to_glib_none().0,
674                device.map(|p| p.as_ref()).to_glib_none().0,
675                specific_object.to_glib_none().0,
676                cancellable.map(|p| p.as_ref()).to_glib_none().0,
677                Some(callback),
678                Box_::into_raw(user_data) as *mut _,
679            );
680        }
681    }
682
683    pub fn add_and_activate_connection_future(
684        &self,
685        partial: Option<&(impl IsA<Connection> + Clone + 'static)>,
686        device: Option<&(impl IsA<Device> + Clone + 'static)>,
687        specific_object: Option<&str>,
688    ) -> Pin<Box_<dyn std::future::Future<Output = Result<ActiveConnection, glib::Error>> + 'static>>
689    {
690        let partial = partial.map(ToOwned::to_owned);
691        let device = device.map(ToOwned::to_owned);
692        let specific_object = specific_object.map(ToOwned::to_owned);
693        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
694            obj.add_and_activate_connection_async(
695                partial.as_ref().map(::std::borrow::Borrow::borrow),
696                device.as_ref().map(::std::borrow::Borrow::borrow),
697                specific_object.as_ref().map(::std::borrow::Borrow::borrow),
698                Some(cancellable),
699                move |res| {
700                    send.resolve(res);
701                },
702            );
703        }))
704    }
705
706    //#[cfg(feature = "v1_20")]
707    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
708    //#[doc(alias = "nm_client_add_connection2")]
709    //pub fn add_connection2<P: FnOnce(Result<(RemoteConnection, /*Ignored*/Option<glib::Variant>), glib::Error>) + 'static>(&self, settings: /*Ignored*/&glib::Variant, flags: SettingsAddConnection2Flags, args: /*Ignored*/Option<&glib::Variant>, ignore_out_result: bool, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
710    //    unsafe { TODO: call ffi:nm_client_add_connection2() }
711    //}
712
713    //
714    //#[cfg(feature = "v1_20")]
715    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
716    //pub fn add_connection2_future(&self, settings: /*Ignored*/&glib::Variant, flags: SettingsAddConnection2Flags, args: /*Ignored*/Option<&glib::Variant>, ignore_out_result: bool) -> Pin<Box_<dyn std::future::Future<Output = Result<(RemoteConnection, /*Ignored*/Option<glib::Variant>), glib::Error>> + 'static>> {
717
718    //let settings = settings.clone();
719    //let args = args.map(ToOwned::to_owned);
720    //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
721    //    obj.add_connection2(
722    //        &settings,
723    //        flags,
724    //        args.as_ref().map(::std::borrow::Borrow::borrow),
725    //        ignore_out_result,
726    //        Some(cancellable),
727    //        move |res| {
728    //            send.resolve(res);
729    //        },
730    //    );
731    //}))
732    //}
733
734    /// Requests that the remote settings service add the given settings to a new
735    /// connection.  If @save_to_disk is [`true`], the connection is immediately written
736    /// to disk; otherwise it is initially only stored in memory, but may be saved
737    /// later by calling the connection's nm_remote_connection_commit_changes()
738    /// method.
739    ///
740    /// @connection is untouched by this function and only serves as a template of
741    /// the settings to add.  The #NMRemoteConnection object that represents what
742    /// NetworkManager actually added is returned to @callback when the addition
743    /// operation is complete.
744    ///
745    /// Note that the #NMRemoteConnection returned in @callback may not contain
746    /// identical settings to @connection as NetworkManager may perform automatic
747    /// completion and/or normalization of connection properties.
748    /// ## `connection`
749    /// the connection to add. Note that this object's settings will be
750    ///   added, not the object itself
751    /// ## `save_to_disk`
752    /// whether to immediately save the connection to disk
753    /// ## `cancellable`
754    /// a #GCancellable, or [`None`]
755    /// ## `callback`
756    /// callback to be called when the add operation completes
757    #[doc(alias = "nm_client_add_connection_async")]
758    pub fn add_connection_async<P: FnOnce(Result<RemoteConnection, glib::Error>) + 'static>(
759        &self,
760        connection: &impl IsA<Connection>,
761        save_to_disk: bool,
762        cancellable: Option<&impl IsA<gio::Cancellable>>,
763        callback: P,
764    ) {
765        let main_context = glib::MainContext::ref_thread_default();
766        let is_main_context_owner = main_context.is_owner();
767        let has_acquired_main_context = (!is_main_context_owner)
768            .then(|| main_context.acquire().ok())
769            .flatten();
770        assert!(
771            is_main_context_owner || has_acquired_main_context.is_some(),
772            "Async operations only allowed if the thread is owning the MainContext"
773        );
774
775        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
776            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
777        unsafe extern "C" fn add_connection_async_trampoline<
778            P: FnOnce(Result<RemoteConnection, glib::Error>) + 'static,
779        >(
780            _source_object: *mut glib::gobject_ffi::GObject,
781            res: *mut gio::ffi::GAsyncResult,
782            user_data: glib::ffi::gpointer,
783        ) {
784            let mut error = std::ptr::null_mut();
785            let ret =
786                ffi::nm_client_add_connection_finish(_source_object as *mut _, res, &mut error);
787            let result = if error.is_null() {
788                Ok(from_glib_full(ret))
789            } else {
790                Err(from_glib_full(error))
791            };
792            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
793                Box_::from_raw(user_data as *mut _);
794            let callback: P = callback.into_inner();
795            callback(result);
796        }
797        let callback = add_connection_async_trampoline::<P>;
798        unsafe {
799            ffi::nm_client_add_connection_async(
800                self.to_glib_none().0,
801                connection.as_ref().to_glib_none().0,
802                save_to_disk.into_glib(),
803                cancellable.map(|p| p.as_ref()).to_glib_none().0,
804                Some(callback),
805                Box_::into_raw(user_data) as *mut _,
806            );
807        }
808    }
809
810    pub fn add_connection_future(
811        &self,
812        connection: &(impl IsA<Connection> + Clone + 'static),
813        save_to_disk: bool,
814    ) -> Pin<Box_<dyn std::future::Future<Output = Result<RemoteConnection, glib::Error>> + 'static>>
815    {
816        let connection = connection.clone();
817        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
818            obj.add_connection_async(&connection, save_to_disk, Some(cancellable), move |res| {
819                send.resolve(res);
820            });
821        }))
822    }
823
824    /// Updates the network connectivity state and returns the (new)
825    /// current state. Contrast nm_client_get_connectivity(), which returns
826    /// the most recent known state without re-checking.
827    ///
828    /// This is a blocking call; use nm_client_check_connectivity_async()
829    /// if you do not want to block.
830    ///
831    /// # Deprecated since 1.22
832    ///
833    /// Use nm_client_check_connectivity_async() or GDBusConnection.
834    /// ## `cancellable`
835    /// a #GCancellable
836    ///
837    /// # Returns
838    ///
839    /// the (new) current connectivity state
840    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
841    #[allow(deprecated)]
842    #[doc(alias = "nm_client_check_connectivity")]
843    pub fn check_connectivity(
844        &self,
845        cancellable: Option<&impl IsA<gio::Cancellable>>,
846    ) -> Result<ConnectivityState, glib::Error> {
847        unsafe {
848            let mut error = std::ptr::null_mut();
849            let ret = ffi::nm_client_check_connectivity(
850                self.to_glib_none().0,
851                cancellable.map(|p| p.as_ref()).to_glib_none().0,
852                &mut error,
853            );
854            if error.is_null() {
855                Ok(from_glib(ret))
856            } else {
857                Err(from_glib_full(error))
858            }
859        }
860    }
861
862    /// Asynchronously updates the network connectivity state and invokes
863    /// @callback when complete. Contrast nm_client_get_connectivity(),
864    /// which (immediately) returns the most recent known state without
865    /// re-checking, and nm_client_check_connectivity(), which blocks.
866    /// ## `cancellable`
867    /// a #GCancellable
868    /// ## `callback`
869    /// callback to call with the result
870    #[doc(alias = "nm_client_check_connectivity_async")]
871    pub fn check_connectivity_async<P: FnOnce(Result<ConnectivityState, glib::Error>) + 'static>(
872        &self,
873        cancellable: Option<&impl IsA<gio::Cancellable>>,
874        callback: P,
875    ) {
876        let main_context = glib::MainContext::ref_thread_default();
877        let is_main_context_owner = main_context.is_owner();
878        let has_acquired_main_context = (!is_main_context_owner)
879            .then(|| main_context.acquire().ok())
880            .flatten();
881        assert!(
882            is_main_context_owner || has_acquired_main_context.is_some(),
883            "Async operations only allowed if the thread is owning the MainContext"
884        );
885
886        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
887            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
888        unsafe extern "C" fn check_connectivity_async_trampoline<
889            P: FnOnce(Result<ConnectivityState, glib::Error>) + 'static,
890        >(
891            _source_object: *mut glib::gobject_ffi::GObject,
892            res: *mut gio::ffi::GAsyncResult,
893            user_data: glib::ffi::gpointer,
894        ) {
895            let mut error = std::ptr::null_mut();
896            let ret =
897                ffi::nm_client_check_connectivity_finish(_source_object as *mut _, res, &mut error);
898            let result = if error.is_null() {
899                Ok(from_glib(ret))
900            } else {
901                Err(from_glib_full(error))
902            };
903            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
904                Box_::from_raw(user_data as *mut _);
905            let callback: P = callback.into_inner();
906            callback(result);
907        }
908        let callback = check_connectivity_async_trampoline::<P>;
909        unsafe {
910            ffi::nm_client_check_connectivity_async(
911                self.to_glib_none().0,
912                cancellable.map(|p| p.as_ref()).to_glib_none().0,
913                Some(callback),
914                Box_::into_raw(user_data) as *mut _,
915            );
916        }
917    }
918
919    pub fn check_connectivity_future(
920        &self,
921    ) -> Pin<Box_<dyn std::future::Future<Output = Result<ConnectivityState, glib::Error>> + 'static>>
922    {
923        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
924            obj.check_connectivity_async(Some(cancellable), move |res| {
925                send.resolve(res);
926            });
927        }))
928    }
929
930    /// Resets the timeout for the checkpoint with path @checkpoint_path
931    /// to @timeout_add.
932    /// ## `checkpoint_path`
933    /// a D-Bus path to a checkpoint
934    /// ## `add_timeout`
935    /// the timeout in seconds counting from now.
936    ///   Set to zero, to disable the timeout.
937    /// ## `cancellable`
938    /// a #GCancellable, or [`None`]
939    /// ## `callback`
940    /// callback to be called when the add operation completes
941    #[cfg(feature = "v1_12")]
942    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
943    #[doc(alias = "nm_client_checkpoint_adjust_rollback_timeout")]
944    pub fn checkpoint_adjust_rollback_timeout<P: FnOnce(Result<(), glib::Error>) + 'static>(
945        &self,
946        checkpoint_path: &str,
947        add_timeout: u32,
948        cancellable: Option<&impl IsA<gio::Cancellable>>,
949        callback: P,
950    ) {
951        let main_context = glib::MainContext::ref_thread_default();
952        let is_main_context_owner = main_context.is_owner();
953        let has_acquired_main_context = (!is_main_context_owner)
954            .then(|| main_context.acquire().ok())
955            .flatten();
956        assert!(
957            is_main_context_owner || has_acquired_main_context.is_some(),
958            "Async operations only allowed if the thread is owning the MainContext"
959        );
960
961        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
962            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
963        unsafe extern "C" fn checkpoint_adjust_rollback_timeout_trampoline<
964            P: FnOnce(Result<(), glib::Error>) + 'static,
965        >(
966            _source_object: *mut glib::gobject_ffi::GObject,
967            res: *mut gio::ffi::GAsyncResult,
968            user_data: glib::ffi::gpointer,
969        ) {
970            let mut error = std::ptr::null_mut();
971            ffi::nm_client_checkpoint_adjust_rollback_timeout_finish(
972                _source_object as *mut _,
973                res,
974                &mut error,
975            );
976            let result = if error.is_null() {
977                Ok(())
978            } else {
979                Err(from_glib_full(error))
980            };
981            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
982                Box_::from_raw(user_data as *mut _);
983            let callback: P = callback.into_inner();
984            callback(result);
985        }
986        let callback = checkpoint_adjust_rollback_timeout_trampoline::<P>;
987        unsafe {
988            ffi::nm_client_checkpoint_adjust_rollback_timeout(
989                self.to_glib_none().0,
990                checkpoint_path.to_glib_none().0,
991                add_timeout,
992                cancellable.map(|p| p.as_ref()).to_glib_none().0,
993                Some(callback),
994                Box_::into_raw(user_data) as *mut _,
995            );
996        }
997    }
998
999    #[cfg(feature = "v1_12")]
1000    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1001    pub fn checkpoint_adjust_rollback_timeout_future(
1002        &self,
1003        checkpoint_path: &str,
1004        add_timeout: u32,
1005    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1006        let checkpoint_path = String::from(checkpoint_path);
1007        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1008            obj.checkpoint_adjust_rollback_timeout(
1009                &checkpoint_path,
1010                add_timeout,
1011                Some(cancellable),
1012                move |res| {
1013                    send.resolve(res);
1014                },
1015            );
1016        }))
1017    }
1018
1019    /// Creates a checkpoint of the current networking configuration
1020    /// for given interfaces. An empty @devices argument means all
1021    /// devices. If @rollback_timeout is not zero, a rollback is
1022    /// automatically performed after the given timeout.
1023    /// ## `devices`
1024    /// a list of devices for which a
1025    ///   checkpoint should be created.
1026    /// ## `rollback_timeout`
1027    /// the rollback timeout in seconds
1028    /// ## `flags`
1029    /// creation flags
1030    /// ## `cancellable`
1031    /// a #GCancellable, or [`None`]
1032    /// ## `callback`
1033    /// callback to be called when the add operation completes
1034    #[cfg(feature = "v1_12")]
1035    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1036    #[doc(alias = "nm_client_checkpoint_create")]
1037    pub fn checkpoint_create<P: FnOnce(Result<Checkpoint, glib::Error>) + 'static>(
1038        &self,
1039        devices: &[Device],
1040        rollback_timeout: u32,
1041        flags: CheckpointCreateFlags,
1042        cancellable: Option<&impl IsA<gio::Cancellable>>,
1043        callback: P,
1044    ) {
1045        let main_context = glib::MainContext::ref_thread_default();
1046        let is_main_context_owner = main_context.is_owner();
1047        let has_acquired_main_context = (!is_main_context_owner)
1048            .then(|| main_context.acquire().ok())
1049            .flatten();
1050        assert!(
1051            is_main_context_owner || has_acquired_main_context.is_some(),
1052            "Async operations only allowed if the thread is owning the MainContext"
1053        );
1054
1055        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1056            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1057        unsafe extern "C" fn checkpoint_create_trampoline<
1058            P: FnOnce(Result<Checkpoint, glib::Error>) + 'static,
1059        >(
1060            _source_object: *mut glib::gobject_ffi::GObject,
1061            res: *mut gio::ffi::GAsyncResult,
1062            user_data: glib::ffi::gpointer,
1063        ) {
1064            let mut error = std::ptr::null_mut();
1065            let ret =
1066                ffi::nm_client_checkpoint_create_finish(_source_object as *mut _, res, &mut error);
1067            let result = if error.is_null() {
1068                Ok(from_glib_full(ret))
1069            } else {
1070                Err(from_glib_full(error))
1071            };
1072            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1073                Box_::from_raw(user_data as *mut _);
1074            let callback: P = callback.into_inner();
1075            callback(result);
1076        }
1077        let callback = checkpoint_create_trampoline::<P>;
1078        unsafe {
1079            ffi::nm_client_checkpoint_create(
1080                self.to_glib_none().0,
1081                devices.to_glib_none().0,
1082                rollback_timeout,
1083                flags.into_glib(),
1084                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1085                Some(callback),
1086                Box_::into_raw(user_data) as *mut _,
1087            );
1088        }
1089    }
1090
1091    #[cfg(feature = "v1_12")]
1092    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1093    pub fn checkpoint_create_future(
1094        &self,
1095        devices: &[Device],
1096        rollback_timeout: u32,
1097        flags: CheckpointCreateFlags,
1098    ) -> Pin<Box_<dyn std::future::Future<Output = Result<Checkpoint, glib::Error>> + 'static>>
1099    {
1100        let devices = devices.to_vec();
1101        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1102            obj.checkpoint_create(
1103                devices.as_slice(),
1104                rollback_timeout,
1105                flags,
1106                Some(cancellable),
1107                move |res| {
1108                    send.resolve(res);
1109                },
1110            );
1111        }))
1112    }
1113
1114    #[cfg(feature = "v1_12")]
1115    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1116    #[doc(alias = "nm_client_checkpoint_destroy")]
1117    pub fn checkpoint_destroy<P: FnOnce(Result<(), glib::Error>) + 'static>(
1118        &self,
1119        checkpoint_path: &str,
1120        cancellable: Option<&impl IsA<gio::Cancellable>>,
1121        callback: P,
1122    ) {
1123        let main_context = glib::MainContext::ref_thread_default();
1124        let is_main_context_owner = main_context.is_owner();
1125        let has_acquired_main_context = (!is_main_context_owner)
1126            .then(|| main_context.acquire().ok())
1127            .flatten();
1128        assert!(
1129            is_main_context_owner || has_acquired_main_context.is_some(),
1130            "Async operations only allowed if the thread is owning the MainContext"
1131        );
1132
1133        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1134            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1135        unsafe extern "C" fn checkpoint_destroy_trampoline<
1136            P: FnOnce(Result<(), glib::Error>) + 'static,
1137        >(
1138            _source_object: *mut glib::gobject_ffi::GObject,
1139            res: *mut gio::ffi::GAsyncResult,
1140            user_data: glib::ffi::gpointer,
1141        ) {
1142            let mut error = std::ptr::null_mut();
1143            ffi::nm_client_checkpoint_destroy_finish(_source_object as *mut _, res, &mut error);
1144            let result = if error.is_null() {
1145                Ok(())
1146            } else {
1147                Err(from_glib_full(error))
1148            };
1149            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1150                Box_::from_raw(user_data as *mut _);
1151            let callback: P = callback.into_inner();
1152            callback(result);
1153        }
1154        let callback = checkpoint_destroy_trampoline::<P>;
1155        unsafe {
1156            ffi::nm_client_checkpoint_destroy(
1157                self.to_glib_none().0,
1158                checkpoint_path.to_glib_none().0,
1159                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1160                Some(callback),
1161                Box_::into_raw(user_data) as *mut _,
1162            );
1163        }
1164    }
1165
1166    #[cfg(feature = "v1_12")]
1167    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1168    pub fn checkpoint_destroy_future(
1169        &self,
1170        checkpoint_path: &str,
1171    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1172        let checkpoint_path = String::from(checkpoint_path);
1173        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1174            obj.checkpoint_destroy(&checkpoint_path, Some(cancellable), move |res| {
1175                send.resolve(res);
1176            });
1177        }))
1178    }
1179
1180    //#[cfg(feature = "v1_12")]
1181    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1182    //#[doc(alias = "nm_client_checkpoint_rollback")]
1183    //pub fn checkpoint_rollback<P: FnOnce(Result</*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 7 }, glib::Error>) + 'static>(&self, checkpoint_path: &str, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
1184    //    unsafe { TODO: call ffi:nm_client_checkpoint_rollback() }
1185    //}
1186
1187    //
1188    //#[cfg(feature = "v1_12")]
1189    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1190    //pub fn checkpoint_rollback_future(&self, checkpoint_path: &str) -> Pin<Box_<dyn std::future::Future<Output = Result</*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 7 }, glib::Error>> + 'static>> {
1191
1192    //let checkpoint_path = String::from(checkpoint_path);
1193    //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1194    //    obj.checkpoint_rollback(
1195    //        &checkpoint_path,
1196    //        Some(cancellable),
1197    //        move |res| {
1198    //            send.resolve(res);
1199    //        },
1200    //    );
1201    //}))
1202    //}
1203
1204    /// Determine whether connectivity checking is available.  This
1205    /// requires that the URI of a connectivity service has been set in the
1206    /// configuration file.
1207    ///
1208    /// # Returns
1209    ///
1210    /// [`true`] if connectivity checking is available.
1211    #[cfg(feature = "v1_10")]
1212    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1213    #[doc(alias = "nm_client_connectivity_check_get_available")]
1214    pub fn connectivity_check_get_available(&self) -> bool {
1215        unsafe {
1216            from_glib(ffi::nm_client_connectivity_check_get_available(
1217                self.to_glib_none().0,
1218            ))
1219        }
1220    }
1221
1222    /// Determine whether connectivity checking is enabled.
1223    ///
1224    /// # Returns
1225    ///
1226    /// [`true`] if connectivity checking is enabled.
1227    #[cfg(feature = "v1_10")]
1228    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1229    #[doc(alias = "nm_client_connectivity_check_get_enabled")]
1230    pub fn connectivity_check_get_enabled(&self) -> bool {
1231        unsafe {
1232            from_glib(ffi::nm_client_connectivity_check_get_enabled(
1233                self.to_glib_none().0,
1234            ))
1235        }
1236    }
1237
1238    /// Get the URI that will be queried to determine if there is internet
1239    /// connectivity.
1240    ///
1241    /// # Returns
1242    ///
1243    /// the connectivity URI in use
1244    #[cfg(feature = "v1_20")]
1245    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1246    #[doc(alias = "nm_client_connectivity_check_get_uri")]
1247    pub fn connectivity_check_get_uri(&self) -> glib::GString {
1248        unsafe {
1249            from_glib_none(ffi::nm_client_connectivity_check_get_uri(
1250                self.to_glib_none().0,
1251            ))
1252        }
1253    }
1254
1255    /// Enable or disable connectivity checking.  Note that if a
1256    /// connectivity checking URI has not been configured, this will not
1257    /// have any effect.
1258    ///
1259    /// # Deprecated since 1.22
1260    ///
1261    /// Use the async command nm_client_dbus_set_property() on [`DBUS_PATH`][crate::DBUS_PATH],
1262    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to set "ConnectivityCheckEnabled" property to a "(b)" value.
1263    /// ## `enabled`
1264    /// [`true`] to enable connectivity checking
1265    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1266    #[cfg(feature = "v1_10")]
1267    #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1268    #[allow(deprecated)]
1269    #[doc(alias = "nm_client_connectivity_check_set_enabled")]
1270    pub fn connectivity_check_set_enabled(&self, enabled: bool) {
1271        unsafe {
1272            ffi::nm_client_connectivity_check_set_enabled(
1273                self.to_glib_none().0,
1274                enabled.into_glib(),
1275            );
1276        }
1277    }
1278
1279    //#[cfg(feature = "v1_24")]
1280    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1281    //#[doc(alias = "nm_client_dbus_call")]
1282    //pub fn dbus_call<P: FnOnce(Result</*Ignored*/glib::Variant, glib::Error>) + 'static>(&self, object_path: &str, interface_name: &str, method_name: &str, parameters: /*Ignored*/Option<&glib::Variant>, reply_type: /*Ignored*/Option<&glib::VariantTy>, timeout_msec: i32, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
1283    //    unsafe { TODO: call ffi:nm_client_dbus_call() }
1284    //}
1285
1286    //
1287    //#[cfg(feature = "v1_24")]
1288    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1289    //pub fn dbus_call_future(&self, object_path: &str, interface_name: &str, method_name: &str, parameters: /*Ignored*/Option<&glib::Variant>, reply_type: /*Ignored*/Option<&glib::VariantTy>, timeout_msec: i32) -> Pin<Box_<dyn std::future::Future<Output = Result</*Ignored*/glib::Variant, glib::Error>> + 'static>> {
1290
1291    //let object_path = String::from(object_path);
1292    //let interface_name = String::from(interface_name);
1293    //let method_name = String::from(method_name);
1294    //let parameters = parameters.map(ToOwned::to_owned);
1295    //let reply_type = reply_type.map(ToOwned::to_owned);
1296    //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1297    //    obj.dbus_call(
1298    //        &object_path,
1299    //        &interface_name,
1300    //        &method_name,
1301    //        parameters.as_ref().map(::std::borrow::Borrow::borrow),
1302    //        reply_type.as_ref().map(::std::borrow::Borrow::borrow),
1303    //        timeout_msec,
1304    //        Some(cancellable),
1305    //        move |res| {
1306    //            send.resolve(res);
1307    //        },
1308    //    );
1309    //}))
1310    //}
1311
1312    //#[cfg(feature = "v1_24")]
1313    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1314    //#[doc(alias = "nm_client_dbus_set_property")]
1315    //pub fn dbus_set_property<P: FnOnce(Result<(), glib::Error>) + 'static>(&self, object_path: &str, interface_name: &str, property_name: &str, value: /*Ignored*/&glib::Variant, timeout_msec: i32, cancellable: Option<&impl IsA<gio::Cancellable>>, callback: P) {
1316    //    unsafe { TODO: call ffi:nm_client_dbus_set_property() }
1317    //}
1318
1319    //
1320    //#[cfg(feature = "v1_24")]
1321    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1322    //pub fn dbus_set_property_future(&self, object_path: &str, interface_name: &str, property_name: &str, value: /*Ignored*/&glib::Variant, timeout_msec: i32) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1323
1324    //let object_path = String::from(object_path);
1325    //let interface_name = String::from(interface_name);
1326    //let property_name = String::from(property_name);
1327    //let value = value.clone();
1328    //Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1329    //    obj.dbus_set_property(
1330    //        &object_path,
1331    //        &interface_name,
1332    //        &property_name,
1333    //        &value,
1334    //        timeout_msec,
1335    //        Some(cancellable),
1336    //        move |res| {
1337    //            send.resolve(res);
1338    //        },
1339    //    );
1340    //}))
1341    //}
1342
1343    /// Deactivates an active #NMActiveConnection.
1344    ///
1345    /// # Deprecated since 1.22
1346    ///
1347    /// Use nm_client_deactivate_connection_async() or GDBusConnection.
1348    /// ## `active`
1349    /// the #NMActiveConnection to deactivate
1350    /// ## `cancellable`
1351    /// a #GCancellable, or [`None`]
1352    ///
1353    /// # Returns
1354    ///
1355    /// success or failure
1356    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1357    #[allow(deprecated)]
1358    #[doc(alias = "nm_client_deactivate_connection")]
1359    pub fn deactivate_connection(
1360        &self,
1361        active: &impl IsA<ActiveConnection>,
1362        cancellable: Option<&impl IsA<gio::Cancellable>>,
1363    ) -> Result<(), glib::Error> {
1364        unsafe {
1365            let mut error = std::ptr::null_mut();
1366            let is_ok = ffi::nm_client_deactivate_connection(
1367                self.to_glib_none().0,
1368                active.as_ref().to_glib_none().0,
1369                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1370                &mut error,
1371            );
1372            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1373            if error.is_null() {
1374                Ok(())
1375            } else {
1376                Err(from_glib_full(error))
1377            }
1378        }
1379    }
1380
1381    /// Asynchronously deactivates an active #NMActiveConnection.
1382    /// ## `active`
1383    /// the #NMActiveConnection to deactivate
1384    /// ## `cancellable`
1385    /// a #GCancellable, or [`None`]
1386    /// ## `callback`
1387    /// callback to be called when the deactivation has completed
1388    #[doc(alias = "nm_client_deactivate_connection_async")]
1389    pub fn deactivate_connection_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
1390        &self,
1391        active: &impl IsA<ActiveConnection>,
1392        cancellable: Option<&impl IsA<gio::Cancellable>>,
1393        callback: P,
1394    ) {
1395        let main_context = glib::MainContext::ref_thread_default();
1396        let is_main_context_owner = main_context.is_owner();
1397        let has_acquired_main_context = (!is_main_context_owner)
1398            .then(|| main_context.acquire().ok())
1399            .flatten();
1400        assert!(
1401            is_main_context_owner || has_acquired_main_context.is_some(),
1402            "Async operations only allowed if the thread is owning the MainContext"
1403        );
1404
1405        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1406            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1407        unsafe extern "C" fn deactivate_connection_async_trampoline<
1408            P: FnOnce(Result<(), glib::Error>) + 'static,
1409        >(
1410            _source_object: *mut glib::gobject_ffi::GObject,
1411            res: *mut gio::ffi::GAsyncResult,
1412            user_data: glib::ffi::gpointer,
1413        ) {
1414            let mut error = std::ptr::null_mut();
1415            ffi::nm_client_deactivate_connection_finish(_source_object as *mut _, res, &mut error);
1416            let result = if error.is_null() {
1417                Ok(())
1418            } else {
1419                Err(from_glib_full(error))
1420            };
1421            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1422                Box_::from_raw(user_data as *mut _);
1423            let callback: P = callback.into_inner();
1424            callback(result);
1425        }
1426        let callback = deactivate_connection_async_trampoline::<P>;
1427        unsafe {
1428            ffi::nm_client_deactivate_connection_async(
1429                self.to_glib_none().0,
1430                active.as_ref().to_glib_none().0,
1431                cancellable.map(|p| p.as_ref()).to_glib_none().0,
1432                Some(callback),
1433                Box_::into_raw(user_data) as *mut _,
1434            );
1435        }
1436    }
1437
1438    pub fn deactivate_connection_future(
1439        &self,
1440        active: &(impl IsA<ActiveConnection> + Clone + 'static),
1441    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1442        let active = active.clone();
1443        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1444            obj.deactivate_connection_async(&active, Some(cancellable), move |res| {
1445                send.resolve(res);
1446            });
1447        }))
1448    }
1449
1450    /// Gets the #NMActiveConnection corresponding to a
1451    /// currently-activating connection that is expected to become the new
1452    /// #NMClient:primary-connection upon successful activation.
1453    ///
1454    /// # Returns
1455    ///
1456    /// the appropriate #NMActiveConnection, if
1457    /// any.
1458    #[doc(alias = "nm_client_get_activating_connection")]
1459    #[doc(alias = "get_activating_connection")]
1460    #[doc(alias = "activating-connection")]
1461    pub fn activating_connection(&self) -> ActiveConnection {
1462        unsafe {
1463            from_glib_none(ffi::nm_client_get_activating_connection(
1464                self.to_glib_none().0,
1465            ))
1466        }
1467    }
1468
1469    /// Gets the active connections.
1470    ///
1471    /// # Returns
1472    ///
1473    /// a #GPtrArray
1474    ///  containing all the active #NMActiveConnections.
1475    /// The returned array is owned by the client and should not be modified.
1476    #[doc(alias = "nm_client_get_active_connections")]
1477    #[doc(alias = "get_active_connections")]
1478    #[doc(alias = "active-connections")]
1479    pub fn active_connections(&self) -> Vec<ActiveConnection> {
1480        unsafe {
1481            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_active_connections(
1482                self.to_glib_none().0,
1483            ))
1484        }
1485    }
1486
1487    /// Gets both real devices and device placeholders (eg, software devices which
1488    /// do not currently exist, but could be created automatically by NetworkManager
1489    /// if one of their NMDevice::ActivatableConnections was activated).  Use
1490    /// nm_device_is_real() to determine whether each device is a real device or
1491    /// a placeholder.
1492    ///
1493    /// Use nm_device_get_type() or the NM_IS_DEVICE_XXXX() functions to determine
1494    /// what kind of device each member of the returned array is, and then you may
1495    /// use device-specific methods such as nm_device_ethernet_get_hw_address().
1496    ///
1497    /// # Returns
1498    ///
1499    /// a #GPtrArray
1500    /// containing all the #NMDevices.  The returned array is owned by the
1501    /// #NMClient object and should not be modified.
1502    #[cfg(feature = "v1_2")]
1503    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
1504    #[doc(alias = "nm_client_get_all_devices")]
1505    #[doc(alias = "get_all_devices")]
1506    #[doc(alias = "all-devices")]
1507    pub fn all_devices(&self) -> Vec<Device> {
1508        unsafe {
1509            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_all_devices(
1510                self.to_glib_none().0,
1511            ))
1512        }
1513    }
1514
1515    ///
1516    /// # Returns
1517    ///
1518    /// the
1519    ///   list of capabilities reported by the server or [`None`]
1520    ///   if the capabilities are unknown.
1521    ///   The numeric values correspond to #NMCapability enum.
1522    ///   The array is terminated by a numeric zero sentinel
1523    ///   at position @length.
1524    #[cfg(feature = "v1_24")]
1525    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1526    #[doc(alias = "nm_client_get_capabilities")]
1527    #[doc(alias = "get_capabilities")]
1528    pub fn capabilities(&self) -> Vec<u32> {
1529        unsafe {
1530            let mut length = std::mem::MaybeUninit::uninit();
1531            let ret = FromGlibContainer::from_glib_none_num(
1532                ffi::nm_client_get_capabilities(self.to_glib_none().0, length.as_mut_ptr()),
1533                length.assume_init() as _,
1534            );
1535            ret
1536        }
1537    }
1538
1539    /// Gets all the active checkpoints.
1540    ///
1541    /// # Returns
1542    ///
1543    /// a #GPtrArray
1544    /// containing all the #NMCheckpoint.  The returned array is owned by the
1545    /// #NMClient object and should not be modified.
1546    #[cfg(feature = "v1_12")]
1547    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1548    #[doc(alias = "nm_client_get_checkpoints")]
1549    #[doc(alias = "get_checkpoints")]
1550    pub fn checkpoints(&self) -> Vec<Checkpoint> {
1551        unsafe {
1552            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_checkpoints(
1553                self.to_glib_none().0,
1554            ))
1555        }
1556    }
1557
1558    /// Returns the first matching `NMRemoteConnection` matching a given @id.
1559    /// ## `id`
1560    /// the id of the remote connection
1561    ///
1562    /// # Returns
1563    ///
1564    /// the remote connection object on success, or [`None`] if no
1565    ///  matching object was found.
1566    ///
1567    /// The connection is as received from D-Bus and might not validate according
1568    /// to nm_connection_verify().
1569    #[doc(alias = "nm_client_get_connection_by_id")]
1570    #[doc(alias = "get_connection_by_id")]
1571    pub fn connection_by_id(&self, id: &str) -> RemoteConnection {
1572        unsafe {
1573            from_glib_none(ffi::nm_client_get_connection_by_id(
1574                self.to_glib_none().0,
1575                id.to_glib_none().0,
1576            ))
1577        }
1578    }
1579
1580    /// Returns the `NMRemoteConnection` representing the connection at @path.
1581    /// ## `path`
1582    /// the D-Bus object path of the remote connection
1583    ///
1584    /// # Returns
1585    ///
1586    /// the remote connection object on success, or [`None`] if the object was
1587    ///  not known
1588    ///
1589    /// The connection is as received from D-Bus and might not validate according
1590    /// to nm_connection_verify().
1591    #[doc(alias = "nm_client_get_connection_by_path")]
1592    #[doc(alias = "get_connection_by_path")]
1593    pub fn connection_by_path(&self, path: &str) -> RemoteConnection {
1594        unsafe {
1595            from_glib_none(ffi::nm_client_get_connection_by_path(
1596                self.to_glib_none().0,
1597                path.to_glib_none().0,
1598            ))
1599        }
1600    }
1601
1602    /// Returns the `NMRemoteConnection` identified by @uuid.
1603    /// ## `uuid`
1604    /// the UUID of the remote connection
1605    ///
1606    /// # Returns
1607    ///
1608    /// the remote connection object on success, or [`None`] if the object was
1609    ///  not known
1610    ///
1611    /// The connection is as received from D-Bus and might not validate according
1612    /// to nm_connection_verify().
1613    #[doc(alias = "nm_client_get_connection_by_uuid")]
1614    #[doc(alias = "get_connection_by_uuid")]
1615    pub fn connection_by_uuid(&self, uuid: &str) -> RemoteConnection {
1616        unsafe {
1617            from_glib_none(ffi::nm_client_get_connection_by_uuid(
1618                self.to_glib_none().0,
1619                uuid.to_glib_none().0,
1620            ))
1621        }
1622    }
1623
1624    ///
1625    /// # Returns
1626    ///
1627    /// an array
1628    /// containing all connections provided by the remote settings service.  The
1629    /// returned array is owned by the #NMClient object and should not be modified.
1630    ///
1631    /// The connections are as received from D-Bus and might not validate according
1632    /// to nm_connection_verify().
1633    #[doc(alias = "nm_client_get_connections")]
1634    #[doc(alias = "get_connections")]
1635    pub fn connections(&self) -> Vec<RemoteConnection> {
1636        unsafe {
1637            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_connections(
1638                self.to_glib_none().0,
1639            ))
1640        }
1641    }
1642
1643    /// Gets the current network connectivity state. Contrast
1644    /// nm_client_check_connectivity() and
1645    /// nm_client_check_connectivity_async(), which re-check the
1646    /// connectivity state first before returning any information.
1647    ///
1648    /// # Returns
1649    ///
1650    /// the current connectivity state
1651    #[doc(alias = "nm_client_get_connectivity")]
1652    #[doc(alias = "get_connectivity")]
1653    pub fn connectivity(&self) -> ConnectivityState {
1654        unsafe { from_glib(ffi::nm_client_get_connectivity(self.to_glib_none().0)) }
1655    }
1656
1657    //#[cfg(feature = "v1_22")]
1658    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1659    //#[doc(alias = "nm_client_get_context_busy_watcher")]
1660    //#[doc(alias = "get_context_busy_watcher")]
1661    //pub fn context_busy_watcher(&self) -> /*Ignored*/glib::Object {
1662    //    unsafe { TODO: call ffi:nm_client_get_context_busy_watcher() }
1663    //}
1664
1665    //#[cfg(feature = "v1_22")]
1666    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1667    //#[doc(alias = "nm_client_get_dbus_connection")]
1668    //#[doc(alias = "get_dbus_connection")]
1669    //#[doc(alias = "dbus-connection")]
1670    //pub fn dbus_connection(&self) -> /*Ignored*/gio::DBusConnection {
1671    //    unsafe { TODO: call ffi:nm_client_get_dbus_connection() }
1672    //}
1673
1674    ///
1675    /// # Returns
1676    ///
1677    /// the current name owner of the D-Bus service of NetworkManager.
1678    #[cfg(feature = "v1_22")]
1679    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1680    #[doc(alias = "nm_client_get_dbus_name_owner")]
1681    #[doc(alias = "get_dbus_name_owner")]
1682    #[doc(alias = "dbus-name-owner")]
1683    pub fn dbus_name_owner(&self) -> glib::GString {
1684        unsafe { from_glib_none(ffi::nm_client_get_dbus_name_owner(self.to_glib_none().0)) }
1685    }
1686
1687    /// Gets a #NMDevice from a #NMClient.
1688    /// ## `iface`
1689    /// the interface name to search for
1690    ///
1691    /// # Returns
1692    ///
1693    /// the #NMDevice for the given @iface or [`None`] if none is found.
1694    #[doc(alias = "nm_client_get_device_by_iface")]
1695    #[doc(alias = "get_device_by_iface")]
1696    pub fn device_by_iface(&self, iface: &str) -> Device {
1697        unsafe {
1698            from_glib_none(ffi::nm_client_get_device_by_iface(
1699                self.to_glib_none().0,
1700                iface.to_glib_none().0,
1701            ))
1702        }
1703    }
1704
1705    /// Gets a #NMDevice from a #NMClient.
1706    /// ## `object_path`
1707    /// the object path to search for
1708    ///
1709    /// # Returns
1710    ///
1711    /// the #NMDevice for the given @object_path or [`None`] if none is found.
1712    #[doc(alias = "nm_client_get_device_by_path")]
1713    #[doc(alias = "get_device_by_path")]
1714    pub fn device_by_path(&self, object_path: &str) -> Device {
1715        unsafe {
1716            from_glib_none(ffi::nm_client_get_device_by_path(
1717                self.to_glib_none().0,
1718                object_path.to_glib_none().0,
1719            ))
1720        }
1721    }
1722
1723    /// Gets all the known network devices.  Use nm_device_get_type() or the
1724    /// <literal>NM_IS_DEVICE_XXXX</literal> functions to determine what kind of
1725    /// device member of the returned array is, and then you may use device-specific
1726    /// methods such as nm_device_ethernet_get_hw_address().
1727    ///
1728    /// # Returns
1729    ///
1730    /// a #GPtrArray
1731    /// containing all the #NMDevices.  The returned array is owned by the
1732    /// #NMClient object and should not be modified.
1733    #[doc(alias = "nm_client_get_devices")]
1734    #[doc(alias = "get_devices")]
1735    pub fn devices(&self) -> Vec<Device> {
1736        unsafe {
1737            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_devices(self.to_glib_none().0))
1738        }
1739    }
1740
1741    /// Gets the current DNS configuration
1742    ///
1743    /// # Returns
1744    ///
1745    /// a #GPtrArray
1746    /// containing #NMDnsEntry elements or [`None`] in case the value is not
1747    /// available.  The returned array is owned by the #NMClient object
1748    /// and should not be modified.
1749    #[cfg(feature = "v1_6")]
1750    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1751    #[doc(alias = "nm_client_get_dns_configuration")]
1752    #[doc(alias = "get_dns_configuration")]
1753    #[doc(alias = "dns-configuration")]
1754    pub fn dns_configuration(&self) -> Vec<DnsEntry> {
1755        unsafe {
1756            FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_dns_configuration(
1757                self.to_glib_none().0,
1758            ))
1759        }
1760    }
1761
1762    /// Gets the current DNS processing mode.
1763    ///
1764    /// # Returns
1765    ///
1766    /// the DNS processing mode, or [`None`] in case the
1767    ///   value is not available.
1768    #[cfg(feature = "v1_6")]
1769    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1770    #[doc(alias = "nm_client_get_dns_mode")]
1771    #[doc(alias = "get_dns_mode")]
1772    #[doc(alias = "dns-mode")]
1773    pub fn dns_mode(&self) -> glib::GString {
1774        unsafe { from_glib_none(ffi::nm_client_get_dns_mode(self.to_glib_none().0)) }
1775    }
1776
1777    /// Gets the current DNS resolv.conf manager.
1778    ///
1779    /// # Returns
1780    ///
1781    /// the resolv.conf manager or [`None`] in case the
1782    ///   value is not available.
1783    #[cfg(feature = "v1_6")]
1784    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1785    #[doc(alias = "nm_client_get_dns_rc_manager")]
1786    #[doc(alias = "get_dns_rc_manager")]
1787    #[doc(alias = "dns-rc-manager")]
1788    pub fn dns_rc_manager(&self) -> glib::GString {
1789        unsafe { from_glib_none(ffi::nm_client_get_dns_rc_manager(self.to_glib_none().0)) }
1790    }
1791
1792    ///
1793    /// # Returns
1794    ///
1795    /// the #NMClientInstanceFlags flags.
1796    #[cfg(feature = "v1_24")]
1797    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1798    #[doc(alias = "nm_client_get_instance_flags")]
1799    #[doc(alias = "get_instance_flags")]
1800    #[doc(alias = "instance-flags")]
1801    pub fn instance_flags(&self) -> ClientInstanceFlags {
1802        unsafe { from_glib(ffi::nm_client_get_instance_flags(self.to_glib_none().0)) }
1803    }
1804
1805    /// Gets NetworkManager current logging level and domains.
1806    ///
1807    /// # Deprecated since 1.22
1808    ///
1809    /// Use the async command nm_client_dbus_call() on [`DBUS_PATH`][crate::DBUS_PATH],
1810    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to call "GetLogging" with no arguments to get "(ss)" for level
1811    /// and domains.
1812    ///
1813    /// # Returns
1814    ///
1815    /// [`true`] on success, [`false`] otherwise
1816    ///
1817    /// ## `level`
1818    /// return location for logging level string
1819    ///
1820    /// ## `domains`
1821    /// return location for log domains string. The string is
1822    ///   a list of domains separated by ","
1823    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1824    #[allow(deprecated)]
1825    #[doc(alias = "nm_client_get_logging")]
1826    #[doc(alias = "get_logging")]
1827    pub fn logging(&self) -> Result<(Option<glib::GString>, Option<glib::GString>), glib::Error> {
1828        unsafe {
1829            let mut level = std::ptr::null_mut();
1830            let mut domains = std::ptr::null_mut();
1831            let mut error = std::ptr::null_mut();
1832            let is_ok = ffi::nm_client_get_logging(
1833                self.to_glib_none().0,
1834                &mut level,
1835                &mut domains,
1836                &mut error,
1837            );
1838            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1839            if error.is_null() {
1840                Ok((from_glib_full(level), from_glib_full(domains)))
1841            } else {
1842                Err(from_glib_full(error))
1843            }
1844        }
1845    }
1846
1847    //#[cfg(feature = "v1_22")]
1848    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1849    //#[doc(alias = "nm_client_get_main_context")]
1850    //#[doc(alias = "get_main_context")]
1851    //pub fn main_context(&self) -> /*Ignored*/glib::MainContext {
1852    //    unsafe { TODO: call ffi:nm_client_get_main_context() }
1853    //}
1854
1855    ///
1856    /// # Returns
1857    ///
1858    /// whether the default route is metered.
1859    #[cfg(feature = "v1_22")]
1860    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1861    #[doc(alias = "nm_client_get_metered")]
1862    #[doc(alias = "get_metered")]
1863    pub fn metered(&self) -> Metered {
1864        unsafe { from_glib(ffi::nm_client_get_metered(self.to_glib_none().0)) }
1865    }
1866
1867    /// Determines whether the daemon is running.
1868    ///
1869    /// # Returns
1870    ///
1871    /// [`true`] if the daemon is running
1872    #[doc(alias = "nm_client_get_nm_running")]
1873    #[doc(alias = "get_nm_running")]
1874    #[doc(alias = "nm-running")]
1875    pub fn is_nm_running(&self) -> bool {
1876        unsafe { from_glib(ffi::nm_client_get_nm_running(self.to_glib_none().0)) }
1877    }
1878
1879    /// ## `dbus_path`
1880    /// the D-Bus path of the object to look up
1881    ///
1882    /// # Returns
1883    ///
1884    /// the #NMObject instance that is
1885    ///   cached under @dbus_path, or [`None`] if no such object exists.
1886    #[cfg(feature = "v1_24")]
1887    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1888    #[doc(alias = "nm_client_get_object_by_path")]
1889    #[doc(alias = "get_object_by_path")]
1890    pub fn object_by_path(&self, dbus_path: &str) -> Object {
1891        unsafe {
1892            from_glib_none(ffi::nm_client_get_object_by_path(
1893                self.to_glib_none().0,
1894                dbus_path.to_glib_none().0,
1895            ))
1896        }
1897    }
1898
1899    /// Requests the result of a specific permission, which indicates whether the
1900    /// client can or cannot perform the action the permission represents
1901    /// ## `permission`
1902    /// the permission for which to return the result, one of #NMClientPermission
1903    ///
1904    /// # Returns
1905    ///
1906    /// the permission's result, one of #NMClientPermissionResult
1907    #[doc(alias = "nm_client_get_permission_result")]
1908    #[doc(alias = "get_permission_result")]
1909    pub fn permission_result(&self, permission: ClientPermission) -> ClientPermissionResult {
1910        unsafe {
1911            from_glib(ffi::nm_client_get_permission_result(
1912                self.to_glib_none().0,
1913                permission.into_glib(),
1914            ))
1915        }
1916    }
1917
1918    ///
1919    /// # Returns
1920    ///
1921    /// the state of the cached permissions. [`Ternary::Default`][crate::Ternary::Default]
1922    ///   means that no permissions result was yet received. All permissions
1923    ///   are unknown. [`Ternary::True`][crate::Ternary::True] means that the permissions got received
1924    ///   and are cached. %[`Ternary::False`][crate::Ternary::False] means that permissions are cached,
1925    ///   but they are invalided as "CheckPermissions" signal was received
1926    ///   in the meantime.
1927    #[cfg(feature = "v1_24")]
1928    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1929    #[doc(alias = "nm_client_get_permissions_state")]
1930    #[doc(alias = "get_permissions_state")]
1931    #[doc(alias = "permissions-state")]
1932    pub fn permissions_state(&self) -> Ternary {
1933        unsafe { from_glib(ffi::nm_client_get_permissions_state(self.to_glib_none().0)) }
1934    }
1935
1936    /// Gets the #NMActiveConnection corresponding to the primary active
1937    /// network device.
1938    ///
1939    /// In particular, when there is no VPN active, or the VPN does not
1940    /// have the default route, this returns the active connection that has
1941    /// the default route. If there is a VPN active with the default route,
1942    /// then this function returns the active connection that contains the
1943    /// route to the VPN endpoint.
1944    ///
1945    /// If there is no default route, or the default route is over a
1946    /// non-NetworkManager-recognized device, this will return [`None`].
1947    ///
1948    /// # Returns
1949    ///
1950    /// the appropriate #NMActiveConnection, if
1951    /// any
1952    #[doc(alias = "nm_client_get_primary_connection")]
1953    #[doc(alias = "get_primary_connection")]
1954    #[doc(alias = "primary-connection")]
1955    pub fn primary_connection(&self) -> ActiveConnection {
1956        unsafe { from_glib_none(ffi::nm_client_get_primary_connection(self.to_glib_none().0)) }
1957    }
1958
1959    /// Get radio flags.
1960    ///
1961    /// # Returns
1962    ///
1963    /// the #NMRadioFlags.
1964    #[cfg(feature = "v1_38")]
1965    #[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
1966    #[doc(alias = "nm_client_get_radio_flags")]
1967    #[doc(alias = "get_radio_flags")]
1968    #[doc(alias = "radio-flags")]
1969    pub fn radio_flags(&self) -> RadioFlags {
1970        unsafe { from_glib(ffi::nm_client_get_radio_flags(self.to_glib_none().0)) }
1971    }
1972
1973    /// Tests whether the daemon is still in the process of activating
1974    /// connections at startup.
1975    ///
1976    /// # Returns
1977    ///
1978    /// whether the daemon is still starting up
1979    #[doc(alias = "nm_client_get_startup")]
1980    #[doc(alias = "get_startup")]
1981    #[doc(alias = "startup")]
1982    pub fn is_startup(&self) -> bool {
1983        unsafe { from_glib(ffi::nm_client_get_startup(self.to_glib_none().0)) }
1984    }
1985
1986    /// Gets the current daemon state.
1987    ///
1988    /// # Returns
1989    ///
1990    /// the current `NMState`
1991    #[doc(alias = "nm_client_get_state")]
1992    #[doc(alias = "get_state")]
1993    pub fn state(&self) -> State {
1994        unsafe { from_glib(ffi::nm_client_get_state(self.to_glib_none().0)) }
1995    }
1996
1997    /// Gets NetworkManager version.
1998    ///
1999    /// # Returns
2000    ///
2001    /// string with the version (or [`None`] if NetworkManager is not running)
2002    #[doc(alias = "nm_client_get_version")]
2003    #[doc(alias = "get_version")]
2004    pub fn version(&self) -> glib::GString {
2005        unsafe { glib::GString::from_glib_none(ffi::nm_client_get_version(self.to_glib_none().0)) }
2006    }
2007
2008    /// If available, the first element in the array is NM_VERSION which
2009    /// encodes the daemon version as "(major << 16 | minor << 8 | micro)".
2010    /// The following elements are a bitfield of `NMVersionInfoCapability`
2011    /// that indicate that the daemon supports a certain capability.
2012    ///
2013    /// # Returns
2014    ///
2015    /// the
2016    ///   list of capabilities reported by the server or [`None`]
2017    ///   if the capabilities are unknown.
2018    #[cfg(feature = "v1_42")]
2019    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2020    #[doc(alias = "nm_client_get_version_info")]
2021    #[doc(alias = "get_version_info")]
2022    #[doc(alias = "version-info")]
2023    pub fn version_info(&self) -> Vec<u32> {
2024        unsafe {
2025            let mut length = std::mem::MaybeUninit::uninit();
2026            let ret = FromGlibContainer::from_glib_none_num(
2027                ffi::nm_client_get_version_info(self.to_glib_none().0, length.as_mut_ptr()),
2028                length.assume_init() as _,
2029            );
2030            ret
2031        }
2032    }
2033
2034    /// Requests that the remote settings service load or reload the given files,
2035    /// adding or updating the connections described within.
2036    ///
2037    /// The changes to the indicated files will not yet be reflected in
2038    /// @self's connections array when the function returns.
2039    ///
2040    /// If all of the indicated files were successfully loaded, the
2041    /// function will return [`true`], and @failures will be set to [`None`]. If
2042    /// NetworkManager tried to load the files, but some (or all) failed,
2043    /// then @failures will be set to a [`None`]-terminated array of the
2044    /// filenames that failed to load.
2045    ///
2046    /// # Deprecated since 1.22
2047    ///
2048    /// Use nm_client_load_connections_async() or GDBusConnection.
2049    /// ## `filenames`
2050    /// [`None`]-terminated array of filenames to load
2051    /// ## `cancellable`
2052    /// a #GCancellable, or [`None`]
2053    ///
2054    /// # Returns
2055    ///
2056    /// [`true`] on success.
2057    ///
2058    /// Warning: before libnm 1.22, the boolean return value was inconsistent.
2059    ///   That is made worse, because when running against certain server versions
2060    ///   before 1.20, the server would return wrong values for success/failure.
2061    ///   This means, if you use this function in libnm before 1.22, you are advised
2062    ///   to ignore the boolean return value and only look at @failures and @error.
2063    ///   With libnm >= 1.22, the boolean return value corresponds to whether @error was
2064    ///   set. Note that even in the success case, you might have individual @failures.
2065    ///   With 1.22, the return value is consistent with nm_client_load_connections_finish().
2066    ///
2067    /// ## `failures`
2068    /// on return, a [`None`]-terminated array of
2069    ///   filenames that failed to load
2070    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2071    #[allow(deprecated)]
2072    #[doc(alias = "nm_client_load_connections")]
2073    pub fn load_connections(
2074        &self,
2075        filenames: &[&str],
2076        cancellable: Option<&impl IsA<gio::Cancellable>>,
2077    ) -> Result<glib::GString, glib::Error> {
2078        unsafe {
2079            let mut failures = std::ptr::null_mut();
2080            let mut error = std::ptr::null_mut();
2081            let is_ok = ffi::nm_client_load_connections(
2082                self.to_glib_none().0,
2083                filenames.to_glib_none().0,
2084                &mut failures,
2085                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2086                &mut error,
2087            );
2088            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2089            if error.is_null() {
2090                Ok(from_glib_full(std::ptr::read(failures)))
2091            } else {
2092                Err(from_glib_full(error))
2093            }
2094        }
2095    }
2096
2097    /// Requests that the remote settings service asynchronously load or reload the
2098    /// given files, adding or updating the connections described within.
2099    ///
2100    /// See nm_client_load_connections() for more details.
2101    /// ## `filenames`
2102    /// [`None`]-terminated array of filenames to load
2103    /// ## `cancellable`
2104    /// a #GCancellable, or [`None`]
2105    /// ## `callback`
2106    /// callback to be called when the operation completes
2107    #[doc(alias = "nm_client_load_connections_async")]
2108    pub fn load_connections_async<P: FnOnce(Result<Vec<glib::GString>, glib::Error>) + 'static>(
2109        &self,
2110        filenames: &[&str],
2111        cancellable: Option<&impl IsA<gio::Cancellable>>,
2112        callback: P,
2113    ) {
2114        let main_context = glib::MainContext::ref_thread_default();
2115        let is_main_context_owner = main_context.is_owner();
2116        let has_acquired_main_context = (!is_main_context_owner)
2117            .then(|| main_context.acquire().ok())
2118            .flatten();
2119        assert!(
2120            is_main_context_owner || has_acquired_main_context.is_some(),
2121            "Async operations only allowed if the thread is owning the MainContext"
2122        );
2123
2124        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2125            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2126        unsafe extern "C" fn load_connections_async_trampoline<
2127            P: FnOnce(Result<Vec<glib::GString>, glib::Error>) + 'static,
2128        >(
2129            _source_object: *mut glib::gobject_ffi::GObject,
2130            res: *mut gio::ffi::GAsyncResult,
2131            user_data: glib::ffi::gpointer,
2132        ) {
2133            let mut error = std::ptr::null_mut();
2134            let mut failures = std::ptr::null_mut();
2135            ffi::nm_client_load_connections_finish(
2136                _source_object as *mut _,
2137                &mut failures,
2138                res,
2139                &mut error,
2140            );
2141            let result = if error.is_null() {
2142                Ok(FromGlibPtrContainer::from_glib_full(failures))
2143            } else {
2144                Err(from_glib_full(error))
2145            };
2146            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2147                Box_::from_raw(user_data as *mut _);
2148            let callback: P = callback.into_inner();
2149            callback(result);
2150        }
2151        let callback = load_connections_async_trampoline::<P>;
2152        unsafe {
2153            ffi::nm_client_load_connections_async(
2154                self.to_glib_none().0,
2155                filenames.to_glib_none().0,
2156                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2157                Some(callback),
2158                Box_::into_raw(user_data) as *mut _,
2159            );
2160        }
2161    }
2162
2163    pub fn load_connections_future(
2164        &self,
2165        filenames: &[&str],
2166    ) -> Pin<
2167        Box_<dyn std::future::Future<Output = Result<Vec<glib::GString>, glib::Error>> + 'static>,
2168    > {
2169        let filenames = filenames
2170            .iter()
2171            .map(ToString::to_string)
2172            .collect::<Vec<_>>();
2173        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2174            obj.load_connections_async(
2175                filenames
2176                    .iter()
2177                    .map(|s| s.as_str())
2178                    .collect::<Vec<&str>>()
2179                    .as_slice(),
2180                Some(cancellable),
2181                move |res| {
2182                    send.resolve(res);
2183                },
2184            );
2185        }))
2186    }
2187
2188    /// Whether networking is enabled or disabled.
2189    ///
2190    /// # Returns
2191    ///
2192    /// [`true`] if networking is enabled, [`false`] if networking is disabled
2193    #[doc(alias = "nm_client_networking_get_enabled")]
2194    pub fn networking_get_enabled(&self) -> bool {
2195        unsafe { from_glib(ffi::nm_client_networking_get_enabled(self.to_glib_none().0)) }
2196    }
2197
2198    /// Enables or disables networking.  When networking is disabled, all controlled
2199    /// interfaces are disconnected and deactivated.  When networking is enabled,
2200    /// all controlled interfaces are available for activation.
2201    ///
2202    /// # Deprecated since 1.22
2203    ///
2204    /// Use the async command nm_client_dbus_call() on [`DBUS_PATH`][crate::DBUS_PATH],
2205    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to call "Enable" with "(b)" arguments and no return value.
2206    /// ## `enabled`
2207    /// [`true`] to set networking enabled, [`false`] to set networking disabled
2208    ///
2209    /// # Returns
2210    ///
2211    /// [`true`] on success, [`false`] otherwise
2212    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2213    #[allow(deprecated)]
2214    #[doc(alias = "nm_client_networking_set_enabled")]
2215    pub fn networking_set_enabled(&self, enabled: bool) -> Result<(), glib::Error> {
2216        unsafe {
2217            let mut error = std::ptr::null_mut();
2218            let is_ok = ffi::nm_client_networking_set_enabled(
2219                self.to_glib_none().0,
2220                enabled.into_glib(),
2221                &mut error,
2222            );
2223            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2224            if error.is_null() {
2225                Ok(())
2226            } else {
2227                Err(from_glib_full(error))
2228            }
2229        }
2230    }
2231
2232    /// Reload NetworkManager's configuration and perform certain updates, like
2233    /// flushing caches or rewriting external state to disk. This is similar to
2234    /// sending SIGHUP to NetworkManager but it allows for more fine-grained control
2235    /// over what to reload (see @flags). It also allows non-root access via
2236    /// PolicyKit and contrary to signals it is synchronous.
2237    /// ## `flags`
2238    /// flags indicating what to reload.
2239    /// ## `cancellable`
2240    /// a #GCancellable, or [`None`]
2241    /// ## `callback`
2242    /// callback to be called when the add operation completes
2243    #[cfg(feature = "v1_22")]
2244    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2245    #[doc(alias = "nm_client_reload")]
2246    pub fn reload<P: FnOnce(Result<(), glib::Error>) + 'static>(
2247        &self,
2248        flags: ManagerReloadFlags,
2249        cancellable: Option<&impl IsA<gio::Cancellable>>,
2250        callback: P,
2251    ) {
2252        let main_context = glib::MainContext::ref_thread_default();
2253        let is_main_context_owner = main_context.is_owner();
2254        let has_acquired_main_context = (!is_main_context_owner)
2255            .then(|| main_context.acquire().ok())
2256            .flatten();
2257        assert!(
2258            is_main_context_owner || has_acquired_main_context.is_some(),
2259            "Async operations only allowed if the thread is owning the MainContext"
2260        );
2261
2262        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2263            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2264        unsafe extern "C" fn reload_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(
2265            _source_object: *mut glib::gobject_ffi::GObject,
2266            res: *mut gio::ffi::GAsyncResult,
2267            user_data: glib::ffi::gpointer,
2268        ) {
2269            let mut error = std::ptr::null_mut();
2270            ffi::nm_client_reload_finish(_source_object as *mut _, res, &mut error);
2271            let result = if error.is_null() {
2272                Ok(())
2273            } else {
2274                Err(from_glib_full(error))
2275            };
2276            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2277                Box_::from_raw(user_data as *mut _);
2278            let callback: P = callback.into_inner();
2279            callback(result);
2280        }
2281        let callback = reload_trampoline::<P>;
2282        unsafe {
2283            ffi::nm_client_reload(
2284                self.to_glib_none().0,
2285                flags.into_glib(),
2286                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2287                Some(callback),
2288                Box_::into_raw(user_data) as *mut _,
2289            );
2290        }
2291    }
2292
2293    #[cfg(feature = "v1_22")]
2294    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2295    pub fn reload_future(
2296        &self,
2297        flags: ManagerReloadFlags,
2298    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2299        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2300            obj.reload(flags, Some(cancellable), move |res| {
2301                send.resolve(res);
2302            });
2303        }))
2304    }
2305
2306    /// Requests that the remote settings service reload all connection
2307    /// files from disk, adding, updating, and removing connections until
2308    /// the in-memory state matches the on-disk state.
2309    ///
2310    /// # Deprecated since 1.22
2311    ///
2312    /// Use nm_client_reload_connections_async() or GDBusConnection.
2313    /// ## `cancellable`
2314    /// a #GCancellable, or [`None`]
2315    ///
2316    /// # Returns
2317    ///
2318    /// [`true`] on success, [`false`] on failure
2319    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2320    #[allow(deprecated)]
2321    #[doc(alias = "nm_client_reload_connections")]
2322    pub fn reload_connections(
2323        &self,
2324        cancellable: Option<&impl IsA<gio::Cancellable>>,
2325    ) -> Result<(), glib::Error> {
2326        unsafe {
2327            let mut error = std::ptr::null_mut();
2328            let is_ok = ffi::nm_client_reload_connections(
2329                self.to_glib_none().0,
2330                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2331                &mut error,
2332            );
2333            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2334            if error.is_null() {
2335                Ok(())
2336            } else {
2337                Err(from_glib_full(error))
2338            }
2339        }
2340    }
2341
2342    /// Requests that the remote settings service begin reloading all connection
2343    /// files from disk, adding, updating, and removing connections until the
2344    /// in-memory state matches the on-disk state.
2345    /// ## `cancellable`
2346    /// a #GCancellable, or [`None`]
2347    /// ## `callback`
2348    /// callback to be called when the reload operation completes
2349    #[doc(alias = "nm_client_reload_connections_async")]
2350    pub fn reload_connections_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
2351        &self,
2352        cancellable: Option<&impl IsA<gio::Cancellable>>,
2353        callback: P,
2354    ) {
2355        let main_context = glib::MainContext::ref_thread_default();
2356        let is_main_context_owner = main_context.is_owner();
2357        let has_acquired_main_context = (!is_main_context_owner)
2358            .then(|| main_context.acquire().ok())
2359            .flatten();
2360        assert!(
2361            is_main_context_owner || has_acquired_main_context.is_some(),
2362            "Async operations only allowed if the thread is owning the MainContext"
2363        );
2364
2365        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2366            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2367        unsafe extern "C" fn reload_connections_async_trampoline<
2368            P: FnOnce(Result<(), glib::Error>) + 'static,
2369        >(
2370            _source_object: *mut glib::gobject_ffi::GObject,
2371            res: *mut gio::ffi::GAsyncResult,
2372            user_data: glib::ffi::gpointer,
2373        ) {
2374            let mut error = std::ptr::null_mut();
2375            ffi::nm_client_reload_connections_finish(_source_object as *mut _, res, &mut error);
2376            let result = if error.is_null() {
2377                Ok(())
2378            } else {
2379                Err(from_glib_full(error))
2380            };
2381            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2382                Box_::from_raw(user_data as *mut _);
2383            let callback: P = callback.into_inner();
2384            callback(result);
2385        }
2386        let callback = reload_connections_async_trampoline::<P>;
2387        unsafe {
2388            ffi::nm_client_reload_connections_async(
2389                self.to_glib_none().0,
2390                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2391                Some(callback),
2392                Box_::into_raw(user_data) as *mut _,
2393            );
2394        }
2395    }
2396
2397    pub fn reload_connections_future(
2398        &self,
2399    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2400        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2401            obj.reload_connections_async(Some(cancellable), move |res| {
2402                send.resolve(res);
2403            });
2404        }))
2405    }
2406
2407    /// Requests that the machine's persistent hostname be set to the specified value
2408    /// or cleared.
2409    ///
2410    /// # Deprecated since 1.22
2411    ///
2412    /// Use nm_client_save_hostname_async() or GDBusConnection.
2413    /// ## `hostname`
2414    /// the new persistent hostname to set, or [`None`] to
2415    ///   clear any existing persistent hostname
2416    /// ## `cancellable`
2417    /// a #GCancellable, or [`None`]
2418    ///
2419    /// # Returns
2420    ///
2421    /// [`true`] if the request was successful, [`false`] if it failed
2422    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2423    #[allow(deprecated)]
2424    #[doc(alias = "nm_client_save_hostname")]
2425    pub fn save_hostname(
2426        &self,
2427        hostname: Option<&str>,
2428        cancellable: Option<&impl IsA<gio::Cancellable>>,
2429    ) -> Result<(), glib::Error> {
2430        unsafe {
2431            let mut error = std::ptr::null_mut();
2432            let is_ok = ffi::nm_client_save_hostname(
2433                self.to_glib_none().0,
2434                hostname.to_glib_none().0,
2435                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2436                &mut error,
2437            );
2438            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2439            if error.is_null() {
2440                Ok(())
2441            } else {
2442                Err(from_glib_full(error))
2443            }
2444        }
2445    }
2446
2447    /// Requests that the machine's persistent hostname be set to the specified value
2448    /// or cleared.
2449    /// ## `hostname`
2450    /// the new persistent hostname to set, or [`None`] to
2451    ///   clear any existing persistent hostname
2452    /// ## `cancellable`
2453    /// a #GCancellable, or [`None`]
2454    /// ## `callback`
2455    /// callback to be called when the operation completes
2456    #[doc(alias = "nm_client_save_hostname_async")]
2457    pub fn save_hostname_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
2458        &self,
2459        hostname: Option<&str>,
2460        cancellable: Option<&impl IsA<gio::Cancellable>>,
2461        callback: P,
2462    ) {
2463        let main_context = glib::MainContext::ref_thread_default();
2464        let is_main_context_owner = main_context.is_owner();
2465        let has_acquired_main_context = (!is_main_context_owner)
2466            .then(|| main_context.acquire().ok())
2467            .flatten();
2468        assert!(
2469            is_main_context_owner || has_acquired_main_context.is_some(),
2470            "Async operations only allowed if the thread is owning the MainContext"
2471        );
2472
2473        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2474            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2475        unsafe extern "C" fn save_hostname_async_trampoline<
2476            P: FnOnce(Result<(), glib::Error>) + 'static,
2477        >(
2478            _source_object: *mut glib::gobject_ffi::GObject,
2479            res: *mut gio::ffi::GAsyncResult,
2480            user_data: glib::ffi::gpointer,
2481        ) {
2482            let mut error = std::ptr::null_mut();
2483            ffi::nm_client_save_hostname_finish(_source_object as *mut _, res, &mut error);
2484            let result = if error.is_null() {
2485                Ok(())
2486            } else {
2487                Err(from_glib_full(error))
2488            };
2489            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2490                Box_::from_raw(user_data as *mut _);
2491            let callback: P = callback.into_inner();
2492            callback(result);
2493        }
2494        let callback = save_hostname_async_trampoline::<P>;
2495        unsafe {
2496            ffi::nm_client_save_hostname_async(
2497                self.to_glib_none().0,
2498                hostname.to_glib_none().0,
2499                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2500                Some(callback),
2501                Box_::into_raw(user_data) as *mut _,
2502            );
2503        }
2504    }
2505
2506    pub fn save_hostname_future(
2507        &self,
2508        hostname: Option<&str>,
2509    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2510        let hostname = hostname.map(ToOwned::to_owned);
2511        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2512            obj.save_hostname_async(
2513                hostname.as_ref().map(::std::borrow::Borrow::borrow),
2514                Some(cancellable),
2515                move |res| {
2516                    send.resolve(res);
2517                },
2518            );
2519        }))
2520    }
2521
2522    /// Sets NetworkManager logging level and/or domains.
2523    ///
2524    /// # Deprecated since 1.22
2525    ///
2526    /// Use the async command nm_client_dbus_call() on [`DBUS_PATH`][crate::DBUS_PATH],
2527    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to call "SetLogging" with "(ss)" arguments for level and domains.
2528    /// ## `level`
2529    /// logging level to set ([`None`] or an empty string for no change)
2530    /// ## `domains`
2531    /// logging domains to set. The string should be a list of log
2532    ///   domains separated by ",". ([`None`] or an empty string for no change)
2533    ///
2534    /// # Returns
2535    ///
2536    /// [`true`] on success, [`false`] otherwise
2537    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2538    #[allow(deprecated)]
2539    #[doc(alias = "nm_client_set_logging")]
2540    pub fn set_logging(
2541        &self,
2542        level: Option<&str>,
2543        domains: Option<&str>,
2544    ) -> Result<(), glib::Error> {
2545        unsafe {
2546            let mut error = std::ptr::null_mut();
2547            let is_ok = ffi::nm_client_set_logging(
2548                self.to_glib_none().0,
2549                level.to_glib_none().0,
2550                domains.to_glib_none().0,
2551                &mut error,
2552            );
2553            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2554            if error.is_null() {
2555                Ok(())
2556            } else {
2557                Err(from_glib_full(error))
2558            }
2559        }
2560    }
2561
2562    /// The way to stop #NMClient is by unrefing it. That will cancel all
2563    /// internally pending async operations. However, as async operations in
2564    /// NMClient use GTask, hence they cannot complete right away. Instead,
2565    /// their (internal) result callback still needs to be dispatched by iterating
2566    /// the client's main context.
2567    ///
2568    /// You thus cannot stop iterating the client's main context until
2569    /// everything is wrapped up. nm_client_get_context_busy_watcher()
2570    /// helps to watch how long that will be.
2571    ///
2572    /// This function automates that waiting. Like all glib async operations
2573    /// this honors the current g_main_context_get_thread_default().
2574    ///
2575    /// In any case, to complete the shutdown, nm_client_get_main_context()
2576    /// must be iterated. If the current g_main_context_get_thread_default() is
2577    /// the same as nm_client_get_main_context(), then @integrate_maincontext
2578    /// is ignored. In that case, the caller is required to iterate the context
2579    /// for shutdown to complete. Otherwise, if g_main_context_get_thread_default()
2580    /// differs from nm_client_get_main_context() and @integrate_maincontext
2581    /// is [`false`], the caller must make sure that both contexts are iterated
2582    /// until completion. Otherwise, if @integrate_maincontext is [`true`], then
2583    /// nm_client_get_main_context() will be integrated in g_main_context_get_thread_default().
2584    /// This means, the caller gives nm_client_get_main_context() up until the waiting
2585    /// completes, the function will acquire the context and hook it into
2586    /// g_main_context_get_thread_default().
2587    /// It is a bug to request @integrate_maincontext while having nm_client_get_main_context()
2588    /// acquired or iterated otherwise because a context can only be acquired once
2589    /// at a time.
2590    ///
2591    /// Shutdown can only complete after all references to @self were released.
2592    ///
2593    /// It is possible to call this function multiple times for the same client.
2594    /// But note that with @integrate_maincontext the client's context is acquired,
2595    /// which can only be done once at a time.
2596    ///
2597    /// It is permissible to start waiting before the objects is fully initialized.
2598    ///
2599    /// The function really allows two separate things. To get a notification (callback) when
2600    /// shutdown is complete, and to integrate the client's context in another context.
2601    /// The latter case is useful if the client has a separate context and you hand it
2602    /// over to another GMainContext to wrap up.
2603    ///
2604    /// The main use is to have a NMClient and a separate GMainContext on a worker
2605    /// thread. When being done, you can hand over the cleanup of the context
2606    /// to g_main_context_default(), assuming that the main thread iterates
2607    /// the default context. In that case, you don't need to care about passing
2608    /// a callback to know when shutdown completed.
2609    /// ## `integrate_maincontext`
2610    /// whether to hook the client's maincontext
2611    ///   in the current thread default. Otherwise, you must ensure
2612    ///   that the client's maincontext gets iterated so that it can complete.
2613    ///   By integrating the maincontext in the current thread default, you
2614    ///   may instead only iterate the latter.
2615    /// ## `cancellable`
2616    /// the #GCancellable to abort the shutdown.
2617    /// ## `callback`
2618    /// a #GAsyncReadyCallback to call when the request
2619    ///   is satisfied or [`None`] if you don't care about the result of the
2620    ///   method invocation.
2621    #[cfg(feature = "v1_42")]
2622    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2623    #[doc(alias = "nm_client_wait_shutdown")]
2624    pub fn wait_shutdown<P: FnOnce(Result<(), glib::Error>) + 'static>(
2625        &self,
2626        integrate_maincontext: bool,
2627        cancellable: Option<&impl IsA<gio::Cancellable>>,
2628        callback: P,
2629    ) {
2630        let main_context = glib::MainContext::ref_thread_default();
2631        let is_main_context_owner = main_context.is_owner();
2632        let has_acquired_main_context = (!is_main_context_owner)
2633            .then(|| main_context.acquire().ok())
2634            .flatten();
2635        assert!(
2636            is_main_context_owner || has_acquired_main_context.is_some(),
2637            "Async operations only allowed if the thread is owning the MainContext"
2638        );
2639
2640        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2641            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2642        unsafe extern "C" fn wait_shutdown_trampoline<
2643            P: FnOnce(Result<(), glib::Error>) + 'static,
2644        >(
2645            _source_object: *mut glib::gobject_ffi::GObject,
2646            res: *mut gio::ffi::GAsyncResult,
2647            user_data: glib::ffi::gpointer,
2648        ) {
2649            let mut error: *mut glib::ffi::GError = std::ptr::null_mut();
2650            ffi::nm_client_wait_shutdown_finish(res, &mut error);
2651            let result = if error.is_null() {
2652                Ok(())
2653            } else {
2654                Err(from_glib_full(error))
2655            };
2656            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2657                Box_::from_raw(user_data as *mut _);
2658            let callback: P = callback.into_inner();
2659            callback(result);
2660        }
2661        let callback = wait_shutdown_trampoline::<P>;
2662        unsafe {
2663            ffi::nm_client_wait_shutdown(
2664                self.to_glib_none().0,
2665                integrate_maincontext.into_glib(),
2666                cancellable.map(|p| p.as_ref()).to_glib_none().0,
2667                Some(callback),
2668                Box_::into_raw(user_data) as *mut _,
2669            );
2670        }
2671    }
2672
2673    #[cfg(feature = "v1_42")]
2674    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2675    pub fn wait_shutdown_future(
2676        &self,
2677        integrate_maincontext: bool,
2678    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2679        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2680            obj.wait_shutdown(integrate_maincontext, Some(cancellable), move |res| {
2681                send.resolve(res);
2682            });
2683        }))
2684    }
2685
2686    /// Determines whether WiMAX is enabled.
2687    ///
2688    /// # Deprecated since 1.22
2689    ///
2690    /// This function always returns FALSE because WiMax is no longer supported.
2691    ///
2692    /// # Returns
2693    ///
2694    /// [`true`] if WiMAX is enabled
2695    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2696    #[allow(deprecated)]
2697    #[doc(alias = "nm_client_wimax_get_enabled")]
2698    pub fn wimax_get_enabled(&self) -> bool {
2699        unsafe { from_glib(ffi::nm_client_wimax_get_enabled(self.to_glib_none().0)) }
2700    }
2701
2702    /// Determines whether the WiMAX hardware is enabled.
2703    ///
2704    /// # Deprecated since 1.22
2705    ///
2706    /// This function always returns FALSE because WiMax is no longer supported.
2707    ///
2708    /// # Returns
2709    ///
2710    /// [`true`] if the WiMAX hardware is enabled
2711    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2712    #[allow(deprecated)]
2713    #[doc(alias = "nm_client_wimax_hardware_get_enabled")]
2714    pub fn wimax_hardware_get_enabled(&self) -> bool {
2715        unsafe {
2716            from_glib(ffi::nm_client_wimax_hardware_get_enabled(
2717                self.to_glib_none().0,
2718            ))
2719        }
2720    }
2721
2722    /// Enables or disables WiMAX devices.
2723    ///
2724    /// # Deprecated since 1.22
2725    ///
2726    /// This function does nothing because WiMax is no longer supported.
2727    /// ## `enabled`
2728    /// [`true`] to enable WiMAX
2729    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2730    #[allow(deprecated)]
2731    #[doc(alias = "nm_client_wimax_set_enabled")]
2732    pub fn wimax_set_enabled(&self, enabled: bool) {
2733        unsafe {
2734            ffi::nm_client_wimax_set_enabled(self.to_glib_none().0, enabled.into_glib());
2735        }
2736    }
2737
2738    /// Determines whether the wireless is enabled.
2739    ///
2740    /// # Returns
2741    ///
2742    /// [`true`] if wireless is enabled
2743    #[doc(alias = "nm_client_wireless_get_enabled")]
2744    pub fn wireless_get_enabled(&self) -> bool {
2745        unsafe { from_glib(ffi::nm_client_wireless_get_enabled(self.to_glib_none().0)) }
2746    }
2747
2748    /// Determines whether the wireless hardware is enabled.
2749    ///
2750    /// # Returns
2751    ///
2752    /// [`true`] if the wireless hardware is enabled
2753    #[doc(alias = "nm_client_wireless_hardware_get_enabled")]
2754    pub fn wireless_hardware_get_enabled(&self) -> bool {
2755        unsafe {
2756            from_glib(ffi::nm_client_wireless_hardware_get_enabled(
2757                self.to_glib_none().0,
2758            ))
2759        }
2760    }
2761
2762    /// Enables or disables wireless devices.
2763    ///
2764    /// # Deprecated since 1.22
2765    ///
2766    /// Use the async command nm_client_dbus_set_property() on [`DBUS_PATH`][crate::DBUS_PATH],
2767    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to set "WirelessEnabled" property to a "(b)" value.
2768    /// ## `enabled`
2769    /// [`true`] to enable wireless
2770    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2771    #[allow(deprecated)]
2772    #[doc(alias = "nm_client_wireless_set_enabled")]
2773    pub fn wireless_set_enabled(&self, enabled: bool) {
2774        unsafe {
2775            ffi::nm_client_wireless_set_enabled(self.to_glib_none().0, enabled.into_glib());
2776        }
2777    }
2778
2779    /// Determines whether WWAN is enabled.
2780    ///
2781    /// # Returns
2782    ///
2783    /// [`true`] if WWAN is enabled
2784    #[doc(alias = "nm_client_wwan_get_enabled")]
2785    pub fn wwan_get_enabled(&self) -> bool {
2786        unsafe { from_glib(ffi::nm_client_wwan_get_enabled(self.to_glib_none().0)) }
2787    }
2788
2789    /// Determines whether the WWAN hardware is enabled.
2790    ///
2791    /// # Returns
2792    ///
2793    /// [`true`] if the WWAN hardware is enabled
2794    #[doc(alias = "nm_client_wwan_hardware_get_enabled")]
2795    pub fn wwan_hardware_get_enabled(&self) -> bool {
2796        unsafe {
2797            from_glib(ffi::nm_client_wwan_hardware_get_enabled(
2798                self.to_glib_none().0,
2799            ))
2800        }
2801    }
2802
2803    /// Enables or disables WWAN devices.
2804    ///
2805    /// # Deprecated since 1.22
2806    ///
2807    /// Use the async command nm_client_dbus_set_property() on [`DBUS_PATH`][crate::DBUS_PATH],
2808    /// [`DBUS_INTERFACE`][crate::DBUS_INTERFACE] to set "WwanEnabled" property to a "(b)" value.
2809    /// ## `enabled`
2810    /// [`true`] to enable WWAN
2811    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2812    #[allow(deprecated)]
2813    #[doc(alias = "nm_client_wwan_set_enabled")]
2814    pub fn wwan_set_enabled(&self, enabled: bool) {
2815        unsafe {
2816            ffi::nm_client_wwan_set_enabled(self.to_glib_none().0, enabled.into_glib());
2817        }
2818    }
2819
2820    /// If [`true`], adding and modifying connections is supported.
2821    #[doc(alias = "can-modify")]
2822    pub fn can_modify(&self) -> bool {
2823        ObjectExt::property(self, "can-modify")
2824    }
2825
2826    #[doc(alias = "connectivity-check-available")]
2827    pub fn is_connectivity_check_available(&self) -> bool {
2828        ObjectExt::property(self, "connectivity-check-available")
2829    }
2830
2831    #[doc(alias = "connectivity-check-enabled")]
2832    pub fn is_connectivity_check_enabled(&self) -> bool {
2833        ObjectExt::property(self, "connectivity-check-enabled")
2834    }
2835
2836    #[doc(alias = "connectivity-check-enabled")]
2837    pub fn set_connectivity_check_enabled(&self, connectivity_check_enabled: bool) {
2838        ObjectExt::set_property(
2839            self,
2840            "connectivity-check-enabled",
2841            connectivity_check_enabled,
2842        )
2843    }
2844
2845    /// The used URI for connectivity checking.
2846    #[cfg(feature = "v1_22")]
2847    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2848    #[doc(alias = "connectivity-check-uri")]
2849    pub fn connectivity_check_uri(&self) -> Option<glib::GString> {
2850        ObjectExt::property(self, "connectivity-check-uri")
2851    }
2852
2853    /// The machine hostname stored in persistent configuration. This can be
2854    /// modified by calling nm_client_save_hostname().
2855    pub fn hostname(&self) -> Option<glib::GString> {
2856        ObjectExt::property(self, "hostname")
2857    }
2858
2859    /// #NMClientInstanceFlags for the instance. These affect behavior of #NMClient.
2860    /// This is a construct property and you may only set most flags only during
2861    /// construction.
2862    ///
2863    /// The flag [`ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS`][crate::ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS] can be toggled any time,
2864    /// even after constructing the instance. Note that you may want to watch NMClient:permissions-state
2865    /// property to know whether permissions are ready. Note that permissions are only fetched
2866    /// when NMClient has a D-Bus name owner.
2867    ///
2868    /// The flags [`ClientInstanceFlags::INITIALIZED_GOOD`][crate::ClientInstanceFlags::INITIALIZED_GOOD] and [`ClientInstanceFlags::INITIALIZED_BAD`][crate::ClientInstanceFlags::INITIALIZED_BAD]
2869    /// cannot be set, however they will be returned by the getter after initialization completes.
2870    #[cfg(feature = "v1_24")]
2871    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
2872    #[doc(alias = "instance-flags")]
2873    pub fn set_instance_flags(&self, instance_flags: u32) {
2874        ObjectExt::set_property(self, "instance-flags", instance_flags)
2875    }
2876
2877    #[cfg(not(feature = "v1_22"))]
2878    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_22"))))]
2879    pub fn metered(&self) -> u32 {
2880        ObjectExt::property(self, "metered")
2881    }
2882
2883    /// Whether networking is enabled.
2884    ///
2885    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2886    #[doc(alias = "networking-enabled")]
2887    pub fn is_networking_enabled(&self) -> bool {
2888        ObjectExt::property(self, "networking-enabled")
2889    }
2890
2891    /// Whether networking is enabled.
2892    ///
2893    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2894    #[doc(alias = "networking-enabled")]
2895    pub fn set_networking_enabled(&self, networking_enabled: bool) {
2896        ObjectExt::set_property(self, "networking-enabled", networking_enabled)
2897    }
2898
2899    /// Whether WiMAX functionality is enabled.
2900    ///
2901    /// # Deprecated since 1.22
2902    ///
2903    /// WiMAX is no longer supported and this always returns FALSE. The setter has no effect.
2904    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2905    #[doc(alias = "wimax-enabled")]
2906    pub fn is_wimax_enabled(&self) -> bool {
2907        ObjectExt::property(self, "wimax-enabled")
2908    }
2909
2910    /// Whether WiMAX functionality is enabled.
2911    ///
2912    /// # Deprecated since 1.22
2913    ///
2914    /// WiMAX is no longer supported and this always returns FALSE. The setter has no effect.
2915    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2916    #[doc(alias = "wimax-enabled")]
2917    pub fn set_wimax_enabled(&self, wimax_enabled: bool) {
2918        ObjectExt::set_property(self, "wimax-enabled", wimax_enabled)
2919    }
2920
2921    /// Whether the WiMAX hardware is enabled.
2922    ///
2923    /// # Deprecated since 1.22
2924    ///
2925    /// WiMAX is no longer supported and this always returns FALSE.
2926    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2927    #[doc(alias = "wimax-hardware-enabled")]
2928    pub fn is_wimax_hardware_enabled(&self) -> bool {
2929        ObjectExt::property(self, "wimax-hardware-enabled")
2930    }
2931
2932    /// Whether wireless is enabled.
2933    ///
2934    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2935    #[doc(alias = "wireless-enabled")]
2936    pub fn is_wireless_enabled(&self) -> bool {
2937        ObjectExt::property(self, "wireless-enabled")
2938    }
2939
2940    /// Whether wireless is enabled.
2941    ///
2942    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2943    #[doc(alias = "wireless-enabled")]
2944    pub fn set_wireless_enabled(&self, wireless_enabled: bool) {
2945        ObjectExt::set_property(self, "wireless-enabled", wireless_enabled)
2946    }
2947
2948    /// Whether the wireless hardware is enabled.
2949    #[doc(alias = "wireless-hardware-enabled")]
2950    pub fn is_wireless_hardware_enabled(&self) -> bool {
2951        ObjectExt::property(self, "wireless-hardware-enabled")
2952    }
2953
2954    /// Whether WWAN functionality is enabled.
2955    ///
2956    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2957    #[doc(alias = "wwan-enabled")]
2958    pub fn is_wwan_enabled(&self) -> bool {
2959        ObjectExt::property(self, "wwan-enabled")
2960    }
2961
2962    /// Whether WWAN functionality is enabled.
2963    ///
2964    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
2965    #[doc(alias = "wwan-enabled")]
2966    pub fn set_wwan_enabled(&self, wwan_enabled: bool) {
2967        ObjectExt::set_property(self, "wwan-enabled", wwan_enabled)
2968    }
2969
2970    /// Whether the WWAN hardware is enabled.
2971    #[doc(alias = "wwan-hardware-enabled")]
2972    pub fn is_wwan_hardware_enabled(&self) -> bool {
2973        ObjectExt::property(self, "wwan-hardware-enabled")
2974    }
2975
2976    /// Creates a new #NMClient asynchronously.
2977    /// @callback will be called when it is done. Use
2978    /// nm_client_new_finish() to get the result.
2979    ///
2980    /// This does nothing beside calling g_async_initable_new_async(). You are free to
2981    /// call g_async_initable_new_async() or g_object_new()/g_async_initable_init_async()
2982    /// directly for more control, to set GObject properties or get access to the NMClient
2983    /// instance while it is still initializing.
2984    ///
2985    /// Creating an #NMClient instance can only fail for two reasons. First, if you didn't
2986    /// provide a [`CLIENT_DBUS_CONNECTION`][crate::CLIENT_DBUS_CONNECTION] and the call to g_bus_get()
2987    /// fails. You can avoid that by using g_async_initable_new_async() directly and
2988    /// set a D-Bus connection.
2989    /// Second, if you cancelled the creation. If you do that, then note
2990    /// that after the failure there might still be idle actions pending
2991    /// which keep nm_client_get_main_context() alive. That means,
2992    /// in that case you must continue iterating the context to avoid
2993    /// leaks. See nm_client_get_context_busy_watcher().
2994    ///
2995    /// Creating an #NMClient instance when NetworkManager is not running
2996    /// does not cause a failure.
2997    /// ## `cancellable`
2998    /// a #GCancellable, or [`None`]
2999    /// ## `callback`
3000    /// callback to call when the client is created
3001    #[doc(alias = "nm_client_new_async")]
3002    pub fn new_async<P: FnOnce(Result<Client, glib::Error>) + 'static>(
3003        cancellable: Option<&impl IsA<gio::Cancellable>>,
3004        callback: P,
3005    ) {
3006        assert_initialized_main_thread!();
3007
3008        let main_context = glib::MainContext::ref_thread_default();
3009        let is_main_context_owner = main_context.is_owner();
3010        let has_acquired_main_context = (!is_main_context_owner)
3011            .then(|| main_context.acquire().ok())
3012            .flatten();
3013        assert!(
3014            is_main_context_owner || has_acquired_main_context.is_some(),
3015            "Async operations only allowed if the thread is owning the MainContext"
3016        );
3017
3018        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
3019            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
3020        unsafe extern "C" fn new_async_trampoline<
3021            P: FnOnce(Result<Client, glib::Error>) + 'static,
3022        >(
3023            _source_object: *mut glib::gobject_ffi::GObject,
3024            res: *mut gio::ffi::GAsyncResult,
3025            user_data: glib::ffi::gpointer,
3026        ) {
3027            let mut error = std::ptr::null_mut();
3028            let ret = ffi::nm_client_new_finish(res, &mut error);
3029            let result = if error.is_null() {
3030                Ok(from_glib_full(ret))
3031            } else {
3032                Err(from_glib_full(error))
3033            };
3034            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
3035                Box_::from_raw(user_data as *mut _);
3036            let callback: P = callback.into_inner();
3037            callback(result);
3038        }
3039        let callback = new_async_trampoline::<P>;
3040        unsafe {
3041            ffi::nm_client_new_async(
3042                cancellable.map(|p| p.as_ref()).to_glib_none().0,
3043                Some(callback),
3044                Box_::into_raw(user_data) as *mut _,
3045            );
3046        }
3047    }
3048
3049    pub fn new_future()
3050    -> Pin<Box_<dyn std::future::Future<Output = Result<Client, glib::Error>> + 'static>> {
3051        skip_assert_initialized!();
3052        Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| {
3053            Self::new_async(Some(cancellable), move |res| {
3054                send.resolve(res);
3055            });
3056        }))
3057    }
3058
3059    /// Notifies that a #NMActiveConnection has been added.
3060    /// ## `active_connection`
3061    /// the new active connection
3062    #[doc(alias = "active-connection-added")]
3063    pub fn connect_active_connection_added<F: Fn(&Self, &ActiveConnection) + 'static>(
3064        &self,
3065        f: F,
3066    ) -> SignalHandlerId {
3067        unsafe extern "C" fn active_connection_added_trampoline<
3068            F: Fn(&Client, &ActiveConnection) + 'static,
3069        >(
3070            this: *mut ffi::NMClient,
3071            active_connection: *mut ffi::NMActiveConnection,
3072            f: glib::ffi::gpointer,
3073        ) {
3074            let f: &F = &*(f as *const F);
3075            f(
3076                &from_glib_borrow(this),
3077                &from_glib_borrow(active_connection),
3078            )
3079        }
3080        unsafe {
3081            let f: Box_<F> = Box_::new(f);
3082            connect_raw(
3083                self.as_ptr() as *mut _,
3084                c"active-connection-added".as_ptr() as *const _,
3085                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3086                    active_connection_added_trampoline::<F> as *const (),
3087                )),
3088                Box_::into_raw(f),
3089            )
3090        }
3091    }
3092
3093    /// Notifies that a #NMActiveConnection has been removed.
3094    /// ## `active_connection`
3095    /// the removed active connection
3096    #[doc(alias = "active-connection-removed")]
3097    pub fn connect_active_connection_removed<F: Fn(&Self, &ActiveConnection) + 'static>(
3098        &self,
3099        f: F,
3100    ) -> SignalHandlerId {
3101        unsafe extern "C" fn active_connection_removed_trampoline<
3102            F: Fn(&Client, &ActiveConnection) + 'static,
3103        >(
3104            this: *mut ffi::NMClient,
3105            active_connection: *mut ffi::NMActiveConnection,
3106            f: glib::ffi::gpointer,
3107        ) {
3108            let f: &F = &*(f as *const F);
3109            f(
3110                &from_glib_borrow(this),
3111                &from_glib_borrow(active_connection),
3112            )
3113        }
3114        unsafe {
3115            let f: Box_<F> = Box_::new(f);
3116            connect_raw(
3117                self.as_ptr() as *mut _,
3118                c"active-connection-removed".as_ptr() as *const _,
3119                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3120                    active_connection_removed_trampoline::<F> as *const (),
3121                )),
3122                Box_::into_raw(f),
3123            )
3124        }
3125    }
3126
3127    /// Notifies that a #NMDevice is added.  This signal is emitted for both
3128    /// regular devices and placeholder devices.
3129    /// ## `device`
3130    /// the new device
3131    #[doc(alias = "any-device-added")]
3132    pub fn connect_any_device_added<F: Fn(&Self, &Device) + 'static>(
3133        &self,
3134        f: F,
3135    ) -> SignalHandlerId {
3136        unsafe extern "C" fn any_device_added_trampoline<F: Fn(&Client, &Device) + 'static>(
3137            this: *mut ffi::NMClient,
3138            device: *mut ffi::NMDevice,
3139            f: glib::ffi::gpointer,
3140        ) {
3141            let f: &F = &*(f as *const F);
3142            f(&from_glib_borrow(this), &from_glib_borrow(device))
3143        }
3144        unsafe {
3145            let f: Box_<F> = Box_::new(f);
3146            connect_raw(
3147                self.as_ptr() as *mut _,
3148                c"any-device-added".as_ptr() as *const _,
3149                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3150                    any_device_added_trampoline::<F> as *const (),
3151                )),
3152                Box_::into_raw(f),
3153            )
3154        }
3155    }
3156
3157    /// Notifies that a #NMDevice is removed.  This signal is emitted for both
3158    /// regular devices and placeholder devices.
3159    /// ## `device`
3160    /// the removed device
3161    #[doc(alias = "any-device-removed")]
3162    pub fn connect_any_device_removed<F: Fn(&Self, &Device) + 'static>(
3163        &self,
3164        f: F,
3165    ) -> SignalHandlerId {
3166        unsafe extern "C" fn any_device_removed_trampoline<F: Fn(&Client, &Device) + 'static>(
3167            this: *mut ffi::NMClient,
3168            device: *mut ffi::NMDevice,
3169            f: glib::ffi::gpointer,
3170        ) {
3171            let f: &F = &*(f as *const F);
3172            f(&from_glib_borrow(this), &from_glib_borrow(device))
3173        }
3174        unsafe {
3175            let f: Box_<F> = Box_::new(f);
3176            connect_raw(
3177                self.as_ptr() as *mut _,
3178                c"any-device-removed".as_ptr() as *const _,
3179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3180                    any_device_removed_trampoline::<F> as *const (),
3181                )),
3182                Box_::into_raw(f),
3183            )
3184        }
3185    }
3186
3187    /// Notifies that a #NMConnection has been added.
3188    /// ## `connection`
3189    /// the new connection
3190    #[doc(alias = "connection-added")]
3191    pub fn connect_connection_added<F: Fn(&Self, &RemoteConnection) + 'static>(
3192        &self,
3193        f: F,
3194    ) -> SignalHandlerId {
3195        unsafe extern "C" fn connection_added_trampoline<
3196            F: Fn(&Client, &RemoteConnection) + 'static,
3197        >(
3198            this: *mut ffi::NMClient,
3199            connection: *mut ffi::NMRemoteConnection,
3200            f: glib::ffi::gpointer,
3201        ) {
3202            let f: &F = &*(f as *const F);
3203            f(&from_glib_borrow(this), &from_glib_borrow(connection))
3204        }
3205        unsafe {
3206            let f: Box_<F> = Box_::new(f);
3207            connect_raw(
3208                self.as_ptr() as *mut _,
3209                c"connection-added".as_ptr() as *const _,
3210                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3211                    connection_added_trampoline::<F> as *const (),
3212                )),
3213                Box_::into_raw(f),
3214            )
3215        }
3216    }
3217
3218    /// Notifies that a #NMConnection has been removed.
3219    /// ## `connection`
3220    /// the removed connection
3221    #[doc(alias = "connection-removed")]
3222    pub fn connect_connection_removed<F: Fn(&Self, &RemoteConnection) + 'static>(
3223        &self,
3224        f: F,
3225    ) -> SignalHandlerId {
3226        unsafe extern "C" fn connection_removed_trampoline<
3227            F: Fn(&Client, &RemoteConnection) + 'static,
3228        >(
3229            this: *mut ffi::NMClient,
3230            connection: *mut ffi::NMRemoteConnection,
3231            f: glib::ffi::gpointer,
3232        ) {
3233            let f: &F = &*(f as *const F);
3234            f(&from_glib_borrow(this), &from_glib_borrow(connection))
3235        }
3236        unsafe {
3237            let f: Box_<F> = Box_::new(f);
3238            connect_raw(
3239                self.as_ptr() as *mut _,
3240                c"connection-removed".as_ptr() as *const _,
3241                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3242                    connection_removed_trampoline::<F> as *const (),
3243                )),
3244                Box_::into_raw(f),
3245            )
3246        }
3247    }
3248
3249    /// Notifies that a #NMDevice is added.  This signal is not emitted for
3250    /// placeholder devices.
3251    /// ## `device`
3252    /// the new device
3253    #[doc(alias = "device-added")]
3254    pub fn connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
3255        unsafe extern "C" fn device_added_trampoline<F: Fn(&Client, &Device) + 'static>(
3256            this: *mut ffi::NMClient,
3257            device: *mut ffi::NMDevice,
3258            f: glib::ffi::gpointer,
3259        ) {
3260            let f: &F = &*(f as *const F);
3261            f(&from_glib_borrow(this), &from_glib_borrow(device))
3262        }
3263        unsafe {
3264            let f: Box_<F> = Box_::new(f);
3265            connect_raw(
3266                self.as_ptr() as *mut _,
3267                c"device-added".as_ptr() as *const _,
3268                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3269                    device_added_trampoline::<F> as *const (),
3270                )),
3271                Box_::into_raw(f),
3272            )
3273        }
3274    }
3275
3276    /// Notifies that a #NMDevice is removed.  This signal is not emitted for
3277    /// placeholder devices.
3278    /// ## `device`
3279    /// the removed device
3280    #[doc(alias = "device-removed")]
3281    pub fn connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
3282        unsafe extern "C" fn device_removed_trampoline<F: Fn(&Client, &Device) + 'static>(
3283            this: *mut ffi::NMClient,
3284            device: *mut ffi::NMDevice,
3285            f: glib::ffi::gpointer,
3286        ) {
3287            let f: &F = &*(f as *const F);
3288            f(&from_glib_borrow(this), &from_glib_borrow(device))
3289        }
3290        unsafe {
3291            let f: Box_<F> = Box_::new(f);
3292            connect_raw(
3293                self.as_ptr() as *mut _,
3294                c"device-removed".as_ptr() as *const _,
3295                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3296                    device_removed_trampoline::<F> as *const (),
3297                )),
3298                Box_::into_raw(f),
3299            )
3300        }
3301    }
3302
3303    /// Notifies that a permission has changed
3304    /// ## `permission`
3305    /// a permission from #NMClientPermission
3306    /// ## `result`
3307    /// the permission's result, one of #NMClientPermissionResult
3308    #[doc(alias = "permission-changed")]
3309    pub fn connect_permission_changed<F: Fn(&Self, u32, u32) + 'static>(
3310        &self,
3311        f: F,
3312    ) -> SignalHandlerId {
3313        unsafe extern "C" fn permission_changed_trampoline<F: Fn(&Client, u32, u32) + 'static>(
3314            this: *mut ffi::NMClient,
3315            permission: std::ffi::c_uint,
3316            result: std::ffi::c_uint,
3317            f: glib::ffi::gpointer,
3318        ) {
3319            let f: &F = &*(f as *const F);
3320            f(&from_glib_borrow(this), permission, result)
3321        }
3322        unsafe {
3323            let f: Box_<F> = Box_::new(f);
3324            connect_raw(
3325                self.as_ptr() as *mut _,
3326                c"permission-changed".as_ptr() as *const _,
3327                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3328                    permission_changed_trampoline::<F> as *const (),
3329                )),
3330                Box_::into_raw(f),
3331            )
3332        }
3333    }
3334
3335    #[doc(alias = "activating-connection")]
3336    pub fn connect_activating_connection_notify<F: Fn(&Self) + 'static>(
3337        &self,
3338        f: F,
3339    ) -> SignalHandlerId {
3340        unsafe extern "C" fn notify_activating_connection_trampoline<F: Fn(&Client) + 'static>(
3341            this: *mut ffi::NMClient,
3342            _param_spec: glib::ffi::gpointer,
3343            f: glib::ffi::gpointer,
3344        ) {
3345            let f: &F = &*(f as *const F);
3346            f(&from_glib_borrow(this))
3347        }
3348        unsafe {
3349            let f: Box_<F> = Box_::new(f);
3350            connect_raw(
3351                self.as_ptr() as *mut _,
3352                c"notify::activating-connection".as_ptr() as *const _,
3353                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3354                    notify_activating_connection_trampoline::<F> as *const (),
3355                )),
3356                Box_::into_raw(f),
3357            )
3358        }
3359    }
3360
3361    #[doc(alias = "active-connections")]
3362    pub fn connect_active_connections_notify<F: Fn(&Self) + 'static>(
3363        &self,
3364        f: F,
3365    ) -> SignalHandlerId {
3366        unsafe extern "C" fn notify_active_connections_trampoline<F: Fn(&Client) + 'static>(
3367            this: *mut ffi::NMClient,
3368            _param_spec: glib::ffi::gpointer,
3369            f: glib::ffi::gpointer,
3370        ) {
3371            let f: &F = &*(f as *const F);
3372            f(&from_glib_borrow(this))
3373        }
3374        unsafe {
3375            let f: Box_<F> = Box_::new(f);
3376            connect_raw(
3377                self.as_ptr() as *mut _,
3378                c"notify::active-connections".as_ptr() as *const _,
3379                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3380                    notify_active_connections_trampoline::<F> as *const (),
3381                )),
3382                Box_::into_raw(f),
3383            )
3384        }
3385    }
3386
3387    #[cfg(feature = "v1_2")]
3388    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
3389    #[doc(alias = "all-devices")]
3390    pub fn connect_all_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3391        unsafe extern "C" fn notify_all_devices_trampoline<F: Fn(&Client) + 'static>(
3392            this: *mut ffi::NMClient,
3393            _param_spec: glib::ffi::gpointer,
3394            f: glib::ffi::gpointer,
3395        ) {
3396            let f: &F = &*(f as *const F);
3397            f(&from_glib_borrow(this))
3398        }
3399        unsafe {
3400            let f: Box_<F> = Box_::new(f);
3401            connect_raw(
3402                self.as_ptr() as *mut _,
3403                c"notify::all-devices".as_ptr() as *const _,
3404                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3405                    notify_all_devices_trampoline::<F> as *const (),
3406                )),
3407                Box_::into_raw(f),
3408            )
3409        }
3410    }
3411
3412    #[doc(alias = "can-modify")]
3413    pub fn connect_can_modify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3414        unsafe extern "C" fn notify_can_modify_trampoline<F: Fn(&Client) + 'static>(
3415            this: *mut ffi::NMClient,
3416            _param_spec: glib::ffi::gpointer,
3417            f: glib::ffi::gpointer,
3418        ) {
3419            let f: &F = &*(f as *const F);
3420            f(&from_glib_borrow(this))
3421        }
3422        unsafe {
3423            let f: Box_<F> = Box_::new(f);
3424            connect_raw(
3425                self.as_ptr() as *mut _,
3426                c"notify::can-modify".as_ptr() as *const _,
3427                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3428                    notify_can_modify_trampoline::<F> as *const (),
3429                )),
3430                Box_::into_raw(f),
3431            )
3432        }
3433    }
3434
3435    #[cfg(feature = "v1_24")]
3436    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3437    #[doc(alias = "capabilities")]
3438    pub fn connect_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3439        unsafe extern "C" fn notify_capabilities_trampoline<F: Fn(&Client) + 'static>(
3440            this: *mut ffi::NMClient,
3441            _param_spec: glib::ffi::gpointer,
3442            f: glib::ffi::gpointer,
3443        ) {
3444            let f: &F = &*(f as *const F);
3445            f(&from_glib_borrow(this))
3446        }
3447        unsafe {
3448            let f: Box_<F> = Box_::new(f);
3449            connect_raw(
3450                self.as_ptr() as *mut _,
3451                c"notify::capabilities".as_ptr() as *const _,
3452                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3453                    notify_capabilities_trampoline::<F> as *const (),
3454                )),
3455                Box_::into_raw(f),
3456            )
3457        }
3458    }
3459
3460    #[cfg(feature = "v1_12")]
3461    #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
3462    #[doc(alias = "checkpoints")]
3463    pub fn connect_checkpoints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3464        unsafe extern "C" fn notify_checkpoints_trampoline<F: Fn(&Client) + 'static>(
3465            this: *mut ffi::NMClient,
3466            _param_spec: glib::ffi::gpointer,
3467            f: glib::ffi::gpointer,
3468        ) {
3469            let f: &F = &*(f as *const F);
3470            f(&from_glib_borrow(this))
3471        }
3472        unsafe {
3473            let f: Box_<F> = Box_::new(f);
3474            connect_raw(
3475                self.as_ptr() as *mut _,
3476                c"notify::checkpoints".as_ptr() as *const _,
3477                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3478                    notify_checkpoints_trampoline::<F> as *const (),
3479                )),
3480                Box_::into_raw(f),
3481            )
3482        }
3483    }
3484
3485    #[doc(alias = "connections")]
3486    pub fn connect_connections_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3487        unsafe extern "C" fn notify_connections_trampoline<F: Fn(&Client) + 'static>(
3488            this: *mut ffi::NMClient,
3489            _param_spec: glib::ffi::gpointer,
3490            f: glib::ffi::gpointer,
3491        ) {
3492            let f: &F = &*(f as *const F);
3493            f(&from_glib_borrow(this))
3494        }
3495        unsafe {
3496            let f: Box_<F> = Box_::new(f);
3497            connect_raw(
3498                self.as_ptr() as *mut _,
3499                c"notify::connections".as_ptr() as *const _,
3500                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3501                    notify_connections_trampoline::<F> as *const (),
3502                )),
3503                Box_::into_raw(f),
3504            )
3505        }
3506    }
3507
3508    #[doc(alias = "connectivity")]
3509    pub fn connect_connectivity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3510        unsafe extern "C" fn notify_connectivity_trampoline<F: Fn(&Client) + 'static>(
3511            this: *mut ffi::NMClient,
3512            _param_spec: glib::ffi::gpointer,
3513            f: glib::ffi::gpointer,
3514        ) {
3515            let f: &F = &*(f as *const F);
3516            f(&from_glib_borrow(this))
3517        }
3518        unsafe {
3519            let f: Box_<F> = Box_::new(f);
3520            connect_raw(
3521                self.as_ptr() as *mut _,
3522                c"notify::connectivity".as_ptr() as *const _,
3523                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3524                    notify_connectivity_trampoline::<F> as *const (),
3525                )),
3526                Box_::into_raw(f),
3527            )
3528        }
3529    }
3530
3531    #[doc(alias = "connectivity-check-available")]
3532    pub fn connect_connectivity_check_available_notify<F: Fn(&Self) + 'static>(
3533        &self,
3534        f: F,
3535    ) -> SignalHandlerId {
3536        unsafe extern "C" fn notify_connectivity_check_available_trampoline<
3537            F: Fn(&Client) + 'static,
3538        >(
3539            this: *mut ffi::NMClient,
3540            _param_spec: glib::ffi::gpointer,
3541            f: glib::ffi::gpointer,
3542        ) {
3543            let f: &F = &*(f as *const F);
3544            f(&from_glib_borrow(this))
3545        }
3546        unsafe {
3547            let f: Box_<F> = Box_::new(f);
3548            connect_raw(
3549                self.as_ptr() as *mut _,
3550                c"notify::connectivity-check-available".as_ptr() as *const _,
3551                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3552                    notify_connectivity_check_available_trampoline::<F> as *const (),
3553                )),
3554                Box_::into_raw(f),
3555            )
3556        }
3557    }
3558
3559    #[doc(alias = "connectivity-check-enabled")]
3560    pub fn connect_connectivity_check_enabled_notify<F: Fn(&Self) + 'static>(
3561        &self,
3562        f: F,
3563    ) -> SignalHandlerId {
3564        unsafe extern "C" fn notify_connectivity_check_enabled_trampoline<
3565            F: Fn(&Client) + 'static,
3566        >(
3567            this: *mut ffi::NMClient,
3568            _param_spec: glib::ffi::gpointer,
3569            f: glib::ffi::gpointer,
3570        ) {
3571            let f: &F = &*(f as *const F);
3572            f(&from_glib_borrow(this))
3573        }
3574        unsafe {
3575            let f: Box_<F> = Box_::new(f);
3576            connect_raw(
3577                self.as_ptr() as *mut _,
3578                c"notify::connectivity-check-enabled".as_ptr() as *const _,
3579                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3580                    notify_connectivity_check_enabled_trampoline::<F> as *const (),
3581                )),
3582                Box_::into_raw(f),
3583            )
3584        }
3585    }
3586
3587    #[cfg(feature = "v1_22")]
3588    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
3589    #[doc(alias = "connectivity-check-uri")]
3590    pub fn connect_connectivity_check_uri_notify<F: Fn(&Self) + 'static>(
3591        &self,
3592        f: F,
3593    ) -> SignalHandlerId {
3594        unsafe extern "C" fn notify_connectivity_check_uri_trampoline<F: Fn(&Client) + 'static>(
3595            this: *mut ffi::NMClient,
3596            _param_spec: glib::ffi::gpointer,
3597            f: glib::ffi::gpointer,
3598        ) {
3599            let f: &F = &*(f as *const F);
3600            f(&from_glib_borrow(this))
3601        }
3602        unsafe {
3603            let f: Box_<F> = Box_::new(f);
3604            connect_raw(
3605                self.as_ptr() as *mut _,
3606                c"notify::connectivity-check-uri".as_ptr() as *const _,
3607                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3608                    notify_connectivity_check_uri_trampoline::<F> as *const (),
3609                )),
3610                Box_::into_raw(f),
3611            )
3612        }
3613    }
3614
3615    #[cfg(feature = "v1_22")]
3616    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
3617    #[doc(alias = "dbus-name-owner")]
3618    pub fn connect_dbus_name_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3619        unsafe extern "C" fn notify_dbus_name_owner_trampoline<F: Fn(&Client) + 'static>(
3620            this: *mut ffi::NMClient,
3621            _param_spec: glib::ffi::gpointer,
3622            f: glib::ffi::gpointer,
3623        ) {
3624            let f: &F = &*(f as *const F);
3625            f(&from_glib_borrow(this))
3626        }
3627        unsafe {
3628            let f: Box_<F> = Box_::new(f);
3629            connect_raw(
3630                self.as_ptr() as *mut _,
3631                c"notify::dbus-name-owner".as_ptr() as *const _,
3632                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3633                    notify_dbus_name_owner_trampoline::<F> as *const (),
3634                )),
3635                Box_::into_raw(f),
3636            )
3637        }
3638    }
3639
3640    #[doc(alias = "devices")]
3641    pub fn connect_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3642        unsafe extern "C" fn notify_devices_trampoline<F: Fn(&Client) + 'static>(
3643            this: *mut ffi::NMClient,
3644            _param_spec: glib::ffi::gpointer,
3645            f: glib::ffi::gpointer,
3646        ) {
3647            let f: &F = &*(f as *const F);
3648            f(&from_glib_borrow(this))
3649        }
3650        unsafe {
3651            let f: Box_<F> = Box_::new(f);
3652            connect_raw(
3653                self.as_ptr() as *mut _,
3654                c"notify::devices".as_ptr() as *const _,
3655                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3656                    notify_devices_trampoline::<F> as *const (),
3657                )),
3658                Box_::into_raw(f),
3659            )
3660        }
3661    }
3662
3663    #[cfg(feature = "v1_6")]
3664    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3665    #[doc(alias = "dns-configuration")]
3666    pub fn connect_dns_configuration_notify<F: Fn(&Self) + 'static>(
3667        &self,
3668        f: F,
3669    ) -> SignalHandlerId {
3670        unsafe extern "C" fn notify_dns_configuration_trampoline<F: Fn(&Client) + 'static>(
3671            this: *mut ffi::NMClient,
3672            _param_spec: glib::ffi::gpointer,
3673            f: glib::ffi::gpointer,
3674        ) {
3675            let f: &F = &*(f as *const F);
3676            f(&from_glib_borrow(this))
3677        }
3678        unsafe {
3679            let f: Box_<F> = Box_::new(f);
3680            connect_raw(
3681                self.as_ptr() as *mut _,
3682                c"notify::dns-configuration".as_ptr() as *const _,
3683                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3684                    notify_dns_configuration_trampoline::<F> as *const (),
3685                )),
3686                Box_::into_raw(f),
3687            )
3688        }
3689    }
3690
3691    #[cfg(feature = "v1_6")]
3692    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3693    #[doc(alias = "dns-mode")]
3694    pub fn connect_dns_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3695        unsafe extern "C" fn notify_dns_mode_trampoline<F: Fn(&Client) + 'static>(
3696            this: *mut ffi::NMClient,
3697            _param_spec: glib::ffi::gpointer,
3698            f: glib::ffi::gpointer,
3699        ) {
3700            let f: &F = &*(f as *const F);
3701            f(&from_glib_borrow(this))
3702        }
3703        unsafe {
3704            let f: Box_<F> = Box_::new(f);
3705            connect_raw(
3706                self.as_ptr() as *mut _,
3707                c"notify::dns-mode".as_ptr() as *const _,
3708                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3709                    notify_dns_mode_trampoline::<F> as *const (),
3710                )),
3711                Box_::into_raw(f),
3712            )
3713        }
3714    }
3715
3716    #[cfg(feature = "v1_6")]
3717    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3718    #[doc(alias = "dns-rc-manager")]
3719    pub fn connect_dns_rc_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3720        unsafe extern "C" fn notify_dns_rc_manager_trampoline<F: Fn(&Client) + 'static>(
3721            this: *mut ffi::NMClient,
3722            _param_spec: glib::ffi::gpointer,
3723            f: glib::ffi::gpointer,
3724        ) {
3725            let f: &F = &*(f as *const F);
3726            f(&from_glib_borrow(this))
3727        }
3728        unsafe {
3729            let f: Box_<F> = Box_::new(f);
3730            connect_raw(
3731                self.as_ptr() as *mut _,
3732                c"notify::dns-rc-manager".as_ptr() as *const _,
3733                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3734                    notify_dns_rc_manager_trampoline::<F> as *const (),
3735                )),
3736                Box_::into_raw(f),
3737            )
3738        }
3739    }
3740
3741    #[doc(alias = "hostname")]
3742    pub fn connect_hostname_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3743        unsafe extern "C" fn notify_hostname_trampoline<F: Fn(&Client) + 'static>(
3744            this: *mut ffi::NMClient,
3745            _param_spec: glib::ffi::gpointer,
3746            f: glib::ffi::gpointer,
3747        ) {
3748            let f: &F = &*(f as *const F);
3749            f(&from_glib_borrow(this))
3750        }
3751        unsafe {
3752            let f: Box_<F> = Box_::new(f);
3753            connect_raw(
3754                self.as_ptr() as *mut _,
3755                c"notify::hostname".as_ptr() as *const _,
3756                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3757                    notify_hostname_trampoline::<F> as *const (),
3758                )),
3759                Box_::into_raw(f),
3760            )
3761        }
3762    }
3763
3764    #[cfg(feature = "v1_24")]
3765    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3766    #[doc(alias = "instance-flags")]
3767    pub fn connect_instance_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3768        unsafe extern "C" fn notify_instance_flags_trampoline<F: Fn(&Client) + 'static>(
3769            this: *mut ffi::NMClient,
3770            _param_spec: glib::ffi::gpointer,
3771            f: glib::ffi::gpointer,
3772        ) {
3773            let f: &F = &*(f as *const F);
3774            f(&from_glib_borrow(this))
3775        }
3776        unsafe {
3777            let f: Box_<F> = Box_::new(f);
3778            connect_raw(
3779                self.as_ptr() as *mut _,
3780                c"notify::instance-flags".as_ptr() as *const _,
3781                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3782                    notify_instance_flags_trampoline::<F> as *const (),
3783                )),
3784                Box_::into_raw(f),
3785            )
3786        }
3787    }
3788
3789    #[cfg(feature = "v1_2")]
3790    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
3791    #[doc(alias = "metered")]
3792    pub fn connect_metered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3793        unsafe extern "C" fn notify_metered_trampoline<F: Fn(&Client) + 'static>(
3794            this: *mut ffi::NMClient,
3795            _param_spec: glib::ffi::gpointer,
3796            f: glib::ffi::gpointer,
3797        ) {
3798            let f: &F = &*(f as *const F);
3799            f(&from_glib_borrow(this))
3800        }
3801        unsafe {
3802            let f: Box_<F> = Box_::new(f);
3803            connect_raw(
3804                self.as_ptr() as *mut _,
3805                c"notify::metered".as_ptr() as *const _,
3806                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3807                    notify_metered_trampoline::<F> as *const (),
3808                )),
3809                Box_::into_raw(f),
3810            )
3811        }
3812    }
3813
3814    #[doc(alias = "networking-enabled")]
3815    pub fn connect_networking_enabled_notify<F: Fn(&Self) + 'static>(
3816        &self,
3817        f: F,
3818    ) -> SignalHandlerId {
3819        unsafe extern "C" fn notify_networking_enabled_trampoline<F: Fn(&Client) + 'static>(
3820            this: *mut ffi::NMClient,
3821            _param_spec: glib::ffi::gpointer,
3822            f: glib::ffi::gpointer,
3823        ) {
3824            let f: &F = &*(f as *const F);
3825            f(&from_glib_borrow(this))
3826        }
3827        unsafe {
3828            let f: Box_<F> = Box_::new(f);
3829            connect_raw(
3830                self.as_ptr() as *mut _,
3831                c"notify::networking-enabled".as_ptr() as *const _,
3832                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3833                    notify_networking_enabled_trampoline::<F> as *const (),
3834                )),
3835                Box_::into_raw(f),
3836            )
3837        }
3838    }
3839
3840    #[doc(alias = "nm-running")]
3841    pub fn connect_nm_running_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3842        unsafe extern "C" fn notify_nm_running_trampoline<F: Fn(&Client) + 'static>(
3843            this: *mut ffi::NMClient,
3844            _param_spec: glib::ffi::gpointer,
3845            f: glib::ffi::gpointer,
3846        ) {
3847            let f: &F = &*(f as *const F);
3848            f(&from_glib_borrow(this))
3849        }
3850        unsafe {
3851            let f: Box_<F> = Box_::new(f);
3852            connect_raw(
3853                self.as_ptr() as *mut _,
3854                c"notify::nm-running".as_ptr() as *const _,
3855                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3856                    notify_nm_running_trampoline::<F> as *const (),
3857                )),
3858                Box_::into_raw(f),
3859            )
3860        }
3861    }
3862
3863    #[cfg(feature = "v1_24")]
3864    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3865    #[doc(alias = "permissions-state")]
3866    pub fn connect_permissions_state_notify<F: Fn(&Self) + 'static>(
3867        &self,
3868        f: F,
3869    ) -> SignalHandlerId {
3870        unsafe extern "C" fn notify_permissions_state_trampoline<F: Fn(&Client) + 'static>(
3871            this: *mut ffi::NMClient,
3872            _param_spec: glib::ffi::gpointer,
3873            f: glib::ffi::gpointer,
3874        ) {
3875            let f: &F = &*(f as *const F);
3876            f(&from_glib_borrow(this))
3877        }
3878        unsafe {
3879            let f: Box_<F> = Box_::new(f);
3880            connect_raw(
3881                self.as_ptr() as *mut _,
3882                c"notify::permissions-state".as_ptr() as *const _,
3883                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3884                    notify_permissions_state_trampoline::<F> as *const (),
3885                )),
3886                Box_::into_raw(f),
3887            )
3888        }
3889    }
3890
3891    #[doc(alias = "primary-connection")]
3892    pub fn connect_primary_connection_notify<F: Fn(&Self) + 'static>(
3893        &self,
3894        f: F,
3895    ) -> SignalHandlerId {
3896        unsafe extern "C" fn notify_primary_connection_trampoline<F: Fn(&Client) + 'static>(
3897            this: *mut ffi::NMClient,
3898            _param_spec: glib::ffi::gpointer,
3899            f: glib::ffi::gpointer,
3900        ) {
3901            let f: &F = &*(f as *const F);
3902            f(&from_glib_borrow(this))
3903        }
3904        unsafe {
3905            let f: Box_<F> = Box_::new(f);
3906            connect_raw(
3907                self.as_ptr() as *mut _,
3908                c"notify::primary-connection".as_ptr() as *const _,
3909                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3910                    notify_primary_connection_trampoline::<F> as *const (),
3911                )),
3912                Box_::into_raw(f),
3913            )
3914        }
3915    }
3916
3917    #[cfg(feature = "v1_38")]
3918    #[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
3919    #[doc(alias = "radio-flags")]
3920    pub fn connect_radio_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3921        unsafe extern "C" fn notify_radio_flags_trampoline<F: Fn(&Client) + 'static>(
3922            this: *mut ffi::NMClient,
3923            _param_spec: glib::ffi::gpointer,
3924            f: glib::ffi::gpointer,
3925        ) {
3926            let f: &F = &*(f as *const F);
3927            f(&from_glib_borrow(this))
3928        }
3929        unsafe {
3930            let f: Box_<F> = Box_::new(f);
3931            connect_raw(
3932                self.as_ptr() as *mut _,
3933                c"notify::radio-flags".as_ptr() as *const _,
3934                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3935                    notify_radio_flags_trampoline::<F> as *const (),
3936                )),
3937                Box_::into_raw(f),
3938            )
3939        }
3940    }
3941
3942    #[doc(alias = "startup")]
3943    pub fn connect_startup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3944        unsafe extern "C" fn notify_startup_trampoline<F: Fn(&Client) + 'static>(
3945            this: *mut ffi::NMClient,
3946            _param_spec: glib::ffi::gpointer,
3947            f: glib::ffi::gpointer,
3948        ) {
3949            let f: &F = &*(f as *const F);
3950            f(&from_glib_borrow(this))
3951        }
3952        unsafe {
3953            let f: Box_<F> = Box_::new(f);
3954            connect_raw(
3955                self.as_ptr() as *mut _,
3956                c"notify::startup".as_ptr() as *const _,
3957                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3958                    notify_startup_trampoline::<F> as *const (),
3959                )),
3960                Box_::into_raw(f),
3961            )
3962        }
3963    }
3964
3965    #[doc(alias = "state")]
3966    pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3967        unsafe extern "C" fn notify_state_trampoline<F: Fn(&Client) + 'static>(
3968            this: *mut ffi::NMClient,
3969            _param_spec: glib::ffi::gpointer,
3970            f: glib::ffi::gpointer,
3971        ) {
3972            let f: &F = &*(f as *const F);
3973            f(&from_glib_borrow(this))
3974        }
3975        unsafe {
3976            let f: Box_<F> = Box_::new(f);
3977            connect_raw(
3978                self.as_ptr() as *mut _,
3979                c"notify::state".as_ptr() as *const _,
3980                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3981                    notify_state_trampoline::<F> as *const (),
3982                )),
3983                Box_::into_raw(f),
3984            )
3985        }
3986    }
3987
3988    #[doc(alias = "version")]
3989    pub fn connect_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3990        unsafe extern "C" fn notify_version_trampoline<F: Fn(&Client) + 'static>(
3991            this: *mut ffi::NMClient,
3992            _param_spec: glib::ffi::gpointer,
3993            f: glib::ffi::gpointer,
3994        ) {
3995            let f: &F = &*(f as *const F);
3996            f(&from_glib_borrow(this))
3997        }
3998        unsafe {
3999            let f: Box_<F> = Box_::new(f);
4000            connect_raw(
4001                self.as_ptr() as *mut _,
4002                c"notify::version".as_ptr() as *const _,
4003                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4004                    notify_version_trampoline::<F> as *const (),
4005                )),
4006                Box_::into_raw(f),
4007            )
4008        }
4009    }
4010
4011    #[cfg(feature = "v1_42")]
4012    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
4013    #[doc(alias = "version-info")]
4014    pub fn connect_version_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4015        unsafe extern "C" fn notify_version_info_trampoline<F: Fn(&Client) + 'static>(
4016            this: *mut ffi::NMClient,
4017            _param_spec: glib::ffi::gpointer,
4018            f: glib::ffi::gpointer,
4019        ) {
4020            let f: &F = &*(f as *const F);
4021            f(&from_glib_borrow(this))
4022        }
4023        unsafe {
4024            let f: Box_<F> = Box_::new(f);
4025            connect_raw(
4026                self.as_ptr() as *mut _,
4027                c"notify::version-info".as_ptr() as *const _,
4028                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4029                    notify_version_info_trampoline::<F> as *const (),
4030                )),
4031                Box_::into_raw(f),
4032            )
4033        }
4034    }
4035
4036    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4037    #[doc(alias = "wimax-enabled")]
4038    pub fn connect_wimax_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4039        unsafe extern "C" fn notify_wimax_enabled_trampoline<F: Fn(&Client) + 'static>(
4040            this: *mut ffi::NMClient,
4041            _param_spec: glib::ffi::gpointer,
4042            f: glib::ffi::gpointer,
4043        ) {
4044            let f: &F = &*(f as *const F);
4045            f(&from_glib_borrow(this))
4046        }
4047        unsafe {
4048            let f: Box_<F> = Box_::new(f);
4049            connect_raw(
4050                self.as_ptr() as *mut _,
4051                c"notify::wimax-enabled".as_ptr() as *const _,
4052                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4053                    notify_wimax_enabled_trampoline::<F> as *const (),
4054                )),
4055                Box_::into_raw(f),
4056            )
4057        }
4058    }
4059
4060    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4061    #[doc(alias = "wimax-hardware-enabled")]
4062    pub fn connect_wimax_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4063        &self,
4064        f: F,
4065    ) -> SignalHandlerId {
4066        unsafe extern "C" fn notify_wimax_hardware_enabled_trampoline<F: Fn(&Client) + 'static>(
4067            this: *mut ffi::NMClient,
4068            _param_spec: glib::ffi::gpointer,
4069            f: glib::ffi::gpointer,
4070        ) {
4071            let f: &F = &*(f as *const F);
4072            f(&from_glib_borrow(this))
4073        }
4074        unsafe {
4075            let f: Box_<F> = Box_::new(f);
4076            connect_raw(
4077                self.as_ptr() as *mut _,
4078                c"notify::wimax-hardware-enabled".as_ptr() as *const _,
4079                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4080                    notify_wimax_hardware_enabled_trampoline::<F> as *const (),
4081                )),
4082                Box_::into_raw(f),
4083            )
4084        }
4085    }
4086
4087    #[doc(alias = "wireless-enabled")]
4088    pub fn connect_wireless_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4089        unsafe extern "C" fn notify_wireless_enabled_trampoline<F: Fn(&Client) + 'static>(
4090            this: *mut ffi::NMClient,
4091            _param_spec: glib::ffi::gpointer,
4092            f: glib::ffi::gpointer,
4093        ) {
4094            let f: &F = &*(f as *const F);
4095            f(&from_glib_borrow(this))
4096        }
4097        unsafe {
4098            let f: Box_<F> = Box_::new(f);
4099            connect_raw(
4100                self.as_ptr() as *mut _,
4101                c"notify::wireless-enabled".as_ptr() as *const _,
4102                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4103                    notify_wireless_enabled_trampoline::<F> as *const (),
4104                )),
4105                Box_::into_raw(f),
4106            )
4107        }
4108    }
4109
4110    #[doc(alias = "wireless-hardware-enabled")]
4111    pub fn connect_wireless_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4112        &self,
4113        f: F,
4114    ) -> SignalHandlerId {
4115        unsafe extern "C" fn notify_wireless_hardware_enabled_trampoline<
4116            F: Fn(&Client) + 'static,
4117        >(
4118            this: *mut ffi::NMClient,
4119            _param_spec: glib::ffi::gpointer,
4120            f: glib::ffi::gpointer,
4121        ) {
4122            let f: &F = &*(f as *const F);
4123            f(&from_glib_borrow(this))
4124        }
4125        unsafe {
4126            let f: Box_<F> = Box_::new(f);
4127            connect_raw(
4128                self.as_ptr() as *mut _,
4129                c"notify::wireless-hardware-enabled".as_ptr() as *const _,
4130                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4131                    notify_wireless_hardware_enabled_trampoline::<F> as *const (),
4132                )),
4133                Box_::into_raw(f),
4134            )
4135        }
4136    }
4137
4138    #[doc(alias = "wwan-enabled")]
4139    pub fn connect_wwan_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4140        unsafe extern "C" fn notify_wwan_enabled_trampoline<F: Fn(&Client) + 'static>(
4141            this: *mut ffi::NMClient,
4142            _param_spec: glib::ffi::gpointer,
4143            f: glib::ffi::gpointer,
4144        ) {
4145            let f: &F = &*(f as *const F);
4146            f(&from_glib_borrow(this))
4147        }
4148        unsafe {
4149            let f: Box_<F> = Box_::new(f);
4150            connect_raw(
4151                self.as_ptr() as *mut _,
4152                c"notify::wwan-enabled".as_ptr() as *const _,
4153                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4154                    notify_wwan_enabled_trampoline::<F> as *const (),
4155                )),
4156                Box_::into_raw(f),
4157            )
4158        }
4159    }
4160
4161    #[doc(alias = "wwan-hardware-enabled")]
4162    pub fn connect_wwan_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4163        &self,
4164        f: F,
4165    ) -> SignalHandlerId {
4166        unsafe extern "C" fn notify_wwan_hardware_enabled_trampoline<F: Fn(&Client) + 'static>(
4167            this: *mut ffi::NMClient,
4168            _param_spec: glib::ffi::gpointer,
4169            f: glib::ffi::gpointer,
4170        ) {
4171            let f: &F = &*(f as *const F);
4172            f(&from_glib_borrow(this))
4173        }
4174        unsafe {
4175            let f: Box_<F> = Box_::new(f);
4176            connect_raw(
4177                self.as_ptr() as *mut _,
4178                c"notify::wwan-hardware-enabled".as_ptr() as *const _,
4179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4180                    notify_wwan_hardware_enabled_trampoline::<F> as *const (),
4181                )),
4182                Box_::into_raw(f),
4183            )
4184        }
4185    }
4186}
4187
4188impl Default for Client {
4189    fn default() -> Self {
4190        glib::object::Object::new::<Self>()
4191    }
4192}
4193
4194// rustdoc-stripper-ignore-next
4195/// A [builder-pattern] type to construct [`Client`] objects.
4196///
4197/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
4198#[must_use = "The builder must be built to be used"]
4199pub struct ClientBuilder {
4200    builder: glib::object::ObjectBuilder<'static, Client>,
4201}
4202
4203impl ClientBuilder {
4204    fn new() -> Self {
4205        Self {
4206            builder: glib::object::Object::builder(),
4207        }
4208    }
4209
4210    pub fn connectivity_check_enabled(self, connectivity_check_enabled: bool) -> Self {
4211        Self {
4212            builder: self
4213                .builder
4214                .property("connectivity-check-enabled", connectivity_check_enabled),
4215        }
4216    }
4217
4218    //    #[cfg(feature = "v1_22")]
4219    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
4220    //pub fn dbus_connection(self, dbus_connection: /*Ignored*/&gio::DBusConnection) -> Self {
4221    //    Self { builder: self.builder.property("dbus-connection", dbus_connection), }
4222    //}
4223    /// #NMClientInstanceFlags for the instance. These affect behavior of #NMClient.
4224    /// This is a construct property and you may only set most flags only during
4225    /// construction.
4226    ///
4227    /// The flag [`ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS`][crate::ClientInstanceFlags::NO_AUTO_FETCH_PERMISSIONS] can be toggled any time,
4228    /// even after constructing the instance. Note that you may want to watch NMClient:permissions-state
4229    /// property to know whether permissions are ready. Note that permissions are only fetched
4230    /// when NMClient has a D-Bus name owner.
4231    ///
4232    /// The flags [`ClientInstanceFlags::INITIALIZED_GOOD`][crate::ClientInstanceFlags::INITIALIZED_GOOD] and [`ClientInstanceFlags::INITIALIZED_BAD`][crate::ClientInstanceFlags::INITIALIZED_BAD]
4233    /// cannot be set, however they will be returned by the getter after initialization completes.
4234    #[cfg(feature = "v1_24")]
4235    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
4236    pub fn instance_flags(self, instance_flags: u32) -> Self {
4237        Self {
4238            builder: self.builder.property("instance-flags", instance_flags),
4239        }
4240    }
4241
4242    /// Whether networking is enabled.
4243    ///
4244    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
4245    pub fn networking_enabled(self, networking_enabled: bool) -> Self {
4246        Self {
4247            builder: self
4248                .builder
4249                .property("networking-enabled", networking_enabled),
4250        }
4251    }
4252
4253    /// Whether WiMAX functionality is enabled.
4254    /// WiMAX is no longer supported and this always returns FALSE. The setter has no effect.
4255    #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4256    pub fn wimax_enabled(self, wimax_enabled: bool) -> Self {
4257        Self {
4258            builder: self.builder.property("wimax-enabled", wimax_enabled),
4259        }
4260    }
4261
4262    /// Whether wireless is enabled.
4263    ///
4264    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
4265    pub fn wireless_enabled(self, wireless_enabled: bool) -> Self {
4266        Self {
4267            builder: self.builder.property("wireless-enabled", wireless_enabled),
4268        }
4269    }
4270
4271    /// Whether WWAN functionality is enabled.
4272    ///
4273    /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
4274    pub fn wwan_enabled(self, wwan_enabled: bool) -> Self {
4275        Self {
4276            builder: self.builder.property("wwan-enabled", wwan_enabled),
4277        }
4278    }
4279
4280    // rustdoc-stripper-ignore-next
4281    /// Build the [`Client`].
4282    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
4283    pub fn build(self) -> Client {
4284        assert_initialized_main_thread!();
4285        self.builder.build()
4286    }
4287}