Class Collection

All Implemented Interfaces:
AsyncInitable, DBusInterface, Initable, Proxy

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

A proxy object representing a collection of secrets in the Secret Service.

SecretCollection represents a collection of secret items stored in the Secret Service.

A collection can be in a locked or unlocked state. Use SecretService.lock or SecretService.unlock to lock or unlock the collection.

Use the SecretCollection:items property or SecretCollection.getItems to lookup the items in the collection. There may not be any items exposed when the collection is locked.

  • Constructor Details

    • Collection

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

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

    • getType

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

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

      protected Collection 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
    • forDbusPathFinish

      public static Collection forDbusPathFinish(AsyncResult result) throws GErrorException
      Finish asynchronous operation to get a new collection proxy for a collection in the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • forDbusPathSync

      public static Collection forDbusPathSync(@Nullable Service service, String collectionPath, Set<CollectionFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Get a new collection proxy for a collection in the secret service.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      service - a secret service object
      collectionPath - the D-Bus path of the collection
      flags - options for the collection initialization
      cancellable - optional cancellation object
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • forDbusPathSync

      public static Collection forDbusPathSync(@Nullable Service service, String collectionPath, CollectionFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Get a new collection proxy for a collection in the secret service.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      service - a secret service object
      collectionPath - the D-Bus path of the collection
      flags - options for the collection initialization
      cancellable - optional cancellation object
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • create

      public static void create(@Nullable Service service, String label, @Nullable String alias, Set<CollectionCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new collection in the secret service.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If you specify an alias, and a collection with that alias already exists, then a new collection will not be created. The previous one will be returned instead.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      Parameters:
      service - a secret service object
      label - label for the new collection
      alias - alias to assign to the collection
      flags - currently unused
      cancellable - optional cancellation object
      callback - called when the operation completes
    • create

      public static void create(@Nullable Service service, String label, @Nullable String alias, CollectionCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new collection in the secret service.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If you specify an alias, and a collection with that alias already exists, then a new collection will not be created. The previous one will be returned instead.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      Parameters:
      service - a secret service object
      label - label for the new collection
      alias - alias to assign to the collection
      flags - currently unused
      cancellable - optional cancellation object
      callback - called when the operation completes
    • createFinish

      public static Collection createFinish(AsyncResult result) throws GErrorException
      Finish operation to create a new collection in the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • createSync

      public static Collection createSync(@Nullable Service service, String label, @Nullable String alias, Set<CollectionCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new collection in the secret service.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      An alias is a well-known tag for a collection, such as default (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If you specify an alias, and a collection with that alias already exists, then a new collection will not be created. The previous one will be returned instead.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

      Parameters:
      service - a secret service object
      label - label for the new collection
      alias - alias to assign to the collection
      flags - currently unused
      cancellable - optional cancellation object
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • createSync

      public static Collection createSync(@Nullable Service service, String label, @Nullable String alias, CollectionCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new collection in the secret service.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      An alias is a well-known tag for a collection, such as default (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If you specify an alias, and a collection with that alias already exists, then a new collection will not be created. The previous one will be returned instead.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

      Parameters:
      service - a secret service object
      label - label for the new collection
      alias - alias to assign to the collection
      flags - currently unused
      cancellable - optional cancellation object
      Returns:
      the new collection, which should be unreferenced with GObject#unref
      Throws:
      GErrorException - see GError
    • forAlias

      public static void forAlias(@Nullable Service service, String alias, Set<CollectionFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lookup which collection is assigned to this alias. Aliases help determine well known collections, such as 'default'.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      service - a secret service object
      alias - the alias to lookup
      flags - options for the collection initialization
      cancellable - optional cancellation object
      callback - called when the operation completes
    • forAlias

      public static void forAlias(@Nullable Service service, String alias, CollectionFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lookup which collection is assigned to this alias. Aliases help determine well known collections, such as 'default'.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      service - a secret service object
      alias - the alias to lookup
      flags - options for the collection initialization
      cancellable - optional cancellation object
      callback - called when the operation completes
    • forAliasFinish

      public static @Nullable Collection forAliasFinish(AsyncResult result) throws GErrorException
      Finish an asynchronous operation to lookup which collection is assigned to an alias.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      the collection, or null if none assigned to the alias
      Throws:
      GErrorException - see GError
    • forAliasSync

      public static @Nullable Collection forAliasSync(@Nullable Service service, String alias, Set<CollectionFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Lookup which collection is assigned to this alias. Aliases help determine well known collections, such as default.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      service - a secret service object
      alias - the alias to lookup
      flags - options for the collection initialization
      cancellable - optional cancellation object
      Returns:
      the collection, or null if none assigned to the alias
      Throws:
      GErrorException - see GError
    • forAliasSync

      public static @Nullable Collection forAliasSync(@Nullable Service service, String alias, CollectionFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Lookup which collection is assigned to this alias. Aliases help determine well known collections, such as default.

      If service is null, then Service.getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      service - a secret service object
      alias - the alias to lookup
      flags - options for the collection initialization
      cancellable - optional cancellation object
      Returns:
      the collection, or null if none assigned to the alias
      Throws:
      GErrorException - see GError
    • newForDbusPath

      public static void newForDbusPath(@Nullable Service service, String collectionPath, Set<CollectionFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Get a new collection proxy for a collection in the secret service.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      service - a secret service object
      collectionPath - the D-Bus path of the collection
      flags - options for the collection initialization
      cancellable - optional cancellation object
      callback - called when the operation completes
    • newForDbusPath

      public static void newForDbusPath(@Nullable Service service, String collectionPath, CollectionFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Get a new collection proxy for a collection in the secret service.

      If service is null, then Service.get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      service - a secret service object
      collectionPath - the D-Bus path of the collection
      flags - options for the collection initialization
      cancellable - optional cancellation object
      callback - called when the operation completes
    • delete

      public void delete(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Delete this collection.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      cancellable - optional cancellation object
      callback - called when the operation completes
    • deleteFinish

      public boolean deleteFinish(AsyncResult result) throws GErrorException
      Complete operation to delete this collection.
      Parameters:
      result - asynchronous result passed to the callback
      Returns:
      whether the collection was successfully deleted or not
      Throws:
      GErrorException - see GError
    • deleteSync

      public boolean deleteSync(@Nullable Cancellable cancellable) throws GErrorException

      Delete this collection.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. Service.prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      cancellable - optional cancellation object
      Returns:
      whether the collection was successfully deleted or not
      Throws:
      GErrorException - see GError
    • getCreated

      public long getCreated()

      Get the created date and time of the collection.

      The return value is the number of seconds since the unix epoch, January 1st 1970.

      Returns:
      the created date and time
    • getCollectionFlags

      public Set<CollectionFlags> getCollectionFlags()

      Get the flags representing what features of the SecretCollection proxy have been initialized.

      Use loadItems(Cancellable, AsyncReadyCallback) to initialize further features and change the flags.

      Returns:
      the flags for features initialized
    • getItems

      public List<Item> getItems()
      Get the list of items in this collection.
      Returns:
      a list of items, when done, the list should be freed with List#free, and each item should be released with GObject#unref
    • getLabel

      public String getLabel()
      Get the label of this collection.
      Returns:
      the label, which should be freed with GLib#free
    • getLocked

      public boolean getLocked()

      Get whether the collection is locked or not.

      Use Service.lock(List, Cancellable, AsyncReadyCallback) or Service.unlock(List, Cancellable, AsyncReadyCallback) to lock or unlock the collection.

      Returns:
      whether the collection is locked or not
    • getModified

      public long getModified()

      Get the modified date and time of the collection.

      The return value is the number of seconds since the unix epoch, January 1st 1970.

      Returns:
      the modified date and time
    • getService

      public Service getService()
      Get the Secret Service object that this collection was created with.
      Returns:
      the Secret Service object
    • loadItems

      public void loadItems(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Ensure that the SecretCollection proxy has loaded all the items present in the Secret Service.

      This affects the result of getItems().

      For collections returned from Service.getCollections() the items will have already been loaded.

      This method will return immediately and complete asynchronously.

      Parameters:
      cancellable - optional cancellation object
      callback - called when the operation completes
    • loadItemsFinish

      public boolean loadItemsFinish(AsyncResult result) throws GErrorException
      Complete an asynchronous operation to ensure that the SecretCollection proxy has loaded all the items present in the Secret Service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether the load was successful or not
      Throws:
      GErrorException - see GError
    • loadItemsSync

      public boolean loadItemsSync(@Nullable Cancellable cancellable) throws GErrorException

      Ensure that the SecretCollection proxy has loaded all the items present in the Secret Service. This affects the result of getItems().

      For collections returned from Service.getCollections() the items will have already been loaded.

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

      Parameters:
      cancellable - optional cancellation object
      Returns:
      whether the load was successful or not
      Throws:
      GErrorException - see GError
    • refresh

      public void refresh()

      Refresh the properties on this collection. This fires off a request to refresh, and the properties will be updated later.

      Calling this method is not normally necessary, as the secret service will notify the client when properties change.

    • search

      public void search(@Nullable Schema schema, HashTable<String,String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items matching the attributes in the collection. The attributes should be a table of string keys and string values.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function returns immediately and completes asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      callback - called when the operation completes
    • search

      public void search(@Nullable Schema schema, HashTable<String,String> attributes, SearchFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items matching the attributes in the collection. The attributes should be a table of string keys and string values.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function returns immediately and completes asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      callback - called when the operation completes
    • searchFinish

      public List<Item> searchFinish(AsyncResult result) throws GErrorException
      Complete asynchronous operation to search for items in a collection.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • searchForDbusPaths

      public void searchForDbusPaths(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items in this Collection matching the attributes, and return their DBus object paths.

      Only the specified collection is searched. The attributes should be a table of string keys and string values.

      This function returns immediately and completes asynchronously.

      When your callback is called use searchForDbusPathsFinish(AsyncResult) to get the results of this function. Only the DBus object paths of the items will be returned. If you would like Item objects to be returned instead, then use the search(Schema, HashTable, Set, Cancellable, AsyncReadyCallback) function.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      cancellable - optional cancellation object
      callback - called when the operation completes
    • searchForDbusPathsFinish

      public String[] searchForDbusPathsFinish(AsyncResult result) throws GErrorException

      Complete asynchronous operation to search for items in a collection.

      DBus object paths of the items will be returned. If you would to have Item objects to be returned instead, then use the search(Schema, HashTable, Set, Cancellable, AsyncReadyCallback) and searchFinish(AsyncResult) functions.

      Parameters:
      result - asynchronous result passed to callback
      Returns:
      an array of DBus object paths for matching items.
      Throws:
      GErrorException - see GError
    • searchForDbusPathsSync

      public String[] searchForDbusPathsSync(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable) throws GErrorException

      Search for items matching the attributes in collection, and return their DBus object paths.

      The attributes should be a table of string keys and string values.

      This function may block indefinitely. Use the asynchronous version in user interface threads.

      DBus object paths of the items will be returned. If you would to have Item objects to be returned instead, then use the searchSync(Schema, HashTable, Set, Cancellable) function.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      cancellable - optional cancellation object
      Returns:
      an array of DBus object paths for matching items.
      Throws:
      GErrorException - see GError
    • searchSync

      public List<Item> searchSync(@Nullable Schema schema, HashTable<String,String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Search for items matching the attributes in the collection. The attributes should be a table of string keys and string values.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function may block indefinitely. Use the asynchronous version in user interface threads.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • searchSync

      public List<Item> searchSync(@Nullable Schema schema, HashTable<String,String> attributes, SearchFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Search for items matching the attributes in the collection. The attributes should be a table of string keys and string values.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function may block indefinitely. Use the asynchronous version in user interface threads.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • setLabel

      public void setLabel(String label, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Set the label of this collection.

      This function returns immediately and completes asynchronously.

      Parameters:
      label - a new label
      cancellable - optional cancellation object
      callback - called when the operation completes
    • setLabelFinish

      public boolean setLabelFinish(AsyncResult result) throws GErrorException
      Complete asynchronous operation to set the label of this collection.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      whether the change was successful or not
      Throws:
      GErrorException - see GError
    • setLabelSync

      public boolean setLabelSync(String label, @Nullable Cancellable cancellable) throws GErrorException

      Set the label of this collection.

      This function may block indefinitely. Use the asynchronous version in user interface threads.

      Parameters:
      label - a new label
      cancellable - optional cancellation object
      Returns:
      whether the change was successful or not
      Throws:
      GErrorException - see GError
    • builder

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