[gnome-todo/wip/goa-lists] storage-goa: setup calendar url



commit 4fc28014dde6804f9178e86130fb4d723bc4d97b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Aug 24 13:00:01 2015 -0300

    storage-goa: setup calendar url

 src/gtd-manager.c             |   11 ++++++++-
 src/storage/gtd-storage-goa.c |   48 +++++++++++++++++++++++++++++++++++++++++
 src/storage/gtd-storage-goa.h |    5 ++++
 3 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/gtd-manager.c b/src/gtd-manager.c
index 038bbd1..8f7b49e 100644
--- a/src/gtd-manager.c
+++ b/src/gtd-manager.c
@@ -324,15 +324,22 @@ gtd_manager__goa_client_finish_cb (GObject      *client,
           GoaAccount *account;
 
           object = l->data;
-          account = goa_object_get_account (object);
+          account = goa_object_peek_account (object);
 
           if (g_strv_contains (supported_providers, goa_account_get_provider_type (account)))
             {
               GtdStorage *storage;
+              GoaCalendar *calendar;
+              gchar *uri;
 
+              calendar = goa_object_peek_calendar (object);
+              uri = goa_calendar_dup_uri (calendar);
+
+              /* Create the new GOA storage */
               storage = gtd_storage_goa_new (account);
               gtd_storage_set_enabled (storage, !goa_account_get_calendar_disabled (account));
               gtd_storage_set_is_default (storage, g_strcmp0 (gtd_storage_get_id (storage), 
default_location) == 0);
+              gtd_storage_goa_set_uri (GTD_STORAGE_GOA (storage), uri);
 
               g_assert (gtd_storage_goa_get_account (GTD_STORAGE_GOA (storage)) == account);
 
@@ -342,6 +349,8 @@ gtd_manager__goa_client_finish_cb (GObject      *client,
                                                               storage,
                                                               (GCompareFunc) gtd_storage_compare);
 
+              g_free (uri);
+
               g_signal_emit (user_data, signals[STORAGE_ADDED], 0, storage);
             }
         }
diff --git a/src/storage/gtd-storage-goa.c b/src/storage/gtd-storage-goa.c
index 88b570c..13adea7 100644
--- a/src/storage/gtd-storage-goa.c
+++ b/src/storage/gtd-storage-goa.c
@@ -29,6 +29,7 @@ struct _GtdStorageGoa
   GoaAccount         *account;
   GIcon              *icon;
   gchar              *parent_source;
+  gchar              *uri;
 };
 
 G_DEFINE_TYPE (GtdStorageGoa, gtd_storage_goa, GTD_TYPE_STORAGE)
@@ -37,6 +38,7 @@ enum {
   PROP_0,
   PROP_ACCOUNT,
   PROP_PARENT,
+  PROP_URI,
   LAST_PROP
 };
 
@@ -148,6 +150,10 @@ gtd_storage_goa_get_property (GObject    *object,
       g_value_set_string (value, gtd_storage_goa_get_parent (self));
       break;
 
+    case PROP_URI:
+      g_value_set_string (value, gtd_storage_goa_get_uri (self));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -188,6 +194,10 @@ gtd_storage_goa_set_property (GObject      *object,
       gtd_storage_goa_set_parent (self, g_value_get_string (value));
       break;
 
+    case PROP_URI:
+      gtd_storage_goa_set_uri (self, g_value_get_string (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -234,6 +244,20 @@ gtd_storage_goa_class_init (GtdStorageGoaClass *klass)
                              _("The parent source identifier of the storage location."),
                              NULL,
                              G_PARAM_READWRITE));
+
+  /**
+   * GtdStorageGoa::uri:
+   *
+   * The uri of this GOA calendar.
+   */
+  g_object_class_install_property (
+        object_class,
+        PROP_URI,
+        g_param_spec_string ("uri",
+                             _("URI of the storage"),
+                             _("The URI of the calendar of the storage location."),
+                             NULL,
+                             G_PARAM_READWRITE));
 }
 
 static void
@@ -308,3 +332,27 @@ gtd_storage_goa_set_parent (GtdStorageGoa *goa_storage,
       g_object_notify (G_OBJECT (goa_storage), "parent");
     }
 }
+
+const gchar*
+gtd_storage_goa_get_uri (GtdStorageGoa *goa_storage)
+{
+  g_return_val_if_fail (GTD_IS_STORAGE_GOA (goa_storage), NULL);
+
+  return goa_storage->uri;
+}
+
+void
+gtd_storage_goa_set_uri (GtdStorageGoa *goa_storage,
+                         const gchar   *uri)
+{
+  g_return_if_fail (GTD_IS_STORAGE_GOA (goa_storage));
+
+  if (g_strcmp0 (goa_storage->uri, uri) != 0)
+    {
+      g_clear_pointer (&goa_storage->uri, g_free);
+
+      goa_storage->uri = g_strdup (uri);
+
+      g_object_notify (G_OBJECT (goa_storage), "uri");
+    }
+}
diff --git a/src/storage/gtd-storage-goa.h b/src/storage/gtd-storage-goa.h
index b146b01..4095d56 100644
--- a/src/storage/gtd-storage-goa.h
+++ b/src/storage/gtd-storage-goa.h
@@ -40,6 +40,11 @@ const gchar*         gtd_storage_goa_get_parent                  (GtdStorageGoa
 void                 gtd_storage_goa_set_parent                  (GtdStorageGoa      *goa_storage,
                                                                   const gchar        *parent);
 
+const gchar*         gtd_storage_goa_get_uri                     (GtdStorageGoa      *goa_storage);
+
+void                 gtd_storage_goa_set_uri                     (GtdStorageGoa      *goa_storage,
+                                                                  const gchar        *uri);
+
 G_END_DECLS
 
 #endif /* GTD_STORAGE_GOA_H */


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