[gnome-online-accounts/wip/rishi/gtask: 2/4] ewsclient: Split the idle handler into two parts



commit 3c6e523baee6fb2be9ae90ee67e71050deeb6a5a
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Nov 23 18:04:33 2018 +0100

    ewsclient: Split the idle handler into two parts
    
    Instead of completing the GSimpleAsyncResult and freeing
    AutodiscoverData in one block of code, let's split the latter into a
    separate function.
    
    This will make the subsequent commit easier to read.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764157

 src/goabackend/goaewsclient.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/goabackend/goaewsclient.c b/src/goabackend/goaewsclient.c
index d762d071..f3721592 100644
--- a/src/goabackend/goaewsclient.c
+++ b/src/goabackend/goaewsclient.c
@@ -79,13 +79,11 @@ typedef struct
   gchar *username;
 } AutodiscoverAuthData;
 
-static gboolean
+static void
 ews_client_autodiscover_data_free (gpointer user_data)
 {
   AutodiscoverData *data = user_data;
 
-  g_simple_async_result_complete_in_idle (data->res);
-
   if (data->cancellable_id > 0)
     {
       g_cancellable_disconnect (data->cancellable, data->cancellable_id);
@@ -97,8 +95,6 @@ ews_client_autodiscover_data_free (gpointer user_data)
   g_object_unref (data->res);
   g_object_unref (data->session);
   g_slice_free (AutodiscoverData, data);
-
-  return G_SOURCE_REMOVE;
 }
 
 static void
@@ -159,6 +155,17 @@ ews_client_autodiscover_cancelled_cb (GCancellable *cancellable, gpointer user_d
   soup_session_abort (data->session);
 }
 
+static gboolean
+ews_client_autodiscover_complete_and_free_in_idle (gpointer user_data)
+{
+  AutodiscoverData *data = user_data;
+
+  g_simple_async_result_complete_in_idle (data->res);
+  ews_client_autodiscover_data_free (data);
+
+  return G_SOURCE_REMOVE;
+}
+
 static gboolean
 ews_client_autodiscover_parse_protocol (xmlNode *node)
 {
@@ -349,8 +356,8 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
 
       source = g_idle_source_new ();
       g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
-      g_source_set_callback (source, ews_client_autodiscover_data_free, data, NULL);
-      g_source_set_name (source, "[goa] ews_client_autodiscover_data_free");
+      g_source_set_callback (source, ews_client_autodiscover_complete_and_free_in_idle, data, NULL);
+      g_source_set_name (source, "[goa] ews_client_autodiscover_complete_and_free_in_idle");
 
       context = g_main_context_get_thread_default ();
       g_source_attach (source, context);


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