23 #include <glib/gi18n.h>
28 #include <libsecret/secret.h>
30 static const SecretSchema doc_password_schema = {
31 "org.gnome.Evince.Document",
32 SECRET_SCHEMA_DONT_MATCH_NAME,
34 {
"type", SECRET_SCHEMA_ATTRIBUTE_STRING },
35 {
"uri", SECRET_SCHEMA_ATTRIBUTE_STRING },
39 const SecretSchema *EV_DOCUMENT_PASSWORD_SCHEMA = &doc_password_schema;
56 g_return_val_if_fail (uri != NULL, NULL);
58 return secret_password_lookup_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
60 "type",
"document_password",
70 const gchar *password,
79 g_return_val_if_fail (uri != NULL,
FALSE);
81 if (flags == G_PASSWORD_SAVE_NEVER)
84 keyring = (flags == G_PASSWORD_SAVE_FOR_SESSION) ? SECRET_COLLECTION_SESSION : NULL;
85 unescaped_uri = g_uri_unescape_string (uri, NULL);
86 name = g_strdup_printf (
_(
"Password for document %s"), unescaped_uri);
87 g_free (unescaped_uri);
89 retval = secret_password_store_sync (EV_DOCUMENT_PASSWORD_SCHEMA, keyring,
90 name, password, NULL, NULL,
91 "type",
"document_password",