[gnome-online-accounts] backend: Add and use goa_object_skeleton_attach_read_later



commit 67706bb4bd0ae37eb62248fac52c6aae57fdf7fa
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun May 3 22:26:06 2015 +0200

    backend: Add and use goa_object_skeleton_attach_read_later
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761510

 src/goabackend/goaobjectskeletonutils.c |   23 +++++++++++++++++++++++
 src/goabackend/goaobjectskeletonutils.h |    3 +++
 src/goabackend/goapocketprovider.c      |   18 ++----------------
 3 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/src/goabackend/goaobjectskeletonutils.c b/src/goabackend/goaobjectskeletonutils.c
index c952826..77c8a60 100644
--- a/src/goabackend/goaobjectskeletonutils.c
+++ b/src/goabackend/goaobjectskeletonutils.c
@@ -231,3 +231,26 @@ goa_object_skeleton_attach_maps (GoaObjectSkeleton *object,
     }
   g_clear_object (&maps);
 }
+
+void
+goa_object_skeleton_attach_read_later (GoaObjectSkeleton *object,
+                                       gboolean           read_later_enabled)
+{
+  GoaReadLater *readlater = NULL;
+
+  readlater = goa_object_get_read_later (GOA_OBJECT (object));
+  if (read_later_enabled)
+    {
+      if (readlater == NULL)
+        {
+          readlater = goa_read_later_skeleton_new ();
+          goa_object_skeleton_set_read_later (object, readlater);
+        }
+    }
+  else
+    {
+      if (readlater != NULL)
+        goa_object_skeleton_set_read_later (object, NULL);
+    }
+  g_clear_object (&readlater);
+}
diff --git a/src/goabackend/goaobjectskeletonutils.h b/src/goabackend/goaobjectskeletonutils.h
index 815675f..45821f6 100644
--- a/src/goabackend/goaobjectskeletonutils.h
+++ b/src/goabackend/goaobjectskeletonutils.h
@@ -58,6 +58,9 @@ void             goa_object_skeleton_attach_photos         (GoaObjectSkeleton *o
 void             goa_object_skeleton_attach_printers       (GoaObjectSkeleton *object,
                                                             gboolean           printers_enabled);
 
+void             goa_object_skeleton_attach_read_later     (GoaObjectSkeleton *object,
+                                                            gboolean           read_later_enabled);
+
 G_END_DECLS
 
 #endif /* __GOA_OBJECT_SKELETON_UTILS_H__ */
diff --git a/src/goabackend/goapocketprovider.c b/src/goabackend/goapocketprovider.c
index 30b4cee..13699af 100644
--- a/src/goabackend/goapocketprovider.c
+++ b/src/goabackend/goapocketprovider.c
@@ -27,6 +27,7 @@
 #include "goaprovider-priv.h"
 #include "goaoauth2provider.h"
 #include "goapocketprovider.h"
+#include "goaobjectskeletonutils.h"
 
 #define V3_OAUTH_AUTHORIZE_URL "https://getpocket.com/v3/oauth/authorize";
 
@@ -331,7 +332,6 @@ build_object (GoaProvider         *provider,
               GError             **error)
 {
   GoaAccount *account;
-  GoaReadLater *readlater = NULL;
   gboolean read_later_enabled;
   gboolean ret = FALSE;
 
@@ -350,21 +350,8 @@ build_object (GoaProvider         *provider,
   account = goa_object_get_account (GOA_OBJECT (object));
 
   /* Read Later */
-  readlater = goa_object_get_read_later (GOA_OBJECT (object));
   read_later_enabled = g_key_file_get_boolean (key_file, group, "ReadLaterEnabled", NULL);
-  if (read_later_enabled)
-    {
-      if (readlater == NULL)
-        {
-          readlater = goa_read_later_skeleton_new ();
-          goa_object_skeleton_set_read_later (object, readlater);
-        }
-    }
-  else
-    {
-      if (readlater != NULL)
-        goa_object_skeleton_set_read_later (object, NULL);
-    }
+  goa_object_skeleton_attach_read_later (object, read_later_enabled);
 
   if (just_added)
     {
@@ -379,7 +366,6 @@ build_object (GoaProvider         *provider,
   ret = TRUE;
 
  out:
-  g_clear_object (&readlater);
   g_clear_object (&account);
   return ret;
 }


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