[gnome-online-accounts] backend: Add goa_object_skeleton_attach_calendar helper



commit 2a472cc3e71e213511019e2ab5d055a62de21344
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun May 3 11:03:55 2015 +0200

    backend: Add goa_object_skeleton_attach_calendar helper
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761510

 src/goabackend/Makefile.am              |    1 +
 src/goabackend/goaobjectskeletonutils.c |   52 +++++++++++++++++++++++++++++++
 src/goabackend/goaobjectskeletonutils.h |   38 ++++++++++++++++++++++
 3 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index d383f2e..22c271a 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -92,6 +92,7 @@ libgoa_backend_1_0_la_SOURCES =                                               \
        goawindowsliveprovider.h        goawindowsliveprovider.c        \
        goapocketprovider.h             goapocketprovider.c             \
        goalastfmprovider.h             goalastfmprovider.c             \
+       goaobjectskeletonutils.h        goaobjectskeletonutils.c        \
        goautils.h                      goautils.c                      \
        goawebview.h                    goawebview.c                    \
        nautilus-floating-bar.h         nautilus-floating-bar.c         \
diff --git a/src/goabackend/goaobjectskeletonutils.c b/src/goabackend/goaobjectskeletonutils.c
new file mode 100644
index 0000000..f60e20c
--- /dev/null
+++ b/src/goabackend/goaobjectskeletonutils.c
@@ -0,0 +1,52 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012, 2013, 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "goaobjectskeletonutils.h"
+
+void
+goa_object_skeleton_attach_calendar (GoaObjectSkeleton *object,
+                                     const gchar       *uri,
+                                     gboolean           calendar_enabled,
+                                     gboolean           accept_ssl_errors)
+{
+  GoaCalendar *calendar;
+
+  calendar = goa_object_get_calendar (GOA_OBJECT (object));
+  if (calendar_enabled)
+    {
+      if (calendar == NULL)
+        {
+          calendar = goa_calendar_skeleton_new ();
+          g_object_set (G_OBJECT (calendar),
+                        "accept-ssl-errors", accept_ssl_errors,
+                        "uri", uri,
+                        NULL);
+          goa_object_skeleton_set_calendar (object, calendar);
+        }
+    }
+  else
+    {
+      if (calendar != NULL)
+        goa_object_skeleton_set_calendar (object, NULL);
+    }
+  g_clear_object (&calendar);
+}
diff --git a/src/goabackend/goaobjectskeletonutils.h b/src/goabackend/goaobjectskeletonutils.h
new file mode 100644
index 0000000..bce621a
--- /dev/null
+++ b/src/goabackend/goaobjectskeletonutils.h
@@ -0,0 +1,38 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012-2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined (__GOA_BACKEND_INSIDE_GOA_BACKEND_H__) && !defined (GOA_BACKEND_COMPILATION)
+#error "Only <goabackend/goabackend.h> can be included directly."
+#endif
+
+#ifndef __GOA_OBJECT_SKELETON_UTILS_H__
+#define __GOA_OBJECT_SKELETON_UTILS_H__
+
+#include <glib.h>
+#include <goa/goa.h>
+
+G_BEGIN_DECLS
+
+void             goa_object_skeleton_attach_calendar       (GoaObjectSkeleton *object,
+                                                            const gchar       *uri,
+                                                            gboolean           calendar_enabled,
+                                                            gboolean           accept_ssl_errors);
+
+G_END_DECLS
+
+#endif /* __GOA_OBJECT_SKELETON_UTILS_H__ */


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