[evince] Migrate from libgnome-keyring to libsecret
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Migrate from libgnome-keyring to libsecret
- Date: Sat, 5 Jan 2013 11:53:15 +0000 (UTC)
commit 8022b6bba1d9a4d030fa3230638214c70add33c3
Author: Stef Walter <stefw gnome org>
Date: Sat Jan 5 12:52:33 2013 +0100
Migrate from libgnome-keyring to libsecret
https://bugzilla.gnome.org/show_bug.cgi?id=679855
configure.ac | 8 +++---
shell/ev-keyring.c | 70 ++++++++++++++++++++--------------------------------
2 files changed, 31 insertions(+), 47 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7dbb740..15a61ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,7 +116,7 @@ AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"])
dnl Specify required versions of dependencies
CAIRO_REQUIRED=1.10.0
GLIB_REQUIRED=2.33.2
-KEYRING_REQUIRED=2.22.0
+LIBSECRET_REQUIRED=0.5
GTK_REQUIRED=3.4.4
NAUTILUS_REQUIRED=2.91.4
@@ -301,7 +301,7 @@ AC_ARG_WITH(keyring,
AM_CONDITIONAL([WITH_KEYRING],[test "$with_keyring" = "yes"])
if test "$with_keyring" = "yes"; then
- PKG_CHECK_MODULES(KEYRING, gnome-keyring-1 >= $KEYRING_REQUIRED)
+ PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= $LIBSECRET_REQUIRED)
AC_DEFINE([WITH_KEYRING],[1],[Define if KEYRING support is enabled])
fi
@@ -365,8 +365,8 @@ BACKEND_LIBS="$BACKEND_LIBS -lm"
AC_SUBST(BACKEND_CFLAGS)
AC_SUBST(BACKEND_LIBS)
-SHELL_CFLAGS="$SHELL_CORE_CFLAGS $KEYRING_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
-SHELL_LIBS="$SHELL_CORE_LIBS $KEYRING_LIBS -lz -lm"
+SHELL_CFLAGS="$SHELL_CORE_CFLAGS $LIBSECRET_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
+SHELL_LIBS="$SHELL_CORE_LIBS $LIBSECRET_LIBS -lz -lm"
AC_SUBST(SHELL_CFLAGS)
AC_SUBST(SHELL_LIBS)
diff --git a/shell/ev-keyring.c b/shell/ev-keyring.c
index cc5784e..1a91508 100644
--- a/shell/ev-keyring.c
+++ b/shell/ev-keyring.c
@@ -25,24 +25,25 @@
#include "ev-keyring.h"
#ifdef WITH_KEYRING
-#include <gnome-keyring.h>
+#include <libsecret/secret.h>
-static const GnomeKeyringPasswordSchema doc_password_schema = {
- GNOME_KEYRING_ITEM_GENERIC_SECRET,
+static const SecretSchema doc_password_schema = {
+ "org.gnome.Evince.Document",
+ SECRET_SCHEMA_DONT_MATCH_NAME,
{
- { "type", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
- { "uri", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
+ { "type", SECRET_SCHEMA_ATTRIBUTE_STRING },
+ { "uri", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 }
}
};
-const GnomeKeyringPasswordSchema *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 gnome_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
- GnomeKeyringResult result;
- gchar *password = NULL;
-
g_return_val_if_fail (uri != NULL, NULL);
- if (!gnome_keyring_is_available ())
- return NULL;
-
- result = gnome_keyring_find_password_sync (EV_DOCUMENT_PASSWORD_SCHEMA,
- &password,
- "type", "document_password",
- "uri", uri,
- NULL);
- if (result != GNOME_KEYRING_RESULT_OK || !password) {
- if (password)
- gnome_keyring_free_password (password);
- return NULL;
- }
-
- retval = g_strdup (password);
- gnome_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
- GnomeKeyringResult 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 (!gnome_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 = gnome_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 == GNOME_KEYRING_RESULT_OK);
+ return retval;
#else
return FALSE;
#endif /* WITH_KEYRING */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]