Merge branch '976-disable-assert-checks' into 'master'
[glib.git] / gio / gmountoperation.c
blobd59acb3b5d9c29289ed1f7f4f63e28d1294e8a86
1 /* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Alexander Larsson <alexl@redhat.com>
21 #include "config.h"
23 #include <string.h>
25 #include "gmountoperation.h"
26 #include "gioenumtypes.h"
27 #include "glibintl.h"
30 /**
31 * SECTION:gmountoperation
32 * @short_description: Object used for authentication and user interaction
33 * @include: gio/gio.h
35 * #GMountOperation provides a mechanism for interacting with the user.
36 * It can be used for authenticating mountable operations, such as loop
37 * mounting files, hard drive partitions or server locations. It can
38 * also be used to ask the user questions or show a list of applications
39 * preventing unmount or eject operations from completing.
41 * Note that #GMountOperation is used for more than just #GMount
42 * objects – for example it is also used in g_drive_start() and
43 * g_drive_stop().
45 * Users should instantiate a subclass of this that implements all the
46 * various callbacks to show the required dialogs, such as
47 * #GtkMountOperation. If no user interaction is desired (for example
48 * when automounting filesystems at login time), usually %NULL can be
49 * passed, see each method taking a #GMountOperation for details.
51 * The term ‘TCRYPT’ is used to mean ‘compatible with TrueCrypt and VeraCrypt’.
52 * [TrueCrypt](https://en.wikipedia.org/wiki/TrueCrypt) is a discontinued system for
53 * encrypting file containers, partitions or whole disks, typically used with Windows.
54 * [VeraCrypt](https://www.veracrypt.fr/) is a maintained fork of TrueCrypt with various
55 * improvements and auditing fixes.
58 enum {
59 ASK_PASSWORD,
60 ASK_QUESTION,
61 REPLY,
62 ABORTED,
63 SHOW_PROCESSES,
64 SHOW_UNMOUNT_PROGRESS,
65 LAST_SIGNAL
68 static guint signals[LAST_SIGNAL] = { 0 };
70 struct _GMountOperationPrivate {
71 char *password;
72 char *user;
73 char *domain;
74 gboolean anonymous;
75 GPasswordSave password_save;
76 int choice;
77 gboolean hidden_volume;
78 gboolean system_volume;
79 guint pim;
82 enum {
83 PROP_0,
84 PROP_USERNAME,
85 PROP_PASSWORD,
86 PROP_ANONYMOUS,
87 PROP_DOMAIN,
88 PROP_PASSWORD_SAVE,
89 PROP_CHOICE,
90 PROP_IS_TCRYPT_HIDDEN_VOLUME,
91 PROP_IS_TCRYPT_SYSTEM_VOLUME,
92 PROP_PIM
95 G_DEFINE_TYPE_WITH_PRIVATE (GMountOperation, g_mount_operation, G_TYPE_OBJECT)
97 static void
98 g_mount_operation_set_property (GObject *object,
99 guint prop_id,
100 const GValue *value,
101 GParamSpec *pspec)
103 GMountOperation *operation;
105 operation = G_MOUNT_OPERATION (object);
107 switch (prop_id)
109 case PROP_USERNAME:
110 g_mount_operation_set_username (operation,
111 g_value_get_string (value));
112 break;
114 case PROP_PASSWORD:
115 g_mount_operation_set_password (operation,
116 g_value_get_string (value));
117 break;
119 case PROP_ANONYMOUS:
120 g_mount_operation_set_anonymous (operation,
121 g_value_get_boolean (value));
122 break;
124 case PROP_DOMAIN:
125 g_mount_operation_set_domain (operation,
126 g_value_get_string (value));
127 break;
129 case PROP_PASSWORD_SAVE:
130 g_mount_operation_set_password_save (operation,
131 g_value_get_enum (value));
132 break;
134 case PROP_CHOICE:
135 g_mount_operation_set_choice (operation,
136 g_value_get_int (value));
137 break;
139 case PROP_IS_TCRYPT_HIDDEN_VOLUME:
140 g_mount_operation_set_is_tcrypt_hidden_volume (operation,
141 g_value_get_boolean (value));
142 break;
144 case PROP_IS_TCRYPT_SYSTEM_VOLUME:
145 g_mount_operation_set_is_tcrypt_system_volume (operation,
146 g_value_get_boolean (value));
147 break;
149 case PROP_PIM:
150 g_mount_operation_set_pim (operation,
151 g_value_get_uint (value));
152 break;
154 default:
155 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
156 break;
161 static void
162 g_mount_operation_get_property (GObject *object,
163 guint prop_id,
164 GValue *value,
165 GParamSpec *pspec)
167 GMountOperation *operation;
168 GMountOperationPrivate *priv;
170 operation = G_MOUNT_OPERATION (object);
171 priv = operation->priv;
173 switch (prop_id)
175 case PROP_USERNAME:
176 g_value_set_string (value, priv->user);
177 break;
179 case PROP_PASSWORD:
180 g_value_set_string (value, priv->password);
181 break;
183 case PROP_ANONYMOUS:
184 g_value_set_boolean (value, priv->anonymous);
185 break;
187 case PROP_DOMAIN:
188 g_value_set_string (value, priv->domain);
189 break;
191 case PROP_PASSWORD_SAVE:
192 g_value_set_enum (value, priv->password_save);
193 break;
195 case PROP_CHOICE:
196 g_value_set_int (value, priv->choice);
197 break;
199 case PROP_IS_TCRYPT_HIDDEN_VOLUME:
200 g_value_set_boolean (value, priv->hidden_volume);
201 break;
203 case PROP_IS_TCRYPT_SYSTEM_VOLUME:
204 g_value_set_boolean (value, priv->system_volume);
205 break;
207 case PROP_PIM:
208 g_value_set_uint (value, priv->pim);
209 break;
211 default:
212 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
213 break;
218 static void
219 g_mount_operation_finalize (GObject *object)
221 GMountOperation *operation;
222 GMountOperationPrivate *priv;
224 operation = G_MOUNT_OPERATION (object);
226 priv = operation->priv;
228 g_free (priv->password);
229 g_free (priv->user);
230 g_free (priv->domain);
232 G_OBJECT_CLASS (g_mount_operation_parent_class)->finalize (object);
235 static gboolean
236 reply_non_handled_in_idle (gpointer data)
238 GMountOperation *op = data;
240 g_mount_operation_reply (op, G_MOUNT_OPERATION_UNHANDLED);
241 return G_SOURCE_REMOVE;
244 static void
245 ask_password (GMountOperation *op,
246 const char *message,
247 const char *default_user,
248 const char *default_domain,
249 GAskPasswordFlags flags)
251 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
252 reply_non_handled_in_idle,
253 g_object_ref (op),
254 g_object_unref);
257 static void
258 ask_question (GMountOperation *op,
259 const char *message,
260 const char *choices[])
262 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
263 reply_non_handled_in_idle,
264 g_object_ref (op),
265 g_object_unref);
268 static void
269 show_processes (GMountOperation *op,
270 const gchar *message,
271 GArray *processes,
272 const gchar *choices[])
274 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
275 reply_non_handled_in_idle,
276 g_object_ref (op),
277 g_object_unref);
280 static void
281 show_unmount_progress (GMountOperation *op,
282 const gchar *message,
283 gint64 time_left,
284 gint64 bytes_left)
286 /* nothing to do */
289 static void
290 g_mount_operation_class_init (GMountOperationClass *klass)
292 GObjectClass *object_class;
294 object_class = G_OBJECT_CLASS (klass);
295 object_class->finalize = g_mount_operation_finalize;
296 object_class->get_property = g_mount_operation_get_property;
297 object_class->set_property = g_mount_operation_set_property;
299 klass->ask_password = ask_password;
300 klass->ask_question = ask_question;
301 klass->show_processes = show_processes;
302 klass->show_unmount_progress = show_unmount_progress;
305 * GMountOperation::ask-password:
306 * @op: a #GMountOperation requesting a password.
307 * @message: string containing a message to display to the user.
308 * @default_user: string containing the default user name.
309 * @default_domain: string containing the default domain.
310 * @flags: a set of #GAskPasswordFlags.
312 * Emitted when a mount operation asks the user for a password.
314 * If the message contains a line break, the first line should be
315 * presented as a heading. For example, it may be used as the
316 * primary text in a #GtkMessageDialog.
318 signals[ASK_PASSWORD] =
319 g_signal_new (I_("ask-password"),
320 G_TYPE_FROM_CLASS (object_class),
321 G_SIGNAL_RUN_LAST,
322 G_STRUCT_OFFSET (GMountOperationClass, ask_password),
323 NULL, NULL,
324 NULL,
325 G_TYPE_NONE, 4,
326 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ASK_PASSWORD_FLAGS);
329 * GMountOperation::ask-question:
330 * @op: a #GMountOperation asking a question.
331 * @message: string containing a message to display to the user.
332 * @choices: an array of strings for each possible choice.
334 * Emitted when asking the user a question and gives a list of
335 * choices for the user to choose from.
337 * If the message contains a line break, the first line should be
338 * presented as a heading. For example, it may be used as the
339 * primary text in a #GtkMessageDialog.
341 signals[ASK_QUESTION] =
342 g_signal_new (I_("ask-question"),
343 G_TYPE_FROM_CLASS (object_class),
344 G_SIGNAL_RUN_LAST,
345 G_STRUCT_OFFSET (GMountOperationClass, ask_question),
346 NULL, NULL,
347 NULL,
348 G_TYPE_NONE, 2,
349 G_TYPE_STRING, G_TYPE_STRV);
352 * GMountOperation::reply:
353 * @op: a #GMountOperation.
354 * @result: a #GMountOperationResult indicating how the request was handled
356 * Emitted when the user has replied to the mount operation.
358 signals[REPLY] =
359 g_signal_new (I_("reply"),
360 G_TYPE_FROM_CLASS (object_class),
361 G_SIGNAL_RUN_LAST,
362 G_STRUCT_OFFSET (GMountOperationClass, reply),
363 NULL, NULL,
364 g_cclosure_marshal_VOID__ENUM,
365 G_TYPE_NONE, 1,
366 G_TYPE_MOUNT_OPERATION_RESULT);
369 * GMountOperation::aborted:
371 * Emitted by the backend when e.g. a device becomes unavailable
372 * while a mount operation is in progress.
374 * Implementations of GMountOperation should handle this signal
375 * by dismissing open password dialogs.
377 * Since: 2.20
379 signals[ABORTED] =
380 g_signal_new (I_("aborted"),
381 G_TYPE_FROM_CLASS (object_class),
382 G_SIGNAL_RUN_LAST,
383 G_STRUCT_OFFSET (GMountOperationClass, aborted),
384 NULL, NULL,
385 g_cclosure_marshal_VOID__VOID,
386 G_TYPE_NONE, 0);
389 * GMountOperation::show-processes:
390 * @op: a #GMountOperation.
391 * @message: string containing a message to display to the user.
392 * @processes: (element-type GPid): an array of #GPid for processes
393 * blocking the operation.
394 * @choices: an array of strings for each possible choice.
396 * Emitted when one or more processes are blocking an operation
397 * e.g. unmounting/ejecting a #GMount or stopping a #GDrive.
399 * Note that this signal may be emitted several times to update the
400 * list of blocking processes as processes close files. The
401 * application should only respond with g_mount_operation_reply() to
402 * the latest signal (setting #GMountOperation:choice to the choice
403 * the user made).
405 * If the message contains a line break, the first line should be
406 * presented as a heading. For example, it may be used as the
407 * primary text in a #GtkMessageDialog.
409 * Since: 2.22
411 signals[SHOW_PROCESSES] =
412 g_signal_new (I_("show-processes"),
413 G_TYPE_FROM_CLASS (object_class),
414 G_SIGNAL_RUN_LAST,
415 G_STRUCT_OFFSET (GMountOperationClass, show_processes),
416 NULL, NULL,
417 NULL,
418 G_TYPE_NONE, 3,
419 G_TYPE_STRING, G_TYPE_ARRAY, G_TYPE_STRV);
422 * GMountOperation::show-unmount-progress:
423 * @op: a #GMountOperation:
424 * @message: string containing a mesage to display to the user
425 * @time_left: the estimated time left before the operation completes,
426 * in microseconds, or -1
427 * @bytes_left: the amount of bytes to be written before the operation
428 * completes (or -1 if such amount is not known), or zero if the operation
429 * is completed
431 * Emitted when an unmount operation has been busy for more than some time
432 * (typically 1.5 seconds).
434 * When unmounting or ejecting a volume, the kernel might need to flush
435 * pending data in its buffers to the volume stable storage, and this operation
436 * can take a considerable amount of time. This signal may be emitted several
437 * times as long as the unmount operation is outstanding, and then one
438 * last time when the operation is completed, with @bytes_left set to zero.
440 * Implementations of GMountOperation should handle this signal by
441 * showing an UI notification, and then dismiss it, or show another notification
442 * of completion, when @bytes_left reaches zero.
444 * If the message contains a line break, the first line should be
445 * presented as a heading. For example, it may be used as the
446 * primary text in a #GtkMessageDialog.
448 * Since: 2.34
450 signals[SHOW_UNMOUNT_PROGRESS] =
451 g_signal_new (I_("show-unmount-progress"),
452 G_TYPE_FROM_CLASS (object_class),
453 G_SIGNAL_RUN_LAST,
454 G_STRUCT_OFFSET (GMountOperationClass, show_unmount_progress),
455 NULL, NULL, NULL,
456 G_TYPE_NONE, 3,
457 G_TYPE_STRING, G_TYPE_INT64, G_TYPE_INT64);
460 * GMountOperation:username:
462 * The user name that is used for authentication when carrying out
463 * the mount operation.
465 g_object_class_install_property (object_class,
466 PROP_USERNAME,
467 g_param_spec_string ("username",
468 P_("Username"),
469 P_("The user name"),
470 NULL,
471 G_PARAM_READWRITE|
472 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
475 * GMountOperation:password:
477 * The password that is used for authentication when carrying out
478 * the mount operation.
480 g_object_class_install_property (object_class,
481 PROP_PASSWORD,
482 g_param_spec_string ("password",
483 P_("Password"),
484 P_("The password"),
485 NULL,
486 G_PARAM_READWRITE|
487 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
490 * GMountOperation:anonymous:
492 * Whether to use an anonymous user when authenticating.
494 g_object_class_install_property (object_class,
495 PROP_ANONYMOUS,
496 g_param_spec_boolean ("anonymous",
497 P_("Anonymous"),
498 P_("Whether to use an anonymous user"),
499 FALSE,
500 G_PARAM_READWRITE|
501 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
504 * GMountOperation:domain:
506 * The domain to use for the mount operation.
508 g_object_class_install_property (object_class,
509 PROP_DOMAIN,
510 g_param_spec_string ("domain",
511 P_("Domain"),
512 P_("The domain of the mount operation"),
513 NULL,
514 G_PARAM_READWRITE|
515 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
518 * GMountOperation:password-save:
520 * Determines if and how the password information should be saved.
522 g_object_class_install_property (object_class,
523 PROP_PASSWORD_SAVE,
524 g_param_spec_enum ("password-save",
525 P_("Password save"),
526 P_("How passwords should be saved"),
527 G_TYPE_PASSWORD_SAVE,
528 G_PASSWORD_SAVE_NEVER,
529 G_PARAM_READWRITE|
530 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
533 * GMountOperation:choice:
535 * The index of the user's choice when a question is asked during the
536 * mount operation. See the #GMountOperation::ask-question signal.
538 g_object_class_install_property (object_class,
539 PROP_CHOICE,
540 g_param_spec_int ("choice",
541 P_("Choice"),
542 P_("The users choice"),
543 0, G_MAXINT, 0,
544 G_PARAM_READWRITE|
545 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
548 * GMountOperation:is-tcrypt-hidden-volume:
550 * Whether the device to be unlocked is a TCRYPT hidden volume.
551 * See https://www.veracrypt.fr/en/Hidden%20Volume.html.
553 * Since: 2.58
555 g_object_class_install_property (object_class,
556 PROP_IS_TCRYPT_HIDDEN_VOLUME,
557 g_param_spec_boolean ("is-tcrypt-hidden-volume",
558 P_("TCRYPT Hidden Volume"),
559 P_("Whether to unlock a TCRYPT hidden volume. See https://www.veracrypt.fr/en/Hidden%20Volume.html."),
560 FALSE,
561 G_PARAM_READWRITE|
562 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
565 * GMountOperation:is-tcrypt-system-volume:
567 * Whether the device to be unlocked is a TCRYPT system volume.
568 * In this context, a system volume is a volume with a bootloader
569 * and operating system installed. This is only supported for Windows
570 * operating systems. For further documentation, see
571 * https://www.veracrypt.fr/en/System%20Encryption.html.
573 * Since: 2.58
575 g_object_class_install_property (object_class,
576 PROP_IS_TCRYPT_SYSTEM_VOLUME,
577 g_param_spec_boolean ("is-tcrypt-system-volume",
578 P_("TCRYPT System Volume"),
579 P_("Whether to unlock a TCRYPT system volume. Only supported for unlocking Windows system volumes. See https://www.veracrypt.fr/en/System%20Encryption.html."),
580 FALSE,
581 G_PARAM_READWRITE|
582 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
585 * GMountOperation:pim:
587 * The VeraCrypt PIM value, when unlocking a VeraCrypt volume. See
588 * https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20(PIM).html.
590 * Since: 2.58
592 g_object_class_install_property (object_class,
593 PROP_PIM,
594 g_param_spec_uint ("pim",
595 P_("PIM"),
596 P_("The VeraCrypt PIM value"),
597 0, G_MAXUINT, 0,
598 G_PARAM_READWRITE|
599 G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
602 static void
603 g_mount_operation_init (GMountOperation *operation)
605 operation->priv = g_mount_operation_get_instance_private (operation);
609 * g_mount_operation_new:
611 * Creates a new mount operation.
613 * Returns: a #GMountOperation.
615 GMountOperation *
616 g_mount_operation_new (void)
618 return g_object_new (G_TYPE_MOUNT_OPERATION, NULL);
622 * g_mount_operation_get_username:
623 * @op: a #GMountOperation.
625 * Get the user name from the mount operation.
627 * Returns: a string containing the user name.
629 const char *
630 g_mount_operation_get_username (GMountOperation *op)
632 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
633 return op->priv->user;
637 * g_mount_operation_set_username:
638 * @op: a #GMountOperation.
639 * @username: input username.
641 * Sets the user name within @op to @username.
643 void
644 g_mount_operation_set_username (GMountOperation *op,
645 const char *username)
647 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
648 g_free (op->priv->user);
649 op->priv->user = g_strdup (username);
650 g_object_notify (G_OBJECT (op), "username");
654 * g_mount_operation_get_password:
655 * @op: a #GMountOperation.
657 * Gets a password from the mount operation.
659 * Returns: a string containing the password within @op.
661 const char *
662 g_mount_operation_get_password (GMountOperation *op)
664 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
665 return op->priv->password;
669 * g_mount_operation_set_password:
670 * @op: a #GMountOperation.
671 * @password: password to set.
673 * Sets the mount operation's password to @password.
676 void
677 g_mount_operation_set_password (GMountOperation *op,
678 const char *password)
680 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
681 g_free (op->priv->password);
682 op->priv->password = g_strdup (password);
683 g_object_notify (G_OBJECT (op), "password");
687 * g_mount_operation_get_anonymous:
688 * @op: a #GMountOperation.
690 * Check to see whether the mount operation is being used
691 * for an anonymous user.
693 * Returns: %TRUE if mount operation is anonymous.
695 gboolean
696 g_mount_operation_get_anonymous (GMountOperation *op)
698 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
699 return op->priv->anonymous;
703 * g_mount_operation_set_anonymous:
704 * @op: a #GMountOperation.
705 * @anonymous: boolean value.
707 * Sets the mount operation to use an anonymous user if @anonymous is %TRUE.
708 **/
709 void
710 g_mount_operation_set_anonymous (GMountOperation *op,
711 gboolean anonymous)
713 GMountOperationPrivate *priv;
714 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
715 priv = op->priv;
717 if (priv->anonymous != anonymous)
719 priv->anonymous = anonymous;
720 g_object_notify (G_OBJECT (op), "anonymous");
725 * g_mount_operation_get_domain:
726 * @op: a #GMountOperation.
728 * Gets the domain of the mount operation.
730 * Returns: a string set to the domain.
732 const char *
733 g_mount_operation_get_domain (GMountOperation *op)
735 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
736 return op->priv->domain;
740 * g_mount_operation_set_domain:
741 * @op: a #GMountOperation.
742 * @domain: the domain to set.
744 * Sets the mount operation's domain.
745 **/
746 void
747 g_mount_operation_set_domain (GMountOperation *op,
748 const char *domain)
750 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
751 g_free (op->priv->domain);
752 op->priv->domain = g_strdup (domain);
753 g_object_notify (G_OBJECT (op), "domain");
757 * g_mount_operation_get_password_save:
758 * @op: a #GMountOperation.
760 * Gets the state of saving passwords for the mount operation.
762 * Returns: a #GPasswordSave flag.
763 **/
765 GPasswordSave
766 g_mount_operation_get_password_save (GMountOperation *op)
768 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), G_PASSWORD_SAVE_NEVER);
769 return op->priv->password_save;
773 * g_mount_operation_set_password_save:
774 * @op: a #GMountOperation.
775 * @save: a set of #GPasswordSave flags.
777 * Sets the state of saving passwords for the mount operation.
779 **/
780 void
781 g_mount_operation_set_password_save (GMountOperation *op,
782 GPasswordSave save)
784 GMountOperationPrivate *priv;
785 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
786 priv = op->priv;
788 if (priv->password_save != save)
790 priv->password_save = save;
791 g_object_notify (G_OBJECT (op), "password-save");
796 * g_mount_operation_get_choice:
797 * @op: a #GMountOperation.
799 * Gets a choice from the mount operation.
801 * Returns: an integer containing an index of the user's choice from
802 * the choice's list, or %0.
805 g_mount_operation_get_choice (GMountOperation *op)
807 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), 0);
808 return op->priv->choice;
812 * g_mount_operation_set_choice:
813 * @op: a #GMountOperation.
814 * @choice: an integer.
816 * Sets a default choice for the mount operation.
818 void
819 g_mount_operation_set_choice (GMountOperation *op,
820 int choice)
822 GMountOperationPrivate *priv;
823 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
824 priv = op->priv;
825 if (priv->choice != choice)
827 priv->choice = choice;
828 g_object_notify (G_OBJECT (op), "choice");
833 * g_mount_operation_get_is_tcrypt_hidden_volume:
834 * @op: a #GMountOperation.
836 * Check to see whether the mount operation is being used
837 * for a TCRYPT hidden volume.
839 * Returns: %TRUE if mount operation is for hidden volume.
841 * Since: 2.58
843 gboolean
844 g_mount_operation_get_is_tcrypt_hidden_volume (GMountOperation *op)
846 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
847 return op->priv->hidden_volume;
851 * g_mount_operation_set_is_tcrypt_hidden_volume:
852 * @op: a #GMountOperation.
853 * @hidden_volume: boolean value.
855 * Sets the mount operation to use a hidden volume if @hidden_volume is %TRUE.
857 * Since: 2.58
859 void
860 g_mount_operation_set_is_tcrypt_hidden_volume (GMountOperation *op,
861 gboolean hidden_volume)
863 GMountOperationPrivate *priv;
864 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
865 priv = op->priv;
867 if (priv->hidden_volume != hidden_volume)
869 priv->hidden_volume = hidden_volume;
870 g_object_notify (G_OBJECT (op), "is-tcrypt-hidden-volume");
875 * g_mount_operation_get_is_tcrypt_system_volume:
876 * @op: a #GMountOperation.
878 * Check to see whether the mount operation is being used
879 * for a TCRYPT system volume.
881 * Returns: %TRUE if mount operation is for system volume.
883 * Since: 2.58
885 gboolean
886 g_mount_operation_get_is_tcrypt_system_volume (GMountOperation *op)
888 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
889 return op->priv->system_volume;
893 * g_mount_operation_set_is_tcrypt_system_volume:
894 * @op: a #GMountOperation.
895 * @system_volume: boolean value.
897 * Sets the mount operation to use a system volume if @system_volume is %TRUE.
899 * Since: 2.58
901 void
902 g_mount_operation_set_is_tcrypt_system_volume (GMountOperation *op,
903 gboolean system_volume)
905 GMountOperationPrivate *priv;
906 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
907 priv = op->priv;
909 if (priv->system_volume != system_volume)
911 priv->system_volume = system_volume;
912 g_object_notify (G_OBJECT (op), "is-tcrypt-system-volume");
917 * g_mount_operation_get_pim:
918 * @op: a #GMountOperation.
920 * Gets a PIM from the mount operation.
922 * Returns: The VeraCrypt PIM within @op.
924 * Since: 2.58
926 guint
927 g_mount_operation_get_pim (GMountOperation *op)
929 g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), 0);
930 return op->priv->pim;
934 * g_mount_operation_set_pim:
935 * @op: a #GMountOperation.
936 * @pim: an unsigned integer.
938 * Sets the mount operation's PIM to @pim.
940 * Since: 2.58
942 void
943 g_mount_operation_set_pim (GMountOperation *op,
944 guint pim)
946 GMountOperationPrivate *priv;
947 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
948 priv = op->priv;
949 if (priv->pim != pim)
951 priv->pim = pim;
952 g_object_notify (G_OBJECT (op), "pim");
957 * g_mount_operation_reply:
958 * @op: a #GMountOperation
959 * @result: a #GMountOperationResult
961 * Emits the #GMountOperation::reply signal.
963 void
964 g_mount_operation_reply (GMountOperation *op,
965 GMountOperationResult result)
967 g_return_if_fail (G_IS_MOUNT_OPERATION (op));
968 g_signal_emit (op, signals[REPLY], 0, result);