From 093937a09306fc4f6f2cfb730d5e58c8b7d39e25 Mon Sep 17 00:00:00 2001
From: JP Rosevear <jpr@ximian.com>
Date: Sun, 21 Dec 2003 17:05:24 +0000
Subject: rewrite for new ecal api, cache all ecal's by type and minimize
 loading.

2003-12-21  JP Rosevear <jpr@ximian.com>

	* gui/e-itip-control.[hc]: rewrite for new ecal api, cache all
	ecal's by type and minimize loading.  Switch to using the source
	option menu

	* conduits/todo/todo-conduit.c (start_calendar_server): ditto

	* conduits/calendar/calendar-conduit.c (start_calendar_server):
	use ECalSourceType

	* importers/icalendar-importer.c (load_file_fn): ditto
	(vcal_load_file_fn): ditto
	(gnome_calendar_import_data_fn): ditto

	* gui/dialogs/task-page.c (source_changed_cb): ditto

	* gui/dialogs/event-page.c (source_changed_cb): ditto

	* gui/dialogs/copy-source-dialog.h: update proto

	* gui/dialogs/copy-source-dialog.c (copy_source_dialog): ditto

	* gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): ditto

	* gui/tasks-component.c (copy_task_list_cb): ditto
	(setup_create_ecal): ditto

	* gui/gnome-cal.c (gnome_calendar_construct): ditto
	(gnome_calendar_add_event_uri): ditto

	* gui/e-tasks.c (e_tasks_add_todo_uri): ditto

	* gui/comp-editor-factory.c (open_client): ditto

	* gui/calendar-offline-handler.c (backend_go_offline): ditto
	(backend_go_online): ditto
	(calendar_offline_handler_init): ditto

	* gui/calendar-component.c (copy_calendar_cb): ditto
	(setup_create_ecal): ditto

	* gui/print.c (print_month_small): don't pass type to
	e_cal_generate_instances
	(print_day_details): ditto
	(print_week_summary): ditto

	* gui/tag-calendar.c (tag_calendar_by_client): ditto

svn path=/trunk/; revision=23994
---
 calendar/ChangeLog                            |  49 +++
 calendar/conduits/calendar/calendar-conduit.c |   2 +-
 calendar/conduits/todo/todo-conduit.c         |   2 +-
 calendar/gui/alarm-notify/alarm-notify.c      |   2 +-
 calendar/gui/calendar-component.c             |   6 +-
 calendar/gui/calendar-offline-handler.c       |  13 +-
 calendar/gui/comp-editor-factory.c            |   3 +-
 calendar/gui/dialogs/copy-source-dialog.c     |   8 +-
 calendar/gui/dialogs/copy-source-dialog.h     |   2 +-
 calendar/gui/dialogs/event-page.c             |   2 +-
 calendar/gui/dialogs/task-page.c              |   2 +-
 calendar/gui/e-itip-control.c                 | 490 +++++++++-----------------
 calendar/gui/e-itip-control.h                 |  15 +-
 calendar/gui/e-tasks.c                        |   2 +-
 calendar/gui/gnome-cal.c                      |   4 +-
 calendar/gui/print.c                          |  17 +-
 calendar/gui/tag-calendar.c                   |   5 +-
 calendar/gui/tasks-component.c                |   6 +-
 calendar/importers/icalendar-importer.c       |  12 +-
 19 files changed, 258 insertions(+), 384 deletions(-)

(limited to 'calendar')

diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index bdccbfb0b8..8a73990617 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,52 @@
+2003-12-21  JP Rosevear <jpr@ximian.com>
+
+	* gui/e-itip-control.[hc]: rewrite for new ecal api, cache all
+	ecal's by type and minimize loading.  Switch to using the source
+	option menu
+
+	* conduits/todo/todo-conduit.c (start_calendar_server): ditto
+
+	* conduits/calendar/calendar-conduit.c (start_calendar_server):
+	use ECalSourceType
+	
+	* importers/icalendar-importer.c (load_file_fn): ditto
+	(vcal_load_file_fn): ditto
+	(gnome_calendar_import_data_fn): ditto
+
+	* gui/dialogs/task-page.c (source_changed_cb): ditto
+
+	* gui/dialogs/event-page.c (source_changed_cb): ditto
+
+	* gui/dialogs/copy-source-dialog.h: update proto
+
+	* gui/dialogs/copy-source-dialog.c (copy_source_dialog): ditto
+
+	* gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar): ditto
+
+	* gui/tasks-component.c (copy_task_list_cb): ditto
+	(setup_create_ecal): ditto
+
+	* gui/gnome-cal.c (gnome_calendar_construct): ditto
+	(gnome_calendar_add_event_uri): ditto
+
+	* gui/e-tasks.c (e_tasks_add_todo_uri): ditto
+
+	* gui/comp-editor-factory.c (open_client): ditto
+
+	* gui/calendar-offline-handler.c (backend_go_offline): ditto
+	(backend_go_online): ditto
+	(calendar_offline_handler_init): ditto
+
+	* gui/calendar-component.c (copy_calendar_cb): ditto
+	(setup_create_ecal): ditto
+
+	* gui/print.c (print_month_small): don't pass type to
+	e_cal_generate_instances	
+	(print_day_details): ditto
+	(print_week_summary): ditto
+
+	* gui/tag-calendar.c (tag_calendar_by_client): ditto
+	
 2003-12-19  JP Rosevear <jpr@ximian.com>
 
 	* gui/tasks-control.c (tasks_control_sensitize_commands): make
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index 47b3755ea5..c1c58e5968 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -396,7 +396,7 @@ start_calendar_server (ECalConduitContext *ctxt)
 	/* FIXME Need a mechanism for the user to select uri's */
 	/* FIXME Can we use the cal model? */
 	uri = g_strdup_printf ("file://%s/local/Calendar/", g_get_home_dir ());
-	ctxt->client = e_cal_new (uri, CALOBJ_TYPE_EVENT);
+	ctxt->client = e_cal_new (uri, E_CAL_SOURCE_TYPE_EVENT);
 	g_free (uri);
 	
 	if (!ctxt->client)
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index fe5684252b..a8a7e35671 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -402,7 +402,7 @@ start_calendar_server (EToDoConduitContext *ctxt)
 	/* FIXME Need a mechanism for the user to select uri's */
 	/* FIXME Can we use the cal model? */
 	uri = g_strdup_printf ("file://%s/local/Tasks/", g_get_home_dir ());
-	ctxt->client = e_cal_new (uri, CALOBJ_TYPE_TODO);
+	ctxt->client = e_cal_new (uri, E_CAL_SOURCE_TYPE_TODO);
 	g_free (uri);
 	
 	if (!ctxt->client)
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 37addc4d9a..87b885ed6a 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -173,7 +173,7 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
 	if (g_hash_table_lookup (priv->uri_client_hash, str_uri))
 		return;
 
-	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_EVENT);
+	client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
 
 	if (client) {
 		if (e_cal_open (client, FALSE, NULL)) {
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index bf29355b9d..6a5427bbf3 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -351,7 +351,7 @@ copy_calendar_cb (GtkWidget *widget, CalendarComponent *comp)
 	if (!selected_source)
 		return;
 
-	copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, CALOBJ_TYPE_EVENT);
+	copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, E_CAL_SOURCE_TYPE_EVENT);
 }
 
 static void
@@ -693,14 +693,14 @@ setup_create_ecal (CalendarComponent *calendar_component)
 		source = e_source_list_peek_source_by_uid (priv->source_list, uid);
 		g_free (uid);
 
-		priv->create_ecal = e_cal_new (source, CALOBJ_TYPE_EVENT);
+		priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
 	} 
 
 	if (!priv->create_ecal) {
 		/* Try to create a default if there isn't one */
 		source = find_first_source (priv->source_list);
 		if (source)
-			priv->create_ecal = e_cal_new (source, CALOBJ_TYPE_EVENT);
+			priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
 	}
 		
 	if (priv->create_ecal) {
diff --git a/calendar/gui/calendar-offline-handler.c b/calendar/gui/calendar-offline-handler.c
index 89a7aab36e..4faf15bf7e 100644
--- a/calendar/gui/calendar-offline-handler.c
+++ b/calendar/gui/calendar-offline-handler.c
@@ -182,8 +182,9 @@ backend_go_offline (gpointer data, gpointer user_data)
 	ECal *client;
 	gboolean success;
 	GError *error = NULL;
-	
-	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_ANY);
+
+	/* FIXME This should not use LAST */
+	client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
 	g_signal_connect (client, "cal_opened", G_CALLBACK (backend_cal_opened_offline), offline_handler);
 	success = e_cal_open (client, TRUE, &error);
 	if (!success) {
@@ -203,8 +204,9 @@ backend_go_online (gpointer data, gpointer user_data)
 	ECal *client;
 	gboolean success;
 	GError *error = NULL;
-	
-	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_ANY);
+
+	/* FIXME This should not use LAST */	
+	client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
 	g_signal_connect (G_OBJECT (client), "cal_opened", 
 			  G_CALLBACK (backend_cal_opened_online), offline_handler);
 	success = e_cal_open (client, TRUE, &error);
@@ -326,8 +328,9 @@ calendar_offline_handler_init (CalendarOfflineHandler *offline_handler)
 	priv = g_new (CalendarOfflineHandlerPrivate, 1);
 	offline_handler->priv = priv;
 
+	/* FIXME This should not use LAST */
 	/* FIXME: what URI to use? */
-	priv->client = e_cal_new_from_uri ("", CALOBJ_TYPE_ANY);
+	priv->client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_LAST);
 	priv->listener_interface = CORBA_OBJECT_NIL;
 	priv->is_offline = FALSE;
 }
diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c
index e6075101c6..1bb14c00f9 100644
--- a/calendar/gui/comp-editor-factory.c
+++ b/calendar/gui/comp-editor-factory.c
@@ -495,7 +495,8 @@ open_client (CompEditorFactory *factory, const char *uristr)
 
 	priv = factory->priv;
 
-	client = e_cal_new_from_uri (uristr, CALOBJ_TYPE_ANY);
+	/* FIXME get the type here */
+	client = e_cal_new_from_uri (uristr, E_CAL_SOURCE_TYPE_LAST);
 	if (!client)
 		return NULL;
 
diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c
index 11b523a1f8..1dc440d0ec 100644
--- a/calendar/gui/dialogs/copy-source-dialog.c
+++ b/calendar/gui/dialogs/copy-source-dialog.c
@@ -32,7 +32,7 @@ typedef struct {
 	ESourceList *source_list;
 	GConfClient *conf_client;
 	ESource *orig_source;
-	CalObjType obj_type;
+	ECalSourceType obj_type;
 	ESource *selected_source;
 } CopySourceDialogData;
 
@@ -111,7 +111,7 @@ copy_source (CopySourceDialogData *csdd)
  * source to copy to.
  */
 gboolean
-copy_source_dialog (GtkWindow *parent, ESource *source, CalObjType obj_type)
+copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType obj_type)
 {
 	CopySourceDialogData csdd;
 	gboolean result = FALSE;
@@ -120,9 +120,9 @@ copy_source_dialog (GtkWindow *parent, ESource *source, CalObjType obj_type)
 
 	g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
 
-	if (obj_type == CALOBJ_TYPE_EVENT)
+	if (obj_type == E_CAL_SOURCE_TYPE_EVENT)
 		gconf_key = "/apps/evolution/calendar/sources";
-	else if (obj_type == CALOBJ_TYPE_TODO)
+	else if (obj_type == E_CAL_SOURCE_TYPE_TODO)
 		gconf_key = "/apps/evolution/tasks/sources";
 	else
 		return FALSE;
diff --git a/calendar/gui/dialogs/copy-source-dialog.h b/calendar/gui/dialogs/copy-source-dialog.h
index e3c750d8a0..597b1f25fc 100644
--- a/calendar/gui/dialogs/copy-source-dialog.h
+++ b/calendar/gui/dialogs/copy-source-dialog.h
@@ -26,6 +26,6 @@
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-util.h>
 
-gboolean copy_source_dialog (GtkWindow *parent, ESource *source, CalObjType obj_type);
+gboolean copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType type);
 
 #endif
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index c8b90f6d81..9a6b9c25ba 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -1212,7 +1212,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
 	if (!priv->updating) {
 		ECal *client;
 
-		client = e_cal_new (source, CALOBJ_TYPE_EVENT);
+		client = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
 		if (!client || !e_cal_open (client, FALSE, NULL)) {
 			GtkWidget *dialog;
 
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index e2be632847..69bad550cc 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -794,7 +794,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
 	if (!priv->updating) {
 		ECal *client;
 
-		client = e_cal_new (source, CALOBJ_TYPE_TODO);
+		client = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
 		if (!client || !e_cal_open (client, FALSE, NULL)) {
 			GtkWidget *dialog;
 
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 44f0a97c2c..40b5487e60 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -41,6 +41,7 @@
 #include <bonobo/bonobo-exception.h>
 #include <gtkhtml/gtkhtml.h>
 #include <gtkhtml/gtkhtml-stream.h>
+#include <libedataserver/e-source-list.h>
 #include <libical/ical.h>
 #include <libecal/e-cal-component.h>
 #include <libecal/e-cal-time-util.h>
@@ -48,6 +49,7 @@
 #include <e-util/e-time-utils.h>
 #include <e-util/e-dialog-widgets.h>
 #include <camel/camel-mime-filter-tohtml.h>
+#include <widgets/misc/e-source-option-menu.h>
 #include "dialogs/delete-error.h"
 #include "calendar-config.h"
 #include "itip-utils.h"
@@ -55,11 +57,12 @@
 
 struct _EItipControlPrivate {
 	GtkWidget *html;
-	
-	GPtrArray *event_clients;
-	ECal *event_client;
-	GPtrArray *task_clients;
-	ECal *task_client;
+
+	ESourceList *source_lists[E_CAL_SOURCE_TYPE_LAST];
+	GHashTable *ecals[E_CAL_SOURCE_TYPE_LAST];	
+
+	ECal *current_ecal;
+	ECalSourceType type;
 
 	char *vcalendar;
 	ECalComponent *comp;
@@ -72,7 +75,7 @@ struct _EItipControlPrivate {
 	int current;
 	int total;
 
-	gchar *calendar_uri;
+	gchar *calendar_uid;
 
 	EAccountList *accounts;
 
@@ -91,12 +94,6 @@ struct _EItipControlPrivate {
 #define HTML_BODY_END   "</body>"
 #define HTML_FOOTER     "</html>"
 
-/* We intentionally use "calendar" instead of "calendar / *" here. We
- * don't want public calendars.
- */
-static const char *calendar_types[] = { "calendar", NULL };
-static const char *tasks_types[] = { "tasks", NULL };
-
 static void class_init	(EItipControlClass	 *klass);
 static void init	(EItipControl		 *itip);
 static void destroy	(GtkObject               *obj);
@@ -128,123 +125,78 @@ class_init (EItipControlClass *klass)
 }
 
 static ECal *
-start_calendar_server (EItipControl *itip, char *uri)
+start_calendar_server (EItipControl *itip, ESource *source, ECalSourceType type)
 {
-	ECal *client;
-	GError *error = NULL;
-
-	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_EVENT);
+	EItipControlPrivate *priv;
+	ECal *ecal;
 
-	if (!e_cal_open (client, TRUE, &error)) {
-		g_warning (_("start_calendar_server(): %s"), error->message);
-		g_error_free (error);
- 		g_object_unref (client);
+	priv = itip->priv;
+	
+	ecal = g_hash_table_lookup (priv->ecals[type], e_source_peek_uid (source));
+	if (ecal)
+		return ecal;
+	
+	ecal = e_cal_new (source, type);
+	if (!e_cal_open (ecal, TRUE, NULL))
 		return NULL;
-	}
 	
-	return client;
-}
-
-static gboolean
-start_default_server (EItipControl *itip, ECal *client, gboolean tasks)
-{
-#if 0
-	if (tasks)
-		return e_cal_open_default_tasks (client, FALSE);
-	else
-		return e_cal_open_default_calendar (client, FALSE);
-#endif
-	return FALSE;
+	g_hash_table_insert (priv->ecals[type], g_strdup (e_source_peek_uid (source)), ecal);
+	
+	return ecal;
 }
 
-#if 0				/* EPFIXME, rewrite this */
-static GPtrArray *
-get_servers (EItipControl *itip, EvolutionShellClient *shell_client, const char *possible_types[], gboolean tasks)
+static ECal *
+start_calendar_server_by_uid (EItipControl *itip, const char *uid, ECalSourceType type)
 {
-	GNOME_Evolution_StorageRegistry registry;
-	GNOME_Evolution_StorageRegistry_StorageList *storage_list;
-	GPtrArray *servers;
-	int i, j, k;
-	CORBA_Environment ev;
-	
-	servers = g_ptr_array_new ();
-	
-	g_object_ref (shell_client);
-	registry = evolution_shell_client_get_storage_registry_interface (shell_client);
-	
-	CORBA_exception_init (&ev);
-	storage_list = GNOME_Evolution_StorageRegistry_getStorageList (registry, &ev);
-	if (BONOBO_EX (&ev)) {
-		CORBA_exception_free (&ev);
-		return servers;
-	}
+	EItipControlPrivate *priv;
+	int i;
 	
-	for (i = 0; i < storage_list->_length; i++) {
-		GNOME_Evolution_Storage storage;
-		GNOME_Evolution_FolderList *folder_list;
-
-		CORBA_exception_init (&ev);
-		
-		storage = storage_list->_buffer[i];
-		folder_list = GNOME_Evolution_Storage__get_folderList (storage, &ev);
-		if (BONOBO_EX (&ev)) {
-			CORBA_exception_free (&ev);
-			continue;
-		}
-
-		CORBA_exception_free (&ev);
-
-		for (j = 0; j < folder_list->_length; j++) {
-			GNOME_Evolution_Folder folder;
-			
-			folder = folder_list->_buffer[j];
-			for (k = 0; possible_types[k] != NULL; k++) {
-				ECal *client;
-				char *uri;
-				
-				if (itip->priv->destroyed)
-					continue;
-				
-				if (strcmp (possible_types[k], folder.type))
-					continue;
-
-				uri = e_cal_util_expand_uri (folder.physicalUri, tasks);
-				client = start_calendar_server (itip, uri);
-				if (client != NULL)
-					g_ptr_array_add (servers, client);			
-				g_free (uri);
+	priv = itip->priv;
 
-				break;
-			}
-		}
+	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+		ESource *source;
 
-		CORBA_free (folder_list);		
+		source = e_source_list_peek_source_by_uid (priv->source_lists[i], uid);
+		if (source)
+			return start_calendar_server (itip, source, type);
 	}
 	
-	g_object_unref (shell_client);
-
-	return servers;
+	return NULL;
 }
-#endif
 
 static ECal *
-find_server (GPtrArray *servers, ECalComponent *comp)
+find_server (EItipControl *itip, ECalComponent *comp)
 {
+	EItipControlPrivate *priv;
+	GSList *groups, *l;
 	const char *uid;
-	int i;
 
-	e_cal_component_get_uid (comp, &uid);	
-	for (i = 0; i < servers->len; i++) {
-		ECal *client;
-		icalcomponent *icalcomp;
-		
-		client = g_ptr_array_index (servers, i);
-		if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) {
-			icalcomponent_free (icalcomp);
-			g_object_ref (client);
+	priv = itip->priv;
+	
+	e_cal_component_get_uid (comp, &uid);
 
-			return client;
-		}
+	groups = e_source_list_peek_groups (priv->source_lists[priv->type]);
+	for (l = groups; l; l = l->next) {
+		ESourceGroup *group;
+		GSList *sources, *m;
+		
+		group = l->data;
+		
+		sources = e_source_group_peek_sources (group);
+		for (m = sources; m; m = m->next) {
+			ESource *source;
+			ECal *ecal;
+			icalcomponent *icalcomp;
+			
+			source = m->data;
+			ecal = start_calendar_server (itip, source, priv->type);
+			
+			if (ecal && e_cal_get_object (ecal, uid, NULL, &icalcomp, NULL)) {
+				icalcomponent_free (icalcomp);
+				
+				return ecal;
+			}
+		}		
 	}
 
 	return NULL;
@@ -266,22 +218,28 @@ init (EItipControl *itip)
 {
 	EItipControlPrivate *priv;
 	GtkWidget *scrolled_window;
+	int i;
 
 	priv = g_new0 (EItipControlPrivate, 1);
-
 	itip->priv = priv;
 
 	/* Addresses */
 	priv->accounts = itip_addresses_get ();
 
-	/* Initialize the cal clients */
-	priv->event_clients = NULL;
-	priv->event_client = NULL;
-	priv->task_clients = NULL;
-	priv->task_client = NULL;
+	/* Source Lists */
+	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++)
+		priv->source_lists[i] = NULL;
+
+	priv->source_lists[E_CAL_SOURCE_TYPE_EVENT] = e_source_list_new_for_gconf_default ("/apps/evolution/calendar/sources");
+	priv->source_lists[E_CAL_SOURCE_TYPE_TODO] = e_source_list_new_for_gconf_default ("/apps/evolution/tasks/sources");
+	
+	/* Initialize the ecal hashes */
+	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++)
+		priv->ecals[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);;
+	priv->current_ecal = NULL;
 
 	/* Other fields to init */
-	priv->calendar_uri = NULL;
+	priv->calendar_uid = NULL;
 	priv->from_address = NULL;
 	priv->delegator_address = NULL;
 	priv->delegator_name = NULL;
@@ -344,8 +302,8 @@ clean_up (EItipControl *itip)
 	priv->current = 0;
 	priv->total = 0;
 
-	g_free (priv->calendar_uri);
-	priv->calendar_uri = NULL;
+	g_free (priv->calendar_uid);
+	priv->calendar_uid = NULL;
 
 	g_free (priv->from_address);
 	priv->from_address = NULL;
@@ -385,23 +343,14 @@ finalize (GObject *obj)
  		gtk_object_weakunref (GTK_OBJECT (priv->html), html_destroyed, itip);
 
 	priv->accounts = NULL;
-	
-	if (priv->event_clients) {
-		for (i = 0; i < priv->event_clients->len; i++) 
-			g_object_unref (g_ptr_array_index (priv->event_clients, i));
-		g_ptr_array_free (priv->event_clients, TRUE);
-		priv->event_client = NULL;
-		priv->event_clients = NULL;
-	}
-	
-	if (priv->task_clients) {
-		for (i = 0; i < priv->task_clients->len; i++) 
-			g_object_unref (g_ptr_array_index (priv->task_clients, i));
-		g_ptr_array_free (priv->task_clients, TRUE);
-		priv->task_client = NULL;
-		priv->task_clients = NULL;
+
+	for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+		if (priv->ecals[i]) {
+			g_hash_table_destroy (priv->ecals[i]);
+			priv->ecals[i] = NULL;
+		}
 	}
-	
+
 	g_free (priv);
 	itip->priv = NULL;
 
@@ -724,7 +673,7 @@ write_recurrence_piece (EItipControl *itip, ECalComponent *comp,
 
 		/* FIXME This should get the tzid id, not the whole zone */
 		dt.value = &r->until;
-		dt.tzid = r->until.zone;
+		dt.tzid = icaltimezone_get_tzid ((icaltimezone *)r->until.zone);
 
 		write_label_piece (itip, &dt, buffer, size,
 				   _(", ending on "), NULL, TRUE);
@@ -1180,28 +1129,14 @@ get_real_item (EItipControl *itip)
 	EItipControlPrivate *priv;
 	ECalComponent *comp;
 	icalcomponent *icalcomp;
-	ECalComponentVType type;
 	gboolean found = FALSE;
 	const char *uid;
 	
 	priv = itip->priv;
 
-	type = e_cal_component_get_vtype (priv->comp);
 	e_cal_component_get_uid (priv->comp, &uid);
 
-	switch (type) {
-	case E_CAL_COMPONENT_EVENT:
-		if (priv->event_client != NULL)
-			found = e_cal_get_object (priv->event_client, uid, NULL, &icalcomp, NULL);
-		break;
-	case E_CAL_COMPONENT_TODO:
-		if (priv->task_client != NULL)
-			found = e_cal_get_object (priv->task_client, uid, NULL, &icalcomp, NULL);
-		break;
-	default:
-		found = FALSE;
-	}
-
+	found = e_cal_get_object (priv->current_ecal, uid, NULL, &icalcomp, NULL);
 	if (!found)
 		return NULL;
 
@@ -1251,16 +1186,17 @@ show_current_event (EItipControl *itip)
 
 	priv = itip->priv;
 
-	if (priv->calendar_uri)
-		priv->event_client = start_calendar_server (itip, priv->calendar_uri);
+	priv->type = E_CAL_SOURCE_TYPE_EVENT;
+	if (priv->calendar_uid)
+		priv->current_ecal = start_calendar_server_by_uid (itip, priv->calendar_uid, priv->type);
 	else 
-		priv->event_client = find_server (priv->event_clients, priv->comp);
+		priv->current_ecal = find_server (itip, priv->comp);
 	
 	switch (priv->method) {
 	case ICAL_METHOD_PUBLISH:
 		itip_desc = _("<b>%s</b> has published meeting information.");
 		itip_title = _("Meeting Information");
-		options = get_publish_options (priv->event_client ? FALSE : TRUE);
+		options = get_publish_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_REQUEST:
 		if (priv->delegator_address != NULL)
@@ -1268,12 +1204,12 @@ show_current_event (EItipControl *itip)
 		else
 			itip_desc = _("<b>%s</b> requests your presence at a meeting.");
 		itip_title = _("Meeting Proposal");
-		options = get_request_options (priv->event_client ? FALSE : TRUE);
+		options = get_request_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_ADD:
 		itip_desc = _("<b>%s</b> wishes to add to an existing meeting.");
 		itip_title = _("Meeting Update");
-		options = get_publish_options (priv->event_client ? FALSE : TRUE);
+		options = get_publish_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_REFRESH:
 		itip_desc = _("<b>%s</b> wishes to receive the latest meeting information.");
@@ -1318,16 +1254,17 @@ show_current_todo (EItipControl *itip)
 
 	priv = itip->priv;
 
-	if (priv->calendar_uri)
-		priv->task_client = start_calendar_server (itip, priv->calendar_uri);
+	priv->type = E_CAL_SOURCE_TYPE_TODO;
+	if (priv->calendar_uid)
+		priv->current_ecal = start_calendar_server_by_uid (itip, priv->calendar_uid, priv->type);
 	else 
-		priv->task_client = find_server (priv->task_clients, priv->comp);
+		priv->current_ecal = find_server (itip, priv->comp);
 
 	switch (priv->method) {
 	case ICAL_METHOD_PUBLISH:
 		itip_desc = _("<b>%s</b> has published task information.");
 		itip_title = _("Task Information");
-		options = get_publish_options (priv->task_client ? FALSE : TRUE);
+		options = get_publish_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_REQUEST:
 		if (priv->delegator_address != NULL)
@@ -1335,12 +1272,12 @@ show_current_todo (EItipControl *itip)
 		else
 			itip_desc = _("<b>%s</b> requests you perform a task.");
 		itip_title = _("Task Proposal");
-		options = get_request_options (priv->task_client ? FALSE : TRUE);
+		options = get_request_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_ADD:
 		itip_desc = _("<b>%s</b> wishes to add to an existing task.");
 		itip_title = _("Task Update");
-		options = get_publish_options (priv->task_client ? FALSE : TRUE);
+		options = get_publish_options (priv->current_ecal ? FALSE : TRUE);
 		break;
 	case ICAL_METHOD_REFRESH:
 		itip_desc = _("<b>%s</b> wishes to receive the latest task information.");
@@ -1444,12 +1381,7 @@ show_current (EItipControl *itip)
 	
 	if (priv->comp)
 		g_object_unref (priv->comp);
-	if (priv->event_client != NULL)
-		g_object_unref (priv->event_client);
-	priv->event_client = NULL;
-	if (priv->task_client != NULL)
-		g_object_unref (priv->task_client);
-	priv->task_client = NULL;
+	priv->current_ecal = NULL;
 
 	/* Determine any delegate sections */
 	prop = icalcomponent_get_first_property (priv->ical_comp, ICAL_X_PROPERTY);
@@ -1459,8 +1391,10 @@ show_current (EItipControl *itip)
 		x_name = icalproperty_get_x_name (prop);
 		x_val = icalproperty_get_x (prop);
 
-		if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-CALENDAR-URI"))
-			e_itip_control_set_calendar_uri (itip, x_val);
+		if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-CALENDAR-UID"))
+			e_itip_control_set_calendar_uid (itip, x_val);
+		else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-CALENDAR-URI"))
+			g_warning (G_STRLOC ": X-EVOLUTION-DELEGATOR-CALENDAR-URI used");
 		else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-ADDRESS"))
 			e_itip_control_set_delegator_address (itip, x_val);
 		else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-NAME"))
@@ -1529,18 +1463,9 @@ show_current (EItipControl *itip)
 
 	switch (type) {
 	case E_CAL_COMPONENT_EVENT:
-		if (!priv->event_clients) {
-			priv->event_clients = g_ptr_array_new ();
-			/* EPFIXME */
-			/* priv->event_clients = get_servers (itip, global_shell_client, calendar_types, FALSE); */
-		}
 		show_current_event (itip);
 		break;
 	case E_CAL_COMPONENT_TODO:
-		if (!priv->task_clients) {
-			/* EPFIXME */
-			/* priv->task_clients = get_servers (itip, global_shell_client, tasks_types, TRUE); */
-		}
 		show_current_todo (itip);
 		break;
 	case E_CAL_COMPONENT_FREEBUSY:
@@ -1740,26 +1665,26 @@ e_itip_control_get_delegator_name (EItipControl *itip)
 }
 
 void
-e_itip_control_set_calendar_uri (EItipControl *itip, const gchar *uri)
+e_itip_control_set_calendar_uid (EItipControl *itip, const gchar *uri)
 {
 	EItipControlPrivate *priv;
 
 	priv = itip->priv;
 
-	if (priv->calendar_uri)
-		g_free (priv->calendar_uri);
+	if (priv->calendar_uid)
+		g_free (priv->calendar_uid);
 
-	priv->calendar_uri = g_strdup (uri);
+	priv->calendar_uid = g_strdup (uri);
 }
 
 const gchar *
-e_itip_control_get_calendar_uri (EItipControl *itip)
+e_itip_control_get_calendar_uid (EItipControl *itip)
 {
 	EItipControlPrivate *priv;
 
 	priv = itip->priv;
 
-	return priv->calendar_uri;
+	return priv->calendar_uid;
 }
 
 
@@ -1816,8 +1741,6 @@ update_item (EItipControl *itip)
 	struct icaltimetype stamp;
 	icalproperty *prop;
 	icalcomponent *clone;
-	ECal *client;
-	ECalComponentVType type;
 	GtkWidget *dialog;
 
 	priv = itip->priv;
@@ -1835,19 +1758,13 @@ update_item (EItipControl *itip)
 	prop = icalproperty_new_x (icaltime_as_ical_string (stamp));
 	icalproperty_set_x_name (prop, "X-MICROSOFT-CDO-REPLYTIME");
 	icalcomponent_add_property (priv->ical_comp, prop);
- 
-	type = e_cal_component_get_vtype (priv->comp);
-	if (type == E_CAL_COMPONENT_TODO)
-		client = priv->task_client;
-	else
-		client = priv->event_client;
 
 	clone = icalcomponent_new_clone (priv->ical_comp);
 	icalcomponent_add_component (priv->top_level, clone);
 	icalcomponent_set_method (priv->top_level, priv->method);
 
 	/* FIXME Better error dialog */
-	if (!e_cal_receive_objects (client, priv->top_level, NULL)) {
+	if (!e_cal_receive_objects (priv->current_ecal, priv->top_level, NULL)) {
 		dialog = gnome_warning_dialog (_("Calendar file could not be updated!\n"));
 	} else {
 		dialog = gnome_ok_dialog (_("Update complete\n"));
@@ -1967,30 +1884,23 @@ static void
 remove_item (EItipControl *itip)
 {
 	EItipControlPrivate *priv;
-	ECal *client;
-	ECalComponentVType type;
 	const char *uid;
 	GtkWidget *dialog;
 	GError *error = NULL;
 	
 	priv = itip->priv;
 
-	type = e_cal_component_get_vtype (priv->comp);
-	if (type == E_CAL_COMPONENT_TODO)
-		client = priv->task_client;
-	else
-		client = priv->event_client;
-
-	if (client == NULL)
+	/* FIXME Is this check necessary? */
+	if (!priv->current_ecal)
 		return;
 	
 	e_cal_component_get_uid (priv->comp, &uid);
-	e_cal_remove_object (client, uid, &error);
+	e_cal_remove_object (priv->current_ecal, uid, &error);
 	if (!error || error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) {
 		dialog = gnome_ok_dialog (_("Removal Complete"));
 		gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
 	} else {
-		delete_error_dialog (error, type);
+		delete_error_dialog (error, e_cal_component_get_vtype (priv->comp));
 	}
 	
 	g_clear_error (&error);
@@ -2001,25 +1911,14 @@ send_item (EItipControl *itip)
 {
 	EItipControlPrivate *priv;
 	ECalComponent *comp;
-	ECalComponentVType vtype;
 	GtkWidget *dialog;
 
 	priv = itip->priv;
 
 	comp = get_real_item (itip);
-	vtype = e_cal_component_get_vtype (comp);
 	
 	if (comp != NULL) {
-		switch (vtype) {
-		case E_CAL_COMPONENT_EVENT:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->event_client, NULL);
-			break;
-		case E_CAL_COMPONENT_TODO:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->task_client, NULL);
-			break;
-		default:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, NULL, NULL);
-		}
+		itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->current_ecal, NULL);
 		g_object_unref (comp);
 		dialog = gnome_ok_dialog (_("Item sent!\n"));
 	} else {
@@ -2060,12 +1959,12 @@ send_freebusy (EItipControl *itip)
 	end = icaltime_as_timet_with_zone (*datetime.value, zone);
 	e_cal_component_free_datetime (&datetime);
 
-	if (e_cal_get_free_busy (priv->event_client, NULL, start, end, &comp_list, NULL)) {
+	if (e_cal_get_free_busy (priv->current_ecal, NULL, start, end, &comp_list, NULL)) {
 		GList *l;
 
 		for (l = comp_list; l; l = l->next) {
 			ECalComponent *comp = E_CAL_COMPONENT (l->data);
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->event_client, NULL);
+			itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, NULL);
 
 			g_object_unref (comp);
 		}
@@ -2078,29 +1977,22 @@ send_freebusy (EItipControl *itip)
 	gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
 }
 
-#if 0				/* FIXME */
 static void
-button_selected_cb (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder *folder, gpointer data)
+source_selected_cb (ESourceOptionMenu *esom, ESource *source, gpointer data)
 {
-	EItipControl *itip = E_ITIP_CONTROL (data);
+	EItipControl *itip = data;
 	EItipControlPrivate *priv;
-	ECalComponentVType type;
-	char *uri;
+	ECal *ecal = NULL;
 	
 	priv = itip->priv;
-	
-	type = e_cal_component_get_vtype (priv->comp);
-	if (type == E_CAL_COMPONENT_TODO)
-		uri = e_cal_util_expand_uri (folder->physicalUri, TRUE);
-	else
-		uri = e_cal_util_expand_uri (folder->physicalUri, FALSE);
 
-	g_object_unref (priv->event_client);
-	priv->event_client = start_calendar_server (itip, uri);
+	ecal = start_calendar_server (itip, source, priv->type);
+	if (!ecal) {
+		/* FIXME Show error dialog */
+	}
 
-	g_free (uri);
+	priv->current_ecal = ecal;
 }
-#endif
 
 static void
 url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, gpointer data)
@@ -2133,104 +2025,50 @@ url_requested_cb (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, gpoint
 	g_free (path);
 }
 
-typedef struct
-{
-	EItipControl    *itip;
-	GtkHTMLEmbedded *eb;
-	ECal       *client;
-}
-ObjectRequestContext;
-
-static void
-default_server_started_cb (ECal *client, ECalendarStatus status, gpointer data)
-{
-	ObjectRequestContext *context = data;
-	EItipControlPrivate *priv;
-	GtkWidget *button;
-	ECalComponentVType vtype;
-
-	priv = context->itip->priv;	
-
-	if (status != E_CALENDAR_STATUS_OK ||
-	    context->itip->priv->destroyed    ||
-	    context->itip->priv->html == NULL) {
-		g_object_unref (context->client);
-		g_object_unref (context->itip);
-		g_free (context);
-		return;
-	}
-
-	priv->event_client = client;
-	vtype = e_cal_component_get_vtype (priv->comp);
-
-	switch (vtype) {
-#if 0				/* EPFIXME */
-	case E_CAL_COMPONENT_EVENT:
-		button = evolution_folder_selector_button_new (
-			global_shell_client, _("Select Calendar Folder"),
-			calendar_config_default_calendar_folder (), 
-			calendar_types);
-		break;
-	case E_CAL_COMPONENT_TODO:
-		button = evolution_folder_selector_button_new (
-			global_shell_client, _("Select Tasks Folder"),
-			calendar_config_default_tasks_folder (), 
-			tasks_types);
-		break;
-#endif
-	default:
-		button = NULL;
-	}
-
-#if 0
-	g_signal_connect (button, "selected", G_CALLBACK (button_selected_cb), context->itip);
-#endif
-	
-	gtk_container_add (GTK_CONTAINER (context->eb), button);
-	gtk_widget_show (button);
-
-	g_object_unref (context->itip);
-	g_free (context);
-	return;
-}
-
 static gboolean
 object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) 
 {
 	EItipControl *itip = E_ITIP_CONTROL (data);
-	ObjectRequestContext *context;
 	EItipControlPrivate *priv;
-	ECalComponentVType vtype;
-	gboolean success;
-
+	GtkWidget *esom;
+	ESource *source = NULL;
+	char *uid;
+	
 	priv = itip->priv;	
-	vtype = e_cal_component_get_vtype (priv->comp);
-
-	context = g_new0 (ObjectRequestContext, 1);
-	context->itip   = itip;
-	context->eb     = eb;
 
-	switch (vtype) {
-	case E_CAL_COMPONENT_EVENT:
-		context->client = e_cal_new_from_uri ("", CALOBJ_TYPE_EVENT);
-		success = start_default_server (itip, context->client, FALSE);
+	switch (priv->type) {
+	case E_CAL_SOURCE_TYPE_EVENT:
+		uid = calendar_config_get_primary_calendar ();
 		break;
-	case E_CAL_COMPONENT_TODO:
-		context->client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO);
-		success = start_default_server (itip, context->client, TRUE);
+	case E_CAL_SOURCE_TYPE_TODO:
+		uid = calendar_config_get_primary_tasks ();
 		break;
 	default:
-		g_free (context);
 		return FALSE;
+	}	
+	
+	if (uid) {
+		source = e_source_list_peek_source_by_uid (priv->source_lists[priv->type], uid);
+		g_free (uid);
 	}
-
-	if (!success) {
-		g_object_unref (context->client);
-		g_free (context);
-		return FALSE;
+	if (!source) {
+		ESource *source;
+		
+		/* Try to create a default if there isn't one */
+		source = e_source_list_peek_source_any (priv->source_lists[priv->type]);
 	}
 
-	g_object_ref (itip);
+	esom = e_source_option_menu_new (priv->source_lists[priv->type]);
+	g_signal_connect_object (esom, "source_selected",
+				 G_CALLBACK (source_selected_cb), 
+				 itip, 0);
+
+	gtk_container_add (GTK_CONTAINER (eb), esom);
+	gtk_widget_show (esom);
+
+	/* FIXME What if there is no source? */
+	if (source)
+		e_source_option_menu_select (E_SOURCE_OPTION_MENU (esom), source);
 
 	return TRUE;
 }
@@ -2356,18 +2194,8 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar
 		g_slist_free (list);
 		
 		e_cal_component_rescan (comp);
-		switch (vtype) {
-		case E_CAL_COMPONENT_EVENT:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp,
-					priv->event_client, priv->top_level);
-			break;
-		case E_CAL_COMPONENT_TODO:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp,
-					priv->task_client, priv->top_level);
-			break;
-		default:
-			itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, NULL, NULL);
-		}
+		itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, priv->top_level);
+
 		g_object_unref (comp);
 	}
 }
diff --git a/calendar/gui/e-itip-control.h b/calendar/gui/e-itip-control.h
index 12ddf7354e..1a1e3e6eb9 100644
--- a/calendar/gui/e-itip-control.h
+++ b/calendar/gui/e-itip-control.h
@@ -25,10 +25,7 @@
 
 #include <gtk/gtk.h>
 
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+G_BEGIN_DECLS
 
 #define E_TYPE_ITIP_CONTROL			(e_itip_control_get_type ())
 #define E_ITIP_CONTROL(obj)			(GTK_CHECK_CAST ((obj), E_TYPE_ITIP_CONTROL, EItipControl))
@@ -71,12 +68,10 @@ const gchar *e_itip_control_get_delegator_address   (EItipControl *itip);
 void         e_itip_control_set_delegator_name   (EItipControl *itip,
 						 const gchar  *name);
 const gchar *e_itip_control_get_delegator_name   (EItipControl *itip);
-void         e_itip_control_set_calendar_uri (EItipControl *itip,
-					      const gchar  *uri);
-const gchar *e_itip_control_get_calendar_uri (EItipControl *itip);
+void         e_itip_control_set_calendar_uid (EItipControl *itip,
+					      const gchar  *uid);
+const gchar *e_itip_control_get_calendar_uid (EItipControl *itip);
 
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
 
 #endif /* _E_ITIP_CONTROL_H_ */
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 936344de43..66c51b9032 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -850,7 +850,7 @@ e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri)
 	if (client)
 		return TRUE;
 	
-	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_TODO);
+	client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_TODO);
 	g_hash_table_insert (priv->clients, g_strdup (str_uri), client);
 	priv->clients_list = g_list_prepend (priv->clients_list, client);
 	
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 44766bc958..852c103809 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -2031,7 +2031,7 @@ gnome_calendar_construct (GnomeCalendar *gcal)
 	/*
 	 * TaskPad Folder Client.
 	 */
-	priv->task_pad_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME: use default tasks */
+	priv->task_pad_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default tasks */
 	if (!priv->task_pad_client)
 		return NULL;
 
@@ -2160,7 +2160,7 @@ gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri)
 	if (client)
 		return TRUE;
 	
-	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_EVENT);
+	client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
 	if (!client)
 		return FALSE;
 
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 1e647c096b..06aa854018 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -639,9 +639,9 @@ print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, time_t month,
 				sprintf (buf, "%d", day);
 
 				/* this is a slow messy way to do this ... but easy ... */
-				e_cal_generate_instances (client, now, CALOBJ_TYPE_EVENT, 
-							       time_day_end_with_zone (now, zone),
-							       instance_cb, &found);
+				e_cal_generate_instances (client, now, 
+							  time_day_end_with_zone (now, zone),
+							  instance_cb, &found);
 				
 				font = found ? font_bold : font_normal;
 
@@ -1151,8 +1151,7 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence,
 
 	/* Get the events from the server. */
 	client = gnome_calendar_get_default_client (gcal);
-	e_cal_generate_instances (client, CALOBJ_TYPE_EVENT, start, end,
-				       print_day_details_cb, &pdi);
+	e_cal_generate_instances (client, start, end, print_day_details_cb, &pdi);
 	qsort (pdi.long_events->data, pdi.long_events->len,
 	       sizeof (EDayViewEvent), e_day_view_event_sort_func);
 	qsort (pdi.events[0]->data, pdi.events[0]->len,
@@ -1587,10 +1586,10 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal,
 
 	/* Get the events from the server. */
 	client = gnome_calendar_get_default_client (gcal);
-	e_cal_generate_instances (client, CALOBJ_TYPE_EVENT,
-				       psi.day_starts[0],
-				       psi.day_starts[psi.days_shown],
-				       print_week_summary_cb, &psi);
+	e_cal_generate_instances (client,
+				  psi.day_starts[0],
+				  psi.day_starts[psi.days_shown],
+				  print_week_summary_cb, &psi);
 	qsort (psi.events->data, psi.events->len,
 	       sizeof (EWeekViewEvent), e_week_view_event_sort_func);
 
diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c
index 8e6937d08a..f22055b685 100644
--- a/calendar/gui/tag-calendar.c
+++ b/calendar/gui/tag-calendar.c
@@ -149,9 +149,8 @@ tag_calendar_by_client (ECalendar *ecal, ECal *client)
 #if 0
 	g_print ("DateNavigator generating instances\n");
 #endif
-	e_cal_generate_instances (client, CALOBJ_TYPE_EVENT,
-				       c.start_time, c.end_time,
-				       tag_calendar_cb, &c);
+	e_cal_generate_instances (client, c.start_time, c.end_time,
+				  tag_calendar_cb, &c);
 }
 
 /* Resolves TZIDs for the recurrence generator, for when the comp is not on
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index 2f89ea31bb..3c8650afd1 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -324,7 +324,7 @@ copy_task_list_cb (GtkWidget *widget, TasksComponent *comp)
 	if (!selected_source)
 		return;
 
-	copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, CALOBJ_TYPE_TODO);
+	copy_source_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget)), selected_source, E_CAL_SOURCE_TYPE_TODO);
 }
 
 static void
@@ -643,14 +643,14 @@ setup_create_ecal (TasksComponent *component)
 		source = e_source_list_peek_source_by_uid (priv->source_list, uid);
 		g_free (uid);
 
-		priv->create_ecal = e_cal_new (source, CALOBJ_TYPE_TODO);
+		priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
 	} 
 
 	if (!priv->create_ecal) {
 		/* Try to create a default if there isn't one */
 		source = find_first_source (priv->source_list);
 		if (source)
-			priv->create_ecal = e_cal_new (source, CALOBJ_TYPE_TODO);
+			priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
 	}
 		
 	if (priv->create_ecal) {
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index ae9a5c9b21..ba9478ac8f 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -374,9 +374,9 @@ load_file_fn (EvolutionImporter *importer,
 
 			/* create ECal's */
 			if (!ici->client)
-				ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
+				ici->client = e_cal_new_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
 			if (!ici->tasks_client)
-				ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME */
+				ici->tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME */
 
 			if (e_cal_open (ici->client, TRUE, NULL)
 			    && e_cal_open (ici->tasks_client, FALSE, NULL)) {
@@ -526,9 +526,9 @@ vcal_load_file_fn (EvolutionImporter *importer,
 
 		/* create ECal's */
 		if (!ici->client)
-			ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
+			ici->client = e_cal_new_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
 		if (!ici->tasks_client)
-			ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO);
+			ici->tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO);
 
 		if (e_cal_open (ici->client, TRUE, NULL)
 		    && e_cal_open (ici->tasks_client, FALSE, NULL)) {
@@ -614,13 +614,13 @@ gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii,
 
 	/* Try to open the default calendar & tasks folders. */
 	if (ici->do_calendar) {
-		calendar_client = e_cal_new_from_uri ("", CALOBJ_TYPE_EVENT); /* FIXME: use default folder */
+		calendar_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_EVENT); /* FIXME: use default folder */
 		if (!e_cal_open (calendar_client, FALSE, NULL))
 			goto out;
 	}
 
 	if (ici->do_tasks) {
-		tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */
+		tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default folder */
 		if (!e_cal_open (tasks_client, FALSE, NULL))
 			goto out;
 	}
-- 
cgit v1.2.3