1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.MountOperation;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ArrayG;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 public  import gtkc.giotypes;
35 private import std.algorithm;
36 
37 
38 /**
39  * #GMountOperation provides a mechanism for interacting with the user.
40  * It can be used for authenticating mountable operations, such as loop
41  * mounting files, hard drive partitions or server locations. It can
42  * also be used to ask the user questions or show a list of applications
43  * preventing unmount or eject operations from completing.
44  * 
45  * Note that #GMountOperation is used for more than just #GMount
46  * objects – for example it is also used in g_drive_start() and
47  * g_drive_stop().
48  * 
49  * Users should instantiate a subclass of this that implements all the
50  * various callbacks to show the required dialogs, such as
51  * #GtkMountOperation. If no user interaction is desired (for example
52  * when automounting filesystems at login time), usually %NULL can be
53  * passed, see each method taking a #GMountOperation for details.
54  * 
55  * The term ‘TCRYPT’ is used to mean ‘compatible with TrueCrypt and VeraCrypt’.
56  * [TrueCrypt](https://en.wikipedia.org/wiki/TrueCrypt) is a discontinued system for
57  * encrypting file containers, partitions or whole disks, typically used with Windows.
58  * [VeraCrypt](https://www.veracrypt.fr/) is a maintained fork of TrueCrypt with various
59  * improvements and auditing fixes.
60  */
61 public class MountOperation : ObjectG
62 {
63 	/** the main Gtk struct */
64 	protected GMountOperation* gMountOperation;
65 
66 	/** Get the main Gtk struct */
67 	public GMountOperation* getMountOperationStruct(bool transferOwnership = false)
68 	{
69 		if (transferOwnership)
70 			ownedRef = false;
71 		return gMountOperation;
72 	}
73 
74 	/** the main Gtk struct as a void* */
75 	protected override void* getStruct()
76 	{
77 		return cast(void*)gMountOperation;
78 	}
79 
80 	/**
81 	 * Sets our main struct and passes it to the parent class.
82 	 */
83 	public this (GMountOperation* gMountOperation, bool ownedRef = false)
84 	{
85 		this.gMountOperation = gMountOperation;
86 		super(cast(GObject*)gMountOperation, ownedRef);
87 	}
88 
89 
90 	/** */
91 	public static GType getType()
92 	{
93 		return g_mount_operation_get_type();
94 	}
95 
96 	/**
97 	 * Creates a new mount operation.
98 	 *
99 	 * Returns: a #GMountOperation.
100 	 *
101 	 * Throws: ConstructionException GTK+ fails to create the object.
102 	 */
103 	public this()
104 	{
105 		auto __p = g_mount_operation_new();
106 
107 		if(__p is null)
108 		{
109 			throw new ConstructionException("null returned by new");
110 		}
111 
112 		this(cast(GMountOperation*) __p, true);
113 	}
114 
115 	/**
116 	 * Check to see whether the mount operation is being used
117 	 * for an anonymous user.
118 	 *
119 	 * Returns: %TRUE if mount operation is anonymous.
120 	 */
121 	public bool getAnonymous()
122 	{
123 		return g_mount_operation_get_anonymous(gMountOperation) != 0;
124 	}
125 
126 	/**
127 	 * Gets a choice from the mount operation.
128 	 *
129 	 * Returns: an integer containing an index of the user's choice from
130 	 *     the choice's list, or `0`.
131 	 */
132 	public int getChoice()
133 	{
134 		return g_mount_operation_get_choice(gMountOperation);
135 	}
136 
137 	/**
138 	 * Gets the domain of the mount operation.
139 	 *
140 	 * Returns: a string set to the domain.
141 	 */
142 	public string getDomain()
143 	{
144 		return Str.toString(g_mount_operation_get_domain(gMountOperation));
145 	}
146 
147 	/**
148 	 * Check to see whether the mount operation is being used
149 	 * for a TCRYPT hidden volume.
150 	 *
151 	 * Returns: %TRUE if mount operation is for hidden volume.
152 	 *
153 	 * Since: 2.58
154 	 */
155 	public bool getIsTcryptHiddenVolume()
156 	{
157 		return g_mount_operation_get_is_tcrypt_hidden_volume(gMountOperation) != 0;
158 	}
159 
160 	/**
161 	 * Check to see whether the mount operation is being used
162 	 * for a TCRYPT system volume.
163 	 *
164 	 * Returns: %TRUE if mount operation is for system volume.
165 	 *
166 	 * Since: 2.58
167 	 */
168 	public bool getIsTcryptSystemVolume()
169 	{
170 		return g_mount_operation_get_is_tcrypt_system_volume(gMountOperation) != 0;
171 	}
172 
173 	/**
174 	 * Gets a password from the mount operation.
175 	 *
176 	 * Returns: a string containing the password within @op.
177 	 */
178 	public string getPassword()
179 	{
180 		return Str.toString(g_mount_operation_get_password(gMountOperation));
181 	}
182 
183 	/**
184 	 * Gets the state of saving passwords for the mount operation.
185 	 *
186 	 * Returns: a #GPasswordSave flag.
187 	 */
188 	public GPasswordSave getPasswordSave()
189 	{
190 		return g_mount_operation_get_password_save(gMountOperation);
191 	}
192 
193 	/**
194 	 * Gets a PIM from the mount operation.
195 	 *
196 	 * Returns: The VeraCrypt PIM within @op.
197 	 *
198 	 * Since: 2.58
199 	 */
200 	public uint getPim()
201 	{
202 		return g_mount_operation_get_pim(gMountOperation);
203 	}
204 
205 	/**
206 	 * Get the user name from the mount operation.
207 	 *
208 	 * Returns: a string containing the user name.
209 	 */
210 	public string getUsername()
211 	{
212 		return Str.toString(g_mount_operation_get_username(gMountOperation));
213 	}
214 
215 	/**
216 	 * Emits the #GMountOperation::reply signal.
217 	 *
218 	 * Params:
219 	 *     result = a #GMountOperationResult
220 	 */
221 	public void reply(GMountOperationResult result)
222 	{
223 		g_mount_operation_reply(gMountOperation, result);
224 	}
225 
226 	/**
227 	 * Sets the mount operation to use an anonymous user if @anonymous is %TRUE.
228 	 *
229 	 * Params:
230 	 *     anonymous = boolean value.
231 	 */
232 	public void setAnonymous(bool anonymous)
233 	{
234 		g_mount_operation_set_anonymous(gMountOperation, anonymous);
235 	}
236 
237 	/**
238 	 * Sets a default choice for the mount operation.
239 	 *
240 	 * Params:
241 	 *     choice = an integer.
242 	 */
243 	public void setChoice(int choice)
244 	{
245 		g_mount_operation_set_choice(gMountOperation, choice);
246 	}
247 
248 	/**
249 	 * Sets the mount operation's domain.
250 	 *
251 	 * Params:
252 	 *     domain = the domain to set.
253 	 */
254 	public void setDomain(string domain)
255 	{
256 		g_mount_operation_set_domain(gMountOperation, Str.toStringz(domain));
257 	}
258 
259 	/**
260 	 * Sets the mount operation to use a hidden volume if @hidden_volume is %TRUE.
261 	 *
262 	 * Params:
263 	 *     hiddenVolume = boolean value.
264 	 *
265 	 * Since: 2.58
266 	 */
267 	public void setIsTcryptHiddenVolume(bool hiddenVolume)
268 	{
269 		g_mount_operation_set_is_tcrypt_hidden_volume(gMountOperation, hiddenVolume);
270 	}
271 
272 	/**
273 	 * Sets the mount operation to use a system volume if @system_volume is %TRUE.
274 	 *
275 	 * Params:
276 	 *     systemVolume = boolean value.
277 	 *
278 	 * Since: 2.58
279 	 */
280 	public void setIsTcryptSystemVolume(bool systemVolume)
281 	{
282 		g_mount_operation_set_is_tcrypt_system_volume(gMountOperation, systemVolume);
283 	}
284 
285 	/**
286 	 * Sets the mount operation's password to @password.
287 	 *
288 	 * Params:
289 	 *     password = password to set.
290 	 */
291 	public void setPassword(string password)
292 	{
293 		g_mount_operation_set_password(gMountOperation, Str.toStringz(password));
294 	}
295 
296 	/**
297 	 * Sets the state of saving passwords for the mount operation.
298 	 *
299 	 * Params:
300 	 *     save = a set of #GPasswordSave flags.
301 	 */
302 	public void setPasswordSave(GPasswordSave save)
303 	{
304 		g_mount_operation_set_password_save(gMountOperation, save);
305 	}
306 
307 	/**
308 	 * Sets the mount operation's PIM to @pim.
309 	 *
310 	 * Params:
311 	 *     pim = an unsigned integer.
312 	 *
313 	 * Since: 2.58
314 	 */
315 	public void setPim(uint pim)
316 	{
317 		g_mount_operation_set_pim(gMountOperation, pim);
318 	}
319 
320 	/**
321 	 * Sets the user name within @op to @username.
322 	 *
323 	 * Params:
324 	 *     username = input username.
325 	 */
326 	public void setUsername(string username)
327 	{
328 		g_mount_operation_set_username(gMountOperation, Str.toStringz(username));
329 	}
330 
331 	/**
332 	 * Emitted by the backend when e.g. a device becomes unavailable
333 	 * while a mount operation is in progress.
334 	 *
335 	 * Implementations of GMountOperation should handle this signal
336 	 * by dismissing open password dialogs.
337 	 *
338 	 * Since: 2.20
339 	 */
340 	gulong addOnAborted(void delegate(MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
341 	{
342 		return Signals.connect(this, "aborted", dlg, connectFlags ^ ConnectFlags.SWAPPED);
343 	}
344 
345 	/**
346 	 * Emitted when a mount operation asks the user for a password.
347 	 *
348 	 * If the message contains a line break, the first line should be
349 	 * presented as a heading. For example, it may be used as the
350 	 * primary text in a #GtkMessageDialog.
351 	 *
352 	 * Params:
353 	 *     message = string containing a message to display to the user.
354 	 *     defaultUser = string containing the default user name.
355 	 *     defaultDomain = string containing the default domain.
356 	 *     flags = a set of #GAskPasswordFlags.
357 	 */
358 	gulong addOnAskPassword(void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
359 	{
360 		return Signals.connect(this, "ask-password", dlg, connectFlags ^ ConnectFlags.SWAPPED);
361 	}
362 
363 	/**
364 	 * Emitted when asking the user a question and gives a list of
365 	 * choices for the user to choose from.
366 	 *
367 	 * If the message contains a line break, the first line should be
368 	 * presented as a heading. For example, it may be used as the
369 	 * primary text in a #GtkMessageDialog.
370 	 *
371 	 * Params:
372 	 *     message = string containing a message to display to the user.
373 	 *     choices = an array of strings for each possible choice.
374 	 */
375 	gulong addOnAskQuestion(void delegate(string, string[], MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
376 	{
377 		return Signals.connect(this, "ask-question", dlg, connectFlags ^ ConnectFlags.SWAPPED);
378 	}
379 
380 	/**
381 	 * Emitted when the user has replied to the mount operation.
382 	 *
383 	 * Params:
384 	 *     result = a #GMountOperationResult indicating how the request was handled
385 	 */
386 	gulong addOnReply(void delegate(GMountOperationResult, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
387 	{
388 		return Signals.connect(this, "reply", dlg, connectFlags ^ ConnectFlags.SWAPPED);
389 	}
390 
391 	/**
392 	 * Emitted when one or more processes are blocking an operation
393 	 * e.g. unmounting/ejecting a #GMount or stopping a #GDrive.
394 	 *
395 	 * Note that this signal may be emitted several times to update the
396 	 * list of blocking processes as processes close files. The
397 	 * application should only respond with g_mount_operation_reply() to
398 	 * the latest signal (setting #GMountOperation:choice to the choice
399 	 * the user made).
400 	 *
401 	 * If the message contains a line break, the first line should be
402 	 * presented as a heading. For example, it may be used as the
403 	 * primary text in a #GtkMessageDialog.
404 	 *
405 	 * Params:
406 	 *     message = string containing a message to display to the user.
407 	 *     processes = an array of #GPid for processes
408 	 *         blocking the operation.
409 	 *     choices = an array of strings for each possible choice.
410 	 *
411 	 * Since: 2.22
412 	 */
413 	gulong addOnShowProcesses(void delegate(string, ArrayG, string[], MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
414 	{
415 		return Signals.connect(this, "show-processes", dlg, connectFlags ^ ConnectFlags.SWAPPED);
416 	}
417 
418 	/**
419 	 * Emitted when an unmount operation has been busy for more than some time
420 	 * (typically 1.5 seconds).
421 	 *
422 	 * When unmounting or ejecting a volume, the kernel might need to flush
423 	 * pending data in its buffers to the volume stable storage, and this operation
424 	 * can take a considerable amount of time. This signal may be emitted several
425 	 * times as long as the unmount operation is outstanding, and then one
426 	 * last time when the operation is completed, with @bytes_left set to zero.
427 	 *
428 	 * Implementations of GMountOperation should handle this signal by
429 	 * showing an UI notification, and then dismiss it, or show another notification
430 	 * of completion, when @bytes_left reaches zero.
431 	 *
432 	 * If the message contains a line break, the first line should be
433 	 * presented as a heading. For example, it may be used as the
434 	 * primary text in a #GtkMessageDialog.
435 	 *
436 	 * Params:
437 	 *     message = string containing a mesage to display to the user
438 	 *     timeLeft = the estimated time left before the operation completes,
439 	 *         in microseconds, or -1
440 	 *     bytesLeft = the amount of bytes to be written before the operation
441 	 *         completes (or -1 if such amount is not known), or zero if the operation
442 	 *         is completed
443 	 *
444 	 * Since: 2.34
445 	 */
446 	gulong addOnShowUnmountProgress(void delegate(string, long, long, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
447 	{
448 		return Signals.connect(this, "show-unmount-progress", dlg, connectFlags ^ ConnectFlags.SWAPPED);
449 	}
450 }