1#![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 #[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 }
110
111pub trait VpnPluginOldExt: IsA<VpnPluginOld> + 'static {
117 #[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 #[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")]
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 #[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")]
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 #[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 #[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 = "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 = "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 = "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 {}