soup/auto/
auth.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::{ffi, Message};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "SoupAuth")]
16    pub struct Auth(Object<ffi::SoupAuth, ffi::SoupAuthClass>);
17
18    match fn {
19        type_ => || ffi::soup_auth_get_type(),
20    }
21}
22
23impl Auth {
24    pub const NONE: Option<&'static Auth> = None;
25
26    #[doc(alias = "soup_auth_new")]
27    pub fn new(type_: glib::types::Type, msg: &Message, auth_header: &str) -> Option<Auth> {
28        skip_assert_initialized!();
29        unsafe {
30            from_glib_full(ffi::soup_auth_new(
31                type_.into_glib(),
32                msg.to_glib_none().0,
33                auth_header.to_glib_none().0,
34            ))
35        }
36    }
37}
38
39pub trait AuthExt: IsA<Auth> + 'static {
40    #[doc(alias = "soup_auth_authenticate")]
41    fn authenticate(&self, username: &str, password: &str) {
42        unsafe {
43            ffi::soup_auth_authenticate(
44                self.as_ref().to_glib_none().0,
45                username.to_glib_none().0,
46                password.to_glib_none().0,
47            );
48        }
49    }
50
51    #[doc(alias = "soup_auth_can_authenticate")]
52    fn can_authenticate(&self) -> bool {
53        unsafe {
54            from_glib(ffi::soup_auth_can_authenticate(
55                self.as_ref().to_glib_none().0,
56            ))
57        }
58    }
59
60    #[doc(alias = "soup_auth_cancel")]
61    fn cancel(&self) {
62        unsafe {
63            ffi::soup_auth_cancel(self.as_ref().to_glib_none().0);
64        }
65    }
66
67    //#[doc(alias = "soup_auth_free_protection_space")]
68    //fn free_protection_space(&self, space: /*Unimplemented*/&[&Basic: Pointer]) {
69    //    unsafe { TODO: call ffi:soup_auth_free_protection_space() }
70    //}
71
72    #[doc(alias = "soup_auth_get_authority")]
73    #[doc(alias = "get_authority")]
74    fn authority(&self) -> Option<glib::GString> {
75        unsafe { from_glib_none(ffi::soup_auth_get_authority(self.as_ref().to_glib_none().0)) }
76    }
77
78    #[doc(alias = "soup_auth_get_authorization")]
79    #[doc(alias = "get_authorization")]
80    fn authorization(&self, msg: &Message) -> Option<glib::GString> {
81        unsafe {
82            from_glib_full(ffi::soup_auth_get_authorization(
83                self.as_ref().to_glib_none().0,
84                msg.to_glib_none().0,
85            ))
86        }
87    }
88
89    #[doc(alias = "soup_auth_get_info")]
90    #[doc(alias = "get_info")]
91    fn info(&self) -> Option<glib::GString> {
92        unsafe { from_glib_full(ffi::soup_auth_get_info(self.as_ref().to_glib_none().0)) }
93    }
94
95    #[doc(alias = "soup_auth_get_protection_space")]
96    #[doc(alias = "get_protection_space")]
97    fn protection_space(&self, source_uri: &glib::Uri) -> Vec<glib::GString> {
98        unsafe {
99            FromGlibPtrContainer::from_glib_full(ffi::soup_auth_get_protection_space(
100                self.as_ref().to_glib_none().0,
101                source_uri.to_glib_none().0,
102            ))
103        }
104    }
105
106    #[doc(alias = "soup_auth_get_realm")]
107    #[doc(alias = "get_realm")]
108    fn realm(&self) -> Option<glib::GString> {
109        unsafe { from_glib_none(ffi::soup_auth_get_realm(self.as_ref().to_glib_none().0)) }
110    }
111
112    #[doc(alias = "soup_auth_get_scheme_name")]
113    #[doc(alias = "get_scheme_name")]
114    #[doc(alias = "scheme-name")]
115    fn scheme_name(&self) -> Option<glib::GString> {
116        unsafe {
117            from_glib_none(ffi::soup_auth_get_scheme_name(
118                self.as_ref().to_glib_none().0,
119            ))
120        }
121    }
122
123    #[doc(alias = "soup_auth_is_authenticated")]
124    #[doc(alias = "is-authenticated")]
125    fn is_authenticated(&self) -> bool {
126        unsafe {
127            from_glib(ffi::soup_auth_is_authenticated(
128                self.as_ref().to_glib_none().0,
129            ))
130        }
131    }
132
133    #[doc(alias = "soup_auth_is_cancelled")]
134    #[doc(alias = "is-cancelled")]
135    fn is_cancelled(&self) -> bool {
136        unsafe { from_glib(ffi::soup_auth_is_cancelled(self.as_ref().to_glib_none().0)) }
137    }
138
139    #[doc(alias = "soup_auth_is_for_proxy")]
140    #[doc(alias = "is-for-proxy")]
141    fn is_for_proxy(&self) -> bool {
142        unsafe { from_glib(ffi::soup_auth_is_for_proxy(self.as_ref().to_glib_none().0)) }
143    }
144
145    #[doc(alias = "soup_auth_is_ready")]
146    fn is_ready(&self, msg: &Message) -> bool {
147        unsafe {
148            from_glib(ffi::soup_auth_is_ready(
149                self.as_ref().to_glib_none().0,
150                msg.to_glib_none().0,
151            ))
152        }
153    }
154
155    #[doc(alias = "soup_auth_update")]
156    fn update(&self, msg: &Message, auth_header: &str) -> bool {
157        unsafe {
158            from_glib(ffi::soup_auth_update(
159                self.as_ref().to_glib_none().0,
160                msg.to_glib_none().0,
161                auth_header.to_glib_none().0,
162            ))
163        }
164    }
165
166    fn set_authority(&self, authority: Option<&str>) {
167        ObjectExt::set_property(self.as_ref(), "authority", authority)
168    }
169
170    #[doc(alias = "is-for-proxy")]
171    fn set_is_for_proxy(&self, is_for_proxy: bool) {
172        ObjectExt::set_property(self.as_ref(), "is-for-proxy", is_for_proxy)
173    }
174
175    fn set_realm(&self, realm: Option<&str>) {
176        ObjectExt::set_property(self.as_ref(), "realm", realm)
177    }
178
179    #[doc(alias = "authority")]
180    fn connect_authority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
181        unsafe extern "C" fn notify_authority_trampoline<P: IsA<Auth>, F: Fn(&P) + 'static>(
182            this: *mut ffi::SoupAuth,
183            _param_spec: glib::ffi::gpointer,
184            f: glib::ffi::gpointer,
185        ) {
186            let f: &F = &*(f as *const F);
187            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
188        }
189        unsafe {
190            let f: Box_<F> = Box_::new(f);
191            connect_raw(
192                self.as_ptr() as *mut _,
193                c"notify::authority".as_ptr() as *const _,
194                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
195                    notify_authority_trampoline::<Self, F> as *const (),
196                )),
197                Box_::into_raw(f),
198            )
199        }
200    }
201
202    #[doc(alias = "is-authenticated")]
203    fn connect_is_authenticated_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
204        unsafe extern "C" fn notify_is_authenticated_trampoline<
205            P: IsA<Auth>,
206            F: Fn(&P) + 'static,
207        >(
208            this: *mut ffi::SoupAuth,
209            _param_spec: glib::ffi::gpointer,
210            f: glib::ffi::gpointer,
211        ) {
212            let f: &F = &*(f as *const F);
213            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
214        }
215        unsafe {
216            let f: Box_<F> = Box_::new(f);
217            connect_raw(
218                self.as_ptr() as *mut _,
219                c"notify::is-authenticated".as_ptr() as *const _,
220                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
221                    notify_is_authenticated_trampoline::<Self, F> as *const (),
222                )),
223                Box_::into_raw(f),
224            )
225        }
226    }
227
228    #[doc(alias = "is-cancelled")]
229    fn connect_is_cancelled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
230        unsafe extern "C" fn notify_is_cancelled_trampoline<P: IsA<Auth>, F: Fn(&P) + 'static>(
231            this: *mut ffi::SoupAuth,
232            _param_spec: glib::ffi::gpointer,
233            f: glib::ffi::gpointer,
234        ) {
235            let f: &F = &*(f as *const F);
236            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                c"notify::is-cancelled".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244                    notify_is_cancelled_trampoline::<Self, F> as *const (),
245                )),
246                Box_::into_raw(f),
247            )
248        }
249    }
250
251    #[doc(alias = "is-for-proxy")]
252    fn connect_is_for_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
253        unsafe extern "C" fn notify_is_for_proxy_trampoline<P: IsA<Auth>, F: Fn(&P) + 'static>(
254            this: *mut ffi::SoupAuth,
255            _param_spec: glib::ffi::gpointer,
256            f: glib::ffi::gpointer,
257        ) {
258            let f: &F = &*(f as *const F);
259            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
260        }
261        unsafe {
262            let f: Box_<F> = Box_::new(f);
263            connect_raw(
264                self.as_ptr() as *mut _,
265                c"notify::is-for-proxy".as_ptr() as *const _,
266                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
267                    notify_is_for_proxy_trampoline::<Self, F> as *const (),
268                )),
269                Box_::into_raw(f),
270            )
271        }
272    }
273
274    #[doc(alias = "realm")]
275    fn connect_realm_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
276        unsafe extern "C" fn notify_realm_trampoline<P: IsA<Auth>, F: Fn(&P) + 'static>(
277            this: *mut ffi::SoupAuth,
278            _param_spec: glib::ffi::gpointer,
279            f: glib::ffi::gpointer,
280        ) {
281            let f: &F = &*(f as *const F);
282            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
283        }
284        unsafe {
285            let f: Box_<F> = Box_::new(f);
286            connect_raw(
287                self.as_ptr() as *mut _,
288                c"notify::realm".as_ptr() as *const _,
289                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290                    notify_realm_trampoline::<Self, F> as *const (),
291                )),
292                Box_::into_raw(f),
293            )
294        }
295    }
296
297    #[doc(alias = "scheme-name")]
298    fn connect_scheme_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
299        unsafe extern "C" fn notify_scheme_name_trampoline<P: IsA<Auth>, F: Fn(&P) + 'static>(
300            this: *mut ffi::SoupAuth,
301            _param_spec: glib::ffi::gpointer,
302            f: glib::ffi::gpointer,
303        ) {
304            let f: &F = &*(f as *const F);
305            f(Auth::from_glib_borrow(this).unsafe_cast_ref())
306        }
307        unsafe {
308            let f: Box_<F> = Box_::new(f);
309            connect_raw(
310                self.as_ptr() as *mut _,
311                c"notify::scheme-name".as_ptr() as *const _,
312                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
313                    notify_scheme_name_trampoline::<Self, F> as *const (),
314                )),
315                Box_::into_raw(f),
316            )
317        }
318    }
319}
320
321impl<O: IsA<Auth>> AuthExt for O {}