nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi,ActiveConnection,Object,VpnConnectionState};
use glib::{object::ObjectType as _,prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `banner`
    ///  The VPN login banner of the active VPN connection.
    ///
    /// Readable
    ///
    ///
    /// #### `vpn-state`
    ///  The VPN state of the active VPN connection.
    ///
    /// Readable
    /// <details><summary><h4>ActiveConnection</h4></summary>
    ///
    ///
    /// #### `connection`
    ///  The connection that this is an active instance of.
    ///
    /// Readable
    ///
    ///
    /// #### `controller`
    ///  The controller device if one exists. This replaces the deprecated
    /// "master" property.
    ///
    /// Readable
    ///
    ///
    /// #### `default`
    ///  Whether the active connection is the default IPv4 one.
    ///
    /// Readable
    ///
    ///
    /// #### `default6`
    ///  Whether the active connection is the default IPv6 one.
    ///
    /// Readable
    ///
    ///
    /// #### `devices`
    ///  The devices of the active connection.
    ///
    /// Readable
    ///
    ///
    /// #### `dhcp4-config`
    ///  The IPv4 #NMDhcpConfig of the connection.
    ///
    /// Readable
    ///
    ///
    /// #### `dhcp6-config`
    ///  The IPv6 #NMDhcpConfig of the connection.
    ///
    /// Readable
    ///
    ///
    /// #### `id`
    ///  The active connection's ID
    ///
    /// Readable
    ///
    ///
    /// #### `ip4-config`
    ///  The IPv4 #NMIPConfig of the connection.
    ///
    /// Readable
    ///
    ///
    /// #### `ip6-config`
    ///  The IPv6 #NMIPConfig of the connection.
    ///
    /// Readable
    ///
    ///
    /// #### `master`
    ///  The controller device if one exists. Replaced by the "controller" property.
    ///
    /// Readable
    ///
    ///
    /// #### `specific-object-path`
    ///  The path to the "specific object" of the active connection; see
    /// nm_active_connection_get_specific_object_path() for more details.
    ///
    /// Readable
    ///
    ///
    /// #### `state`
    ///  The state of the active connection.
    ///
    /// Readable
    ///
    ///
    /// #### `state-flags`
    ///  The state flags of the active connection.
    ///
    /// Readable
    ///
    ///
    /// #### `type`
    ///  The active connection's type
    ///
    /// Readable
    ///
    ///
    /// #### `uuid`
    ///  The active connection's UUID
    ///
    /// Readable
    ///
    ///
    /// #### `vpn`
    ///  Whether the active connection is a VPN connection.
    ///
    /// Readable
    /// </details>
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `client`
    ///  The NMClient instance as returned by nm_object_get_client().
    ///
    /// When an NMObject gets removed from the NMClient cache,
    /// the NMObject:path property stays unchanged, but this client
    /// instance gets reset to [`None`]. You can use this property to
    /// track removal of the object from the cache.
    ///
    /// Readable
    ///
    ///
    /// #### `path`
    ///  The D-Bus object path.
    ///
    /// The D-Bus path of an object instance never changes, even if the object
    /// gets removed from the cache. To see whether the object is still in the
    /// cache, check NMObject:client.
    ///
    /// Readable
    /// </details>
    ///
    /// ## Signals
    ///
    ///
    /// #### `vpn-state-changed`
    ///
    /// <details><summary><h4>ActiveConnection</h4></summary>
    ///
    ///
    /// #### `state-changed`
    ///
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ActiveConnectionExt`][trait@crate::prelude::ActiveConnectionExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
    #[doc(alias = "NMVpnConnection")]
    pub struct VpnConnection(Object<ffi::NMVpnConnection, ffi::NMVpnConnectionClass>) @extends ActiveConnection, Object;

    match fn {
        type_ => || ffi::nm_vpn_connection_get_type(),
    }
}

impl VpnConnection {
    /// Gets the VPN login banner of the active #NMVpnConnection.
    ///
    /// # Returns
    ///
    /// the VPN login banner of the VPN connection. This is the internal
    /// string used by the connection, and must not be modified.
    #[doc(alias = "nm_vpn_connection_get_banner")]
    #[doc(alias = "get_banner")]
    pub fn banner(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_vpn_connection_get_banner(self.to_glib_none().0))
        }
    }

    /// Gets the current #NMVpnConnection state.
    ///
    /// # Returns
    ///
    /// the VPN state of the active VPN connection.
    #[doc(alias = "nm_vpn_connection_get_vpn_state")]
    #[doc(alias = "get_vpn_state")]
    #[doc(alias = "vpn-state")]
    pub fn vpn_state(&self) -> VpnConnectionState {
        unsafe {
            from_glib(ffi::nm_vpn_connection_get_vpn_state(self.to_glib_none().0))
        }
    }

    #[doc(alias = "vpn-state-changed")]
    pub fn connect_vpn_state_changed<F: Fn(&Self, u32, u32) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn vpn_state_changed_trampoline<F: Fn(&VpnConnection, u32, u32) + 'static>(this: *mut ffi::NMVpnConnection, object: std::ffi::c_uint, p0: std::ffi::c_uint, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), object, p0)
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"vpn-state-changed".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(vpn_state_changed_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "banner")]
    pub fn connect_banner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_banner_trampoline<F: Fn(&VpnConnection) + 'static>(this: *mut ffi::NMVpnConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::banner".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_banner_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "vpn-state")]
    pub fn connect_vpn_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_vpn_state_trampoline<F: Fn(&VpnConnection) + 'static>(this: *mut ffi::NMVpnConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::vpn-state".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vpn_state_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}