[gthumb] ported to libsecret



commit c928a684bcf8d055cc1e76ad8569d7a7846dc039
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Nov 4 18:15:49 2012 +0100

    ported to libsecret

 configure.ac                                     |   26 ++++----
 extensions/23hq/Makefile.am                      |    4 +-
 extensions/facebook/Makefile.am                  |    4 +-
 extensions/facebook/facebook-account.c           |   15 ++--
 extensions/facebook/facebook-authentication.c    |   78 +++++++++++---------
 extensions/flicker/Makefile.am                   |    4 +-
 extensions/flicker_utils/Makefile.am             |    4 +-
 extensions/flicker_utils/flickr-account.c        |   15 ++--
 extensions/flicker_utils/flickr-authentication.c |   81 +++++++++++----------
 extensions/oauth/Makefile.am                     |    4 +-
 extensions/oauth/oauth-account.c                 |   15 ++--
 extensions/oauth/oauth-authentication.c          |   78 +++++++++++---------
 extensions/photobucket/Makefile.am               |    4 +-
 extensions/picasaweb/Makefile.am                 |    4 +-
 extensions/picasaweb/dlg-export-to-picasaweb.c   |   84 ++++++++++++----------
 extensions/picasaweb/dlg-import-from-picasaweb.c |   84 ++++++++++++----------
 gthumb/Makefile.am                               |    4 +-
 17 files changed, 270 insertions(+), 238 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e7a7bfc..0c5f13a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,7 +65,7 @@ CLUTTER_GTK_REQUIRED=1.0.0
 GSTREAMER_REQUIRED=1.0.0
 OPENRAW_REQUIRED=0.0.8
 LIBSOUP_REQUIRED=2.36
-GNOME_KEYRING_REQUIRED=3.2.0
+LIBSECRET_REQUIRED=0.11
 LIBBRASERO_REQUIRED=3.2.0
 LIBCHAMPLAIN_REQUIRED=0.12.0
 LIBRSVG_REQUIRED=2.34.0
@@ -479,19 +479,19 @@ AM_CONDITIONAL(ENABLE_LIBRSVG, test "x$enable_librsvg" = xyes)
 
 dnl ===========================================================================
 
-AC_ARG_ENABLE([gnome-keyring],
-	      [AS_HELP_STRING([--disable-gnome-keyring],[do not compile code that uses the gnome-keyring library])],,
-	      [enable_gnome_keyring=yes])
+AC_ARG_ENABLE([libsecret],
+	      [AS_HELP_STRING([--disable-libsecret],[do not compile code that uses the libsecret library])],,
+	      [enable_libsecret=yes])
 
-if test x$enable_gnome_keyring = xyes ; then
-	PKG_CHECK_MODULES(GNOME_KEYRING,
-			  [gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED],
-			  [AC_DEFINE(HAVE_GNOME_KEYRING, 1, [Have gnome-keyring])
-			   enable_gnome_keyring=yes],
-			  [enable_gnome_keyring=no])
+if test x$enable_libsecret = xyes ; then
+	PKG_CHECK_MODULES(LIBSECRET,
+			  [libsecret-1 >= $LIBSECRET_REQUIRED],
+			  [AC_DEFINE(HAVE_LIBSECRET, 1, [Have libsecret])
+			   enable_libsecret=yes],
+			  [enable_libsecret=no])
 fi
-AC_SUBST(GNOME_KEYRING_CFLAGS)
-AC_SUBST(GNOME_KEYRING_LIBS)
+AC_SUBST(LIBSECRET_CFLAGS)
+AC_SUBST(LIBSECRET_LIBS)
 
 dnl ===========================================================================
 
@@ -753,7 +753,7 @@ Configuration:
 	GStreamer support    : ${enable_gstreamer}
 	Use libopenraw       : ${enable_libopenraw}
 	Web services support : ${enable_libsoup}
-	Use GNOME Keyring    : ${enable_gnome_keyring}
+	Use libsecret        : ${enable_libsecret}
 	Burn disc support    : ${enable_libbrasero}
 	Web albums           : ${enable_web_albums}
 	SM client support    : ${with_smclient}
diff --git a/extensions/23hq/Makefile.am b/extensions/23hq/Makefile.am
index cdb429d..f684a62 100644
--- a/extensions/23hq/Makefile.am
+++ b/extensions/23hq/Makefile.am
@@ -10,9 +10,9 @@ lib23hq_la_SOURCES = 		\
 	callbacks.h		\
 	main.c
 
-lib23hq_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+lib23hq_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 lib23hq_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-lib23hq_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la ../flicker_utils/libflicker_utils.la
+lib23hq_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la ../flicker_utils/libflicker_utils.la
 lib23hq_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/facebook/Makefile.am b/extensions/facebook/Makefile.am
index 0f45675..d3faec8 100644
--- a/extensions/facebook/Makefile.am
+++ b/extensions/facebook/Makefile.am
@@ -36,9 +36,9 @@ libfacebook_la_SOURCES = 			\
 	main.c					\
 	preferences.h
 
-libfacebook_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libfacebook_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libfacebook_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libfacebook_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../export_tools/libexport_tools.la
+libfacebook_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../export_tools/libexport_tools.la
 libfacebook_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/facebook/facebook-account.c b/extensions/facebook/facebook-account.c
index 50f9c57b..e3ee154 100644
--- a/extensions/facebook/facebook-account.c
+++ b/extensions/facebook/facebook-account.c
@@ -22,9 +22,9 @@
 #include <config.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include <gthumb.h>
 #include "facebook-account.h"
 
@@ -78,14 +78,15 @@ facebook_account_create_element (DomDomizable *base,
 	if (self->username != NULL)
 		dom_element_set_attribute (element, "username", self->username);
 
-	/* Don't save the secret in the configuration file if gnome-keyring is
+	/* Don't save the secret in the configuration file if the keyring is
 	 * available. */
 
+#ifdef HAVE_LIBSECRET
+	set_secret = FALSE;
+#else
 	set_secret = TRUE;
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ())
-		set_secret = FALSE;
 #endif
+
 	if (set_secret) {
 		if (self->session_key != NULL)
 			dom_element_set_attribute (element, "session_key", self->session_key);
diff --git a/extensions/facebook/facebook-authentication.c b/extensions/facebook/facebook-authentication.c
index c75fe67..6e72fca 100644
--- a/extensions/facebook/facebook-authentication.c
+++ b/extensions/facebook/facebook-authentication.c
@@ -21,9 +21,9 @@
 
 #include <config.h>
 #include <glib.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include "facebook-account-chooser-dialog.h"
 #include "facebook-account-manager-dialog.h"
 #include "facebook-authentication.h"
@@ -296,14 +296,16 @@ connect_to_server_step2 (FacebookAuthentication *self)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-find_password_cb (GnomeKeyringResult  result,
-                  const char         *string,
-                  gpointer            user_data)
+password_lookup_ready_cb (GObject      *source_object,
+			  GAsyncResult *result,
+			  gpointer      user_data)
 {
 	FacebookAuthentication *self = user_data;
+	char                   *string;
 
+	string = secret_password_lookup_finish (result, NULL);
 	if (string != NULL) {
 		char **values;
 
@@ -314,6 +316,7 @@ find_password_cb (GnomeKeyringResult  result,
 		}
 
 		g_strfreev (values);
+		g_free (string);
 	}
 
 	connect_to_server_step2 (self);
@@ -326,16 +329,16 @@ connect_to_server (FacebookAuthentication *self)
 {
 	g_return_if_fail (self->priv->account != NULL);
 
-#ifdef HAVE_GNOME_KEYRING
-	if (((self->priv->account->session_key == NULL) || (self->priv->account->secret == NULL)) && gnome_keyring_is_available ()) {
-		gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					     find_password_cb,
-					     self,
-					     NULL,
-					     "user", self->priv->account->user_id,
-					     "server", FACEBOOK_HTTPS_REST_SERVER,
-					     "protocol", "https",
-					     NULL);
+#ifdef HAVE_LIBSECRET
+	if ((self->priv->account->session_key == NULL) || (self->priv->account->secret == NULL)) {
+		secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+					self->priv->cancellable,
+					password_lookup_ready_cb,
+					self,
+					"user", self->priv->account->user_id,
+					"server", FACEBOOK_HTTPS_REST_SERVER,
+					"protocol", "https",
+					NULL);
 		return;
 	}
 #endif
@@ -366,12 +369,15 @@ set_account (FacebookAuthentication *self,
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-store_password_done_cb (GnomeKeyringResult result,
-			gpointer           user_data)
+password_store_ready_cb (GObject      *source_object,
+			 GAsyncResult *result,
+			 gpointer      user_data)
 {
 	FacebookAuthentication *self = user_data;
+
+	secret_password_store_finish (result, NULL);
 	connect_to_server (self);
 }
 #endif
@@ -397,29 +403,29 @@ get_session_ready_cb (GObject      *source_object,
 	facebook_account_set_user_id (account, facebook_connection_get_user_id (self->priv->conn));
 	set_account (self, account);
 
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ()) {
+#ifdef HAVE_LIBSECRET
+	{
 		char *secret;
 
 		secret = g_strconcat (account->session_key, SECRET_SEPARATOR, account->secret, NULL);
-		gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					      NULL,
-					      "Facebook",
-					      secret,
-					      store_password_done_cb,
-					      self,
-					      NULL,
-					      "user", account->user_id,
-					      "server", FACEBOOK_HTTPS_REST_SERVER,
-					      "protocol", "https",
-					      NULL);
+		secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
+				       NULL,
+				       "Facebook",
+				       secret,
+				       self->priv->cancellable,
+				       password_store_ready_cb,
+				       self,
+				       "user", account->user_id,
+				       "server", FACEBOOK_HTTPS_REST_SERVER,
+				       "protocol", "https",
+				       NULL);
+
 		g_free (secret);
-		return;
 	}
-#endif
-
+#else
 	g_object_unref (account);
 	connect_to_server (self);
+#endif
 }
 
 
diff --git a/extensions/flicker/Makefile.am b/extensions/flicker/Makefile.am
index e3c022b..3c8213a 100644
--- a/extensions/flicker/Makefile.am
+++ b/extensions/flicker/Makefile.am
@@ -10,9 +10,9 @@ libflicker_la_SOURCES = 			\
 	callbacks.h				\
 	main.c
 
-libflicker_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libflicker_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libflicker_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libflicker_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la ../flicker_utils/libflicker_utils.la
+libflicker_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la ../flicker_utils/libflicker_utils.la
 libflicker_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/flicker_utils/Makefile.am b/extensions/flicker_utils/Makefile.am
index b596e57..e2a89bc 100644
--- a/extensions/flicker_utils/Makefile.am
+++ b/extensions/flicker_utils/Makefile.am
@@ -32,9 +32,9 @@ libflicker_utils_la_SOURCES = 			\
 	main.c					\
 	preferences.h
 
-libflicker_utils_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libflicker_utils_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libflicker_utils_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libflicker_utils_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la
+libflicker_utils_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la
 libflicker_utils_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/flicker_utils/flickr-account.c b/extensions/flicker_utils/flickr-account.c
index ac28d09..b6b8aa0 100644
--- a/extensions/flicker_utils/flickr-account.c
+++ b/extensions/flicker_utils/flickr-account.c
@@ -22,9 +22,9 @@
 #include <config.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include <gthumb.h>
 #include "flickr-account.h"
 
@@ -74,14 +74,15 @@ flickr_account_create_element (DomDomizable *base,
 	if (self->username != NULL)
 		dom_element_set_attribute (element, "username", self->username);
 
-	/* Don't save the token in the configuration file if gnome-keyring is
+	/* Don't save the token in the configuration file if the keyring is
 	 * available. */
 
+#ifdef HAVE_LIBSECRET
+	set_token = FALSE;
+#else
 	set_token = TRUE;
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ())
-		set_token = FALSE;
 #endif
+
 	if (set_token && (self->token != NULL))
 		dom_element_set_attribute (element, "token", self->token);
 
diff --git a/extensions/flicker_utils/flickr-authentication.c b/extensions/flicker_utils/flickr-authentication.c
index a1a32a9..6c693bc 100644
--- a/extensions/flicker_utils/flickr-authentication.c
+++ b/extensions/flicker_utils/flickr-authentication.c
@@ -21,9 +21,9 @@
 
 #include <config.h>
 #include <glib.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include "flickr-account-chooser-dialog.h"
 #include "flickr-account-manager-dialog.h"
 #include "flickr-authentication.h"
@@ -250,16 +250,21 @@ connect_to_server_step2 (FlickrAuthentication *self)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-find_password_cb (GnomeKeyringResult  result,
-                  const char         *string,
-                  gpointer            user_data)
+password_lookup_ready_cb (GObject      *source_object,
+			  GAsyncResult *result,
+			  gpointer      user_data)
 {
 	FlickrAuthentication *self = user_data;
+	char                 *string;
 
-	if (string != NULL)
+	string = secret_password_lookup_finish (result, NULL);
+	if (string != NULL) {
 		self->priv->account->token = g_strdup (string);
+		g_free (string);
+	}
+
 	connect_to_server_step2 (self);
 }
 #endif
@@ -270,16 +275,16 @@ connect_to_server (FlickrAuthentication *self)
 {
 	g_return_if_fail (self->priv->account != NULL);
 
-#ifdef HAVE_GNOME_KEYRING
-	if ((self->priv->account->token == NULL) && gnome_keyring_is_available ()) {
-		gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					     find_password_cb,
-					     self,
-					     NULL,
-					     "user", self->priv->account->username,
-					     "server", self->priv->conn->server->url,
-					     "protocol", "http",
-					     NULL);
+#ifdef HAVE_LIBSECRET
+	if (self->priv->account->token == NULL) {
+		secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+					self->priv->cancellable,
+					password_lookup_ready_cb,
+					self,
+					"user", self->priv->account->username,
+					"server", self->priv->conn->server->url,
+					"protocol", "http",
+					NULL);
 		return;
 	}
 #endif
@@ -310,12 +315,15 @@ set_account (FlickrAuthentication *self,
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-store_password_done_cb (GnomeKeyringResult result,
-			gpointer           user_data)
+password_store_ready_cb (GObject      *source_object,
+			 GAsyncResult *result,
+			 gpointer      user_data)
 {
 	FlickrAuthentication *self = user_data;
+
+	secret_password_store_finish (result, NULL);
 	connect_to_server (self);
 }
 #endif
@@ -338,24 +346,21 @@ connection_token_ready_cb (GObject      *source_object,
 	account = flickr_connection_get_account (self->priv->conn);
 	set_account (self, account);
 
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ()) {
-		gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					      NULL,
-					      self->priv->conn->server->name,
-					      account->token,
-					      store_password_done_cb,
-					      self,
-					      NULL,
-					      "user", account->username,
-					      "server", self->priv->conn->server->url,
-					      "protocol", "http",
-					      NULL);
-		return;
-	}
-#endif
-
+#ifdef HAVE_LIBSECRET
+	secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
+			       NULL,
+			       self->priv->conn->server->name,
+			       account->token,
+			       self->priv->cancellable,
+			       password_store_ready_cb,
+			       self,
+			       "user", account->username,
+			       "server", self->priv->conn->server->url,
+			       "protocol", "http",
+			       NULL);
+#else
 	connect_to_server (self);
+#endif
 }
 
 
diff --git a/extensions/oauth/Makefile.am b/extensions/oauth/Makefile.am
index 02185d4..044c127 100644
--- a/extensions/oauth/Makefile.am
+++ b/extensions/oauth/Makefile.am
@@ -18,9 +18,9 @@ liboauth_la_SOURCES = 				\
 	oauth-connection.c			\
 	oauth-connection.h
 
-liboauth_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+liboauth_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 liboauth_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-liboauth_la_LIBADD = $(GTHUMB_LIBS) $(JPEG_LIBS) $(GNOME_KEYRING_LIBS) $(LIBSOUP_LIBS)
+liboauth_la_LIBADD = $(GTHUMB_LIBS) $(JPEG_LIBS) $(LIBSECRET_LIBS) $(LIBSOUP_LIBS)
 liboauth_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/oauth/oauth-account.c b/extensions/oauth/oauth-account.c
index e7ad067..2a59e9a 100644
--- a/extensions/oauth/oauth-account.c
+++ b/extensions/oauth/oauth-account.c
@@ -22,9 +22,9 @@
 #include <config.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include <gthumb.h>
 #include "oauth-account.h"
 
@@ -75,14 +75,15 @@ oauth_account_create_element (DomDomizable *base,
 	if (self->username != NULL)
 		dom_element_set_attribute (element, "username", self->username);
 
-	/* Don't save the token in the configuration file if gnome-keyring is
+	/* Don't save the token in the configuration file if the keyring is
 	 * available. */
 
+#ifdef HAVE_LIBSECRET
+	set_token = FALSE;
+#else
 	set_token = TRUE;
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ())
-		set_token = FALSE;
 #endif
+
 	if (set_token && (self->token != NULL))
 		dom_element_set_attribute (element, "token", self->token);
 
diff --git a/extensions/oauth/oauth-authentication.c b/extensions/oauth/oauth-authentication.c
index c398693..6315603 100644
--- a/extensions/oauth/oauth-authentication.c
+++ b/extensions/oauth/oauth-authentication.c
@@ -21,9 +21,9 @@
 
 #include <config.h>
 #include <glib.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include "oauth-account.h"
 #include "oauth-account-chooser-dialog.h"
 #include "oauth-account-manager-dialog.h"
@@ -248,14 +248,16 @@ connect_to_server_step2 (OAuthAuthentication *self)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-find_password_cb (GnomeKeyringResult  result,
-                  const char         *string,
-                  gpointer            user_data)
+password_lookup_ready_cb (GObject      *source_object,
+			  GAsyncResult *result,
+			  gpointer      user_data)
 {
 	OAuthAuthentication *self = user_data;
+	char                *string;
 
+	string = secret_password_lookup_finish (result, NULL);
 	if (string != NULL) {
 		char **values;
 
@@ -266,6 +268,7 @@ find_password_cb (GnomeKeyringResult  result,
 		}
 
 		g_strfreev (values);
+		g_free (string);
 	}
 
 	connect_to_server_step2 (self);
@@ -278,16 +281,16 @@ connect_to_server (OAuthAuthentication *self)
 {
 	g_return_if_fail (self->priv->account != NULL);
 
-#ifdef HAVE_GNOME_KEYRING
-	if (((self->priv->account->token == NULL) || (self->priv->account->token_secret == NULL)) && gnome_keyring_is_available ()) {
-		gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					     find_password_cb,
-					     self,
-					     NULL,
-					     "user", self->priv->account->username,
-					     "server", self->priv->conn->consumer->url,
-					     "protocol", self->priv->conn->consumer->protocol,
-					     NULL);
+#ifdef HAVE_LIBSECRET
+	if ((self->priv->account->token == NULL) || (self->priv->account->token_secret == NULL)) {
+		secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+					self->priv->cancellable,
+					password_lookup_ready_cb,
+					self,
+					"user", self->priv->account->username,
+					"server", self->priv->conn->consumer->url,
+					"protocol", self->priv->conn->consumer->protocol,
+					NULL);
 		return;
 	}
 #endif
@@ -318,12 +321,15 @@ set_account (OAuthAuthentication *self,
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-store_password_done_cb (GnomeKeyringResult result,
-			gpointer           user_data)
+password_store_ready_cb (GObject      *source_object,
+			 GAsyncResult *result,
+			 gpointer      user_data)
 {
 	OAuthAuthentication *self = user_data;
+
+	secret_password_store_finish (result, NULL);
 	connect_to_server (self);
 }
 #endif
@@ -346,31 +352,31 @@ get_access_token_ready_cb (GObject      *source_object,
 
 	set_account (self, account);
 
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ()) {
+#ifdef HAVE_LIBSECRET
+	{
 		char *secret;
 
 		secret = g_strconcat (account->token,
 				      TOKEN_SECRET_SEPARATOR,
 				      account->token_secret,
 				      NULL);
-		gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					      NULL,
-					      self->priv->conn->consumer->display_name,
-					      secret,
-					      store_password_done_cb,
-					      self,
-					      NULL,
-					      "user", account->username,
-					      "server", self->priv->conn->consumer->url,
-					      "protocol", self->priv->conn->consumer->protocol,
-					      NULL);
-		return;
+		secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
+				       NULL,
+				       self->priv->conn->consumer->display_name,
+				       secret,
+				       self->priv->cancellable,
+				       password_store_ready_cb,
+				       "user", account->username,
+				       "server", self->priv->conn->consumer->url,
+				       "protocol", self->priv->conn->consumer->protocol,
+				       NULL);
+
+		g_free (secret);
 	}
-#endif
-
+#else
 	g_object_unref (account);
 	connect_to_server (self);
+#endif
 }
 
 
diff --git a/extensions/photobucket/Makefile.am b/extensions/photobucket/Makefile.am
index f06e49a..916068e 100644
--- a/extensions/photobucket/Makefile.am
+++ b/extensions/photobucket/Makefile.am
@@ -26,9 +26,9 @@ libphotobucket_la_SOURCES = 			\
 	photobucket-service.c			\
 	photobucket-service.h
 
-libphotobucket_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libphotobucket_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libphotobucket_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libphotobucket_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../oauth/liboauth.la ../export_tools/libexport_tools.la
+libphotobucket_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../oauth/liboauth.la ../export_tools/libexport_tools.la
 libphotobucket_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/picasaweb/Makefile.am b/extensions/picasaweb/Makefile.am
index 91a270f..33ce52a 100644
--- a/extensions/picasaweb/Makefile.am
+++ b/extensions/picasaweb/Makefile.am
@@ -36,9 +36,9 @@ libpicasaweb_la_SOURCES = 			\
 	picasa-web-user.h			\
 	preferences.h
 
-libpicasaweb_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
+libpicasaweb_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(LIBSECRET_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libpicasaweb_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libpicasaweb_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(GNOME_KEYRING_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la
+libpicasaweb_la_LIBADD = $(GTHUMB_LIBS) $(LIBSOUP_LIBS) $(LIBSECRET_LIBS) ../importer/libimporter.la ../export_tools/libexport_tools.la
 libpicasaweb_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
 
 extensioninidir = $(extensiondir)
diff --git a/extensions/picasaweb/dlg-export-to-picasaweb.c b/extensions/picasaweb/dlg-export-to-picasaweb.c
index e5dec8d..aad8de7 100644
--- a/extensions/picasaweb/dlg-export-to-picasaweb.c
+++ b/extensions/picasaweb/dlg-export-to-picasaweb.c
@@ -21,9 +21,9 @@
 
 #include <config.h>
 #include <gtk/gtk.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include <gthumb.h>
 #include "dlg-export-to-picasaweb.h"
 #include "picasa-account-chooser-dialog.h"
@@ -401,12 +401,16 @@ get_album_list (DialogData *data)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-store_password_done_cb (GnomeKeyringResult result,
-			gpointer           user_data)
+password_store_ready_cb (GObject      *source_object,
+			 GAsyncResult *result,
+			 gpointer      user_data)
 {
-	get_album_list ((DialogData *) user_data);
+	DialogData *data = user_data;
+
+	secret_password_store_finish (result, NULL);
+	get_album_list (data);
 }
 #endif
 
@@ -449,24 +453,21 @@ connection_ready_cb (GObject      *source_object,
 	if (! g_list_find_custom (data->accounts, data->email, (GCompareFunc) strcmp))
 		data->accounts = g_list_append (data->accounts, g_strdup (data->email));
 
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ()) {
-		gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					      NULL,
-					      _("Picasa Web Album"),
-					      data->password,
-					      store_password_done_cb,
-					      data,
-					      NULL,
-					      "user", data->email,
-					      "server", "picasaweb.google.com",
-					      "protocol", "http",
-					      NULL);
-		return;
-	}
-#endif
-
+#ifdef HAVE_LIBSECRET
+	secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
+			       NULL,
+			       _("Picasa Web Album"),
+			       data->password,
+			       data->cancellable,
+			       password_store_ready_cb,
+			       data,
+			       "user", data->email,
+			       "server", "picasaweb.google.com",
+			       "protocol", "http",
+			       NULL);
+#else
 	get_album_list (data);
+#endif
 }
 
 
@@ -567,16 +568,21 @@ connect_to_server_step2 (DialogData *data)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-find_password_cb (GnomeKeyringResult result,
-                  const char        *string,
-                  gpointer           user_data)
+password_lookup_ready_cb (GObject      *source_object,
+			  GAsyncResult *result,
+			  gpointer      user_data)
 {
 	DialogData *data = user_data;
+	char       *string;
 
-	if (string != NULL)
+	string = secret_password_lookup_finish (result, NULL);
+	if (string != NULL) {
 		data->password = g_strdup (string);
+		g_free (string);
+	}
+
 	connect_to_server_step2 (data);
 }
 #endif
@@ -591,16 +597,16 @@ connect_to_server (DialogData *data)
 		gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->conn));
 	}
 
-#ifdef HAVE_GNOME_KEYRING
-	if ((data->password == NULL) && gnome_keyring_is_available ()) {
-		gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					     find_password_cb,
-					     data,
-					     NULL,
-					     "user", data->email,
-					     "server", "picasaweb.google.com",
-					     "protocol", "http",
-					     NULL);
+#ifdef HAVE_LIBSECRET
+	if (data->password == NULL) {
+		secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+				        data->cancellable,
+				        password_lookup_ready_cb,
+				        data,
+				        "user", data->email,
+				        "server", "picasaweb.google.com",
+				        "protocol", "http",
+				        NULL);
 		return;
 	}
 #endif
diff --git a/extensions/picasaweb/dlg-import-from-picasaweb.c b/extensions/picasaweb/dlg-import-from-picasaweb.c
index 3a7f37d..6de7f03 100644
--- a/extensions/picasaweb/dlg-import-from-picasaweb.c
+++ b/extensions/picasaweb/dlg-import-from-picasaweb.c
@@ -22,9 +22,9 @@
 #include <config.h>
 #define GDK_PIXBUF_ENABLE_BACKEND
 #include <gtk/gtk.h>
-#ifdef HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
-#endif /* HAVE_GNOME_KEYRING */
+#ifdef HAVE_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* HAVE_LIBSECRET */
 #include <gthumb.h>
 #include <extensions/importer/importer.h>
 #include "dlg-import-from-picasaweb.h"
@@ -339,12 +339,16 @@ get_album_list (DialogData *data)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-store_password_done_cb (GnomeKeyringResult result,
-			gpointer           user_data)
+password_store_ready_cb (GObject      *source_object,
+			 GAsyncResult *result,
+			 gpointer      user_data)
 {
-	get_album_list ((DialogData *) user_data);
+	DialogData *data = user_data;
+
+	secret_password_store_finish (result, NULL);
+	get_album_list (data);
 }
 #endif
 
@@ -387,24 +391,21 @@ connection_ready_cb (GObject      *source_object,
 	if (! g_list_find_custom (data->accounts, data->email, (GCompareFunc) strcmp))
 		data->accounts = g_list_append (data->accounts, g_strdup (data->email));
 
-#ifdef HAVE_GNOME_KEYRING
-	if (gnome_keyring_is_available ()) {
-		gnome_keyring_store_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					      NULL,
-					      _("Picasa Web Album"),
-					      data->password,
-					      store_password_done_cb,
-					      data,
-					      NULL,
-					      "user", data->email,
-					      "server", "picasaweb.google.com",
-					      "protocol", "http",
-					      NULL);
-		return;
-	}
-#endif
-
+#ifdef HAVE_LIBSECRET
+	secret_password_store (SECRET_SCHEMA_COMPAT_NETWORK,
+			       NULL,
+			       _("Picasa Web Album"),
+			       data->password,
+			       data->cancellable,
+			       password_store_ready_cb,
+			       data,
+			       "user", data->email,
+			       "server", "picasaweb.google.com",
+			       "protocol", "http",
+			       NULL);
+#else
 	get_album_list (data);
+#endif
 }
 
 
@@ -505,16 +506,21 @@ connect_to_server_step2 (DialogData *data)
 }
 
 
-#ifdef HAVE_GNOME_KEYRING
+#ifdef HAVE_LIBSECRET
 static void
-find_password_cb (GnomeKeyringResult result,
-                  const char        *string,
-                  gpointer           user_data)
+password_lookup_ready_cb (GObject      *source_object,
+			  GAsyncResult *result,
+			  gpointer      user_data)
 {
 	DialogData *data = user_data;
+	char       *string;
 
-	if (string != NULL)
+	string = secret_password_lookup_finish (result, NULL);
+	if (string != NULL) {
 		data->password = g_strdup (string);
+		g_free (string);
+	}
+
 	connect_to_server_step2 (data);
 }
 #endif
@@ -529,16 +535,16 @@ connect_to_server (DialogData *data)
 		gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->conn));
 	}
 
-#ifdef HAVE_GNOME_KEYRING
-	if ((data->password == NULL) && gnome_keyring_is_available ()) {
-		gnome_keyring_find_password (GNOME_KEYRING_NETWORK_PASSWORD,
-					     find_password_cb,
-					     data,
-					     NULL,
-					     "user", data->email,
-					     "server", "picasaweb.google.com",
-					     "protocol", "http",
-					     NULL);
+#ifdef HAVE_LIBSECRET
+	if (data->password == NULL) {
+		secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+					data->cancellable,
+					password_lookup_ready_cb,
+					data,
+					"user", data->email,
+					"server", "picasaweb.google.com",
+					"protocol", "http",
+					NULL);
 		return;
 	}
 #endif
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index 99367c2..758fac3 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -279,7 +279,7 @@ gthumb_LDADD =						\
 	$(TIFF_LIBS)					\
 	$(CLUTTER_LIBS)					\
 	$(SMCLIENT_LIBS)				\
-	$(GNOME_KEYRING_LIBS)				\
+	$(LIBSECRET_LIBS)				\
 	$(GSTREAMER_LIBS)				\
 	$(LIBBRASERO_LIBS)				\
 	$(LIBOPENRAW_LIBS)				\
@@ -310,7 +310,7 @@ gthumb_CFLAGS =							\
 	$(JPEG_CFLAGS)						\
 	$(TIFF_CFLAGS)						\
 	$(CLUTTER_CFLAGS)					\
-	$(GNOME_KEYRING_CFLAGS)					\
+	$(LIBSECRET_CFLAGS)					\
 	$(GSTREAMER_CFLAGS)					\
 	$(LIBBRASERO_CFLAGS)					\
 	$(LIBOPENRAW_CFLAGS)					\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]