[vino] Migrate from libgnome-keyring to libsecret



commit 73d4922c71418cdbcfe1e35eaa41173b260b1b10
Author: Stef Walter <stefw gnome org>
Date:   Fri Jul 13 16:18:18 2012 +0200

    Migrate from libgnome-keyring to libsecret
    
    See: https://live.gnome.org/GnomeGoals/LibsecretMigration

 common/vino-keyring.c |   61 +++++++++++++-----------------------------------
 configure.ac          |   12 +++++-----
 server/vino-server.c  |   37 ++++++-----------------------
 tools/vino-passwd.c   |   27 ++++++++-------------
 4 files changed, 41 insertions(+), 96 deletions(-)
---
diff --git a/common/vino-keyring.c b/common/vino-keyring.c
index e88ddcc..f34753c 100644
--- a/common/vino-keyring.c
+++ b/common/vino-keyring.c
@@ -32,59 +32,32 @@
 
 /* TODO: canhas async? */
 
-#include <gnome-keyring.h>
+#include <secret/secret.h>
 
 char *
 vino_keyring_get_password (void)
 {
-  GnomeKeyringNetworkPasswordData *found_item;
-  GnomeKeyringResult               result;
-  GList                           *matches;
-  char                            *password;
-
-  matches = NULL;
-
-  result = gnome_keyring_find_network_password_sync (
-                NULL,           /* user     */
-                NULL,           /* domain   */
-                "vino.local",   /* server   */
-                NULL,           /* object   */
-                "rfb",          /* protocol */
-                "vnc-password", /* authtype */
-                5900,           /* port     */
-                &matches);
-
-  if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
-    return NULL;
-
-  found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
-
-  password = g_strdup (found_item->password);
-
-  gnome_keyring_network_password_list_free (matches);
-
-  return password;
+  return secret_password_lookup (SECRET_SCHEMA_COMPAT_NETWORK,
+                                 NULL, NULL,
+                                 "server", "vino.local",
+                                 "protocol", "rfb",
+                                 "authtype", "vnc-password",
+                                 "port", 5900,
+                                 NULL);
 }
 
 gboolean
 vino_keyring_set_password (const char *password)
 {
-  GnomeKeyringResult result;
-  guint32            item_id;
-
-  result = gnome_keyring_set_network_password_sync (
-                NULL,           /* default keyring */
-                NULL,           /* user            */
-                NULL,           /* domain          */
-                "vino.local",   /* server          */
-                NULL,           /* object          */
-                "rfb",          /* protocol        */
-                "vnc-password", /* authtype        */
-                5900,           /* port            */
-                password,       /* password        */
-                &item_id);
-
-  return result == GNOME_KEYRING_RESULT_OK;
+  return secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK,
+                                     SECRET_COLLECTION_DEFAULT,
+                                     _("Remote desktop sharing password"),
+                                     password, NULL, NULL,
+                                     "server", "vino.local",
+                                     "protocol", "rfb",
+                                     "authtype", "vnc-password",
+                                     "port", 5900,
+                                     NULL);
 }
 
 #else
diff --git a/configure.ac b/configure.ac
index 68ee556..7dcdb36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,21 +117,21 @@ AS_IF([test "x$have_network_manager" = "xyes"],
     [AC_MSG_ERROR([NetworkManager support requested but not found])])])
 
 # Check for gnome-keyring
-GNOME_KEYRING_DEPS="gnome-keyring-1"
+LIBSECRET_DEPS="libsecret-1"
 
 AC_ARG_WITH([gnome-keyring],
   [AS_HELP_STRING([--without-gnome-keyring],
     [ignore the presence of gnome-keyring and disable it])])
 
 AS_IF([test "x$with_gnome_keyring" != "xno"],
-  [PKG_CHECK_EXISTS([$GNOME_KEYRING_DEPS],
+  [PKG_CHECK_EXISTS([$LIBSECRET_DEPS],
     [have_gnome_keyring=yes],
     [have_gnome_keyring=no])],
   [have_gnome_keyring=no])
 
 AS_IF([test "x$have_gnome_keyring" != "xno"],
   [AC_DEFINE([VINO_HAVE_GNOME_KEYRING], [], [Build with gnome-keyring support])],
-  [GNOME_KEYRING_DEPS=""
+  [LIBSECRET_DEPS=""
     AS_IF([test "x$with_gnome_keyring" = "xyes"],
     [AC_MSG_ERROR([gnome-keyring support requested but not found])])])
 
@@ -328,11 +328,11 @@ GLIB_VERSION=2.17.0
 GIO_VERSION=2.26
 SOUP_VERSION=2.24.0
 
-PKG_CHECK_MODULES([VINO_SERVER], [glib-2.0 >= $GLIB_VERSION gio-unix-2.0 gtk+-x11-3.0 >= $GTK_VERSION $TELEPATHY_GLIB_DEPS $LIBNOTIFY_DEPS $GNOME_KEYRING_DEPS $NETWORKMANAGER_DEPS $GNUTLS_DEPS $AVAHI_DEPS])
+PKG_CHECK_MODULES([VINO_SERVER], [glib-2.0 >= $GLIB_VERSION gio-unix-2.0 gtk+-x11-3.0 >= $GTK_VERSION $TELEPATHY_GLIB_DEPS $LIBNOTIFY_DEPS $LIBSECRET_DEPS $NETWORKMANAGER_DEPS $GNUTLS_DEPS $AVAHI_DEPS])
 
-PKG_CHECK_MODULES([VINO_CAPPLET], [glib-2.0 >= $GLIB_VERSION gio-2.0 >= $GIO_VERSION gtk+-3.0 >= $GTK_VERSION libsoup-2.4 >= $SOUP_VERSION $GNOME_KEYRING_DEPS])
+PKG_CHECK_MODULES([VINO_CAPPLET], [glib-2.0 >= $GLIB_VERSION gio-2.0 >= $GIO_VERSION gtk+-3.0 >= $GTK_VERSION libsoup-2.4 >= $SOUP_VERSION $LIBSECRET_DEPS])
 
-PKG_CHECK_MODULES([VINO_TOOLS], [glib-2.0 >= $GLIB_VERSION gio-2.0 >= $GIO_VERSION gobject-2.0 >= $GLIB_VERSION $GNOME_KEYRING_DEPS])
+PKG_CHECK_MODULES([VINO_TOOLS], [glib-2.0 >= $GLIB_VERSION gio-2.0 >= $GIO_VERSION gobject-2.0 >= $GLIB_VERSION $LIBSECRET_DEPS])
 
 # EGG stuff
 PKG_CHECK_MODULES([EGG_SMCLIENT], [gtk+-3.0])
diff --git a/server/vino-server.c b/server/vino-server.c
index bdc0963..5486bf1 100644
--- a/server/vino-server.c
+++ b/server/vino-server.c
@@ -40,7 +40,7 @@
 #include <gtk/gtk.h>
 
 #ifdef VINO_HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
+#include <libsecret/secret.h>
 #endif
 
 G_DEFINE_TYPE (VinoServer, vino_server, G_TYPE_OBJECT);
@@ -687,34 +687,13 @@ static char *
 vino_server_get_password_from_keyring (VinoServer *server)
 {
 #ifdef VINO_HAVE_GNOME_KEYRING
-  GnomeKeyringNetworkPasswordData *found_item;
-  GnomeKeyringResult               result;
-  GList                           *matches;
-  char                            *password;
-  
-  matches = NULL;
-
-  result = gnome_keyring_find_network_password_sync (
-                NULL,           /* user     */
-		NULL,           /* domain   */
-		"vino.local",   /* server   */
-		NULL,           /* object   */
-		"rfb",          /* protocol */
-		"vnc-password", /* authtype */
-		5900,           /* port     */
-		&matches);
-
-  if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
-    return NULL;
-
-
-  found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
-
-  password = g_strdup (found_item->password);
-
-  gnome_keyring_network_password_list_free (matches);
-
-  return password;
+  return secret_password_lookup_sync (SECRET_SCHEMA_COMPAT_NETWORK,
+                                      NULL, NULL,
+                                      "server", "vino.local",
+                                      "protocol", "rfb",
+                                      "authtype", "vnc-password",
+                                      "port", 5900,
+                                      NULL);
 #else
   return NULL;
 #endif
diff --git a/tools/vino-passwd.c b/tools/vino-passwd.c
index 765aa9a..5ab6d15 100644
--- a/tools/vino-passwd.c
+++ b/tools/vino-passwd.c
@@ -38,7 +38,7 @@
 #include <gio/gio.h>
 
 #ifdef VINO_HAVE_GNOME_KEYRING
-#include <gnome-keyring.h>
+#include <libsecret/secret.h>
 #endif
 
 #define VINO_PREFS_SCHEMA       "org.gnome.Vino"
@@ -49,22 +49,15 @@ static gboolean
 vino_passwd_set_password_in_keyring (const char *password)
 {
 #ifdef VINO_HAVE_GNOME_KEYRING
-  GnomeKeyringResult result;
-  guint32            item_id;
-
-  result = gnome_keyring_set_network_password_sync (
-		NULL,           /* default keyring */
-		NULL,           /* user            */
-		NULL,           /* domain          */
-		"vino.local",   /* server          */
-		NULL,           /* object          */
-		"rfb",          /* protocol        */
-		"vnc-password", /* authtype        */
-		5900,           /* port            */
-		password,       /* password        */
-		&item_id);
-
-  return result == GNOME_KEYRING_RESULT_OK;
+  return secret_password_store_sync (SECRET_SCHEMA_COMPAT_NETWORK,
+                                     SECRET_COLLECTION_DEFAULT,
+                                     _("Remote desktop sharing password"),
+                                     password, NULL, NULL,
+                                     "server", "vino.local",
+                                     "protocol", "rfb",
+                                     "authtype", "vnc-password",
+                                     "port", 5900,
+                                     NULL);
 #else
   return FALSE;
 #endif



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