[gnome-online-accounts] utils: Add goa_utils_delete_credentials_for_id_sync helper



commit 51a6e8300c01fcea653eb3d1daddd8b8a771c81c
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri May 6 19:11:02 2016 +0200

    utils: Add goa_utils_delete_credentials_for_id_sync helper
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688041

 src/goabackend/goautils.c |   22 ++++++++++++++++++----
 src/goabackend/goautils.h |    5 +++++
 2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 8a28c29..567666f 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -179,13 +179,29 @@ goa_utils_delete_credentials_for_account_sync (GoaProvider   *provider,
                                                GCancellable  *cancellable,
                                                GError       **error)
 {
+  const gchar *id;
+
+  g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
+  g_return_val_if_fail (GOA_IS_ACCOUNT (object), FALSE);
+  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  id = goa_account_get_id (object);
+  return goa_utils_delete_credentials_for_id_sync (provider, id, cancellable, error);
+}
+
+gboolean
+goa_utils_delete_credentials_for_id_sync (GoaProvider   *provider,
+                                          const gchar   *id,
+                                          GCancellable  *cancellable,
+                                          GError       **error)
+{
   gboolean ret;
   gchar *password_key;
-  const gchar *id;
   GError *sec_error = NULL;
 
   g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
-  g_return_val_if_fail (GOA_IS_ACCOUNT (object), FALSE);
+  g_return_val_if_fail (id != NULL && id[0] != '\0', FALSE);
   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
@@ -193,8 +209,6 @@ goa_utils_delete_credentials_for_account_sync (GoaProvider   *provider,
 
   password_key = NULL;
 
-  id = goa_account_get_id (object);
-
   password_key = g_strdup_printf ("%s:gen%d:%s",
                                   goa_provider_get_provider_type (GOA_PROVIDER (provider)),
                                   goa_provider_get_credentials_generation (GOA_PROVIDER (provider)),
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index f106ecf..83a5d70 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -59,6 +59,11 @@ gboolean         goa_utils_delete_credentials_for_account_sync (GoaProvider    *
                                                                 GCancellable   *cancellable,
                                                                 GError        **error);
 
+gboolean         goa_utils_delete_credentials_for_id_sync (GoaProvider    *provider,
+                                                           const gchar    *id,
+                                                           GCancellable   *cancellable,
+                                                           GError        **error);
+
 GVariant        *goa_utils_lookup_credentials_sync (GoaProvider    *provider,
                                                     GoaObject      *object,
                                                     GCancellable   *cancellable,


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