Skip to main content

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::{AuthDomain, 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 = "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 std::ffi::c_char,
52            user_data: glib::ffi::gpointer,
53        ) -> *mut std::ffi::c_char {
54            unsafe {
55                let domain = from_glib_borrow(domain);
56                let msg = from_glib_borrow(msg);
57                let username: Borrowed<glib::GString> = from_glib_borrow(username);
58                let callback = &*(user_data as *mut P);
59                (*callback)(&domain, &msg, username.as_str()).to_glib_full()
60            }
61        }
62        let callback = Some(callback_func::<P> as _);
63        unsafe extern "C" fn dnotify_func<
64            P: Fn(&AuthDomainDigest, &ServerMessage, &str) -> Option<String> + 'static,
65        >(
66            data: glib::ffi::gpointer,
67        ) {
68            unsafe {
69                let _callback = Box_::from_raw(data as *mut P);
70            }
71        }
72        let destroy_call3 = Some(dnotify_func::<P> as _);
73        let super_callback0: Box_<P> = callback_data;
74        unsafe {
75            ffi::soup_auth_domain_digest_set_auth_callback(
76                self.to_glib_none().0,
77                callback,
78                Box_::into_raw(super_callback0) as *mut _,
79                destroy_call3,
80            );
81        }
82    }
83
84    //#[doc(alias = "auth-data")]
85    //pub fn auth_data(&self) -> /*Unimplemented*/Basic: Pointer {
86    //    ObjectExt::property(self, "auth-data")
87    //}
88
89    //#[doc(alias = "auth-data")]
90    //pub fn set_auth_data(&self, auth_data: /*Unimplemented*/Basic: Pointer) {
91    //    ObjectExt::set_property(self,"auth-data", auth_data)
92    //}
93
94    #[doc(alias = "soup_auth_domain_digest_encode_password")]
95    pub fn encode_password(username: &str, realm: &str, password: &str) -> Option<glib::GString> {
96        assert_initialized_main_thread!();
97        unsafe {
98            from_glib_full(ffi::soup_auth_domain_digest_encode_password(
99                username.to_glib_none().0,
100                realm.to_glib_none().0,
101                password.to_glib_none().0,
102            ))
103        }
104    }
105
106    #[doc(alias = "auth-data")]
107    pub fn connect_auth_data_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
108        unsafe extern "C" fn notify_auth_data_trampoline<F: Fn(&AuthDomainDigest) + 'static>(
109            this: *mut ffi::SoupAuthDomainDigest,
110            _param_spec: glib::ffi::gpointer,
111            f: glib::ffi::gpointer,
112        ) {
113            unsafe {
114                let f: &F = &*(f as *const F);
115                f(&from_glib_borrow(this))
116            }
117        }
118        unsafe {
119            let f: Box_<F> = Box_::new(f);
120            connect_raw(
121                self.as_ptr() as *mut _,
122                c"notify::auth-data".as_ptr(),
123                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
124                    notify_auth_data_trampoline::<F> as *const (),
125                )),
126                Box_::into_raw(f),
127            )
128        }
129    }
130}
131
132impl Default for AuthDomainDigest {
133    fn default() -> Self {
134        glib::object::Object::new::<Self>()
135    }
136}
137
138// rustdoc-stripper-ignore-next
139/// A [builder-pattern] type to construct [`AuthDomainDigest`] objects.
140///
141/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
142#[must_use = "The builder must be built to be used"]
143pub struct AuthDomainDigestBuilder {
144    builder: glib::object::ObjectBuilder<'static, AuthDomainDigest>,
145}
146
147impl AuthDomainDigestBuilder {
148    fn new() -> Self {
149        Self {
150            builder: glib::object::Object::builder(),
151        }
152    }
153
154    //pub fn auth_data(self, auth_data: /*Unimplemented*/Basic: Pointer) -> Self {
155    //    Self { builder: self.builder.property("auth-data", auth_data), }
156    //}
157
158    //pub fn filter_data(self, filter_data: /*Unimplemented*/Basic: Pointer) -> Self {
159    //    Self { builder: self.builder.property("filter-data", filter_data), }
160    //}
161
162    //pub fn generic_auth_data(self, generic_auth_data: /*Unimplemented*/Basic: Pointer) -> Self {
163    //    Self { builder: self.builder.property("generic-auth-data", generic_auth_data), }
164    //}
165
166    pub fn proxy(self, proxy: bool) -> Self {
167        Self {
168            builder: self.builder.property("proxy", proxy),
169        }
170    }
171
172    pub fn realm(self, realm: impl Into<glib::GString>) -> Self {
173        Self {
174            builder: self.builder.property("realm", realm.into()),
175        }
176    }
177
178    // rustdoc-stripper-ignore-next
179    /// Build the [`AuthDomainDigest`].
180    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
181    pub fn build(self) -> AuthDomainDigest {
182        assert_initialized_main_thread!();
183        self.builder.build()
184    }
185}