Skip to main content

spice_client_glib/auto/
smartcard_manager.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, VReader};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "SpiceSmartcardManager")]
17    pub struct SmartcardManager(Object<ffi::SpiceSmartcardManager, ffi::SpiceSmartcardManagerClass>);
18
19    match fn {
20        type_ => || ffi::spice_smartcard_manager_get_type(),
21    }
22}
23
24impl SmartcardManager {
25    pub const NONE: Option<&'static SmartcardManager> = None;
26
27    #[doc(alias = "spice_smartcard_manager_get")]
28    pub fn get() -> Option<SmartcardManager> {
29        assert_initialized_main_thread!();
30        unsafe { from_glib_none(ffi::spice_smartcard_manager_get()) }
31    }
32}
33
34pub trait SmartcardManagerExt: IsA<SmartcardManager> + 'static {
35    //#[doc(alias = "spice_smartcard_manager_get_readers")]
36    //#[doc(alias = "get_readers")]
37    //fn readers(&self) -> /*Ignored*/Vec<SmartcardReader> {
38    //    unsafe { TODO: call ffi:spice_smartcard_manager_get_readers() }
39    //}
40
41    #[doc(alias = "spice_smartcard_manager_insert_card")]
42    fn insert_card(&self) -> bool {
43        unsafe {
44            from_glib(ffi::spice_smartcard_manager_insert_card(
45                self.as_ref().to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "spice_smartcard_manager_remove_card")]
51    fn remove_card(&self) -> bool {
52        unsafe {
53            from_glib(ffi::spice_smartcard_manager_remove_card(
54                self.as_ref().to_glib_none().0,
55            ))
56        }
57    }
58
59    #[doc(alias = "card-inserted")]
60    fn connect_card_inserted<F: Fn(&Self, &VReader) + 'static>(&self, f: F) -> SignalHandlerId {
61        unsafe extern "C" fn card_inserted_trampoline<
62            P: IsA<SmartcardManager>,
63            F: Fn(&P, &VReader) + 'static,
64        >(
65            this: *mut ffi::SpiceSmartcardManager,
66            vreader: *mut ffi::VReader,
67            f: glib::ffi::gpointer,
68        ) {
69            unsafe {
70                let f: &F = &*(f as *const F);
71                f(
72                    SmartcardManager::from_glib_borrow(this).unsafe_cast_ref(),
73                    &from_glib_borrow(vreader),
74                )
75            }
76        }
77        unsafe {
78            let f: Box_<F> = Box_::new(f);
79            connect_raw(
80                self.as_ptr() as *mut _,
81                c"card-inserted".as_ptr(),
82                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
83                    card_inserted_trampoline::<Self, F> as *const (),
84                )),
85                Box_::into_raw(f),
86            )
87        }
88    }
89
90    #[doc(alias = "card-removed")]
91    fn connect_card_removed<F: Fn(&Self, &VReader) + 'static>(&self, f: F) -> SignalHandlerId {
92        unsafe extern "C" fn card_removed_trampoline<
93            P: IsA<SmartcardManager>,
94            F: Fn(&P, &VReader) + 'static,
95        >(
96            this: *mut ffi::SpiceSmartcardManager,
97            vreader: *mut ffi::VReader,
98            f: glib::ffi::gpointer,
99        ) {
100            unsafe {
101                let f: &F = &*(f as *const F);
102                f(
103                    SmartcardManager::from_glib_borrow(this).unsafe_cast_ref(),
104                    &from_glib_borrow(vreader),
105                )
106            }
107        }
108        unsafe {
109            let f: Box_<F> = Box_::new(f);
110            connect_raw(
111                self.as_ptr() as *mut _,
112                c"card-removed".as_ptr(),
113                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
114                    card_removed_trampoline::<Self, F> as *const (),
115                )),
116                Box_::into_raw(f),
117            )
118        }
119    }
120
121    #[doc(alias = "reader-added")]
122    fn connect_reader_added<F: Fn(&Self, &VReader) + 'static>(&self, f: F) -> SignalHandlerId {
123        unsafe extern "C" fn reader_added_trampoline<
124            P: IsA<SmartcardManager>,
125            F: Fn(&P, &VReader) + 'static,
126        >(
127            this: *mut ffi::SpiceSmartcardManager,
128            vreader: *mut ffi::VReader,
129            f: glib::ffi::gpointer,
130        ) {
131            unsafe {
132                let f: &F = &*(f as *const F);
133                f(
134                    SmartcardManager::from_glib_borrow(this).unsafe_cast_ref(),
135                    &from_glib_borrow(vreader),
136                )
137            }
138        }
139        unsafe {
140            let f: Box_<F> = Box_::new(f);
141            connect_raw(
142                self.as_ptr() as *mut _,
143                c"reader-added".as_ptr(),
144                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
145                    reader_added_trampoline::<Self, F> as *const (),
146                )),
147                Box_::into_raw(f),
148            )
149        }
150    }
151
152    #[doc(alias = "reader-removed")]
153    fn connect_reader_removed<F: Fn(&Self, &VReader) + 'static>(&self, f: F) -> SignalHandlerId {
154        unsafe extern "C" fn reader_removed_trampoline<
155            P: IsA<SmartcardManager>,
156            F: Fn(&P, &VReader) + 'static,
157        >(
158            this: *mut ffi::SpiceSmartcardManager,
159            vreader: *mut ffi::VReader,
160            f: glib::ffi::gpointer,
161        ) {
162            unsafe {
163                let f: &F = &*(f as *const F);
164                f(
165                    SmartcardManager::from_glib_borrow(this).unsafe_cast_ref(),
166                    &from_glib_borrow(vreader),
167                )
168            }
169        }
170        unsafe {
171            let f: Box_<F> = Box_::new(f);
172            connect_raw(
173                self.as_ptr() as *mut _,
174                c"reader-removed".as_ptr(),
175                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
176                    reader_removed_trampoline::<Self, F> as *const (),
177                )),
178                Box_::into_raw(f),
179            )
180        }
181    }
182}
183
184impl<O: IsA<SmartcardManager>> SmartcardManagerExt for O {}