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