libsecret uses standard the standard GCancellable idiom to cancel operations.
It is not necessary to check whether the keyring daemon is available before using it. It is started automatically.
Errors are returned as standard GError in the usual way. There are fewer errors that are worth handling in an intelligent way, exceptions are in the SecretError enumeration. It is not recommended to display any GError message returned by libsecret to the user. Most of the possible errors are DBus communication problems or similar.
Replacements for related libgnome-keyring functions and types are described below:
Table 10.
libgnome-keyring | libsecret |
---|---|
gnome_keyring_cancel_request() |
g_cancellable_cancel() on a GCancellable passed to the relevant operation |
gnome_keyring_is_available() |
no equivalent, the secret service is autostarted as necessary |
gnome_keyring_result_to_message() |
use the message in the GError, although most failures are not appropriate for display to the user |
GNOME_KEYRING_RESULT_OK |
no GError returned |
GNOME_KEYRING_RESULT_DENIED |
no longer used, item or collection is simply not unlocked |
GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON |
G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND |
GNOME_KEYRING_RESULT_ALREADY_UNLOCKED |
no error, success returned |
GNOME_KEYRING_RESULT_NO_SUCH_KEYRING |
keyrings no longer have names, accessing an missing DBus object has usual failure |
GNOME_KEYRING_RESULT_BAD_ARGUMENTS |
G_DBUS_ERROR_INVALID_ARGS or precondition failure in libsecret, this is always
a programmer error |
GNOME_KEYRING_RESULT_IO_ERROR |
relevant DBus errors, or SECRET_ERROR_PROTOCOL
|
GNOME_KEYRING_RESULT_CANCELLED |
G_IO_ERROR_CANCELLED |
GNOME_KEYRING_RESULT_KEYRING_ALREADY_EXISTS |
no error, simply returns already existing keyring |
GNOME_KEYRING_RESULT_NO_MATCH |
on error, an empty list is returned |
gnome_keyring_string_list_free() |
no equivalent |