Class MountOperation

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
MountOperation

@Generated("org.javagi.JavaGI") public class MountOperation extends GObject

GMountOperation provides a mechanism for interacting with the user. It can be used for authenticating mountable operations, such as loop mounting files, hard drive partitions or server locations. It can also be used to ask the user questions or show a list of applications preventing unmount or eject operations from completing.

Note that GMountOperation is used for more than just Mount objects – for example it is also used in Drive.start(Set, MountOperation, Cancellable, AsyncReadyCallback) and Drive.stop(Set, MountOperation, Cancellable, AsyncReadyCallback).

Users should instantiate a subclass of this that implements all the various callbacks to show the required dialogs, such as GtkMountOperation. If no user interaction is desired (for example when automounting filesystems at login time), usually NULL can be passed, see each method taking a GMountOperation for details.

Throughout the API, the term ‘TCRYPT’ is used to mean ‘compatible with TrueCrypt and VeraCrypt’. TrueCrypt is a discontinued system for encrypting file containers, partitions or whole disks, typically used with Windows. VeraCrypt is a maintained fork of TrueCrypt with various improvements and auditing fixes.

  • Constructor Details

    • MountOperation

      public MountOperation(MemorySegment address)
      Create a MountOperation instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • MountOperation

      public MountOperation()
      Create a new MountOperation.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the MountOperation class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected MountOperation asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getAnonymous

      public boolean getAnonymous()
      Check to see whether the mount operation is being used for an anonymous user.
      Returns:
      true if mount operation is anonymous.
    • getChoice

      public int getChoice()
      Gets a choice from the mount operation.
      Returns:
      an integer containing an index of the user's choice from the choice's list, or 0.
    • getDomain

      public @Nullable String getDomain()
      Gets the domain of the mount operation.
      Returns:
      a string set to the domain.
    • getIsTcryptHiddenVolume

      public boolean getIsTcryptHiddenVolume()
      Check to see whether the mount operation is being used for a TCRYPT hidden volume.
      Returns:
      true if mount operation is for hidden volume.
      Since:
      2.58
    • getIsTcryptSystemVolume

      public boolean getIsTcryptSystemVolume()
      Check to see whether the mount operation is being used for a TCRYPT system volume.
      Returns:
      true if mount operation is for system volume.
      Since:
      2.58
    • getPassword

      public @Nullable String getPassword()
      Gets a password from the mount operation.
      Returns:
      a string containing the password within op.
    • getPasswordSave

      public PasswordSave getPasswordSave()
      Gets the state of saving passwords for the mount operation.
      Returns:
      a GPasswordSave flag.
    • getPim

      public int getPim()
      Gets a PIM from the mount operation.
      Returns:
      The VeraCrypt PIM within op.
      Since:
      2.58
    • getUsername

      public @Nullable String getUsername()
      Get the user name from the mount operation.
      Returns:
      a string containing the user name.
    • reply

      public void reply(MountOperationResult result)
      Emits the GMountOperation::reply signal.
      Parameters:
      result - a GMountOperationResult
    • setAnonymous

      public void setAnonymous(boolean anonymous)
      Sets the mount operation to use an anonymous user if anonymous is true.
      Parameters:
      anonymous - boolean value.
    • setChoice

      public void setChoice(int choice)
      Sets a default choice for the mount operation.
      Parameters:
      choice - an integer.
    • setDomain

      public void setDomain(@Nullable String domain)
      Sets the mount operation's domain.
      Parameters:
      domain - the domain to set.
    • setIsTcryptHiddenVolume

      public void setIsTcryptHiddenVolume(boolean hiddenVolume)
      Sets the mount operation to use a hidden volume if hiddenVolume is true.
      Parameters:
      hiddenVolume - boolean value.
      Since:
      2.58
    • setIsTcryptSystemVolume

      public void setIsTcryptSystemVolume(boolean systemVolume)
      Sets the mount operation to use a system volume if systemVolume is true.
      Parameters:
      systemVolume - boolean value.
      Since:
      2.58
    • setPassword

      public void setPassword(@Nullable String password)
      Sets the mount operation's password to password.
      Parameters:
      password - password to set.
    • setPasswordSave

      public void setPasswordSave(PasswordSave save)
      Sets the state of saving passwords for the mount operation.
      Parameters:
      save - a set of GPasswordSave flags.
    • setPim

      public void setPim(int pim)
      Sets the mount operation's PIM to pim.
      Parameters:
      pim - an unsigned integer.
      Since:
      2.58
    • setUsername

      public void setUsername(@Nullable String username)
      Sets the user name within this MountOperation to username.
      Parameters:
      username - input username.
    • aborted

      protected void aborted()
    • askPassword

      protected void askPassword(String message, String defaultUser, String defaultDomain, Set<AskPasswordFlags> flags)
    • askQuestion

      protected void askQuestion(String message, @Nullable String @Nullable [] choices)
      Virtual implementation of GMountOperation::ask-question.
      Parameters:
      message - string containing a message to display to the user
      choices - an array of strings for each possible choice
    • showProcesses

      protected void showProcesses(String message, @Nullable Pid @Nullable [] processes, @Nullable String @Nullable [] choices)
      Virtual implementation of GMountOperation::show-processes.
      Parameters:
      message - string containing a message to display to the user
      processes - an array of GPid for processes blocking the operation
      choices - an array of strings for each possible choice
      Since:
      2.22
    • showUnmountProgress

      protected void showUnmountProgress(String message, long timeLeft, long bytesLeft)
    • onAborted

      Emitted by the backend when e.g. a device becomes unavailable while a mount operation is in progress.

      Implementations of GMountOperation should handle this signal by dismissing open password dialogs.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.20
      See Also:
    • emitAborted

      public void emitAborted()
      Emits the "aborted" signal. See onAborted(MountOperation.AbortedCallback).
    • onAskPassword

      Emitted when a mount operation asks the user for a password.

      If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a GtkMessageDialog.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitAskPassword

      public void emitAskPassword(String message, String defaultUser, String defaultDomain, Set<AskPasswordFlags> flags)
      Emits the "ask-password" signal. See onAskPassword(MountOperation.AskPasswordCallback).
    • onAskQuestion

      Emitted when asking the user a question and gives a list of choices for the user to choose from.

      If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a GtkMessageDialog.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitAskQuestion

      public void emitAskQuestion(String message, @Nullable String @Nullable [] choices)
      Emits the "ask-question" signal. See onAskQuestion(MountOperation.AskQuestionCallback).
    • onReply

      Emitted when the user has replied to the mount operation.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitReply

      public void emitReply(MountOperationResult result)
      Emits the "reply" signal. See onReply(MountOperation.ReplyCallback).
    • onShowProcesses

      Emitted when one or more processes are blocking an operation e.g. unmounting/ejecting a GMount or stopping a GDrive.

      Note that this signal may be emitted several times to update the list of blocking processes as processes close files. The application should only respond with g_mount_operation_reply() to the latest signal (setting GMountOperation:choice to the choice the user made).

      If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a GtkMessageDialog.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.22
      See Also:
    • emitShowProcesses

      public void emitShowProcesses(String message, @Nullable Pid @Nullable [] processes, @Nullable String @Nullable [] choices)
      Emits the "show-processes" signal. See onShowProcesses(MountOperation.ShowProcessesCallback).
    • onShowUnmountProgress

      Emitted when an unmount operation has been busy for more than some time (typically 1.5 seconds).

      When unmounting or ejecting a volume, the kernel might need to flush pending data in its buffers to the volume stable storage, and this operation can take a considerable amount of time. This signal may be emitted several times as long as the unmount operation is outstanding, and then one last time when the operation is completed, with bytesLeft set to zero.

      Implementations of GMountOperation should handle this signal by showing an UI notification, and then dismiss it, or show another notification of completion, when bytesLeft reaches zero.

      If the message contains a line break, the first line should be presented as a heading. For example, it may be used as the primary text in a GtkMessageDialog.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.34
      See Also:
    • emitShowUnmountProgress

      public void emitShowUnmountProgress(String message, long timeLeft, long bytesLeft)
      Emits the "show-unmount-progress" signal. See onShowUnmountProgress(MountOperation.ShowUnmountProgressCallback).
    • builder

      public static MountOperation.Builder<? extends MountOperation.Builder> builder()
      A MountOperation.Builder object constructs a MountOperation with the specified properties. Use the various set...() methods to set properties, and finish construction with MountOperation.Builder.build().
      Returns:
      the builder object