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