1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// A prompt in the Service
    ///
    /// A proxy object representing a prompt that the Secret Service will display
    /// to the user.
    ///
    /// Certain actions on the Secret Service require user prompting to complete,
    /// such as creating a collection, or unlocking a collection. When such a prompt
    /// is necessary, then a #SecretPrompt object is created by this library, and
    /// passed to the [`ServiceExt::prompt()`][crate::prelude::ServiceExt::prompt()] method. In this way it is handled
    /// automatically.
    ///
    /// In order to customize prompt handling, override the
    /// `vfunc::Service::prompt_async` and `vfunc::Service::prompt_finish` virtual
    /// methods of the [`Service`][crate::Service] class.
    ///
    /// # Implements
    ///
    /// [`PromptExt`][trait@crate::prelude::PromptExt], [`trait@gio::prelude::DBusProxyExt`], [`trait@gio::prelude::DBusInterfaceExt`], [`trait@gio::prelude::InitableExt`], [`PromptExtManual`][trait@crate::prelude::PromptExtManual]
    #[doc(alias = "SecretPrompt")]
    pub struct Prompt(Object<ffi::SecretPrompt, ffi::SecretPromptClass>) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable;

    match fn {
        type_ => || ffi::secret_prompt_get_type(),
    }
}

impl Prompt {
    pub const NONE: Option<&'static Prompt> = None;
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Prompt>> Sealed for T {}
}

/// Trait containing all [`struct@Prompt`] methods.
///
/// # Implementors
///
/// [`Prompt`][struct@crate::Prompt]
pub trait PromptExt: IsA<Prompt> + sealed::Sealed + 'static {
    /// Runs a prompt and performs the prompting.
    ///
    /// Returns a variant result if the prompt was completed and not dismissed. The
    /// type of result depends on the action the prompt is completing, and is defined
    /// in the Secret Service DBus API specification.
    ///
    /// If @window_id is non-null then it is used as an XWindow id on Linux. The API
    /// expects this id to be converted to a string using the ``d`` printf format. The
    /// Secret Service can make its prompt transient for the window with this id. In
    /// some Secret Service implementations this is not possible, so the behavior
    /// depending on this should degrade gracefully.
    ///
    /// This method may block indefinitely and should not be used in user interface
    /// threads.
    /// ## `window_id`
    /// string form of XWindow id for parent window to be transient for
    /// ## `cancellable`
    /// optional cancellation object
    /// ## `return_type`
    /// the variant type of the prompt result
    ///
    /// # Returns
    ///
    /// [`None`] if the prompt was dismissed or an error occurred
    #[doc(alias = "secret_prompt_perform_sync")]
    fn perform_sync(
        &self,
        window_id: Option<&str>,
        cancellable: Option<&impl IsA<gio::Cancellable>>,
        return_type: &glib::VariantTy,
    ) -> Result<glib::Variant, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::secret_prompt_perform_sync(
                self.as_ref().to_glib_none().0,
                window_id.to_glib_none().0,
                cancellable.map(|p| p.as_ref()).to_glib_none().0,
                return_type.to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_full(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Runs a prompt and performs the prompting.
    ///
    /// Returns a variant result if the prompt was completed and not dismissed. The
    /// type of result depends on the action the prompt is completing, and is defined
    /// in the Secret Service DBus API specification.
    ///
    /// If @window_id is non-null then it is used as an XWindow id on Linux. The API
    /// expects this id to be converted to a string using the ``d`` printf format. The
    /// Secret Service can make its prompt transient for the window with this id. In
    /// some Secret Service implementations this is not possible, so the behavior
    /// depending on this should degrade gracefully.
    ///
    /// This runs the dialog in a recursive mainloop. When run from a user interface
    /// thread, this means the user interface will remain responsive. Care should be
    /// taken that appropriate user interface actions are disabled while running the
    /// prompt.
    /// ## `window_id`
    /// string form of XWindow id for parent window to be transient for
    /// ## `cancellable`
    /// optional cancellation object
    /// ## `return_type`
    /// the variant type of the prompt result
    ///
    /// # Returns
    ///
    /// [`None`] if the prompt was dismissed or an error occurred
    #[doc(alias = "secret_prompt_run")]
    fn run(
        &self,
        window_id: Option<&str>,
        cancellable: Option<&impl IsA<gio::Cancellable>>,
        return_type: &glib::VariantTy,
    ) -> Result<glib::Variant, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::secret_prompt_run(
                self.as_ref().to_glib_none().0,
                window_id.to_glib_none().0,
                cancellable.map(|p| p.as_ref()).to_glib_none().0,
                return_type.to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_full(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }
}

impl<O: IsA<Prompt>> PromptExt for O {}