Skip to main content

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