[evolution-data-server] yahoo-backend: Implement dup_resource_id() method.



commit ad1626dc925124b270bc6e2c1d07a886b9438efe
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jun 12 21:14:32 2012 -0400

    yahoo-backend: Implement dup_resource_id() method.

 modules/yahoo-backend/module-yahoo-backend.c |   33 ++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/modules/yahoo-backend/module-yahoo-backend.c b/modules/yahoo-backend/module-yahoo-backend.c
index 78ff77c..a90a51f 100644
--- a/modules/yahoo-backend/module-yahoo-backend.c
+++ b/modules/yahoo-backend/module-yahoo-backend.c
@@ -47,6 +47,11 @@
 #define YAHOO_CALENDAR_BACKEND_NAME	"caldav"
 #define YAHOO_CALENDAR_HOST		"caldav.calendar.yahoo.com"
 #define YAHOO_CALENDAR_CALDAV_PATH	"/dav/%s/Calendar/%s"
+#define YAHOO_CALENDAR_RESOURCE_ID	"Calendar"
+
+/* Tasks Configuration Details
+ * (mostly the same as calendar) */
+#define YAHOO_TASKS_RESOURCE_ID		"Tasks"
 
 typedef struct _EYahooBackend EYahooBackend;
 typedef struct _EYahooBackendClass EYahooBackendClass;
@@ -176,6 +181,7 @@ yahoo_backend_add_calendar (ECollectionBackend *backend)
 	ESourceRegistryServer *server;
 	const gchar *backend_name;
 	const gchar *extension_name;
+	const gchar *resource_id;
 
 	/* XXX We could just stick a [Calendar] and [Task List] extension
 	 *     into the same ESource since all other settings are exactly
@@ -189,7 +195,8 @@ yahoo_backend_add_calendar (ECollectionBackend *backend)
 
 	/* Add Yahoo! Calendar */
 
-	source = e_collection_backend_new_child (backend, "Calendar");
+	resource_id = YAHOO_CALENDAR_RESOURCE_ID;
+	source = e_collection_backend_new_child (backend, resource_id);
 	e_source_set_display_name (source, _("Calendar"));
 
 	extension_name = E_SOURCE_EXTENSION_CALENDAR;
@@ -203,7 +210,8 @@ yahoo_backend_add_calendar (ECollectionBackend *backend)
 
 	/* Add Yahoo! Tasks */
 
-	source = e_collection_backend_new_child (backend, "Tasks");
+	resource_id = YAHOO_TASKS_RESOURCE_ID;
+	source = e_collection_backend_new_child (backend, resource_id);
 	e_source_set_display_name (source, _("Tasks"));
 
 	extension_name = E_SOURCE_EXTENSION_TASK_LIST;
@@ -234,6 +242,26 @@ yahoo_backend_populate (ECollectionBackend *backend)
 	g_list_free_full (list, (GDestroyNotify) g_object_unref);
 }
 
+static gchar *
+yahoo_backend_dup_resource_id (ECollectionBackend *backend,
+                               ESource *child_source)
+{
+	const gchar *extension_name;
+
+	/* XXX This is trival for now since we only
+	 *     add one calendar and one task list. */
+
+	extension_name = E_SOURCE_EXTENSION_CALENDAR;
+	if (e_source_has_extension (child_source, extension_name))
+		return g_strdup (YAHOO_CALENDAR_RESOURCE_ID);
+
+	extension_name = E_SOURCE_EXTENSION_TASK_LIST;
+	if (e_source_has_extension (child_source, extension_name))
+		return g_strdup (YAHOO_TASKS_RESOURCE_ID);
+
+	return NULL;
+}
+
 static void
 yahoo_backend_child_added (ECollectionBackend *backend,
                            ESource *child_source)
@@ -302,6 +330,7 @@ e_yahoo_backend_class_init (EYahooBackendClass *class)
 
 	backend_class = E_COLLECTION_BACKEND_CLASS (class);
 	backend_class->populate = yahoo_backend_populate;
+	backend_class->dup_resource_id = yahoo_backend_dup_resource_id;
 	backend_class->child_added = yahoo_backend_child_added;
 }
 



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