nm_rs/auto/
vpn_connection.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,ActiveConnection,Object,VpnConnectionState};
7use glib::{object::ObjectType as _,prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11    ///
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `banner`
17    ///  The VPN login banner of the active VPN connection.
18    ///
19    /// Readable
20    ///
21    ///
22    /// #### `vpn-state`
23    ///  The VPN state of the active VPN connection.
24    ///
25    /// Readable
26    /// <details><summary><h4>ActiveConnection</h4></summary>
27    ///
28    ///
29    /// #### `connection`
30    ///  The connection that this is an active instance of.
31    ///
32    /// Readable
33    ///
34    ///
35    /// #### `controller`
36    ///  The controller device if one exists. This replaces the deprecated
37    /// "master" property.
38    ///
39    /// Readable
40    ///
41    ///
42    /// #### `default`
43    ///  Whether the active connection is the default IPv4 one.
44    ///
45    /// Readable
46    ///
47    ///
48    /// #### `default6`
49    ///  Whether the active connection is the default IPv6 one.
50    ///
51    /// Readable
52    ///
53    ///
54    /// #### `devices`
55    ///  The devices of the active connection.
56    ///
57    /// Readable
58    ///
59    ///
60    /// #### `dhcp4-config`
61    ///  The IPv4 #NMDhcpConfig of the connection.
62    ///
63    /// Readable
64    ///
65    ///
66    /// #### `dhcp6-config`
67    ///  The IPv6 #NMDhcpConfig of the connection.
68    ///
69    /// Readable
70    ///
71    ///
72    /// #### `id`
73    ///  The active connection's ID
74    ///
75    /// Readable
76    ///
77    ///
78    /// #### `ip4-config`
79    ///  The IPv4 #NMIPConfig of the connection.
80    ///
81    /// Readable
82    ///
83    ///
84    /// #### `ip6-config`
85    ///  The IPv6 #NMIPConfig of the connection.
86    ///
87    /// Readable
88    ///
89    ///
90    /// #### `master`
91    ///  The controller device if one exists. Replaced by the "controller" property.
92    ///
93    /// Readable
94    ///
95    ///
96    /// #### `specific-object-path`
97    ///  The path to the "specific object" of the active connection; see
98    /// nm_active_connection_get_specific_object_path() for more details.
99    ///
100    /// Readable
101    ///
102    ///
103    /// #### `state`
104    ///  The state of the active connection.
105    ///
106    /// Readable
107    ///
108    ///
109    /// #### `state-flags`
110    ///  The state flags of the active connection.
111    ///
112    /// Readable
113    ///
114    ///
115    /// #### `type`
116    ///  The active connection's type
117    ///
118    /// Readable
119    ///
120    ///
121    /// #### `uuid`
122    ///  The active connection's UUID
123    ///
124    /// Readable
125    ///
126    ///
127    /// #### `vpn`
128    ///  Whether the active connection is a VPN connection.
129    ///
130    /// Readable
131    /// </details>
132    /// <details><summary><h4>Object</h4></summary>
133    ///
134    ///
135    /// #### `client`
136    ///  The NMClient instance as returned by nm_object_get_client().
137    ///
138    /// When an NMObject gets removed from the NMClient cache,
139    /// the NMObject:path property stays unchanged, but this client
140    /// instance gets reset to [`None`]. You can use this property to
141    /// track removal of the object from the cache.
142    ///
143    /// Readable
144    ///
145    ///
146    /// #### `path`
147    ///  The D-Bus object path.
148    ///
149    /// The D-Bus path of an object instance never changes, even if the object
150    /// gets removed from the cache. To see whether the object is still in the
151    /// cache, check NMObject:client.
152    ///
153    /// Readable
154    /// </details>
155    ///
156    /// ## Signals
157    ///
158    ///
159    /// #### `vpn-state-changed`
160    ///
161    /// <details><summary><h4>ActiveConnection</h4></summary>
162    ///
163    ///
164    /// #### `state-changed`
165    ///
166    /// </details>
167    ///
168    /// # Implements
169    ///
170    /// [`ActiveConnectionExt`][trait@crate::prelude::ActiveConnectionExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
171    #[doc(alias = "NMVpnConnection")]
172    pub struct VpnConnection(Object<ffi::NMVpnConnection, ffi::NMVpnConnectionClass>) @extends ActiveConnection, Object;
173
174    match fn {
175        type_ => || ffi::nm_vpn_connection_get_type(),
176    }
177}
178
179impl VpnConnection {
180    /// Gets the VPN login banner of the active #NMVpnConnection.
181    ///
182    /// # Returns
183    ///
184    /// the VPN login banner of the VPN connection. This is the internal
185    /// string used by the connection, and must not be modified.
186    #[doc(alias = "nm_vpn_connection_get_banner")]
187    #[doc(alias = "get_banner")]
188    pub fn banner(&self) -> glib::GString {
189        unsafe {
190            from_glib_none(ffi::nm_vpn_connection_get_banner(self.to_glib_none().0))
191        }
192    }
193
194    /// Gets the current #NMVpnConnection state.
195    ///
196    /// # Returns
197    ///
198    /// the VPN state of the active VPN connection.
199    #[doc(alias = "nm_vpn_connection_get_vpn_state")]
200    #[doc(alias = "get_vpn_state")]
201    #[doc(alias = "vpn-state")]
202    pub fn vpn_state(&self) -> VpnConnectionState {
203        unsafe {
204            from_glib(ffi::nm_vpn_connection_get_vpn_state(self.to_glib_none().0))
205        }
206    }
207
208    #[doc(alias = "vpn-state-changed")]
209    pub fn connect_vpn_state_changed<F: Fn(&Self, u32, u32) + 'static>(&self, f: F) -> SignalHandlerId {
210        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) {
211            let f: &F = &*(f as *const F);
212            f(&from_glib_borrow(this), object, p0)
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(self.as_ptr() as *mut _, c"vpn-state-changed".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(vpn_state_changed_trampoline::<F> as *const ())), Box_::into_raw(f))
218        }
219    }
220
221    #[doc(alias = "banner")]
222    pub fn connect_banner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
223        unsafe extern "C" fn notify_banner_trampoline<F: Fn(&VpnConnection) + 'static>(this: *mut ffi::NMVpnConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
224            let f: &F = &*(f as *const F);
225            f(&from_glib_borrow(this))
226        }
227        unsafe {
228            let f: Box_<F> = Box_::new(f);
229            connect_raw(self.as_ptr() as *mut _, c"notify::banner".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_banner_trampoline::<F> as *const ())), Box_::into_raw(f))
231        }
232    }
233
234    #[doc(alias = "vpn-state")]
235    pub fn connect_vpn_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236        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) {
237            let f: &F = &*(f as *const F);
238            f(&from_glib_borrow(this))
239        }
240        unsafe {
241            let f: Box_<F> = Box_::new(f);
242            connect_raw(self.as_ptr() as *mut _, c"notify::vpn-state".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vpn_state_trampoline::<F> as *const ())), Box_::into_raw(f))
244        }
245    }
246}