Class Prompt

All Implemented Interfaces:
AsyncInitable, DBusInterface, Initable, Proxy

@Generated("org.javagi.JavaGI") public class Prompt extends DBusProxy implements AsyncInitable, DBusInterface, Initable

A prompt in the Service

A proxy object representing a prompt that the Secret Service will display to the user.

Certain actions on the Secret Service require user prompting to complete, such as creating a collection, or unlocking a collection. When such a prompt is necessary, then a SecretPrompt object is created by this library, and passed to the Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) method. In this way it is handled automatically.

In order to customize prompt handling, override the Service.promptAsync(Prompt, VariantType, Cancellable, AsyncReadyCallback) and Service.promptFinish(AsyncResult) virtual methods of the Service class.

  • Constructor Details

    • Prompt

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

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

    • getType

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

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

      protected Prompt 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 DBusProxy
      Returns:
      the instance as if it were its parent type
    • perform

      public void perform(@Nullable String windowId, VariantType returnType, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Runs a prompt and performs the prompting.

      Returns true if the prompt was completed and not dismissed.

      If windowId is non-null then it is used as an XWindow id on Linux. The API expects this id to be converted to a string using the %d printf format. The Secret Service can make its prompt transient for the window with this id. In some Secret Service implementations this is not possible, so the behavior depending on this should degrade gracefully.

      This method will return immediately and complete asynchronously.

      Parameters:
      windowId - string form of XWindow id for parent window to be transient for
      returnType - the variant type of the prompt result
      cancellable - optional cancellation object
      callback - called when the operation completes
    • performFinish

      public Variant performFinish(AsyncResult result) throws GErrorException

      Complete asynchronous operation to run a prompt and perform the prompting.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      null if the prompt was dismissed or an error occurred, a variant result if the prompt was successful
      Throws:
      GErrorException - see GError
    • performSync

      public Variant performSync(@Nullable String windowId, @Nullable Cancellable cancellable, VariantType returnType) throws GErrorException

      Runs a prompt and performs the prompting.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      If windowId is non-null then it is used as an XWindow id on Linux. The API expects this id to be converted to a string using the %d printf format. The Secret Service can make its prompt transient for the window with this id. In some Secret Service implementations this is not possible, so the behavior depending on this should degrade gracefully.

      This method may block indefinitely and should not be used in user interface threads.

      Parameters:
      windowId - string form of XWindow id for parent window to be transient for
      cancellable - optional cancellation object
      returnType - the variant type of the prompt result
      Returns:
      null if the prompt was dismissed or an error occurred
      Throws:
      GErrorException - see GError
    • run

      public Variant run(@Nullable String windowId, @Nullable Cancellable cancellable, VariantType returnType) throws GErrorException

      Runs a prompt and performs the prompting.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      If windowId is non-null then it is used as an XWindow id on Linux. The API expects this id to be converted to a string using the %d printf format. The Secret Service can make its prompt transient for the window with this id. In some Secret Service implementations this is not possible, so the behavior depending on this should degrade gracefully.

      This runs the dialog in a recursive mainloop. When run from a user interface thread, this means the user interface will remain responsive. Care should be taken that appropriate user interface actions are disabled while running the prompt.

      Parameters:
      windowId - string form of XWindow id for parent window to be transient for
      cancellable - optional cancellation object
      returnType - the variant type of the prompt result
      Returns:
      null if the prompt was dismissed or an error occurred
      Throws:
      GErrorException - see GError
    • builder

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