[evolution-data-server/account-mgmt: 16/26] Add an ESource extension for the webcal backend.



commit d40d343b7b32a9623ed60a842c96e8c6963fc96f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Nov 22 23:04:56 2010 -0500

    Add an ESource extension for the webcal backend.

 calendar/backends/http/Makefile.am                 |    4 +-
 .../backends/http/e-cal-backend-http-factory.c     |  220 +++++++++-----------
 calendar/backends/http/e-cal-backend-http.c        |   93 +++++++--
 calendar/backends/http/e-source-webcal.c           |  154 ++++++++++++++
 calendar/backends/http/e-source-webcal.h           |   68 ++++++
 5 files changed, 396 insertions(+), 143 deletions(-)
---
diff --git a/calendar/backends/http/Makefile.am b/calendar/backends/http/Makefile.am
index 3f0be8a..88d2ae4 100644
--- a/calendar/backends/http/Makefile.am
+++ b/calendar/backends/http/Makefile.am
@@ -14,7 +14,9 @@ libecalbackendhttp_la_SOURCES =		\
 	e-cal-backend-http-factory.c	\
 	e-cal-backend-http-factory.h	\
 	e-cal-backend-http.c		\
-	e-cal-backend-http.h
+	e-cal-backend-http.h		\
+	e-source-webcal.c		\
+	e-source-webcal.h
 
 libecalbackendhttp_la_LIBADD =						\
 	$(top_builddir)/calendar/libecal/libecal-1.2.la			\
diff --git a/calendar/backends/http/e-cal-backend-http-factory.c b/calendar/backends/http/e-cal-backend-http-factory.c
index 840762f..b8d9a23 100644
--- a/calendar/backends/http/e-cal-backend-http-factory.c
+++ b/calendar/backends/http/e-cal-backend-http-factory.c
@@ -15,19 +15,36 @@
 
 #include "e-cal-backend-http-factory.h"
 #include "e-cal-backend-http.h"
+#include "e-source-webcal.h"
 
-typedef struct {
-	ECalBackendFactory            parent_object;
-} ECalBackendHttpFactory;
+typedef ECalBackendFactory ECalBackendHttpEventsFactory;
+typedef ECalBackendFactoryClass ECalBackendHttpEventsFactoryClass;
 
-typedef struct {
-	ECalBackendFactoryClass parent_class;
-} ECalBackendHttpFactoryClass;
+typedef ECalBackendFactory ECalBackendHttpJournalFactory;
+typedef ECalBackendFactoryClass ECalBackendHttpJournalFactoryClass;
 
-static void
-e_cal_backend_http_factory_instance_init (ECalBackendHttpFactory *factory)
-{
-}
+typedef ECalBackendFactory ECalBackendHttpTodosFactory;
+typedef ECalBackendFactoryClass ECalBackendHttpTodosFactoryClass;
+
+/* Forward Declarations */
+GType e_cal_backend_http_events_factory_get_type (void);
+GType e_cal_backend_http_journal_factory_get_type (void);
+GType e_cal_backend_http_todos_factory_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendHttpEventsFactory,
+	e_cal_backend_http_events_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendHttpJournalFactory,
+	e_cal_backend_http_journal_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendHttpTodosFactory,
+	e_cal_backend_http_todos_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
 static const gchar *
 _get_protocol (ECalBackendFactory *factory)
@@ -35,170 +52,131 @@ _get_protocol (ECalBackendFactory *factory)
 	return "webcal";
 }
 
-static ECalBackend*
-_todos_new_backend (ECalBackendFactory *factory, ESource *source)
+static icalcomponent_kind
+_events_get_kind (ECalBackendFactory *factory)
+{
+	return ICAL_VEVENT_COMPONENT;
+}
+
+static ECalBackend *
+_events_new_backend (ECalBackendFactory *factory,
+                     ESource *source)
 {
-	return g_object_new (e_cal_backend_http_get_type (),
-			     "source", source,
-			     "kind", ICAL_VTODO_COMPONENT,
-			     NULL);
+	return g_object_new (
+		e_cal_backend_http_get_type (),
+		"kind", ICAL_VEVENT_COMPONENT,
+		"source", source, NULL);
 }
 
 static icalcomponent_kind
-_todos_get_kind (ECalBackendFactory *factory)
+_journal_get_kind (ECalBackendFactory *factory)
 {
-	return ICAL_VTODO_COMPONENT;
+	return ICAL_VJOURNAL_COMPONENT;
 }
 
-static ECalBackend*
-_events_new_backend (ECalBackendFactory *factory, ESource *source)
+static ECalBackend *
+_journal_new_backend (ECalBackendFactory *factory,
+                      ESource *source)
 {
-	return g_object_new (e_cal_backend_http_get_type (),
-			     "source", source,
-			     "kind", ICAL_VEVENT_COMPONENT,
-			     NULL);
+	return g_object_new (
+		e_cal_backend_http_get_type (),
+		"kind", ICAL_VJOURNAL_COMPONENT,
+		"source", source, NULL);
 }
 
 static icalcomponent_kind
-_events_get_kind (ECalBackendFactory *factory)
+_todos_get_kind (ECalBackendFactory *factory)
 {
-	return ICAL_VEVENT_COMPONENT;
+	return ICAL_VTODO_COMPONENT;
 }
 
-static ECalBackend*
-_memos_new_backend (ECalBackendFactory *factory, ESource *source)
+static ECalBackend *
+_todos_new_backend (ECalBackendFactory *factory,
+                    ESource *source)
 {
-	return g_object_new (e_cal_backend_http_get_type (),
-			     "source", source,
-			     "kind", ICAL_VJOURNAL_COMPONENT,
-			     NULL);
+	return g_object_new (
+		e_cal_backend_http_get_type (),
+		"kind", ICAL_VTODO_COMPONENT,
+		"source", source, NULL);
 }
 
-static icalcomponent_kind
-_memos_get_kind (ECalBackendFactory *factory)
+static void
+e_cal_backend_http_events_factory_class_init (ECalBackendFactoryClass *class)
 {
-	return ICAL_VJOURNAL_COMPONENT;
+	class->get_protocol = _get_protocol;
+	class->get_kind     = _events_get_kind;
+	class->new_backend  = _events_new_backend;
 }
 
 static void
-todos_backend_factory_class_init (ECalBackendHttpFactoryClass *klass)
+e_cal_backend_http_events_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _todos_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _todos_new_backend;
 }
 
 static void
-events_backend_factory_class_init (ECalBackendHttpFactoryClass *klass)
+e_cal_backend_http_events_factory_init (ECalBackendFactory *factory)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _events_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _events_new_backend;
 }
 
 static void
-memos_backend_factory_class_init (ECalBackendHttpFactoryClass *klass)
+e_cal_backend_http_journal_factory_class_init (ECalBackendFactoryClass *class)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _memos_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _memos_new_backend;
+	class->get_protocol = _get_protocol;
+	class->get_kind     = _journal_get_kind;
+	class->new_backend  = _journal_new_backend;
 }
 
-static GType
-events_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_http_journal_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendHttpFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  events_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_http_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendHttpEventsFactory",
-					    &info, 0);
-
-	return type;
 }
 
-static GType
-todos_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_http_journal_factory_init (ECalBackendFactory *factory)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendHttpFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  todos_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_http_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendHttpTodosFactory",
-					    &info, 0);
-
-	return type;
 }
 
-static GType
-memos_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_http_todos_factory_class_init (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendHttpFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  memos_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_http_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendHttpMemosFactory",
-					    &info, 0);
-
-	return type;
+	class->get_protocol = _get_protocol;
+	class->get_kind     = _todos_get_kind;
+	class->new_backend  = _todos_new_backend;
 }
 
-
+static void
+e_cal_backend_http_todos_factory_class_finalize (ECalBackendFactoryClass *class)
+{
+}
 
-static GType http_types[3];
+static void
+e_cal_backend_http_todos_factory_init (ECalBackendFactory *factory)
+{
+}
 
 void
-eds_module_initialize (GTypeModule *module)
+eds_module_initialize (GTypeModule *type_module)
 {
-	http_types[0] = todos_backend_factory_get_type (module);
-	http_types[1] = events_backend_factory_get_type (module);
-	http_types[2] = memos_backend_factory_get_type (module);
+	e_source_webcal_type_register (type_module);
+	e_cal_backend_http_events_factory_register_type (type_module);
+	e_cal_backend_http_journal_factory_register_type (type_module);
+	e_cal_backend_http_todos_factory_register_type (type_module);
 }
 
 void
-eds_module_shutdown   (void)
+eds_module_shutdown (void)
 {
 }
 
 void
 eds_module_list_types (const GType **types, gint *num_types)
 {
+	static GType http_types[3];
+
+	http_types[0] = e_cal_backend_http_events_factory_get_type ();
+	http_types[1] = e_cal_backend_http_journal_factory_get_type ();
+	http_types[2] = e_cal_backend_http_todos_factory_get_type ();
+
 	*types = http_types;
-	*num_types = 3;
+	*num_types = G_N_ELEMENTS (http_types);
 }
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index a37d801..532429f 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -28,6 +28,9 @@
 #include <glib/gi18n-lib.h>
 #include "libedataserver/e-xml-hash-utils.h"
 #include "libedataserver/e-proxy.h"
+#include "libedataserver/e-source-authentication.h"
+#include "libedataserver/e-source-refresh.h"
+#include "libedataserver/e-source-security.h"
 #include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
@@ -38,6 +41,7 @@
 #include <libedata-cal/e-cal-backend-sexp.h>
 #include <libsoup/soup.h>
 #include "e-cal-backend-http.h"
+#include "e-source-webcal.h"
 
 #define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
 #define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
@@ -595,11 +599,27 @@ begin_retrieval_cb (ECalBackendHttp *cbhttp)
 	priv->is_loading = TRUE;
 
 	if (priv->uri == NULL) {
-		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
-		const gchar *secure_prop = e_source_get_property (source, "use_ssl");
+		ESource *source;
+		ESourceSecurity *security_extension;
+		ESourceWebcal *webcal_extension;
+		gboolean use_secure_connection;
+		const gchar *extension_name;
+		const gchar *method;
 
-		priv->uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
-						   (secure_prop && g_str_equal(secure_prop, "1")));
+		source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+
+		extension_name = E_SOURCE_EXTENSION_SECURITY;
+		security_extension = e_source_get_extension (source, extension_name);
+
+		extension_name = E_SOURCE_EXTENSION_WEBCAL_BACKEND;
+		webcal_extension = e_source_get_extension (source, extension_name);
+
+		method = e_source_security_get_method (security_extension);
+		use_secure_connection = (g_strcmp0 (method, "none") != 0);
+
+		priv->uri = webcal_to_http_method (
+			e_source_webcal_get_uri (webcal_extension),
+			use_secure_connection);
 	}
 
 	/* create the Soup session if not already created */
@@ -679,7 +699,9 @@ maybe_start_reload_timeout (ECalBackendHttp *cbhttp)
 {
 	ECalBackendHttpPrivate *priv;
 	ESource *source;
-	const gchar *refresh_str;
+	ESourceRefresh *refresh_extension;
+	const gchar *extension_name;
+	guint interval;
 
 	priv = cbhttp->priv;
 
@@ -694,10 +716,12 @@ maybe_start_reload_timeout (ECalBackendHttp *cbhttp)
 		return;
 	}
 
-	refresh_str = e_source_get_property (source, "refresh");
+	extension_name = E_SOURCE_EXTENSION_REFRESH;
+	refresh_extension = e_source_get_extension (source, extension_name);
+	interval = e_source_refresh_get_interval (refresh_extension);
 
-	priv->reload_timeout_id = g_timeout_add ((refresh_str ? atoi (refresh_str) : 30) * 60000,
-						 (GSourceFunc) reload_cb, cbhttp);
+	priv->reload_timeout_id = g_timeout_add (
+		interval * 60000, (GSourceFunc) reload_cb, cbhttp);
 }
 
 static void
@@ -711,12 +735,28 @@ source_changed_cb (ESource *source, ECalBackendHttp *cbhttp)
 	priv = cbhttp->priv;
 
 	if (priv->uri) {
-		ESource *source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
-		const gchar *secure_prop = e_source_get_property (source, "use_ssl");
+		ESource *source;
+		ESourceSecurity *security_extension;
+		ESourceWebcal *webcal_extension;
+		gboolean use_secure_connection;
+		const gchar *extension_name;
+		const gchar *method;
 		gchar *new_uri;
 
-		new_uri = webcal_to_http_method (e_cal_backend_get_uri (E_CAL_BACKEND (cbhttp)),
-						 (secure_prop && g_str_equal(secure_prop, "1")));
+		source = e_cal_backend_get_source (E_CAL_BACKEND (cbhttp));
+
+		extension_name = E_SOURCE_EXTENSION_SECURITY;
+		security_extension = e_source_get_extension (source, extension_name);
+
+		extension_name = E_SOURCE_EXTENSION_WEBCAL_BACKEND;
+		webcal_extension = e_source_get_extension (source, extension_name);
+
+		method = e_source_security_get_method (security_extension);
+		use_secure_connection = (g_strcmp0 (method, "none") != 0);
+
+		new_uri = webcal_to_http_method (
+			e_source_webcal_get_uri (webcal_extension),
+			use_secure_connection);
 
 		if (new_uri && !g_str_equal (priv->uri, new_uri)) {
 			/* uri changed, do reload some time soon */
@@ -739,6 +779,8 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
 	ESource *source;
+	ESourceAuthentication *auth_extension;
+	const gchar *extension_name;
 	gchar *tmp;
 
 	cbhttp = E_CAL_BACKEND_HTTP (backend);
@@ -750,6 +792,9 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 
 	source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
 
+	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+	auth_extension = e_source_get_extension (source, extension_name);
+
 	if (priv->source_changed_id == 0) {
 		priv->source_changed_id = g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), cbhttp);
 	}
@@ -759,7 +804,7 @@ e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_
 	priv->uri = NULL;
 	g_free (tmp);
 
-	if (e_source_get_property (source, "auth") != NULL) {
+	if (e_source_authentication_required (auth_extension)) {
 		if ((username == NULL || password == NULL)) {
 			g_propagate_error (perror, EDC_ERROR (AuthenticationRequired));
 			return;
@@ -814,8 +859,9 @@ e_cal_backend_http_refresh (ECalBackendSync *backend, EDataCal *cal, GError **pe
 	priv->reload_timeout_id = g_timeout_add (1000, (GSourceFunc) reload_cb, cbhttp);
 }
 
-static void
-e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal, GError **perror)
+/* is_loaded handler for the file backend */
+static gboolean
+e_cal_backend_http_is_loaded (ECalBackend *backend)
 {
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
@@ -824,14 +870,14 @@ e_cal_backend_http_remove (ECalBackendSync *backend, EDataCal *cal, GError **per
 	priv = cbhttp->priv;
 
 	if (!priv->store)
-		return;
+		return FALSE;
 
-	e_cal_backend_store_remove (priv->store);
+	return TRUE;
 }
 
-/* is_loaded handler for the file backend */
 static gboolean
-e_cal_backend_http_is_loaded (ECalBackend *backend)
+e_cal_backend_http_remove (ECalBackend *backend,
+                           GError **error)
 {
 	ECalBackendHttp *cbhttp;
 	ECalBackendHttpPrivate *priv;
@@ -840,7 +886,9 @@ e_cal_backend_http_is_loaded (ECalBackend *backend)
 	priv = cbhttp->priv;
 
 	if (!priv->store)
-		return FALSE;
+		return TRUE;
+
+	e_cal_backend_store_remove (priv->store);
 
 	return TRUE;
 }
@@ -1471,7 +1519,6 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
 	sync_class->get_static_capabilities_sync = e_cal_backend_http_get_static_capabilities;
 	sync_class->open_sync = e_cal_backend_http_open;
 	sync_class->refresh_sync = e_cal_backend_http_refresh;
-	sync_class->remove_sync = e_cal_backend_http_remove;
 	sync_class->create_object_sync = e_cal_backend_http_create_object;
 	sync_class->modify_object_sync = e_cal_backend_http_modify_object;
 	sync_class->remove_object_sync = e_cal_backend_http_remove_object;
@@ -1487,10 +1534,14 @@ e_cal_backend_http_class_init (ECalBackendHttpClass *class)
 	sync_class->get_changes_sync = e_cal_backend_http_get_changes;
 
 	backend_class->is_loaded = e_cal_backend_http_is_loaded;
+	backend_class->remove = e_cal_backend_http_remove;
 	backend_class->start_query = e_cal_backend_http_start_query;
 	backend_class->get_mode = e_cal_backend_http_get_mode;
 	backend_class->set_mode = e_cal_backend_http_set_mode;
 
 	backend_class->internal_get_default_timezone = e_cal_backend_http_internal_get_default_timezone;
 	backend_class->internal_get_timezone = e_cal_backend_http_internal_get_timezone;
+
+	/* Register our ESource extension. */
+	E_TYPE_SOURCE_WEBCAL;
 }
diff --git a/calendar/backends/http/e-source-webcal.c b/calendar/backends/http/e-source-webcal.c
new file mode 100644
index 0000000..0ba9aeb
--- /dev/null
+++ b/calendar/backends/http/e-source-webcal.c
@@ -0,0 +1,154 @@
+/*
+ * e-source-webcal.c
+ *
+ * This program 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) version 3.
+ *
+ * This program 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 the program; if not, see <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-source-webcal.h"
+
+#define E_SOURCE_WEBCAL_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_SOURCE_WEBCAL, ESourceWebcalPrivate))
+
+struct _ESourceWebcalPrivate {
+	gchar *uri;
+};
+
+enum {
+	PROP_0,
+	PROP_URI
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+	ESourceWebcal,
+	e_source_webcal,
+	E_TYPE_SOURCE_EXTENSION)
+
+static void
+source_webcal_set_property (GObject *object,
+                            guint property_id,
+                            const GValue *value,
+                            GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_URI:
+			e_source_webcal_set_uri (
+				E_SOURCE_WEBCAL (object),
+				g_value_get_string (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+source_webcal_get_property (GObject *object,
+                            guint property_id,
+                            GValue *value,
+                            GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_URI:
+			g_value_set_string (
+				value,
+				e_source_webcal_get_uri (
+				E_SOURCE_WEBCAL (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+source_webcal_finalize (GObject *object)
+{
+	ESourceWebcalPrivate *priv;
+
+	priv = E_SOURCE_WEBCAL_GET_PRIVATE (object);
+
+	g_free (priv->uri);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_source_webcal_parent_class)->finalize (object);
+}
+
+static void
+e_source_webcal_class_init (ESourceWebcalClass *class)
+{
+	GObjectClass *object_class;
+	ESourceExtensionClass *extension_class;
+
+	g_type_class_add_private (class, sizeof (ESourceWebcalPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = source_webcal_set_property;
+	object_class->get_property = source_webcal_get_property;
+	object_class->finalize = source_webcal_finalize;
+
+	extension_class = E_SOURCE_EXTENSION_CLASS (class);
+	extension_class->name = E_SOURCE_EXTENSION_WEBCAL_BACKEND;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_URI,
+		g_param_spec_string (
+			"uri",
+			"URI",
+			"URI of the web calendar",
+			NULL,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			E_SOURCE_PARAM_SETTING));
+}
+
+static void
+e_source_webcal_class_finalize (ESourceWebcalClass *class)
+{
+}
+
+static void
+e_source_webcal_init (ESourceWebcal *extension)
+{
+	extension->priv = E_SOURCE_WEBCAL_GET_PRIVATE (extension);
+}
+
+void
+e_source_webcal_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_source_webcal_register_type (type_module);
+}
+
+const gchar *
+e_source_webcal_get_uri (ESourceWebcal *extension)
+{
+	g_return_val_if_fail (E_IS_SOURCE_WEBCAL (extension), NULL);
+
+	return extension->priv->uri;
+}
+
+void
+e_source_webcal_set_uri (ESourceWebcal *extension,
+                         const gchar *uri)
+{
+	g_return_if_fail (E_IS_SOURCE_WEBCAL (extension));
+
+	g_free (extension->priv->uri);
+	extension->priv->uri = g_strdup (uri);
+
+	g_object_notify (G_OBJECT (extension), "uri");
+}
diff --git a/calendar/backends/http/e-source-webcal.h b/calendar/backends/http/e-source-webcal.h
new file mode 100644
index 0000000..722ba3e
--- /dev/null
+++ b/calendar/backends/http/e-source-webcal.h
@@ -0,0 +1,68 @@
+/*
+ * e-source-webcal.h
+ *
+ * This program 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) version 3.
+ *
+ * This program 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 the program; if not, see <webcal://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_SOURCE_WEBCAL_H
+#define E_SOURCE_WEBCAL_H
+
+#include <libedataserver/e-source-extension.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SOURCE_WEBCAL \
+	(e_source_webcal_get_type ())
+#define E_SOURCE_WEBCAL(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_SOURCE_WEBCAL, ESourceWebcal))
+#define E_SOURCE_WEBCAL_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_SOURCE_WEBCAL, ESourceWebcalClass))
+#define E_IS_SOURCE_WEBCAL(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_SOURCE_WEBCAL))
+#define E_IS_SOURCE_WEBCAL_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_SOURCE_WEBCAL))
+#define E_SOURCE_WEBCAL_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_SOURCE_WEBCAL, ESourceWebcalClass))
+
+#define E_SOURCE_EXTENSION_WEBCAL_BACKEND "Webcal Backend"
+
+G_BEGIN_DECLS
+
+typedef struct _ESourceWebcal ESourceWebcal;
+typedef struct _ESourceWebcalClass ESourceWebcalClass;
+typedef struct _ESourceWebcalPrivate ESourceWebcalPrivate;
+
+struct _ESourceWebcal {
+	ESourceExtension parent;
+	ESourceWebcalPrivate *priv;
+};
+
+struct _ESourceWebcalClass {
+	ESourceExtensionClass parent_class;
+};
+
+GType		e_source_webcal_get_type	(void);
+void		e_source_webcal_type_register	(GTypeModule *type_module);
+const gchar *	e_source_webcal_get_uri		(ESourceWebcal *extension);
+void		e_source_webcal_set_uri		(ESourceWebcal *extension,
+						 const gchar *uri);
+
+G_END_DECLS
+
+#endif /* E_SOURCE_WEBCAL_H */



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