[gnome-online-accounts/gnome-3-20] provider: Skip EnsureCredentials if an account is disabled



commit 6cfb1d2787be82f433ec28e3e267c5107b9e87e0
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue May 3 19:05:02 2016 +0200

    provider: Skip EnsureCredentials if an account is disabled
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762155

 src/goabackend/goaprovider.c |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 64e305e..e6652ed 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -781,12 +781,46 @@ goa_provider_ensure_credentials_sync (GoaProvider     *self,
                                       GCancellable    *cancellable,
                                       GError         **error)
 {
+  GoaAccount *account = NULL;
+  GoaProviderFeatures features;
+  gboolean disabled = TRUE;
+  gboolean ret = FALSE;
+  guint i;
+
   g_return_val_if_fail (GOA_IS_PROVIDER (self), FALSE);
   g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  return GOA_PROVIDER_GET_CLASS (self)->ensure_credentials_sync (self, object, out_expires_in, cancellable, 
error);
+  account = goa_object_get_account (object);
+  g_return_val_if_fail (GOA_IS_ACCOUNT (account), FALSE);
+
+  features = goa_provider_get_provider_features (self);
+
+  for (i = 0; provider_features_info[i].property != NULL; i++)
+    {
+      if ((features & provider_features_info[i].feature) != 0)
+        {
+          gboolean feature_disabled;
+
+          g_object_get (account, provider_features_info[i].property, &feature_disabled, NULL);
+          disabled = disabled && feature_disabled;
+          if (!disabled)
+            break;
+        }
+    }
+
+  if (disabled)
+    {
+      g_set_error_literal (error, GOA_ERROR, GOA_ERROR_NOT_SUPPORTED, _("Account is disabled"));
+      goto out;
+    }
+
+  ret = GOA_PROVIDER_GET_CLASS (self)->ensure_credentials_sync (self, object, out_expires_in, cancellable, 
error);
+
+ out:
+  g_clear_object (&account);
+  return ret;
 }
 
 /* ---------------------------------------------------------------------------------------------------- */


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