[gnome-online-accounts/wip/rishi/skip-ensure-credentials: 1/2] provider: Skip EnsureCredentials if an account is disabled



commit 632cb15fb29ad3a4a5bfc6ff37606e8e9fcf8e5f
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 |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index c96e97b..497fdad 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -789,12 +789,49 @@ goa_provider_ensure_credentials_sync (GoaProvider     *self,
                                       GCancellable    *cancellable,
                                       GError         **error)
 {
+  GList *interfaces = NULL;
+  GList *l;
+  gboolean disabled = TRUE;
+  gboolean ret = FALSE;
+
   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);
+  interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (object));
+  for (l = interfaces; l != NULL; l = l->next)
+    {
+      GDBusInterface *interface = G_DBUS_INTERFACE (l->data);
+      GDBusInterfaceInfo *interface_info;
+      const gchar *baseline_interface_names[] = {
+        "org.gnome.OnlineAccounts.Account",
+        "org.gnome.OnlineAccounts.Manager",
+        "org.gnome.OnlineAccounts.OAuthBased",
+        "org.gnome.OnlineAccounts.OAuth2Based",
+        "org.gnome.OnlineAccounts.PasswordBased",
+        NULL
+      };
+
+      interface_info = g_dbus_interface_get_info (interface);
+      if (!g_strv_contains (baseline_interface_names, interface_info->name))
+        {
+          disabled = FALSE;
+          break;
+        }
+    }
+
+  if (disabled)
+    {
+      g_set_error (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_list_free_full (interfaces, g_object_unref);
+  return ret;
 }
 
 /* ---------------------------------------------------------------------------------------------------- */


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