summaryrefslogtreecommitdiff
path: root/shell/ev-keyring.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-06-26 11:51:04 +0200
committerStefano Karapetsas <[email protected]>2013-06-26 11:51:04 +0200
commit700ab8de5c9498a3211688eeef93e3e2cded1900 (patch)
tree9aacd42a90f020533811620ecdc23cbdc8d0ad1d /shell/ev-keyring.c
parent8d97ce39f0dc6254baa24513d57894eb1bff7493 (diff)
downloadatril-700ab8de5c9498a3211688eeef93e3e2cded1900.tar.bz2
atril-700ab8de5c9498a3211688eeef93e3e2cded1900.tar.xz
Drop libmatekeyring and use libsecret
From https://git.gnome.org/browse/evince/commit/?id=8022b6b
Diffstat (limited to 'shell/ev-keyring.c')
-rw-r--r--shell/ev-keyring.c68
1 files changed, 26 insertions, 42 deletions
diff --git a/shell/ev-keyring.c b/shell/ev-keyring.c
index ac1d33a2..884fde85 100644
--- a/shell/ev-keyring.c
+++ b/shell/ev-keyring.c
@@ -25,24 +25,25 @@
#include "ev-keyring.h"
#ifdef WITH_KEYRING
-#include <mate-keyring.h>
+#include <libsecret/secret.h>
-static const MateKeyringPasswordSchema doc_password_schema = {
- MATE_KEYRING_ITEM_GENERIC_SECRET,
+static const SecretSchema doc_password_schema = {
+ "org.gnome.Evince.Document",
+ SECRET_SCHEMA_DONT_MATCH_NAME,
{
- { "type", MATE_KEYRING_ATTRIBUTE_TYPE_STRING },
- { "uri", MATE_KEYRING_ATTRIBUTE_TYPE_STRING },
+ { "type", SECRET_SCHEMA_ATTRIBUTE_STRING },
+ { "uri", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 }
}
};
-const MateKeyringPasswordSchema *EV_DOCUMENT_PASSWORD_SCHEMA = &doc_password_schema;
+const SecretSchema *EV_DOCUMENT_PASSWORD_SCHEMA = &doc_password_schema;
#endif /* WITH_KEYRING */
gboolean
ev_keyring_is_available (void)
{
#ifdef WITH_KEYRING
- return mate_keyring_is_available ();
+ return TRUE;
#else
return FALSE;
#endif
@@ -51,31 +52,17 @@ ev_keyring_is_available (void)
gchar *
ev_keyring_lookup_password (const gchar *uri)
{
- gchar *retval = NULL;
#ifdef WITH_KEYRING
- MateKeyringResult result;
- gchar *password = NULL;
-
g_return_val_if_fail (uri != NULL, NULL);
- if (!mate_keyring_is_available ())
- return NULL;
-
- result = mate_keyring_find_password_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
- &password,
- "type", "document_password",
- "uri", uri,
- NULL);
- if (result != MATE_KEYRING_RESULT_OK || !password) {
- if (password)
- mate_keyring_free_password (password);
- return NULL;
- }
-
- retval = g_strdup (password);
- mate_keyring_free_password (password);
+ return secret_password_lookup_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
+ NULL, NULL,
+ "type", "document_password",
+ "uri", uri,
+ NULL);
+#else
+ return NULL;
#endif /* WITH_KEYRING */
- return retval;
}
gboolean
@@ -84,32 +71,29 @@ ev_keyring_save_password (const gchar *uri,
GPasswordSave flags)
{
#ifdef WITH_KEYRING
- MateKeyringResult result;
- const gchar *keyring;
- gchar *name;
- gchar *unescaped_uri;
+ const gchar *keyring;
+ gchar *name;
+ gchar *unescaped_uri;
+ gboolean retval;
g_return_val_if_fail (uri != NULL, FALSE);
- if (!mate_keyring_is_available ())
- return FALSE;
-
if (flags == G_PASSWORD_SAVE_NEVER)
return FALSE;
- keyring = (flags == G_PASSWORD_SAVE_FOR_SESSION) ? "session" : NULL;
+ keyring = (flags == G_PASSWORD_SAVE_FOR_SESSION) ? SECRET_COLLECTION_SESSION : NULL;
unescaped_uri = g_uri_unescape_string (uri, NULL);
name = g_strdup_printf (_("Password for document %s"), unescaped_uri);
g_free (unescaped_uri);
- result = mate_keyring_store_password_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
- keyring, name, password,
- "type", "document_password",
- "uri", uri,
- NULL);
+ retval = secret_password_store_sync (EV_DOCUMENT_PASSWORD_SCHEMA, keyring,
+ name, password, NULL, NULL,
+ "type", "document_password",
+ "uri", uri,
+ NULL);
g_free (name);
- return (result == MATE_KEYRING_RESULT_OK);
+ return retval;
#else
return FALSE;
#endif /* WITH_KEYRING */