[gnome-disk-utility] Port from libgnome-keyring-1 to libsecret-1



commit 3ddf1ab497d5e67b65822be6941f7cf3d9b2e100
Author: David Zeuthen <zeuthen gmail com>
Date:   Thu Jul 26 16:28:58 2012 -0400

    Port from libgnome-keyring-1 to libsecret-1
    
    This was requested in bug 679861.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679861
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 configure.ac                |    4 ++--
 src/disks/Makefile.am       |    4 ++--
 src/disks/gduunlockdialog.c |   36 ++++++++++++++++++++----------------
 3 files changed, 24 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6b6b278..9857875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,13 +84,13 @@ CC_CHECK_CFLAGS_APPEND([                          \
 GLIB2_REQUIRED=2.31.0
 UDISKS2_REQUIRED=1.99.0
 GTK3_REQUIRED=3.5.8
-KEYRING1_REQUIRED=3.4.0
+LIBSECRET1_REQUIRED=0.7
 PWQUALITY_REQUIRED=1.0.0
 
 PKG_CHECK_MODULES(GLIB2, [gio-unix-2.0 >= $GLIB2_REQUIRED])
 PKG_CHECK_MODULES(UDISKS2, [udisks2 >= $UDISKS2_REQUIRED])
 PKG_CHECK_MODULES(GTK3, [gtk+-3.0 >= $GTK3_REQUIRED])
-PKG_CHECK_MODULES(KEYRING1, [gnome-keyring-1 >= $KEYRING1_REQUIRED])
+PKG_CHECK_MODULES(LIBSECRET1, [libsecret-1 >= $LIBSECRET1_REQUIRED])
 PKG_CHECK_MODULES(PWQUALITY, [pwquality >= $PWQUALITY_REQUIRED])
 
 dnl **********************************
diff --git a/src/disks/Makefile.am b/src/disks/Makefile.am
index c3914a0..5aba86a 100644
--- a/src/disks/Makefile.am
+++ b/src/disks/Makefile.am
@@ -64,7 +64,7 @@ gnome_disks_CFLAGS = 					\
 	$(GLIB2_CFLAGS)					\
 	$(UDISKS2_CFLAGS)				\
 	$(GTK3_CFLAGS)					\
-	$(KEYRING1_CFLAGS)				\
+	$(LIBSECRET1_CFLAGS)				\
 	$(LIBSYSTEMD_LOGIN_CFLAGS)			\
 	$(PWQUALITY_CFLAGS)				\
 	$(WARN_CFLAGS)					\
@@ -75,7 +75,7 @@ gnome_disks_LDADD = 					\
 	$(GLIB2_LIBS)					\
 	$(UDISKS2_LIBS)					\
 	$(GTK3_LIBS)					\
-	$(KEYRING1_LIBS)				\
+	$(LIBSECRET1_LIBS)				\
 	$(LIBSYSTEMD_LOGIN_LIBS)			\
 	$(PWQUALITY_LIBS)				\
 	$(NULL)
diff --git a/src/disks/gduunlockdialog.c b/src/disks/gduunlockdialog.c
index 01b73b9..040e014 100644
--- a/src/disks/gduunlockdialog.c
+++ b/src/disks/gduunlockdialog.c
@@ -23,7 +23,7 @@
 #include "config.h"
 
 #include <glib/gi18n.h>
-#include <gnome-keyring.h>
+#include <libsecret/secret.h>
 
 #include "gduapplication.h"
 #include "gduwindow.h"
@@ -32,12 +32,13 @@
 #include "gduutils.h"
 
 /* From GVfs's monitor/udisks2/gvfsudisks2volume.c */
-static GnomeKeyringPasswordSchema luks_passphrase_schema =
+static const SecretSchema luks_passphrase_schema =
 {
-  GNOME_KEYRING_ITEM_GENERIC_SECRET,
+  "org.gnome.GVfs.Luks.Password",
+  SECRET_SCHEMA_DONT_MATCH_NAME,
   {
-    {"gvfs-luks-uuid", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
-    {NULL, 0}
+    { "gvfs-luks-uuid", SECRET_SCHEMA_ATTRIBUTE_STRING },
+    { NULL, 0 },
   }
 };
 
@@ -137,24 +138,26 @@ show_dialog (DialogData *data)
 }
 
 static void
-luks_find_passphrase_cb (GnomeKeyringResult result,
-                         const gchar       *string,
-                         gpointer           user_data)
+luks_find_passphrase_cb (GObject      *source,
+                         GAsyncResult *result,
+                         gpointer      user_data)
 {
   DialogData *data = user_data;
+  gchar *passphrase = NULL;
 
   /* Don't fail if a keyring error occured... but if we do find a
    * passphrase then put it into the entry field and show a
    * cluebar
    */
-  if (result == GNOME_KEYRING_RESULT_OK)
+  passphrase = secret_password_lookup_finish (result, NULL);
+  if (passphrase != NULL)
     {
       GtkWidget *infobar;
       infobar = gdu_utils_create_info_bar (GTK_MESSAGE_INFO,
                                            _("The encryption passphrase was retrieved from the keyring"),
                                            NULL);
       gtk_box_pack_start (GTK_BOX (data->infobar_vbox), infobar, TRUE, TRUE, 0);
-      gtk_entry_set_text (GTK_ENTRY (data->entry), string);
+      gtk_entry_set_text (GTK_ENTRY (data->entry), passphrase);
     }
   else
     {
@@ -162,6 +165,7 @@ luks_find_passphrase_cb (GnomeKeyringResult result,
       gtk_widget_set_no_show_all (data->infobar_vbox, TRUE);
     }
   show_dialog (data);
+  g_free (passphrase);
 }
 
 void
@@ -206,11 +210,11 @@ gdu_unlock_dialog_show (GduWindow    *window,
   else
     {
       /* see if there's a passphrase in the keyring */
-      gnome_keyring_find_password (&luks_passphrase_schema,
-                                   luks_find_passphrase_cb,
-                                   data,
-                                   NULL, /* GDestroyNotify */
-                                   "gvfs-luks-uuid", udisks_block_get_id_uuid (data->block),
-                                   NULL); /* sentinel */
+      secret_password_lookup (&luks_passphrase_schema,
+                              NULL, /* GCancellable */
+                              luks_find_passphrase_cb,
+                              data,
+                              "gvfs-luks-uuid", udisks_block_get_id_uuid (data->block),
+                              NULL); /* sentinel */
     }
 }



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