soup/auto/
auth_domain_digest.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, AuthDomain, ServerMessage};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "SoupAuthDomainDigest")]
16    pub struct AuthDomainDigest(Object<ffi::SoupAuthDomainDigest, ffi::SoupAuthDomainDigestClass>) @extends AuthDomain;
17
18    match fn {
19        type_ => || ffi::soup_auth_domain_digest_get_type(),
20    }
21}
22
23impl AuthDomainDigest {
24    //#[doc(alias = "soup_auth_domain_digest_new")]
25    //pub fn new(optname1: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> AuthDomainDigest {
26    //    unsafe { TODO: call ffi:soup_auth_domain_digest_new() }
27    //}
28
29    // rustdoc-stripper-ignore-next
30    /// Creates a new builder-pattern struct instance to construct [`AuthDomainDigest`] objects.
31    ///
32    /// This method returns an instance of [`AuthDomainDigestBuilder`](crate::builders::AuthDomainDigestBuilder) which can be used to create [`AuthDomainDigest`] objects.
33    pub fn builder() -> AuthDomainDigestBuilder {
34        AuthDomainDigestBuilder::new()
35    }
36
37    #[doc(alias = "soup_auth_domain_digest_set_auth_callback")]
38    #[doc(alias = "auth-callback")]
39    pub fn set_auth_callback<
40        P: Fn(&AuthDomainDigest, &ServerMessage, &str) -> Option<String> + 'static,
41    >(
42        &self,
43        callback: P,
44    ) {
45        let callback_data: Box_<P> = Box_::new(callback);
46        unsafe extern "C" fn callback_func<
47            P: Fn(&AuthDomainDigest, &ServerMessage, &str) -> Option<String> + 'static,
48        >(
49            domain: *mut ffi::SoupAuthDomainDigest,
50            msg: *mut ffi::SoupServerMessage,
51            username: *const libc::c_char,
52            user_data: glib::ffi::gpointer,
53        ) -> *mut libc::c_char {
54            let domain = from_glib_borrow(domain);
55            let msg = from_glib_borrow(msg);
56            let username: Borrowed<glib::GString> = from_glib_borrow(username);
57            let callback = &*(user_data as *mut P);
58            (*callback)(&domain, &msg, username.as_str()).to_glib_full()
59        }
60        let callback = Some(callback_func::<P> as _);
61        unsafe extern "C" fn dnotify_func<
62            P: Fn(&AuthDomainDigest, &ServerMessage, &str) -> Option<String> + 'static,
63        >(
64            data: glib::ffi::gpointer,
65        ) {
66            let _callback = Box_::from_raw(data as *mut P);
67        }
68        let destroy_call3 = Some(dnotify_func::<P> as _);
69        let super_callback0: Box_<P> = callback_data;
70        unsafe {
71            ffi::soup_auth_domain_digest_set_auth_callback(
72                self.to_glib_none().0,
73                callback,
74                Box_::into_raw(super_callback0) as *mut _,
75                destroy_call3,
76            );
77        }
78    }
79
80    //#[doc(alias = "auth-data")]
81    //pub fn auth_data(&self) -> /*Unimplemented*/Basic: Pointer {
82    //    ObjectExt::property(self, "auth-data")
83    //}
84
85    //#[doc(alias = "auth-data")]
86    //pub fn set_auth_data(&self, auth_data: /*Unimplemented*/Basic: Pointer) {
87    //    ObjectExt::set_property(self,"auth-data", auth_data)
88    //}
89
90    #[doc(alias = "soup_auth_domain_digest_encode_password")]
91    pub fn encode_password(username: &str, realm: &str, password: &str) -> Option<glib::GString> {
92        assert_initialized_main_thread!();
93        unsafe {
94            from_glib_full(ffi::soup_auth_domain_digest_encode_password(
95                username.to_glib_none().0,
96                realm.to_glib_none().0,
97                password.to_glib_none().0,
98            ))
99        }
100    }
101
102    #[doc(alias = "auth-data")]
103    pub fn connect_auth_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
104        unsafe extern "C" fn notify_auth_data_trampoline<F: Fn(&AuthDomainDigest) + 'static>(
105            this: *mut ffi::SoupAuthDomainDigest,
106            _param_spec: glib::ffi::gpointer,
107            f: glib::ffi::gpointer,
108        ) {
109            let f: &F = &*(f as *const F);
110            f(&from_glib_borrow(this))
111        }
112        unsafe {
113            let f: Box_<F> = Box_::new(f);
114            connect_raw(
115                self.as_ptr() as *mut _,
116                b"notify::auth-data\0".as_ptr() as *const _,
117                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
118                    notify_auth_data_trampoline::<F> as *const (),
119                )),
120                Box_::into_raw(f),
121            )
122        }
123    }
124}
125
126impl Default for AuthDomainDigest {
127    fn default() -> Self {
128        glib::object::Object::new::<Self>()
129    }
130}
131
132// rustdoc-stripper-ignore-next
133/// A [builder-pattern] type to construct [`AuthDomainDigest`] objects.
134///
135/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
136#[must_use = "The builder must be built to be used"]
137pub struct AuthDomainDigestBuilder {
138    builder: glib::object::ObjectBuilder<'static, AuthDomainDigest>,
139}
140
141impl AuthDomainDigestBuilder {
142    fn new() -> Self {
143        Self {
144            builder: glib::object::Object::builder(),
145        }
146    }
147
148    //pub fn auth_data(self, auth_data: /*Unimplemented*/Basic: Pointer) -> Self {
149    //    Self { builder: self.builder.property("auth-data", auth_data), }
150    //}
151
152    //pub fn filter_data(self, filter_data: /*Unimplemented*/Basic: Pointer) -> Self {
153    //    Self { builder: self.builder.property("filter-data", filter_data), }
154    //}
155
156    //pub fn generic_auth_data(self, generic_auth_data: /*Unimplemented*/Basic: Pointer) -> Self {
157    //    Self { builder: self.builder.property("generic-auth-data", generic_auth_data), }
158    //}
159
160    pub fn proxy(self, proxy: bool) -> Self {
161        Self {
162            builder: self.builder.property("proxy", proxy),
163        }
164    }
165
166    pub fn realm(self, realm: impl Into<glib::GString>) -> Self {
167        Self {
168            builder: self.builder.property("realm", realm.into()),
169        }
170    }
171
172    // rustdoc-stripper-ignore-next
173    /// Build the [`AuthDomainDigest`].
174    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
175    pub fn build(self) -> AuthDomainDigest {
176        self.builder.build()
177    }
178}