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