1 /*
2  * This file is part of libsecret-d.
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/
7  */
8 
9 // generated automatically - do not change
10 // find conversion definition on APILookup.txt
11 
12 
13 module libsecret.Prompt;
14 
15 private import gio.AsyncInitableIF;
16 private import gio.AsyncInitableT;
17 private import gio.AsyncResultIF;
18 private import gio.Cancellable;
19 private import gio.DBusInterfaceIF;
20 private import gio.DBusInterfaceT;
21 private import gio.DBusProxy;
22 private import gio.InitableIF;
23 private import gio.InitableT;
24 private import glib.ErrorG;
25 private import glib.GException;
26 private import glib.Str;
27 private import glib.Variant;
28 private import glib.VariantType;
29 private import libsecret.c.functions;
30 public  import libsecret.c.types;
31 
32 
33 /**
34  * A proxy object representing a prompt that the Secret Service will display
35  * to the user.
36  */
37 public class Prompt : DBusProxy
38 {
39 	/** the main Gtk struct */
40 	protected SecretPrompt* secretPrompt;
41 
42 	/** Get the main Gtk struct */
43 	public SecretPrompt* getPromptStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return secretPrompt;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)secretPrompt;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (SecretPrompt* secretPrompt, bool ownedRef = false)
60 	{
61 		this.secretPrompt = secretPrompt;
62 		super(cast(GDBusProxy*)secretPrompt, ownedRef);
63 	}
64 
65 
66 	/** */
67 	public static GType getType()
68 	{
69 		return secret_prompt_get_type();
70 	}
71 
72 	/**
73 	 * Runs a prompt and performs the prompting. Returns %TRUE if the prompt
74 	 * was completed and not dismissed.
75 	 *
76 	 * If @window_id is non-null then it is used as an XWindow id on Linux. The API
77 	 * expects this id to be converted to a string using the <literal>%d</literal>
78 	 * printf format. The Secret Service can make its prompt transient for the window
79 	 * with this id. In some Secret Service implementations this is not possible, so
80 	 * the behavior depending on this should degrade gracefully.
81 	 *
82 	 * This method will return immediately and complete asynchronously.
83 	 *
84 	 * Params:
85 	 *     windowId = string form of XWindow id for parent window to be transient for
86 	 *     returnType = the variant type of the prompt result
87 	 *     cancellable = optional cancellation object
88 	 *     callback = called when the operation completes
89 	 *     userData = data to be passed to the callback
90 	 */
91 	public void perform(string windowId, VariantType returnType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
92 	{
93 		secret_prompt_perform(secretPrompt, Str.toStringz(windowId), (returnType is null) ? null : returnType.getVariantTypeStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
94 	}
95 
96 	/**
97 	 * Complete asynchronous operation to run a prompt and perform the prompting.
98 	 *
99 	 * Returns a variant result if the prompt was completed and not dismissed. The
100 	 * type of result depends on the action the prompt is completing, and is
101 	 * defined in the Secret Service DBus API specification.
102 	 *
103 	 * Params:
104 	 *     result = the asynchronous result passed to the callback
105 	 *
106 	 * Returns: %NULL if the prompt was dismissed or an error occurred,
107 	 *     a variant result if the prompt was successful
108 	 *
109 	 * Throws: GException on failure.
110 	 */
111 	public Variant performFinish(AsyncResultIF result)
112 	{
113 		GError* err = null;
114 
115 		auto p = secret_prompt_perform_finish(secretPrompt, (result is null) ? null : result.getAsyncResultStruct(), &err);
116 
117 		if (err !is null)
118 		{
119 			throw new GException( new ErrorG(err) );
120 		}
121 
122 		if(p is null)
123 		{
124 			return null;
125 		}
126 
127 		return new Variant(cast(GVariant*) p, true);
128 	}
129 
130 	/**
131 	 * Runs a prompt and performs the prompting. Returns a variant result if the
132 	 * prompt was completed and not dismissed. The type of result depends on the
133 	 * action the prompt is completing, and is defined in the Secret Service DBus
134 	 * API specification.
135 	 *
136 	 * If @window_id is non-null then it is used as an XWindow id on Linux. The API
137 	 * expects this id to be converted to a string using the <literal>%d</literal>
138 	 * printf format. The Secret Service can make its prompt transient for the window
139 	 * with this id. In some Secret Service implementations this is not possible,
140 	 * so the behavior depending on this should degrade gracefully.
141 	 *
142 	 * This method may block indefinitely and should not be used in user interface
143 	 * threads.
144 	 *
145 	 * Params:
146 	 *     windowId = string form of XWindow id for parent window to be transient for
147 	 *     cancellable = optional cancellation object
148 	 *     returnType = the variant type of the prompt result
149 	 *
150 	 * Returns: %NULL if the prompt was dismissed or an error occurred
151 	 *
152 	 * Throws: GException on failure.
153 	 */
154 	public Variant performSync(string windowId, Cancellable cancellable, VariantType returnType)
155 	{
156 		GError* err = null;
157 
158 		auto p = secret_prompt_perform_sync(secretPrompt, Str.toStringz(windowId), (cancellable is null) ? null : cancellable.getCancellableStruct(), (returnType is null) ? null : returnType.getVariantTypeStruct(), &err);
159 
160 		if (err !is null)
161 		{
162 			throw new GException( new ErrorG(err) );
163 		}
164 
165 		if(p is null)
166 		{
167 			return null;
168 		}
169 
170 		return new Variant(cast(GVariant*) p, true);
171 	}
172 
173 	/**
174 	 * Runs a prompt and performs the prompting. Returns a variant result if the
175 	 * prompt was completed and not dismissed. The type of result depends on the
176 	 * action the prompt is completing, and is defined in the Secret Service DBus
177 	 * API specification.
178 	 *
179 	 * If @window_id is non-null then it is used as an XWindow id on Linux. The API
180 	 * expects this id to be converted to a string using the <literal>%d</literal>
181 	 * printf format. The Secret Service can make its prompt transient for the window
182 	 * with this id. In some Secret Service implementations this is not possible, so
183 	 * the behavior depending on this should degrade gracefully.
184 	 *
185 	 * This runs the dialog in a recursive mainloop. When run from a user interface
186 	 * thread, this means the user interface will remain responsive. Care should be
187 	 * taken that appropriate user interface actions are disabled while running the
188 	 * prompt.
189 	 *
190 	 * Params:
191 	 *     windowId = string form of XWindow id for parent window to be transient for
192 	 *     cancellable = optional cancellation object
193 	 *     returnType = the variant type of the prompt result
194 	 *
195 	 * Returns: %NULL if the prompt was dismissed or an error occurred
196 	 *
197 	 * Throws: GException on failure.
198 	 */
199 	public Variant run(string windowId, Cancellable cancellable, VariantType returnType)
200 	{
201 		GError* err = null;
202 
203 		auto p = secret_prompt_run(secretPrompt, Str.toStringz(windowId), (cancellable is null) ? null : cancellable.getCancellableStruct(), (returnType is null) ? null : returnType.getVariantTypeStruct(), &err);
204 
205 		if (err !is null)
206 		{
207 			throw new GException( new ErrorG(err) );
208 		}
209 
210 		if(p is null)
211 		{
212 			return null;
213 		}
214 
215 		return new Variant(cast(GVariant*) p, true);
216 	}
217 }