nm_rs/auto/
vpn_plugin_old.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5#![allow(deprecated)]
6
7use crate::{VpnPluginFailure, VpnServiceState, ffi};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16#[cfg(feature = "gio_v2_22")]
17#[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_22")))]
18glib::wrapper! {
19    ///
20    ///
21    /// This is an Abstract Base Class, you cannot instantiate it.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `service-name`
27    ///  The D-Bus service name of this plugin.
28    ///
29    /// Readable | Writeable | Construct Only
30    ///
31    ///
32    /// #### `state`
33    ///  The state of the plugin.
34    ///
35    /// Readable | Writeable
36    ///
37    /// ## Signals
38    ///
39    ///
40    /// #### `config`
41    ///
42    ///
43    ///
44    /// #### `failure`
45    ///
46    ///
47    ///
48    /// #### `ip4-config`
49    ///
50    ///
51    ///
52    /// #### `ip6-config`
53    ///
54    ///
55    ///
56    /// #### `login-banner`
57    ///
58    ///
59    ///
60    /// #### `quit`
61    ///
62    ///
63    ///
64    /// #### `secrets-required`
65    ///
66    ///
67    ///
68    /// #### `state-changed`
69    ///
70    ///
71    /// # Implements
72    ///
73    /// [`VpnPluginOldExt`][trait@crate::prelude::VpnPluginOldExt], [`trait@gio::prelude::InitableExt`]
74    #[doc(alias = "NMVpnPluginOld")]
75    pub struct VpnPluginOld(Object<ffi::NMVpnPluginOld, ffi::NMVpnPluginOldClass>) @implements gio::Initable;
76
77    match fn {
78        type_ => || ffi::nm_vpn_plugin_old_get_type(),
79    }
80}
81
82#[cfg(not(any(feature = "gio_v2_22")))]
83glib::wrapper! {
84    #[doc(alias = "NMVpnPluginOld")]
85    pub struct VpnPluginOld(Object<ffi::NMVpnPluginOld, ffi::NMVpnPluginOldClass>);
86
87    match fn {
88        type_ => || ffi::nm_vpn_plugin_old_get_type(),
89    }
90}
91
92impl VpnPluginOld {
93    pub const NONE: Option<&'static VpnPluginOld> = None;
94
95    //#[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
96    //#[allow(deprecated)]
97    //#[doc(alias = "nm_vpn_plugin_old_get_secret_flags")]
98    //#[doc(alias = "get_secret_flags")]
99    //pub fn secret_flags(data: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, secret_name: &str) -> Option<SettingSecretFlags> {
100    //    unsafe { TODO: call ffi:nm_vpn_plugin_old_get_secret_flags() }
101    //}
102
103    //#[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
104    //#[allow(deprecated)]
105    //#[doc(alias = "nm_vpn_plugin_old_read_vpn_details")]
106    //pub fn read_vpn_details(fd: i32, out_data: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, out_secrets: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }) -> bool {
107    //    unsafe { TODO: call ffi:nm_vpn_plugin_old_read_vpn_details() }
108    //}
109}
110
111/// Trait containing all [`struct@VpnPluginOld`] methods.
112///
113/// # Implementors
114///
115/// [`VpnPluginOld`][struct@crate::VpnPluginOld]
116pub trait VpnPluginOldExt: IsA<VpnPluginOld> + 'static {
117    ///
118    /// # Deprecated since 1.2
119    ///
120    /// Replaced by NMVpnServicePlugin.
121    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
122    #[allow(deprecated)]
123    #[doc(alias = "nm_vpn_plugin_old_disconnect")]
124    fn disconnect(&self) -> Result<(), glib::Error> {
125        unsafe {
126            let mut error = std::ptr::null_mut();
127            let is_ok =
128                ffi::nm_vpn_plugin_old_disconnect(self.as_ref().to_glib_none().0, &mut error);
129            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
130            if error.is_null() {
131                Ok(())
132            } else {
133                Err(from_glib_full(error))
134            }
135        }
136    }
137
138    ///
139    /// # Deprecated since 1.2
140    ///
141    /// Replaced by NMVpnServicePlugin.
142    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
143    #[allow(deprecated)]
144    #[doc(alias = "nm_vpn_plugin_old_failure")]
145    fn failure(&self, reason: VpnPluginFailure) {
146        unsafe {
147            ffi::nm_vpn_plugin_old_failure(self.as_ref().to_glib_none().0, reason.into_glib());
148        }
149    }
150
151    //#[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
152    //#[allow(deprecated)]
153    //#[doc(alias = "nm_vpn_plugin_old_get_connection")]
154    //#[doc(alias = "get_connection")]
155    //fn connection(&self) -> /*Ignored*/gio::DBusConnection {
156    //    unsafe { TODO: call ffi:nm_vpn_plugin_old_get_connection() }
157    //}
158
159    ///
160    /// # Deprecated since 1.2
161    ///
162    /// Replaced by NMVpnServicePlugin.
163    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
164    #[allow(deprecated)]
165    #[doc(alias = "nm_vpn_plugin_old_get_state")]
166    #[doc(alias = "get_state")]
167    fn state(&self) -> VpnServiceState {
168        unsafe {
169            from_glib(ffi::nm_vpn_plugin_old_get_state(
170                self.as_ref().to_glib_none().0,
171            ))
172        }
173    }
174
175    /// Called by VPN plugin implementations to signal to NetworkManager that secrets
176    /// are required during the connection process.  This signal may be used to
177    /// request new secrets when the secrets originally provided by NetworkManager
178    /// are insufficient, or the VPN process indicates that it needs additional
179    /// information to complete the request.
180    ///
181    /// # Deprecated since 1.2
182    ///
183    /// Replaced by NMVpnServicePlugin.
184    /// ## `message`
185    /// an information message about why secrets are required, if any
186    /// ## `hints`
187    /// VPN specific secret names for required new secrets
188    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
189    #[allow(deprecated)]
190    #[doc(alias = "nm_vpn_plugin_old_secrets_required")]
191    fn secrets_required(&self, message: &str, hints: &str) {
192        unsafe {
193            ffi::nm_vpn_plugin_old_secrets_required(
194                self.as_ref().to_glib_none().0,
195                message.to_glib_none().0,
196                &mut hints.to_glib_none().0,
197            );
198        }
199    }
200
201    //#[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
202    //#[allow(deprecated)]
203    //#[doc(alias = "nm_vpn_plugin_old_set_ip4_config")]
204    //fn set_ip4_config(&self, ip4_config: /*Ignored*/&glib::Variant) {
205    //    unsafe { TODO: call ffi:nm_vpn_plugin_old_set_ip4_config() }
206    //}
207
208    ///
209    /// # Deprecated since 1.2
210    ///
211    /// Replaced by NMVpnServicePlugin.
212    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
213    #[allow(deprecated)]
214    #[doc(alias = "nm_vpn_plugin_old_set_login_banner")]
215    fn set_login_banner(&self, banner: &str) {
216        unsafe {
217            ffi::nm_vpn_plugin_old_set_login_banner(
218                self.as_ref().to_glib_none().0,
219                banner.to_glib_none().0,
220            );
221        }
222    }
223
224    ///
225    /// # Deprecated since 1.2
226    ///
227    /// Replaced by NMVpnServicePlugin.
228    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
229    #[allow(deprecated)]
230    #[doc(alias = "nm_vpn_plugin_old_set_state")]
231    #[doc(alias = "state")]
232    fn set_state(&self, state: VpnServiceState) {
233        unsafe {
234            ffi::nm_vpn_plugin_old_set_state(self.as_ref().to_glib_none().0, state.into_glib());
235        }
236    }
237
238    /// The D-Bus service name of this plugin.
239    ///
240    /// # Deprecated since 1.2
241    ///
242    /// Replaced by NMVpnServicePlugin.
243    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
244    #[doc(alias = "service-name")]
245    fn service_name(&self) -> Option<glib::GString> {
246        ObjectExt::property(self.as_ref(), "service-name")
247    }
248
249    //#[doc(alias = "config")]
250    //fn connect_config<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
251    //    Ignored object: GLib.Variant
252    //}
253
254    #[doc(alias = "failure")]
255    fn connect_failure<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
256        unsafe extern "C" fn failure_trampoline<P: IsA<VpnPluginOld>, F: Fn(&P, u32) + 'static>(
257            this: *mut ffi::NMVpnPluginOld,
258            object: std::ffi::c_uint,
259            f: glib::ffi::gpointer,
260        ) {
261            let f: &F = &*(f as *const F);
262            f(
263                VpnPluginOld::from_glib_borrow(this).unsafe_cast_ref(),
264                object,
265            )
266        }
267        unsafe {
268            let f: Box_<F> = Box_::new(f);
269            connect_raw(
270                self.as_ptr() as *mut _,
271                c"failure".as_ptr() as *const _,
272                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
273                    failure_trampoline::<Self, F> as *const (),
274                )),
275                Box_::into_raw(f),
276            )
277        }
278    }
279
280    //#[doc(alias = "ip4-config")]
281    //fn connect_ip4_config<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
282    //    Ignored object: GLib.Variant
283    //}
284
285    //#[doc(alias = "ip6-config")]
286    //fn connect_ip6_config<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
287    //    Ignored object: GLib.Variant
288    //}
289
290    #[doc(alias = "login-banner")]
291    fn connect_login_banner<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
292        unsafe extern "C" fn login_banner_trampoline<
293            P: IsA<VpnPluginOld>,
294            F: Fn(&P, &str) + 'static,
295        >(
296            this: *mut ffi::NMVpnPluginOld,
297            object: *mut std::ffi::c_char,
298            f: glib::ffi::gpointer,
299        ) {
300            let f: &F = &*(f as *const F);
301            f(
302                VpnPluginOld::from_glib_borrow(this).unsafe_cast_ref(),
303                &glib::GString::from_glib_borrow(object),
304            )
305        }
306        unsafe {
307            let f: Box_<F> = Box_::new(f);
308            connect_raw(
309                self.as_ptr() as *mut _,
310                c"login-banner".as_ptr() as *const _,
311                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
312                    login_banner_trampoline::<Self, F> as *const (),
313                )),
314                Box_::into_raw(f),
315            )
316        }
317    }
318
319    #[doc(alias = "quit")]
320    fn connect_quit<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
321        unsafe extern "C" fn quit_trampoline<P: IsA<VpnPluginOld>, F: Fn(&P) + 'static>(
322            this: *mut ffi::NMVpnPluginOld,
323            f: glib::ffi::gpointer,
324        ) {
325            let f: &F = &*(f as *const F);
326            f(VpnPluginOld::from_glib_borrow(this).unsafe_cast_ref())
327        }
328        unsafe {
329            let f: Box_<F> = Box_::new(f);
330            connect_raw(
331                self.as_ptr() as *mut _,
332                c"quit".as_ptr() as *const _,
333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334                    quit_trampoline::<Self, F> as *const (),
335                )),
336                Box_::into_raw(f),
337            )
338        }
339    }
340
341    //#[doc(alias = "secrets-required")]
342    //fn connect_secrets_required<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
343    //    Empty ctype p0: *.CArray TypeId { ns_id: 0, id: 28 }
344    //}
345
346    #[doc(alias = "state-changed")]
347    fn connect_state_changed<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
348        unsafe extern "C" fn state_changed_trampoline<
349            P: IsA<VpnPluginOld>,
350            F: Fn(&P, u32) + 'static,
351        >(
352            this: *mut ffi::NMVpnPluginOld,
353            object: std::ffi::c_uint,
354            f: glib::ffi::gpointer,
355        ) {
356            let f: &F = &*(f as *const F);
357            f(
358                VpnPluginOld::from_glib_borrow(this).unsafe_cast_ref(),
359                object,
360            )
361        }
362        unsafe {
363            let f: Box_<F> = Box_::new(f);
364            connect_raw(
365                self.as_ptr() as *mut _,
366                c"state-changed".as_ptr() as *const _,
367                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368                    state_changed_trampoline::<Self, F> as *const (),
369                )),
370                Box_::into_raw(f),
371            )
372        }
373    }
374
375    #[cfg_attr(feature = "v1_2", deprecated = "Since 1.2")]
376    #[doc(alias = "state")]
377    fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
378        unsafe extern "C" fn notify_state_trampoline<P: IsA<VpnPluginOld>, F: Fn(&P) + 'static>(
379            this: *mut ffi::NMVpnPluginOld,
380            _param_spec: glib::ffi::gpointer,
381            f: glib::ffi::gpointer,
382        ) {
383            let f: &F = &*(f as *const F);
384            f(VpnPluginOld::from_glib_borrow(this).unsafe_cast_ref())
385        }
386        unsafe {
387            let f: Box_<F> = Box_::new(f);
388            connect_raw(
389                self.as_ptr() as *mut _,
390                c"notify::state".as_ptr() as *const _,
391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
392                    notify_state_trampoline::<Self, F> as *const (),
393                )),
394                Box_::into_raw(f),
395            )
396        }
397    }
398}
399
400impl<O: IsA<VpnPluginOld>> VpnPluginOldExt for O {}