[gnome-online-accounts] provider: Ignore factories in goa_provider_get_all



commit f07f189719f31a99cf34f594fe09b24fff2c9bce
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Apr 17 15:23:45 2018 +0200

    provider: Ignore factories in goa_provider_get_all
    
    Provider factories were only used for Telepathy support, and are going
    to be removed.
    
    This reverts commit 1a8bfdf90fd24e9bbaeeae15ff9f16e847a6b48e.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=795322

 src/goabackend/goaprovider.c |  116 +++---------------------------------------
 1 files changed, 8 insertions(+), 108 deletions(-)
---
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index a533b33..f7bb163 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -1074,97 +1074,12 @@ goa_provider_get_for_provider_type (const gchar *provider_type)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-typedef struct
-{
-  GQueue ret;
-  gint pending_calls;
-  GTask *task;
-} GetAllData;
-
 static void
 free_list_and_unref (gpointer data)
 {
   g_list_free_full (data, g_object_unref);
 }
 
-static gint
-compare_providers (GoaProvider *a,
-                   GoaProvider *b)
-{
-  gboolean a_branded;
-  gboolean b_branded;
-
-  if (goa_provider_get_provider_features (a) & GOA_PROVIDER_FEATURE_BRANDED)
-    a_branded = TRUE;
-  else
-    a_branded = FALSE;
-
-  if (goa_provider_get_provider_features (b) & GOA_PROVIDER_FEATURE_BRANDED)
-    b_branded = TRUE;
-  else
-    b_branded = FALSE;
-
-  /* g_queue_sort() uses a stable sort, so, if we return 0, the order
-   * is not changed. */
-  if (a_branded == b_branded)
-    return 0;
-  else if (a_branded)
-    return -1;
-  else
-    return 1;
-}
-
-static void
-get_all_check_done (GetAllData *data)
-{
-  if (data->pending_calls > 0)
-    return;
-
-  /* Make sure that branded providers come first, but don't change the
-   * order otherwise. */
-  g_queue_sort (&data->ret, (GCompareDataFunc) compare_providers, NULL);
-
-  /* Steal the list out of the GQueue. */
-  g_task_return_pointer (data->task, data->ret.head, free_list_and_unref);
-
-  g_object_unref (data->task);
-  g_slice_free (GetAllData, data);
-}
-
-static void
-get_providers_cb (GObject      *source,
-                  GAsyncResult *res,
-                  gpointer      user_data)
-{
-  GoaProviderFactory *factory = GOA_PROVIDER_FACTORY (source);
-  GetAllData *data = user_data;
-  GList *providers = NULL;
-  GList *l;
-  GError *error = NULL;
-
-  if (!goa_provider_factory_get_providers_finish (factory, &providers, res, &error))
-    {
-      g_critical ("Error getting providers from a factory: %s (%s, %d)",
-          error->message,
-          g_quark_to_string (error->domain),
-          error->code);
-      g_clear_error (&error);
-      goto out;
-    }
-
-  for (l = providers; l != NULL; l = l->next)
-    {
-      /* Steal the value */
-      g_queue_push_tail (&data->ret, l->data);
-    }
-
-  g_list_free (providers);
-
-out:
-  data->pending_calls--;
-  get_all_check_done (data);
-}
-
 /**
  * goa_provider_get_all:
  * @callback: The function to call when the request is satisfied.
@@ -1185,46 +1100,31 @@ goa_provider_get_all (GAsyncReadyCallback callback,
                       gpointer            user_data)
 {
   GList *extensions;
+  GList *providers = NULL;
   GList *l;
   GIOExtensionPoint *extension_point;
-  GetAllData *data;
-  gint i;
+  GTask *task = NULL;
 
   goa_provider_ensure_builtins_loaded ();
 
-  data = g_slice_new0 (GetAllData);
-  data->task = g_task_new (NULL, NULL, callback, user_data);
-  g_task_set_source_tag (data->task, goa_provider_get_all);
-  g_queue_init (&data->ret);
+  task = g_task_new (NULL, NULL, callback, user_data);
+  g_task_set_source_tag (task, goa_provider_get_all);
 
-  /* Load the normal providers. */
   extension_point = g_io_extension_point_lookup (GOA_PROVIDER_EXTENSION_POINT_NAME);
   extensions = g_io_extension_point_get_extensions (extension_point);
   /* TODO: what if there are two extensions with the same name? */
-  for (l = extensions, i = 0; l != NULL; l = l->next, i++)
+  for (l = extensions; l != NULL; l = l->next)
     {
       GIOExtension *extension = l->data;
       /* The extensions are loaded in the reverse order we used in
        * goa_provider_ensure_builtins_loaded, so we need to push
        * extension if front of the already loaded ones. */
-      g_queue_push_head (&data->ret, g_object_new (g_io_extension_get_type (extension), NULL));
+      providers = g_list_prepend (providers, g_object_new (g_io_extension_get_type (extension), NULL));
     }
 
-  /* Load the provider factories and get the dynamic providers out of them. */
-  extension_point = g_io_extension_point_lookup (GOA_PROVIDER_FACTORY_EXTENSION_POINT_NAME);
-  extensions = g_io_extension_point_get_extensions (extension_point);
-  for (l = extensions, i = 0; l != NULL; l = l->next, i++)
-    {
-      GIOExtension *extension = l->data;
-      GoaProviderFactory *factory;
-
-      factory = GOA_PROVIDER_FACTORY (g_object_new (g_io_extension_get_type (extension), NULL));
-      goa_provider_factory_get_providers (factory, get_providers_cb, data);
-      g_object_unref (factory);
-      data->pending_calls++;
-    }
+  g_task_return_pointer (task, g_steal_pointer (&providers), free_list_and_unref);
 
-  get_all_check_done (data);
+  g_list_free_full (providers, g_object_unref);
 }
 
 /**


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