[gnome-online-accounts] backend: Use goa_object_skeleton_attach_contacts helper



commit 7f2a90fd84162d2ffa6adcf5c6ea9bdb06e78814
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Feb 12 16:52:23 2016 +0100

    backend: Use goa_object_skeleton_attach_contacts helper
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761510

 src/goabackend/goaexchangeprovider.c |   18 +-----------------
 src/goabackend/goagoogleprovider.c   |   24 ++++--------------------
 src/goabackend/goaowncloudprovider.c |   29 ++++-------------------------
 3 files changed, 9 insertions(+), 62 deletions(-)
---
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index af29ff2..ccecda8 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -106,7 +106,6 @@ build_object (GoaProvider         *provider,
               GError             **error)
 {
   GoaAccount *account;
-  GoaContacts *contacts;
   GoaExchange *exchange;
   GoaMail *mail;
   GoaPasswordBased *password_based;
@@ -116,7 +115,6 @@ build_object (GoaProvider         *provider,
   gboolean ret;
 
   account = NULL;
-  contacts = NULL;
   exchange = NULL;
   mail = NULL;
   password_based = NULL;
@@ -174,21 +172,8 @@ build_object (GoaProvider         *provider,
   goa_object_skeleton_attach_calendar (object, NULL, calendar_enabled, FALSE);
 
   /* Contacts */
-  contacts = goa_object_get_contacts (GOA_OBJECT (object));
   contacts_enabled = g_key_file_get_boolean (key_file, group, "ContactsEnabled", NULL);
-  if (contacts_enabled)
-    {
-      if (contacts == NULL)
-        {
-          contacts = goa_contacts_skeleton_new ();
-          goa_object_skeleton_set_contacts (object, contacts);
-        }
-    }
-  else
-    {
-      if (contacts != NULL)
-        goa_object_skeleton_set_contacts (object, NULL);
-    }
+  goa_object_skeleton_attach_contacts (object, NULL, contacts_enabled, FALSE);
 
   /* Exchange */
   exchange = goa_object_get_exchange (GOA_OBJECT (object));
@@ -232,7 +217,6 @@ build_object (GoaProvider         *provider,
 
  out:
   g_clear_object (&exchange);
-  g_clear_object (&contacts);
   g_clear_object (&mail);
   g_clear_object (&password_based);
   return ret;
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index 1504577..9ca8dc3 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -324,7 +324,6 @@ build_object (GoaProvider         *provider,
   GoaAccount *account;
   GoaMail *mail;
   gchar *uri_caldav;
-  GoaContacts *contacts;
   GoaChat *chat;
   GoaDocuments *documents;
   GoaPhotos *photos;
@@ -343,7 +342,6 @@ build_object (GoaProvider         *provider,
 
   account = NULL;
   mail = NULL;
-  contacts = NULL;
   chat = NULL;
   documents = NULL;
   photos = NULL;
@@ -400,24 +398,11 @@ build_object (GoaProvider         *provider,
   g_free (uri_caldav);
 
   /* Contacts */
-  contacts = goa_object_get_contacts (GOA_OBJECT (object));
   contacts_enabled = g_key_file_get_boolean (key_file, group, "ContactsEnabled", NULL);
-  if (contacts_enabled)
-    {
-      if (contacts == NULL)
-        {
-          contacts = goa_contacts_skeleton_new ();
-          g_object_set (G_OBJECT (contacts),
-                        "uri", "https://www.googleapis.com/.well-known/carddav";,
-                        NULL);
-          goa_object_skeleton_set_contacts (object, contacts);
-        }
-    }
-  else
-    {
-      if (contacts != NULL)
-        goa_object_skeleton_set_contacts (object, NULL);
-    }
+  goa_object_skeleton_attach_contacts (object,
+                                       "https://www.googleapis.com/.well-known/carddav";,
+                                       contacts_enabled,
+                                       FALSE);
 
 #ifdef GOA_TELEPATHY_ENABLED
   /* Chat */
@@ -552,7 +537,6 @@ build_object (GoaProvider         *provider,
   g_clear_object (&photos);
   g_clear_object (&documents);
   g_clear_object (&chat);
-  g_clear_object (&contacts);
   g_clear_object (&mail);
   g_clear_object (&account);
   return ret;
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 9d436f4..9fa44cf 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -146,8 +146,8 @@ build_object (GoaProvider         *provider,
 {
   GoaAccount *account;
   gchar *uri_caldav;
+  gchar *uri_carddav;
   gchar *uri_webdav;
-  GoaContacts *contacts;
   GoaDocuments *documents;
   GoaPasswordBased *password_based;
   SoupURI *uri;
@@ -161,7 +161,6 @@ build_object (GoaProvider         *provider,
   gchar *uri_string;
 
   account = NULL;
-  contacts = NULL;
   documents = NULL;
   password_based = NULL;
   uri = NULL;
@@ -209,29 +208,10 @@ build_object (GoaProvider         *provider,
   g_free (uri_caldav);
 
   /* Contacts */
-  contacts = goa_object_get_contacts (GOA_OBJECT (object));
   contacts_enabled = g_key_file_get_boolean (key_file, group, "ContactsEnabled", NULL);
-  if (contacts_enabled)
-    {
-      if (contacts == NULL)
-        {
-          gchar *uri_carddav;
-
-          uri_carddav = uri_to_string_with_path (uri, CARDDAV_ENDPOINT);
-          contacts = goa_contacts_skeleton_new ();
-          g_object_set (G_OBJECT (contacts),
-                        "accept-ssl-errors", accept_ssl_errors,
-                        "uri", uri_carddav,
-                        NULL);
-          goa_object_skeleton_set_contacts (object, contacts);
-          g_free (uri_carddav);
-        }
-    }
-  else
-    {
-      if (contacts != NULL)
-        goa_object_skeleton_set_contacts (object, NULL);
-    }
+  uri_carddav = uri_to_string_with_path (uri, CARDDAV_ENDPOINT);
+  goa_object_skeleton_attach_contacts (object, uri_carddav, contacts_enabled, accept_ssl_errors);
+  g_free (uri_carddav);
 
   /* Documents */
   documents = goa_object_get_documents (GOA_OBJECT (object));
@@ -285,7 +265,6 @@ build_object (GoaProvider         *provider,
   ret = TRUE;
 
  out:
-  g_clear_object (&contacts);
   g_clear_object (&documents);
   g_clear_object (&password_based);
   g_clear_pointer (&uri, (GDestroyNotify *) soup_uri_free);


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