[gnome-online-accounts] backend: Use goa_object_skeleton_attach_photos() helper



commit 27f8ecefc0e9e588becaf0c20bca143968f38c5c
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun May 3 19:16:46 2015 +0200

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

 src/goabackend/goafacebookprovider.c    |   19 ++-----------------
 src/goabackend/goaflickrprovider.c      |   20 ++------------------
 src/goabackend/goagoogleprovider.c      |   19 +------------------
 src/goabackend/goamediaserverprovider.c |   19 ++-----------------
 4 files changed, 7 insertions(+), 70 deletions(-)
---
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index 34e1ccf..a3eb6d6 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -26,6 +26,7 @@
 #include "goaprovider-priv.h"
 #include "goaoauth2provider.h"
 #include "goafacebookprovider.h"
+#include "goaobjectskeletonutils.h"
 
 /**
  * GoaFacebookProvider:
@@ -321,7 +322,6 @@ build_object (GoaProvider         *provider,
               GError             **error)
 {
   GoaAccount *account;
-  GoaPhotos *photos = NULL;
   GoaMaps *maps = NULL;
   gboolean photos_enabled;
   gboolean maps_enabled;
@@ -342,22 +342,8 @@ build_object (GoaProvider         *provider,
   account = goa_object_get_account (GOA_OBJECT (object));
 
   /* Photos */
-  photos = goa_object_get_photos (GOA_OBJECT (object));
   photos_enabled = g_key_file_get_boolean (key_file, group, "PhotosEnabled", NULL);
-
-  if (photos_enabled)
-    {
-      if (photos == NULL)
-        {
-          photos = goa_photos_skeleton_new ();
-          goa_object_skeleton_set_photos (object, photos);
-        }
-    }
-  else
-    {
-      if (photos != NULL)
-        goa_object_skeleton_set_photos (object, NULL);
-    }
+  goa_object_skeleton_attach_photos (object, photos_enabled);
 
   if (just_added)
     {
@@ -400,7 +386,6 @@ build_object (GoaProvider         *provider,
 
  out:
   g_clear_object (&account);
-  g_clear_object (&photos);
   g_clear_object (&maps);
   return ret;
 }
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index d087320..0b087c0 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -27,6 +27,7 @@
 #include "goaprovider-priv.h"
 #include "goaoauthprovider.h"
 #include "goaflickrprovider.h"
+#include "goaobjectskeletonutils.h"
 
 /**
  * GoaFlickrProvider:
@@ -335,12 +336,10 @@ build_object (GoaProvider         *provider,
               GError             **error)
 {
   GoaAccount *account;
-  GoaPhotos *photos;
   gboolean photos_enabled;
   gboolean ret;
 
   account = NULL;
-  photos = NULL;
   ret = FALSE;
 
   /* Chain up */
@@ -356,22 +355,8 @@ build_object (GoaProvider         *provider,
   account = goa_object_get_account (GOA_OBJECT (object));
 
   /* Photos */
-  photos = goa_object_get_photos (GOA_OBJECT (object));
   photos_enabled = g_key_file_get_boolean (key_file, group, "PhotosEnabled", NULL);
-
-  if (photos_enabled)
-    {
-      if (photos == NULL)
-        {
-          photos = goa_photos_skeleton_new ();
-          goa_object_skeleton_set_photos (object, photos);
-        }
-    }
-  else
-    {
-      if (photos != NULL)
-        goa_object_skeleton_set_photos (object, NULL);
-    }
+  goa_object_skeleton_attach_photos (object, photos_enabled);
 
   if (just_added)
     {
@@ -386,7 +371,6 @@ build_object (GoaProvider         *provider,
   ret = TRUE;
 
  out:
-  g_clear_object (&photos);
   g_clear_object (&account);
   return ret;
 }
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index a5107f8..27250df 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;
-  GoaPhotos *photos;
   GoaPrinters *printers;
   gchar *uri_drive;
   gboolean ret;
@@ -340,7 +339,6 @@ build_object (GoaProvider         *provider,
 
   account = NULL;
   mail = NULL;
-  photos = NULL;
   printers = NULL;
   ret = FALSE;
 
@@ -409,22 +407,8 @@ build_object (GoaProvider         *provider,
   goa_object_skeleton_attach_documents (object, documents_enabled);
 
   /* Photos */
-  photos = goa_object_get_photos (GOA_OBJECT (object));
   photos_enabled = g_key_file_get_boolean (key_file, group, "PhotosEnabled", NULL);
-
-  if (photos_enabled)
-    {
-      if (photos == NULL)
-        {
-          photos = goa_photos_skeleton_new ();
-          goa_object_skeleton_set_photos (object, photos);
-        }
-    }
-  else
-    {
-      if (photos != NULL)
-        goa_object_skeleton_set_photos (object, NULL);
-    }
+  goa_object_skeleton_attach_photos (object, photos_enabled);
 
   /* Files */
   files_enabled = g_key_file_get_boolean (key_file, group, "FilesEnabled", NULL);
@@ -499,7 +483,6 @@ build_object (GoaProvider         *provider,
 
  out:
   g_clear_object (&printers);
-  g_clear_object (&photos);
   g_clear_object (&mail);
   g_clear_object (&account);
   return ret;
diff --git a/src/goabackend/goamediaserverprovider.c b/src/goabackend/goamediaserverprovider.c
index 28a9b30..7f9ab5c 100644
--- a/src/goabackend/goamediaserverprovider.c
+++ b/src/goabackend/goamediaserverprovider.c
@@ -20,6 +20,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "goaprovider.h"
+#include "goaobjectskeletonutils.h"
 #include "goautils.h"
 #include "goaprovider-priv.h"
 #include "goamediaserverprovider.h"
@@ -109,12 +110,10 @@ build_object (GoaProvider        *provider,
   gboolean ret;
   GoaAccount *account;
   GoaMediaServer *mediaserver;
-  GoaPhotos *photos;
   const gchar *udn;
   gboolean photos_enabled;
 
   mediaserver = NULL;
-  photos = NULL;
 
   account = NULL;
   ret = FALSE;
@@ -133,21 +132,8 @@ build_object (GoaProvider        *provider,
   udn = goa_account_get_identity (account);
 
   /* Photos */
-  photos = goa_object_get_photos (GOA_OBJECT (object));
   photos_enabled = g_key_file_get_boolean (key_file, group, "PhotosEnabled", NULL);
-  if (photos_enabled)
-    {
-      if (photos == NULL)
-        {
-          photos = goa_photos_skeleton_new ();
-          goa_object_skeleton_set_photos (object, photos);
-        }
-    }
-  else
-    {
-      if (photos == NULL)
-        goa_object_skeleton_set_photos (object, NULL);
-    }
+  goa_object_skeleton_attach_photos (object, photos_enabled);
 
   /* Media Server */
   mediaserver = goa_object_get_media_server (GOA_OBJECT (object));
@@ -176,7 +162,6 @@ build_object (GoaProvider        *provider,
 out:
   g_clear_object (&account);
   g_clear_object (&mediaserver);
-  g_clear_object (&photos);
   return ret;
 }
 


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