[gnome-online-accounts] utils: Don't use the GError from libsecret



commit 99f477975170ffe5ad77aceaea7de249bfe2b092
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jul 20 12:48:26 2012 +0200

    utils: Don't use the GError from libsecret
    
    Libsecret does not always set the GError on failure. eg.,
    secret_password_lookup_sync will not set it even the password was not
    found. This is a departure from libgnome-keyring where you got a
    GnomeKeyringResult which could be converted to a message using
    gnome_keyring_result_to_message.
    
    Therefore, we will need to an additional check for the GError when we
    get a failure. Too much pain for what could be a cryptic error message.

 src/goabackend/goautils.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 3b73a45..0ed8fa0 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -143,16 +143,14 @@ goa_utils_delete_credentials_sync (GoaProvider   *provider,
 
   if (!secret_password_clear_sync (&secret_password_schema,
                                    cancellable,
-                                   error,
+                                   NULL,
                                    "goa-identity", password_key,
                                    NULL))
     {
-      if (error != NULL)
-        {
-          g_prefix_error (error, _("Failed to delete credentials from the keyring: "));
-          (*error)->domain = GOA_ERROR;
-          (*error)->code = GOA_ERROR_FAILED; /* TODO: more specific */
-        }
+      g_set_error_literal (error,
+                           GOA_ERROR,
+                           GOA_ERROR_FAILED, /* TODO: more specific */
+                           _("Failed to delete credentials from the keyring"));
       goto out;
     }
 
@@ -192,17 +190,15 @@ goa_utils_lookup_credentials_sync (GoaProvider   *provider,
 
   password = secret_password_lookup_sync (&secret_password_schema,
                                           cancellable,
-                                          error,
+                                          NULL,
                                           "goa-identity", password_key,
                                           NULL);
   if (password == NULL)
     {
-      if (error != NULL)
-        {
-          g_prefix_error (error, _("Failed to retrieve credentials from the keyring: "));
-          (*error)->domain = GOA_ERROR;
-          (*error)->code = GOA_ERROR_FAILED; /* TODO: more specific */
-        }
+      g_set_error_literal (error,
+                           GOA_ERROR,
+                           GOA_ERROR_FAILED, /* TODO: more specific */
+                           _("Failed to retrieve credentials from the keyring"));
       goto out;
     }
 
@@ -264,16 +260,14 @@ goa_utils_store_credentials_for_id_sync (GoaProvider   *provider,
                                    password_description,
                                    credentials_str,
                                    cancellable,
-                                   error,
+                                   NULL,
                                    "goa-identity", password_key,
                                    NULL))
     {
-      if (error != NULL)
-        {
-          g_prefix_error (error, _("Failed to store credentials from the keyring: "));
-          (*error)->domain = GOA_ERROR;
-          (*error)->code = GOA_ERROR_FAILED; /* TODO: more specific */
-        }
+      g_set_error_literal (error,
+                           GOA_ERROR,
+                           GOA_ERROR_FAILED, /* TODO: more specific */
+                           _("Failed to store credentials in the keyring"));
       goto out;
     }
 



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