LCOV - code coverage report
Current view: top level - glib/gio - gmountoperation.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 194 218 89.0 %
Date: 2024-04-23 05:16:05 Functions: 28 34 82.4 %
Branches: 30 38 78.9 %

           Branch data     Line data    Source code
       1                 :            : /* GIO - GLib Input, Output and Streaming Library
       2                 :            :  * 
       3                 :            :  * Copyright (C) 2006-2007 Red Hat, Inc.
       4                 :            :  *
       5                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       6                 :            :  *
       7                 :            :  * This library is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU Lesser General Public
       9                 :            :  * License as published by the Free Software Foundation; either
      10                 :            :  * version 2.1 of the License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This library is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :            :  * Lesser General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU Lesser General
      18                 :            :  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19                 :            :  *
      20                 :            :  * Author: Alexander Larsson <alexl@redhat.com>
      21                 :            :  */
      22                 :            : 
      23                 :            : #include "config.h"
      24                 :            : 
      25                 :            : #include <string.h>
      26                 :            : 
      27                 :            : #include "gmountoperation.h"
      28                 :            : #include "gioenumtypes.h"
      29                 :            : #include "glibintl.h"
      30                 :            : #include "gmarshal-internal.h"
      31                 :            : 
      32                 :            : 
      33                 :            : /**
      34                 :            :  * GMountOperation:
      35                 :            :  *
      36                 :            :  * `GMountOperation` provides a mechanism for interacting with the user.
      37                 :            :  * It can be used for authenticating mountable operations, such as loop
      38                 :            :  * mounting files, hard drive partitions or server locations. It can
      39                 :            :  * also be used to ask the user questions or show a list of applications
      40                 :            :  * preventing unmount or eject operations from completing.
      41                 :            :  *
      42                 :            :  * Note that `GMountOperation` is used for more than just [iface@Gio.Mount]
      43                 :            :  * objects – for example it is also used in [method@Gio.Drive.start] and
      44                 :            :  * [method@Gio.Drive.stop].
      45                 :            :  *
      46                 :            :  * Users should instantiate a subclass of this that implements all the
      47                 :            :  * various callbacks to show the required dialogs, such as
      48                 :            :  * [`GtkMountOperation`](https://docs.gtk.org/gtk4/class.MountOperation.html).
      49                 :            :  * If no user interaction is desired (for example when automounting
      50                 :            :  * filesystems at login time), usually `NULL` can be passed, see each method
      51                 :            :  * taking a `GMountOperation` for details.
      52                 :            :  *
      53                 :            :  * Throughout the API, the term ‘TCRYPT’ is used to mean ‘compatible with TrueCrypt and VeraCrypt’.
      54                 :            :  * [TrueCrypt](https://en.wikipedia.org/wiki/TrueCrypt) is a discontinued system for
      55                 :            :  * encrypting file containers, partitions or whole disks, typically used with Windows.
      56                 :            :  * [VeraCrypt](https://www.veracrypt.fr/) is a maintained fork of TrueCrypt with various
      57                 :            :  * improvements and auditing fixes.
      58                 :            :  */
      59                 :            : 
      60                 :            : enum {
      61                 :            :   ASK_PASSWORD,
      62                 :            :   ASK_QUESTION,
      63                 :            :   REPLY,
      64                 :            :   ABORTED,
      65                 :            :   SHOW_PROCESSES,
      66                 :            :   SHOW_UNMOUNT_PROGRESS,
      67                 :            :   LAST_SIGNAL
      68                 :            : };
      69                 :            : 
      70                 :            : static guint signals[LAST_SIGNAL] = { 0 };
      71                 :            : 
      72                 :            : struct _GMountOperationPrivate {
      73                 :            :   char *password;
      74                 :            :   char *user;
      75                 :            :   char *domain;
      76                 :            :   gboolean anonymous;
      77                 :            :   GPasswordSave password_save;
      78                 :            :   int choice;
      79                 :            :   gboolean hidden_volume;
      80                 :            :   gboolean system_volume;
      81                 :            :   guint pim;
      82                 :            : };
      83                 :            : 
      84                 :            : enum {
      85                 :            :   PROP_0,
      86                 :            :   PROP_USERNAME,
      87                 :            :   PROP_PASSWORD,
      88                 :            :   PROP_ANONYMOUS,
      89                 :            :   PROP_DOMAIN,
      90                 :            :   PROP_PASSWORD_SAVE,
      91                 :            :   PROP_CHOICE,
      92                 :            :   PROP_IS_TCRYPT_HIDDEN_VOLUME,
      93                 :            :   PROP_IS_TCRYPT_SYSTEM_VOLUME,
      94                 :            :   PROP_PIM
      95                 :            : };
      96                 :            : 
      97   [ +  +  +  -  :         80 : G_DEFINE_TYPE_WITH_PRIVATE (GMountOperation, g_mount_operation, G_TYPE_OBJECT)
                   +  + ]
      98                 :            : 
      99                 :            : static void 
     100                 :          9 : g_mount_operation_set_property (GObject      *object,
     101                 :            :                                 guint         prop_id,
     102                 :            :                                 const GValue *value,
     103                 :            :                                 GParamSpec   *pspec)
     104                 :            : {
     105                 :            :   GMountOperation *operation;
     106                 :            : 
     107                 :          9 :   operation = G_MOUNT_OPERATION (object);
     108                 :            : 
     109   [ +  +  +  +  :          9 :   switch (prop_id)
          +  +  +  +  +  
                      - ]
     110                 :            :     {
     111                 :          1 :     case PROP_USERNAME:
     112                 :          1 :       g_mount_operation_set_username (operation, 
     113                 :          1 :                                       g_value_get_string (value));
     114                 :          1 :       break;
     115                 :            :    
     116                 :          1 :     case PROP_PASSWORD:
     117                 :          1 :       g_mount_operation_set_password (operation, 
     118                 :          1 :                                       g_value_get_string (value));
     119                 :          1 :       break;
     120                 :            : 
     121                 :          1 :     case PROP_ANONYMOUS:
     122                 :          1 :       g_mount_operation_set_anonymous (operation, 
     123                 :            :                                        g_value_get_boolean (value));
     124                 :          1 :       break;
     125                 :            : 
     126                 :          1 :     case PROP_DOMAIN:
     127                 :          1 :       g_mount_operation_set_domain (operation, 
     128                 :          1 :                                     g_value_get_string (value));
     129                 :          1 :       break;
     130                 :            : 
     131                 :          1 :     case PROP_PASSWORD_SAVE:
     132                 :          1 :       g_mount_operation_set_password_save (operation, 
     133                 :          1 :                                            g_value_get_enum (value));
     134                 :          1 :       break;
     135                 :            : 
     136                 :          1 :     case PROP_CHOICE:
     137                 :          1 :       g_mount_operation_set_choice (operation, 
     138                 :            :                                     g_value_get_int (value));
     139                 :          1 :       break;
     140                 :            : 
     141                 :          1 :     case PROP_IS_TCRYPT_HIDDEN_VOLUME:
     142                 :          1 :       g_mount_operation_set_is_tcrypt_hidden_volume (operation,
     143                 :            :                                                      g_value_get_boolean (value));
     144                 :          1 :       break;
     145                 :            : 
     146                 :          1 :     case PROP_IS_TCRYPT_SYSTEM_VOLUME:
     147                 :          1 :       g_mount_operation_set_is_tcrypt_system_volume (operation,
     148                 :            :                                                      g_value_get_boolean (value));
     149                 :          1 :       break;
     150                 :            : 
     151                 :          1 :     case PROP_PIM:
     152                 :          1 :         g_mount_operation_set_pim (operation,
     153                 :            :                                    g_value_get_uint (value));
     154                 :          1 :         break;
     155                 :            : 
     156                 :          0 :     default:
     157                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     158                 :          0 :       break;
     159                 :            :     }
     160                 :          9 : }
     161                 :            : 
     162                 :            : 
     163                 :            : static void 
     164                 :         18 : g_mount_operation_get_property (GObject    *object,
     165                 :            :                                 guint       prop_id,
     166                 :            :                                 GValue     *value,
     167                 :            :                                 GParamSpec *pspec)
     168                 :            : {
     169                 :            :   GMountOperation *operation;
     170                 :            :   GMountOperationPrivate *priv;
     171                 :            : 
     172                 :         18 :   operation = G_MOUNT_OPERATION (object);
     173                 :         18 :   priv = operation->priv;
     174                 :            :   
     175   [ +  +  +  +  :         18 :   switch (prop_id)
          +  +  +  +  +  
                      - ]
     176                 :            :     {
     177                 :          2 :     case PROP_USERNAME:
     178                 :          2 :       g_value_set_string (value, priv->user);
     179                 :          2 :       break;
     180                 :            : 
     181                 :          2 :     case PROP_PASSWORD:
     182                 :          2 :       g_value_set_string (value, priv->password);
     183                 :          2 :       break;
     184                 :            : 
     185                 :          2 :     case PROP_ANONYMOUS:
     186                 :          2 :       g_value_set_boolean (value, priv->anonymous);
     187                 :          2 :       break;
     188                 :            : 
     189                 :          2 :     case PROP_DOMAIN:
     190                 :          2 :       g_value_set_string (value, priv->domain);
     191                 :          2 :       break;
     192                 :            : 
     193                 :          2 :     case PROP_PASSWORD_SAVE:
     194                 :          2 :       g_value_set_enum (value, priv->password_save);
     195                 :          2 :       break;
     196                 :            : 
     197                 :          2 :     case PROP_CHOICE:
     198                 :          2 :       g_value_set_int (value, priv->choice);
     199                 :          2 :       break;
     200                 :            : 
     201                 :          2 :     case PROP_IS_TCRYPT_HIDDEN_VOLUME:
     202                 :          2 :       g_value_set_boolean (value, priv->hidden_volume);
     203                 :          2 :       break;
     204                 :            : 
     205                 :          2 :     case PROP_IS_TCRYPT_SYSTEM_VOLUME:
     206                 :          2 :       g_value_set_boolean (value, priv->system_volume);
     207                 :          2 :       break;
     208                 :            : 
     209                 :          2 :     case PROP_PIM:
     210                 :          2 :       g_value_set_uint (value, priv->pim);
     211                 :          2 :       break;
     212                 :            : 
     213                 :          0 :     default:
     214                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     215                 :          0 :       break;
     216                 :            :     }
     217                 :         18 : }
     218                 :            : 
     219                 :            : 
     220                 :            : static void
     221                 :          3 : g_mount_operation_finalize (GObject *object)
     222                 :            : {
     223                 :            :   GMountOperation *operation;
     224                 :            :   GMountOperationPrivate *priv;
     225                 :            : 
     226                 :          3 :   operation = G_MOUNT_OPERATION (object);
     227                 :            : 
     228                 :          3 :   priv = operation->priv;
     229                 :            :   
     230                 :          3 :   g_free (priv->password);
     231                 :          3 :   g_free (priv->user);
     232                 :          3 :   g_free (priv->domain);
     233                 :            : 
     234                 :          3 :   G_OBJECT_CLASS (g_mount_operation_parent_class)->finalize (object);
     235                 :          3 : }
     236                 :            : 
     237                 :            : static gboolean
     238                 :          0 : reply_non_handled_in_idle (gpointer data)
     239                 :            : {
     240                 :          0 :   GMountOperation *op = data;
     241                 :            : 
     242                 :          0 :   g_mount_operation_reply (op, G_MOUNT_OPERATION_UNHANDLED);
     243                 :          0 :   return G_SOURCE_REMOVE;
     244                 :            : }
     245                 :            : 
     246                 :            : static void
     247                 :          0 : ask_password (GMountOperation *op,
     248                 :            :               const char      *message,
     249                 :            :               const char      *default_user,
     250                 :            :               const char      *default_domain,
     251                 :            :               GAskPasswordFlags flags)
     252                 :            : {
     253                 :          0 :   g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
     254                 :            :                    reply_non_handled_in_idle,
     255                 :            :                    g_object_ref (op),
     256                 :            :                    g_object_unref);
     257                 :          0 : }
     258                 :            :   
     259                 :            : static void
     260                 :          0 : ask_question (GMountOperation *op,
     261                 :            :               const char      *message,
     262                 :            :               const char      *choices[])
     263                 :            : {
     264                 :          0 :   g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
     265                 :            :                    reply_non_handled_in_idle,
     266                 :            :                    g_object_ref (op),
     267                 :            :                    g_object_unref);
     268                 :          0 : }
     269                 :            : 
     270                 :            : static void
     271                 :          0 : show_processes (GMountOperation      *op,
     272                 :            :                 const gchar          *message,
     273                 :            :                 GArray               *processes,
     274                 :            :                 const gchar          *choices[])
     275                 :            : {
     276                 :          0 :   g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
     277                 :            :                    reply_non_handled_in_idle,
     278                 :            :                    g_object_ref (op),
     279                 :            :                    g_object_unref);
     280                 :          0 : }
     281                 :            : 
     282                 :            : static void
     283                 :          0 : show_unmount_progress (GMountOperation *op,
     284                 :            :                        const gchar     *message,
     285                 :            :                        gint64           time_left,
     286                 :            :                        gint64           bytes_left)
     287                 :            : {
     288                 :            :   /* nothing to do */
     289                 :          0 : }
     290                 :            : 
     291                 :            : static void
     292                 :          3 : g_mount_operation_class_init (GMountOperationClass *klass)
     293                 :            : {
     294                 :            :   GObjectClass *object_class;
     295                 :            :  
     296                 :          3 :   object_class = G_OBJECT_CLASS (klass);
     297                 :          3 :   object_class->finalize = g_mount_operation_finalize;
     298                 :          3 :   object_class->get_property = g_mount_operation_get_property;
     299                 :          3 :   object_class->set_property = g_mount_operation_set_property;
     300                 :            :   
     301                 :          3 :   klass->ask_password = ask_password;
     302                 :          3 :   klass->ask_question = ask_question;
     303                 :          3 :   klass->show_processes = show_processes;
     304                 :          3 :   klass->show_unmount_progress = show_unmount_progress;
     305                 :            :   
     306                 :            :   /**
     307                 :            :    * GMountOperation::ask-password:
     308                 :            :    * @op: a #GMountOperation requesting a password.
     309                 :            :    * @message: string containing a message to display to the user.
     310                 :            :    * @default_user: string containing the default user name.
     311                 :            :    * @default_domain: string containing the default domain.
     312                 :            :    * @flags: a set of #GAskPasswordFlags.
     313                 :            :    *
     314                 :            :    * Emitted when a mount operation asks the user for a password.
     315                 :            :    *
     316                 :            :    * If the message contains a line break, the first line should be
     317                 :            :    * presented as a heading. For example, it may be used as the
     318                 :            :    * primary text in a #GtkMessageDialog.
     319                 :            :    */
     320                 :          3 :   signals[ASK_PASSWORD] =
     321                 :          3 :     g_signal_new (I_("ask-password"),
     322                 :            :                   G_TYPE_FROM_CLASS (object_class),
     323                 :            :                   G_SIGNAL_RUN_LAST,
     324                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, ask_password),
     325                 :            :                   NULL, NULL,
     326                 :            :                   _g_cclosure_marshal_VOID__STRING_STRING_STRING_FLAGS,
     327                 :            :                   G_TYPE_NONE, 4,
     328                 :            :                   G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ASK_PASSWORD_FLAGS);
     329                 :          3 :   g_signal_set_va_marshaller (signals[ASK_PASSWORD],
     330                 :            :                               G_TYPE_FROM_CLASS (object_class),
     331                 :            :                               _g_cclosure_marshal_VOID__STRING_STRING_STRING_FLAGSv);
     332                 :            :                   
     333                 :            :   /**
     334                 :            :    * GMountOperation::ask-question:
     335                 :            :    * @op: a #GMountOperation asking a question.
     336                 :            :    * @message: string containing a message to display to the user.
     337                 :            :    * @choices: an array of strings for each possible choice.
     338                 :            :    *
     339                 :            :    * Emitted when asking the user a question and gives a list of
     340                 :            :    * choices for the user to choose from.
     341                 :            :    *
     342                 :            :    * If the message contains a line break, the first line should be
     343                 :            :    * presented as a heading. For example, it may be used as the
     344                 :            :    * primary text in a #GtkMessageDialog.
     345                 :            :    */
     346                 :          3 :   signals[ASK_QUESTION] =
     347                 :          3 :     g_signal_new (I_("ask-question"),
     348                 :            :                   G_TYPE_FROM_CLASS (object_class),
     349                 :            :                   G_SIGNAL_RUN_LAST,
     350                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, ask_question),
     351                 :            :                   NULL, NULL,
     352                 :            :                   _g_cclosure_marshal_VOID__STRING_BOXED,
     353                 :            :                   G_TYPE_NONE, 2,
     354                 :            :                   G_TYPE_STRING, G_TYPE_STRV);
     355                 :          3 :   g_signal_set_va_marshaller (signals[ASK_QUESTION],
     356                 :            :                               G_TYPE_FROM_CLASS (object_class),
     357                 :            :                               _g_cclosure_marshal_VOID__STRING_BOXEDv);
     358                 :            :                   
     359                 :            :   /**
     360                 :            :    * GMountOperation::reply:
     361                 :            :    * @op: a #GMountOperation.
     362                 :            :    * @result: a #GMountOperationResult indicating how the request was handled
     363                 :            :    *
     364                 :            :    * Emitted when the user has replied to the mount operation.
     365                 :            :    */
     366                 :          3 :   signals[REPLY] =
     367                 :          3 :     g_signal_new (I_("reply"),
     368                 :            :                   G_TYPE_FROM_CLASS (object_class),
     369                 :            :                   G_SIGNAL_RUN_LAST,
     370                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, reply),
     371                 :            :                   NULL, NULL,
     372                 :            :                   NULL,
     373                 :            :                   G_TYPE_NONE, 1,
     374                 :            :                   G_TYPE_MOUNT_OPERATION_RESULT);
     375                 :            : 
     376                 :            :   /**
     377                 :            :    * GMountOperation::aborted:
     378                 :            :    *
     379                 :            :    * Emitted by the backend when e.g. a device becomes unavailable
     380                 :            :    * while a mount operation is in progress.
     381                 :            :    *
     382                 :            :    * Implementations of GMountOperation should handle this signal
     383                 :            :    * by dismissing open password dialogs.
     384                 :            :    *
     385                 :            :    * Since: 2.20
     386                 :            :    */
     387                 :          3 :   signals[ABORTED] =
     388                 :          3 :     g_signal_new (I_("aborted"),
     389                 :            :                   G_TYPE_FROM_CLASS (object_class),
     390                 :            :                   G_SIGNAL_RUN_LAST,
     391                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, aborted),
     392                 :            :                   NULL, NULL,
     393                 :            :                   NULL,
     394                 :            :                   G_TYPE_NONE, 0);
     395                 :            : 
     396                 :            :   /**
     397                 :            :    * GMountOperation::show-processes:
     398                 :            :    * @op: a #GMountOperation.
     399                 :            :    * @message: string containing a message to display to the user.
     400                 :            :    * @processes: (element-type GPid): an array of #GPid for processes
     401                 :            :    *   blocking the operation.
     402                 :            :    * @choices: an array of strings for each possible choice.
     403                 :            :    *
     404                 :            :    * Emitted when one or more processes are blocking an operation
     405                 :            :    * e.g. unmounting/ejecting a #GMount or stopping a #GDrive.
     406                 :            :    *
     407                 :            :    * Note that this signal may be emitted several times to update the
     408                 :            :    * list of blocking processes as processes close files. The
     409                 :            :    * application should only respond with g_mount_operation_reply() to
     410                 :            :    * the latest signal (setting #GMountOperation:choice to the choice
     411                 :            :    * the user made).
     412                 :            :    *
     413                 :            :    * If the message contains a line break, the first line should be
     414                 :            :    * presented as a heading. For example, it may be used as the
     415                 :            :    * primary text in a #GtkMessageDialog.
     416                 :            :    *
     417                 :            :    * Since: 2.22
     418                 :            :    */
     419                 :          3 :   signals[SHOW_PROCESSES] =
     420                 :          3 :     g_signal_new (I_("show-processes"),
     421                 :            :                   G_TYPE_FROM_CLASS (object_class),
     422                 :            :                   G_SIGNAL_RUN_LAST,
     423                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, show_processes),
     424                 :            :                   NULL, NULL,
     425                 :            :                   _g_cclosure_marshal_VOID__STRING_BOXED_BOXED,
     426                 :            :                   G_TYPE_NONE, 3,
     427                 :            :                   G_TYPE_STRING, G_TYPE_ARRAY, G_TYPE_STRV);
     428                 :          3 :   g_signal_set_va_marshaller (signals[SHOW_PROCESSES],
     429                 :            :                               G_TYPE_FROM_CLASS (object_class),
     430                 :            :                               _g_cclosure_marshal_VOID__STRING_BOXED_BOXEDv);
     431                 :            : 
     432                 :            :   /**
     433                 :            :    * GMountOperation::show-unmount-progress:
     434                 :            :    * @op: a #GMountOperation:
     435                 :            :    * @message: string containing a message to display to the user
     436                 :            :    * @time_left: the estimated time left before the operation completes,
     437                 :            :    *     in microseconds, or -1
     438                 :            :    * @bytes_left: the amount of bytes to be written before the operation
     439                 :            :    *     completes (or -1 if such amount is not known), or zero if the operation
     440                 :            :    *     is completed
     441                 :            :    *
     442                 :            :    * Emitted when an unmount operation has been busy for more than some time
     443                 :            :    * (typically 1.5 seconds).
     444                 :            :    *
     445                 :            :    * When unmounting or ejecting a volume, the kernel might need to flush
     446                 :            :    * pending data in its buffers to the volume stable storage, and this operation
     447                 :            :    * can take a considerable amount of time. This signal may be emitted several
     448                 :            :    * times as long as the unmount operation is outstanding, and then one
     449                 :            :    * last time when the operation is completed, with @bytes_left set to zero.
     450                 :            :    *
     451                 :            :    * Implementations of GMountOperation should handle this signal by
     452                 :            :    * showing an UI notification, and then dismiss it, or show another notification
     453                 :            :    * of completion, when @bytes_left reaches zero.
     454                 :            :    *
     455                 :            :    * If the message contains a line break, the first line should be
     456                 :            :    * presented as a heading. For example, it may be used as the
     457                 :            :    * primary text in a #GtkMessageDialog.
     458                 :            :    *
     459                 :            :    * Since: 2.34
     460                 :            :    */
     461                 :          3 :   signals[SHOW_UNMOUNT_PROGRESS] =
     462                 :          3 :     g_signal_new (I_("show-unmount-progress"),
     463                 :            :                   G_TYPE_FROM_CLASS (object_class),
     464                 :            :                   G_SIGNAL_RUN_LAST,
     465                 :            :                   G_STRUCT_OFFSET (GMountOperationClass, show_unmount_progress),
     466                 :            :                   NULL, NULL,
     467                 :            :                   _g_cclosure_marshal_VOID__STRING_INT64_INT64,
     468                 :            :                   G_TYPE_NONE, 3,
     469                 :            :                   G_TYPE_STRING, G_TYPE_INT64, G_TYPE_INT64);
     470                 :          3 :   g_signal_set_va_marshaller (signals[SHOW_UNMOUNT_PROGRESS],
     471                 :            :                               G_TYPE_FROM_CLASS (object_class),
     472                 :            :                               _g_cclosure_marshal_VOID__STRING_INT64_INT64v);
     473                 :            : 
     474                 :            :   /**
     475                 :            :    * GMountOperation:username:
     476                 :            :    *
     477                 :            :    * The user name that is used for authentication when carrying out
     478                 :            :    * the mount operation.
     479                 :            :    */ 
     480                 :          3 :   g_object_class_install_property (object_class,
     481                 :            :                                    PROP_USERNAME,
     482                 :            :                                    g_param_spec_string ("username", NULL, NULL,
     483                 :            :                                                         NULL,
     484                 :            :                                                         G_PARAM_READWRITE|
     485                 :            :                                                         G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     486                 :            : 
     487                 :            :   /**
     488                 :            :    * GMountOperation:password:
     489                 :            :    *
     490                 :            :    * The password that is used for authentication when carrying out
     491                 :            :    * the mount operation.
     492                 :            :    */ 
     493                 :          3 :   g_object_class_install_property (object_class,
     494                 :            :                                    PROP_PASSWORD,
     495                 :            :                                    g_param_spec_string ("password", NULL, NULL,
     496                 :            :                                                         NULL,
     497                 :            :                                                         G_PARAM_READWRITE|
     498                 :            :                                                         G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     499                 :            : 
     500                 :            :   /**
     501                 :            :    * GMountOperation:anonymous:
     502                 :            :    * 
     503                 :            :    * Whether to use an anonymous user when authenticating.
     504                 :            :    */
     505                 :          3 :   g_object_class_install_property (object_class,
     506                 :            :                                    PROP_ANONYMOUS,
     507                 :            :                                    g_param_spec_boolean ("anonymous", NULL, NULL,
     508                 :            :                                                          FALSE,
     509                 :            :                                                          G_PARAM_READWRITE|
     510                 :            :                                                          G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     511                 :            : 
     512                 :            :   /**
     513                 :            :    * GMountOperation:domain:
     514                 :            :    *
     515                 :            :    * The domain to use for the mount operation.
     516                 :            :    */ 
     517                 :          3 :   g_object_class_install_property (object_class,
     518                 :            :                                    PROP_DOMAIN,
     519                 :            :                                    g_param_spec_string ("domain", NULL, NULL,
     520                 :            :                                                         NULL,
     521                 :            :                                                         G_PARAM_READWRITE|
     522                 :            :                                                         G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     523                 :            : 
     524                 :            :   /**
     525                 :            :    * GMountOperation:password-save:
     526                 :            :    *
     527                 :            :    * Determines if and how the password information should be saved. 
     528                 :            :    */ 
     529                 :          3 :   g_object_class_install_property (object_class,
     530                 :            :                                    PROP_PASSWORD_SAVE,
     531                 :            :                                    g_param_spec_enum ("password-save", NULL, NULL,
     532                 :            :                                                       G_TYPE_PASSWORD_SAVE,
     533                 :            :                                                       G_PASSWORD_SAVE_NEVER,
     534                 :            :                                                       G_PARAM_READWRITE|
     535                 :            :                                                       G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     536                 :            : 
     537                 :            :   /**
     538                 :            :    * GMountOperation:choice:
     539                 :            :    *
     540                 :            :    * The index of the user's choice when a question is asked during the 
     541                 :            :    * mount operation. See the #GMountOperation::ask-question signal.
     542                 :            :    */ 
     543                 :          3 :   g_object_class_install_property (object_class,
     544                 :            :                                    PROP_CHOICE,
     545                 :            :                                    g_param_spec_int ("choice", NULL, NULL,
     546                 :            :                                                      0, G_MAXINT, 0,
     547                 :            :                                                      G_PARAM_READWRITE|
     548                 :            :                                                      G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     549                 :            : 
     550                 :            :   /**
     551                 :            :    * GMountOperation:is-tcrypt-hidden-volume:
     552                 :            :    *
     553                 :            :    * Whether the device to be unlocked is a TCRYPT hidden volume.
     554                 :            :    * See [the VeraCrypt documentation](https://www.veracrypt.fr/en/Hidden%20Volume.html).
     555                 :            :    *
     556                 :            :    * Since: 2.58
     557                 :            :    */
     558                 :          3 :   g_object_class_install_property (object_class,
     559                 :            :                                    PROP_IS_TCRYPT_HIDDEN_VOLUME,
     560                 :            :                                    g_param_spec_boolean ("is-tcrypt-hidden-volume", NULL, NULL,
     561                 :            :                                                          FALSE,
     562                 :            :                                                          G_PARAM_READWRITE|
     563                 :            :                                                          G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     564                 :            : 
     565                 :            :   /**
     566                 :            :   * GMountOperation:is-tcrypt-system-volume:
     567                 :            :   *
     568                 :            :   * Whether the device to be unlocked is a TCRYPT system volume.
     569                 :            :   * In this context, a system volume is a volume with a bootloader
     570                 :            :   * and operating system installed. This is only supported for Windows
     571                 :            :   * operating systems. For further documentation, see
     572                 :            :   * [the VeraCrypt documentation](https://www.veracrypt.fr/en/System%20Encryption.html).
     573                 :            :   *
     574                 :            :   * Since: 2.58
     575                 :            :   */
     576                 :          3 :   g_object_class_install_property (object_class,
     577                 :            :                                    PROP_IS_TCRYPT_SYSTEM_VOLUME,
     578                 :            :                                    g_param_spec_boolean ("is-tcrypt-system-volume", NULL, NULL,
     579                 :            :                                                          FALSE,
     580                 :            :                                                          G_PARAM_READWRITE|
     581                 :            :                                                          G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     582                 :            : 
     583                 :            :   /**
     584                 :            :   * GMountOperation:pim:
     585                 :            :   *
     586                 :            :   * The VeraCrypt PIM value, when unlocking a VeraCrypt volume. See
     587                 :            :   * [the VeraCrypt documentation](https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20(PIM).html).
     588                 :            :   *
     589                 :            :   * Since: 2.58
     590                 :            :   */
     591                 :          3 :   g_object_class_install_property (object_class,
     592                 :            :                                    PROP_PIM,
     593                 :            :                                    g_param_spec_uint ("pim", NULL, NULL,
     594                 :            :                                                       0, G_MAXUINT, 0,
     595                 :            :                                                       G_PARAM_READWRITE|
     596                 :            :                                                       G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
     597                 :          3 : }
     598                 :            : 
     599                 :            : static void
     600                 :          3 : g_mount_operation_init (GMountOperation *operation)
     601                 :            : {
     602                 :          3 :   operation->priv = g_mount_operation_get_instance_private (operation);
     603                 :          3 : }
     604                 :            : 
     605                 :            : /**
     606                 :            :  * g_mount_operation_new:
     607                 :            :  * 
     608                 :            :  * Creates a new mount operation.
     609                 :            :  * 
     610                 :            :  * Returns: a #GMountOperation.
     611                 :            :  **/
     612                 :            : GMountOperation *
     613                 :          2 : g_mount_operation_new (void)
     614                 :            : {
     615                 :          2 :   return g_object_new (G_TYPE_MOUNT_OPERATION, NULL);
     616                 :            : }
     617                 :            : 
     618                 :            : /**
     619                 :            :  * g_mount_operation_get_username:
     620                 :            :  * @op: a #GMountOperation.
     621                 :            :  * 
     622                 :            :  * Get the user name from the mount operation.
     623                 :            :  *
     624                 :            :  * Returns: (nullable): a string containing the user name.
     625                 :            :  **/
     626                 :            : const char *
     627                 :          2 : g_mount_operation_get_username (GMountOperation *op)
     628                 :            : {
     629                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
     630                 :          2 :   return op->priv->user;
     631                 :            : }
     632                 :            : 
     633                 :            : /**
     634                 :            :  * g_mount_operation_set_username:
     635                 :            :  * @op: a #GMountOperation.
     636                 :            :  * @username: (nullable): input username.
     637                 :            :  *
     638                 :            :  * Sets the user name within @op to @username.
     639                 :            :  **/
     640                 :            : void
     641                 :          2 : g_mount_operation_set_username (GMountOperation *op,
     642                 :            :                                 const char      *username)
     643                 :            : {
     644                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     645                 :          2 :   g_free (op->priv->user);
     646                 :          2 :   op->priv->user = g_strdup (username);
     647                 :          2 :   g_object_notify (G_OBJECT (op), "username");
     648                 :            : }
     649                 :            : 
     650                 :            : /**
     651                 :            :  * g_mount_operation_get_password:
     652                 :            :  * @op: a #GMountOperation.
     653                 :            :  *
     654                 :            :  * Gets a password from the mount operation. 
     655                 :            :  *
     656                 :            :  * Returns: (nullable): a string containing the password within @op.
     657                 :            :  **/
     658                 :            : const char *
     659                 :          2 : g_mount_operation_get_password (GMountOperation *op)
     660                 :            : {
     661                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
     662                 :          2 :   return op->priv->password;
     663                 :            : }
     664                 :            : 
     665                 :            : /**
     666                 :            :  * g_mount_operation_set_password:
     667                 :            :  * @op: a #GMountOperation.
     668                 :            :  * @password: (nullable): password to set.
     669                 :            :  * 
     670                 :            :  * Sets the mount operation's password to @password.  
     671                 :            :  *
     672                 :            :  **/
     673                 :            : void
     674                 :          2 : g_mount_operation_set_password (GMountOperation *op,
     675                 :            :                                 const char      *password)
     676                 :            : {
     677                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     678                 :          2 :   g_free (op->priv->password);
     679                 :          2 :   op->priv->password = g_strdup (password);
     680                 :          2 :   g_object_notify (G_OBJECT (op), "password");
     681                 :            : }
     682                 :            : 
     683                 :            : /**
     684                 :            :  * g_mount_operation_get_anonymous:
     685                 :            :  * @op: a #GMountOperation.
     686                 :            :  * 
     687                 :            :  * Check to see whether the mount operation is being used 
     688                 :            :  * for an anonymous user.
     689                 :            :  * 
     690                 :            :  * Returns: %TRUE if mount operation is anonymous. 
     691                 :            :  **/
     692                 :            : gboolean
     693                 :          2 : g_mount_operation_get_anonymous (GMountOperation *op)
     694                 :            : {
     695                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
     696                 :          2 :   return op->priv->anonymous;
     697                 :            : }
     698                 :            : 
     699                 :            : /**
     700                 :            :  * g_mount_operation_set_anonymous:
     701                 :            :  * @op: a #GMountOperation.
     702                 :            :  * @anonymous: boolean value.
     703                 :            :  * 
     704                 :            :  * Sets the mount operation to use an anonymous user if @anonymous is %TRUE.
     705                 :            :  **/  
     706                 :            : void
     707                 :          2 : g_mount_operation_set_anonymous (GMountOperation *op,
     708                 :            :                                  gboolean         anonymous)
     709                 :            : {
     710                 :            :   GMountOperationPrivate *priv;
     711                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     712                 :          2 :   priv = op->priv;
     713                 :            : 
     714         [ +  - ]:          2 :   if (priv->anonymous != anonymous)
     715                 :            :     {
     716                 :          2 :       priv->anonymous = anonymous;
     717                 :          2 :       g_object_notify (G_OBJECT (op), "anonymous");
     718                 :            :     }
     719                 :            : }
     720                 :            : 
     721                 :            : /**
     722                 :            :  * g_mount_operation_get_domain:
     723                 :            :  * @op: a #GMountOperation.
     724                 :            :  * 
     725                 :            :  * Gets the domain of the mount operation.
     726                 :            :  * 
     727                 :            :  * Returns: (nullable): a string set to the domain.
     728                 :            :  **/
     729                 :            : const char *
     730                 :          2 : g_mount_operation_get_domain (GMountOperation *op)
     731                 :            : {
     732                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
     733                 :          2 :   return op->priv->domain;
     734                 :            : }
     735                 :            : 
     736                 :            : /**
     737                 :            :  * g_mount_operation_set_domain:
     738                 :            :  * @op: a #GMountOperation.
     739                 :            :  * @domain: (nullable): the domain to set.
     740                 :            :  * 
     741                 :            :  * Sets the mount operation's domain. 
     742                 :            :  **/  
     743                 :            : void
     744                 :          2 : g_mount_operation_set_domain (GMountOperation *op,
     745                 :            :                               const char      *domain)
     746                 :            : {
     747                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     748                 :          2 :   g_free (op->priv->domain);
     749                 :          2 :   op->priv->domain = g_strdup (domain);
     750                 :          2 :   g_object_notify (G_OBJECT (op), "domain");
     751                 :            : }
     752                 :            : 
     753                 :            : /**
     754                 :            :  * g_mount_operation_get_password_save:
     755                 :            :  * @op: a #GMountOperation.
     756                 :            :  * 
     757                 :            :  * Gets the state of saving passwords for the mount operation.
     758                 :            :  *
     759                 :            :  * Returns: a #GPasswordSave flag. 
     760                 :            :  **/  
     761                 :            : 
     762                 :            : GPasswordSave
     763                 :          2 : g_mount_operation_get_password_save (GMountOperation *op)
     764                 :            : {
     765                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), G_PASSWORD_SAVE_NEVER);
     766                 :          2 :   return op->priv->password_save;
     767                 :            : }
     768                 :            : 
     769                 :            : /**
     770                 :            :  * g_mount_operation_set_password_save:
     771                 :            :  * @op: a #GMountOperation.
     772                 :            :  * @save: a set of #GPasswordSave flags.
     773                 :            :  * 
     774                 :            :  * Sets the state of saving passwords for the mount operation.
     775                 :            :  * 
     776                 :            :  **/   
     777                 :            : void
     778                 :          2 : g_mount_operation_set_password_save (GMountOperation *op,
     779                 :            :                                      GPasswordSave    save)
     780                 :            : {
     781                 :            :   GMountOperationPrivate *priv;
     782                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     783                 :          2 :   priv = op->priv;
     784                 :            :  
     785         [ +  + ]:          2 :   if (priv->password_save != save)
     786                 :            :     {
     787                 :          1 :       priv->password_save = save;
     788                 :          1 :       g_object_notify (G_OBJECT (op), "password-save");
     789                 :            :     }
     790                 :            : }
     791                 :            : 
     792                 :            : /**
     793                 :            :  * g_mount_operation_get_choice:
     794                 :            :  * @op: a #GMountOperation.
     795                 :            :  * 
     796                 :            :  * Gets a choice from the mount operation.
     797                 :            :  *
     798                 :            :  * Returns: an integer containing an index of the user's choice from 
     799                 :            :  * the choice's list, or `0`.
     800                 :            :  **/
     801                 :            : int
     802                 :          2 : g_mount_operation_get_choice (GMountOperation *op)
     803                 :            : {
     804                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), 0);
     805                 :          2 :   return op->priv->choice;
     806                 :            : }
     807                 :            : 
     808                 :            : /**
     809                 :            :  * g_mount_operation_set_choice:
     810                 :            :  * @op: a #GMountOperation.
     811                 :            :  * @choice: an integer.
     812                 :            :  *
     813                 :            :  * Sets a default choice for the mount operation.
     814                 :            :  **/
     815                 :            : void
     816                 :          2 : g_mount_operation_set_choice (GMountOperation *op,
     817                 :            :                               int              choice)
     818                 :            : {
     819                 :            :   GMountOperationPrivate *priv;
     820                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     821                 :          2 :   priv = op->priv;
     822         [ +  - ]:          2 :   if (priv->choice != choice)
     823                 :            :     {
     824                 :          2 :       priv->choice = choice;
     825                 :          2 :       g_object_notify (G_OBJECT (op), "choice");
     826                 :            :     }
     827                 :            : }
     828                 :            : 
     829                 :            : /**
     830                 :            :  * g_mount_operation_get_is_tcrypt_hidden_volume:
     831                 :            :  * @op: a #GMountOperation.
     832                 :            :  *
     833                 :            :  * Check to see whether the mount operation is being used
     834                 :            :  * for a TCRYPT hidden volume.
     835                 :            :  *
     836                 :            :  * Returns: %TRUE if mount operation is for hidden volume.
     837                 :            :  *
     838                 :            :  * Since: 2.58
     839                 :            :  **/
     840                 :            : gboolean
     841                 :          2 : g_mount_operation_get_is_tcrypt_hidden_volume (GMountOperation *op)
     842                 :            : {
     843                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
     844                 :          2 :   return op->priv->hidden_volume;
     845                 :            : }
     846                 :            : 
     847                 :            : /**
     848                 :            :  * g_mount_operation_set_is_tcrypt_hidden_volume:
     849                 :            :  * @op: a #GMountOperation.
     850                 :            :  * @hidden_volume: boolean value.
     851                 :            :  *
     852                 :            :  * Sets the mount operation to use a hidden volume if @hidden_volume is %TRUE.
     853                 :            :  *
     854                 :            :  * Since: 2.58
     855                 :            :  **/
     856                 :            : void
     857                 :          2 : g_mount_operation_set_is_tcrypt_hidden_volume (GMountOperation *op,
     858                 :            :                                                gboolean hidden_volume)
     859                 :            : {
     860                 :            :   GMountOperationPrivate *priv;
     861                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     862                 :          2 :   priv = op->priv;
     863                 :            : 
     864         [ +  - ]:          2 :   if (priv->hidden_volume != hidden_volume)
     865                 :            :     {
     866                 :          2 :       priv->hidden_volume = hidden_volume;
     867                 :          2 :       g_object_notify (G_OBJECT (op), "is-tcrypt-hidden-volume");
     868                 :            :     }
     869                 :            : }
     870                 :            : 
     871                 :            : /**
     872                 :            :  * g_mount_operation_get_is_tcrypt_system_volume:
     873                 :            :  * @op: a #GMountOperation.
     874                 :            :  *
     875                 :            :  * Check to see whether the mount operation is being used
     876                 :            :  * for a TCRYPT system volume.
     877                 :            :  *
     878                 :            :  * Returns: %TRUE if mount operation is for system volume.
     879                 :            :  *
     880                 :            :  * Since: 2.58
     881                 :            :  **/
     882                 :            : gboolean
     883                 :          2 : g_mount_operation_get_is_tcrypt_system_volume (GMountOperation *op)
     884                 :            : {
     885                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
     886                 :          2 :   return op->priv->system_volume;
     887                 :            : }
     888                 :            : 
     889                 :            : /**
     890                 :            :  * g_mount_operation_set_is_tcrypt_system_volume:
     891                 :            :  * @op: a #GMountOperation.
     892                 :            :  * @system_volume: boolean value.
     893                 :            :  *
     894                 :            :  * Sets the mount operation to use a system volume if @system_volume is %TRUE.
     895                 :            :  *
     896                 :            :  * Since: 2.58
     897                 :            :  **/
     898                 :            : void
     899                 :          2 : g_mount_operation_set_is_tcrypt_system_volume (GMountOperation *op,
     900                 :            :                                                gboolean system_volume)
     901                 :            : {
     902                 :            :   GMountOperationPrivate *priv;
     903                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     904                 :          2 :   priv = op->priv;
     905                 :            : 
     906         [ +  - ]:          2 :   if (priv->system_volume != system_volume)
     907                 :            :     {
     908                 :          2 :       priv->system_volume = system_volume;
     909                 :          2 :       g_object_notify (G_OBJECT (op), "is-tcrypt-system-volume");
     910                 :            :     }
     911                 :            : }
     912                 :            : 
     913                 :            : /**
     914                 :            :  * g_mount_operation_get_pim:
     915                 :            :  * @op: a #GMountOperation.
     916                 :            :  *
     917                 :            :  * Gets a PIM from the mount operation.
     918                 :            :  *
     919                 :            :  * Returns: The VeraCrypt PIM within @op.
     920                 :            :  *
     921                 :            :  * Since: 2.58
     922                 :            :  **/
     923                 :            : guint
     924                 :          2 : g_mount_operation_get_pim (GMountOperation *op)
     925                 :            : {
     926                 :          2 :   g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), 0);
     927                 :          2 :   return op->priv->pim;
     928                 :            : }
     929                 :            : 
     930                 :            : /**
     931                 :            :  * g_mount_operation_set_pim:
     932                 :            :  * @op: a #GMountOperation.
     933                 :            :  * @pim: an unsigned integer.
     934                 :            :  *
     935                 :            :  * Sets the mount operation's PIM to @pim.
     936                 :            :  *
     937                 :            :  * Since: 2.58
     938                 :            :  **/
     939                 :            : void
     940                 :          2 : g_mount_operation_set_pim (GMountOperation *op,
     941                 :            :                            guint pim)
     942                 :            : {
     943                 :            :   GMountOperationPrivate *priv;
     944                 :          2 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     945                 :          2 :   priv = op->priv;
     946         [ +  - ]:          2 :   if (priv->pim != pim)
     947                 :            :     {
     948                 :          2 :       priv->pim = pim;
     949                 :          2 :       g_object_notify (G_OBJECT (op), "pim");
     950                 :            :     }
     951                 :            : }
     952                 :            : 
     953                 :            : /**
     954                 :            :  * g_mount_operation_reply:
     955                 :            :  * @op: a #GMountOperation
     956                 :            :  * @result: a #GMountOperationResult
     957                 :            :  * 
     958                 :            :  * Emits the #GMountOperation::reply signal.
     959                 :            :  **/
     960                 :            : void
     961                 :          0 : g_mount_operation_reply (GMountOperation *op,
     962                 :            :                          GMountOperationResult result)
     963                 :            : {
     964                 :          0 :   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
     965                 :          0 :   g_signal_emit (op, signals[REPLY], 0, result);
     966                 :            : }

Generated by: LCOV version 1.14