Skip to main content

soup/auto/
auth_domain.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)
4// DO NOT EDIT
5
6use crate::{ServerMessage, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "SoupAuthDomain")]
16    pub struct AuthDomain(Object<ffi::SoupAuthDomain, ffi::SoupAuthDomainClass>);
17
18    match fn {
19        type_ => || ffi::soup_auth_domain_get_type(),
20    }
21}
22
23impl AuthDomain {
24    pub const NONE: Option<&'static AuthDomain> = None;
25}
26
27pub trait AuthDomainExt: IsA<AuthDomain> + 'static {
28    #[doc(alias = "soup_auth_domain_accepts")]
29    fn accepts(&self, msg: &ServerMessage) -> Option<glib::GString> {
30        unsafe {
31            from_glib_full(ffi::soup_auth_domain_accepts(
32                self.as_ref().to_glib_none().0,
33                msg.to_glib_none().0,
34            ))
35        }
36    }
37
38    #[doc(alias = "soup_auth_domain_add_path")]
39    fn add_path(&self, path: &str) {
40        unsafe {
41            ffi::soup_auth_domain_add_path(self.as_ref().to_glib_none().0, path.to_glib_none().0);
42        }
43    }
44
45    #[doc(alias = "soup_auth_domain_challenge")]
46    fn challenge(&self, msg: &ServerMessage) {
47        unsafe {
48            ffi::soup_auth_domain_challenge(self.as_ref().to_glib_none().0, msg.to_glib_none().0);
49        }
50    }
51
52    #[doc(alias = "soup_auth_domain_check_password")]
53    fn check_password(&self, msg: &ServerMessage, username: &str, password: &str) -> bool {
54        unsafe {
55            from_glib(ffi::soup_auth_domain_check_password(
56                self.as_ref().to_glib_none().0,
57                msg.to_glib_none().0,
58                username.to_glib_none().0,
59                password.to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "soup_auth_domain_covers")]
65    fn covers(&self, msg: &ServerMessage) -> bool {
66        unsafe {
67            from_glib(ffi::soup_auth_domain_covers(
68                self.as_ref().to_glib_none().0,
69                msg.to_glib_none().0,
70            ))
71        }
72    }
73
74    #[doc(alias = "soup_auth_domain_get_realm")]
75    #[doc(alias = "get_realm")]
76    fn realm(&self) -> Option<glib::GString> {
77        unsafe {
78            from_glib_none(ffi::soup_auth_domain_get_realm(
79                self.as_ref().to_glib_none().0,
80            ))
81        }
82    }
83
84    #[doc(alias = "soup_auth_domain_remove_path")]
85    fn remove_path(&self, path: &str) {
86        unsafe {
87            ffi::soup_auth_domain_remove_path(
88                self.as_ref().to_glib_none().0,
89                path.to_glib_none().0,
90            );
91        }
92    }
93
94    #[doc(alias = "soup_auth_domain_set_filter")]
95    #[doc(alias = "filter")]
96    fn set_filter<P: Fn(&AuthDomain, &ServerMessage) -> bool + 'static>(&self, filter: P) {
97        let filter_data: Box_<P> = Box_::new(filter);
98        unsafe extern "C" fn filter_func<P: Fn(&AuthDomain, &ServerMessage) -> bool + 'static>(
99            domain: *mut ffi::SoupAuthDomain,
100            msg: *mut ffi::SoupServerMessage,
101            user_data: glib::ffi::gpointer,
102        ) -> glib::ffi::gboolean {
103            unsafe {
104                let domain = from_glib_borrow(domain);
105                let msg = from_glib_borrow(msg);
106                let callback = &*(user_data as *mut P);
107                (*callback)(&domain, &msg).into_glib()
108            }
109        }
110        let filter = Some(filter_func::<P> as _);
111        unsafe extern "C" fn dnotify_func<P: Fn(&AuthDomain, &ServerMessage) -> bool + 'static>(
112            data: glib::ffi::gpointer,
113        ) {
114            unsafe {
115                let _callback = Box_::from_raw(data as *mut P);
116            }
117        }
118        let destroy_call3 = Some(dnotify_func::<P> as _);
119        let super_callback0: Box_<P> = filter_data;
120        unsafe {
121            ffi::soup_auth_domain_set_filter(
122                self.as_ref().to_glib_none().0,
123                filter,
124                Box_::into_raw(super_callback0) as *mut _,
125                destroy_call3,
126            );
127        }
128    }
129
130    #[doc(alias = "soup_auth_domain_set_generic_auth_callback")]
131    #[doc(alias = "generic-auth-callback")]
132    fn set_generic_auth_callback<P: Fn(&AuthDomain, &ServerMessage, &str) -> bool + 'static>(
133        &self,
134        auth_callback: P,
135    ) {
136        let auth_callback_data: Box_<P> = Box_::new(auth_callback);
137        unsafe extern "C" fn auth_callback_func<
138            P: Fn(&AuthDomain, &ServerMessage, &str) -> bool + 'static,
139        >(
140            domain: *mut ffi::SoupAuthDomain,
141            msg: *mut ffi::SoupServerMessage,
142            username: *const std::ffi::c_char,
143            user_data: glib::ffi::gpointer,
144        ) -> glib::ffi::gboolean {
145            unsafe {
146                let domain = from_glib_borrow(domain);
147                let msg = from_glib_borrow(msg);
148                let username: Borrowed<glib::GString> = from_glib_borrow(username);
149                let callback = &*(user_data as *mut P);
150                (*callback)(&domain, &msg, username.as_str()).into_glib()
151            }
152        }
153        let auth_callback = Some(auth_callback_func::<P> as _);
154        unsafe extern "C" fn dnotify_func<
155            P: Fn(&AuthDomain, &ServerMessage, &str) -> bool + 'static,
156        >(
157            data: glib::ffi::gpointer,
158        ) {
159            unsafe {
160                let _callback = Box_::from_raw(data as *mut P);
161            }
162        }
163        let destroy_call3 = Some(dnotify_func::<P> as _);
164        let super_callback0: Box_<P> = auth_callback_data;
165        unsafe {
166            ffi::soup_auth_domain_set_generic_auth_callback(
167                self.as_ref().to_glib_none().0,
168                auth_callback,
169                Box_::into_raw(super_callback0) as *mut _,
170                destroy_call3,
171            );
172        }
173    }
174
175    //#[doc(alias = "filter-data")]
176    //fn filter_data(&self) -> /*Unimplemented*/Basic: Pointer {
177    //    ObjectExt::property(self.as_ref(), "filter-data")
178    //}
179
180    //#[doc(alias = "filter-data")]
181    //fn set_filter_data(&self, filter_data: /*Unimplemented*/Basic: Pointer) {
182    //    ObjectExt::set_property(self.as_ref(),"filter-data", filter_data)
183    //}
184
185    //#[doc(alias = "generic-auth-data")]
186    //fn generic_auth_data(&self) -> /*Unimplemented*/Basic: Pointer {
187    //    ObjectExt::property(self.as_ref(), "generic-auth-data")
188    //}
189
190    //#[doc(alias = "generic-auth-data")]
191    //fn set_generic_auth_data(&self, generic_auth_data: /*Unimplemented*/Basic: Pointer) {
192    //    ObjectExt::set_property(self.as_ref(),"generic-auth-data", generic_auth_data)
193    //}
194
195    fn is_proxy(&self) -> bool {
196        ObjectExt::property(self.as_ref(), "proxy")
197    }
198
199    #[doc(alias = "filter-data")]
200    fn connect_filter_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
201        unsafe extern "C" fn notify_filter_data_trampoline<
202            P: IsA<AuthDomain>,
203            F: Fn(&P) + 'static,
204        >(
205            this: *mut ffi::SoupAuthDomain,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            unsafe {
210                let f: &F = &*(f as *const F);
211                f(AuthDomain::from_glib_borrow(this).unsafe_cast_ref())
212            }
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"notify::filter-data".as_ptr(),
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    notify_filter_data_trampoline::<Self, F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226
227    #[doc(alias = "generic-auth-data")]
228    fn connect_generic_auth_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
229        unsafe extern "C" fn notify_generic_auth_data_trampoline<
230            P: IsA<AuthDomain>,
231            F: Fn(&P) + 'static,
232        >(
233            this: *mut ffi::SoupAuthDomain,
234            _param_spec: glib::ffi::gpointer,
235            f: glib::ffi::gpointer,
236        ) {
237            unsafe {
238                let f: &F = &*(f as *const F);
239                f(AuthDomain::from_glib_borrow(this).unsafe_cast_ref())
240            }
241        }
242        unsafe {
243            let f: Box_<F> = Box_::new(f);
244            connect_raw(
245                self.as_ptr() as *mut _,
246                c"notify::generic-auth-data".as_ptr(),
247                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
248                    notify_generic_auth_data_trampoline::<Self, F> as *const (),
249                )),
250                Box_::into_raw(f),
251            )
252        }
253    }
254}
255
256impl<O: IsA<AuthDomain>> AuthDomainExt for O {}