[evolution-patches] Cal/book backends to use ESource



I thought I'd post the changes to make evolution-data-server backends
take ESources instead of just URIs, so you get a chance to pick them
apart before I commit anything.

Executive summary:

* ESource has two new methods to export and import standalone XML.

* ESource w/o ESourceGroup can fall back to internal absolute URI
  if created from standalone XML.

* EBook gets a new method, e_book_load_source ().

* ECal e_cal_new () takes ESource, new convenience call 
  e_cal_new_from_uri ().

* Backends get access to the ESource they were created with.

* Evolution proper: Calls to e_cal_new () replaced with
  e_cal_new_from_uri () where an ESource is not easily available.
  This probably needs additional adjustments to pass ESource instead
  of URIs in a couple of places, so properties get through, but
  at least it links.

--
Hans Petter
? eds-be-sources.diff
? my-autogen.sh
? my-env.sh
? stamp-h1
? calendar/cal.diff
? calendar/libical/src/libicalss/icalsslexer.c
? calendar/libical/src/libicalss/icalssyacc.c
? calendar/libical/src/libicalss/y.output
? calendar/libical/src/libicalvcal/vcc.c
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution-data-server/configure.in,v
retrieving revision 1.20
diff -u -p -r1.20 configure.in
--- configure.in	18 Nov 2003 01:31:47 -0000	1.20
+++ configure.in	24 Nov 2003 03:51:13 -0000
@@ -307,7 +307,7 @@ AC_SUBST(E_DATA_SERVER_LIBS)
 
 dnl --- evolution-addressbook flags
 
-EVOLUTION_ADDRESSBOOK_DEPS="gconf-2.0 libbonobo-2.0 libgnome-2.0 gnome-vfs-2.0"
+EVOLUTION_ADDRESSBOOK_DEPS="libxml-2.0 gconf-2.0 libbonobo-2.0 libgnome-2.0 gnome-vfs-2.0"
 
 EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS)
 AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
Index: addressbook/backends/file/e-book-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/file/e-book-backend-file.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-book-backend-file.c
--- addressbook/backends/file/e-book-backend-file.c	10 Nov 2003 17:12:11 -0000	1.4
+++ addressbook/backends/file/e-book-backend-file.c	24 Nov 2003 03:51:15 -0000
@@ -49,7 +49,6 @@
 static EBookBackendSyncClass *e_book_backend_file_parent_class;
 
 struct _EBookBackendFilePrivate {
-	char     *uri;
 	char     *dirname;
 	char     *filename;
 	char     *summary_filename;
@@ -844,9 +843,9 @@ e_book_backend_file_maybe_upgrade_db (EB
 #include <libedata-book/ximian-vcard.h>
 
 static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_file_load_uri (EBookBackend           *backend,
-			      const char             *uri,
-			      gboolean                only_if_exists)
+e_book_backend_file_load_source (EBookBackend           *backend,
+				 ESource                *source,
+				 gboolean                only_if_exists)
 {
 	EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
 	char           *dirname, *filename;
@@ -856,9 +855,7 @@ e_book_backend_file_load_uri (EBookBacke
 	int major, minor, patch;
 	time_t db_mtime;
 	struct stat sb;
-
-	g_free(bf->priv->uri);
-	bf->priv->uri = g_strdup (uri);
+	gchar *uri;
 
 	db_version (&major, &minor, &patch);
 
@@ -869,8 +866,10 @@ e_book_backend_file_load_uri (EBookBacke
 		return GNOME_Evolution_Addressbook_OtherError;
 	}
 
+	uri = e_source_get_uri (source);
 	dirname = e_book_backend_file_extract_path_from_uri (uri);
 	filename = g_build_filename (dirname, "addressbook.db", NULL);
+	g_free (uri);
 
 	db_error = e_db3_utils_maybe_recover (filename);
 	if (db_error != 0)
@@ -1085,7 +1084,6 @@ e_book_backend_file_dispose (GObject *ob
 	if (bf->priv) {
 		if (bf->priv->summary)
 			g_object_unref(bf->priv->summary);
-		g_free (bf->priv->uri);
 		g_free (bf->priv->filename);
 		g_free (bf->priv->dirname);
 		g_free (bf->priv->summary_filename);
@@ -1110,7 +1108,7 @@ e_book_backend_file_class_init (EBookBac
 	backend_class = E_BOOK_BACKEND_CLASS (klass);
 
 	/* Set the virtual methods. */
-	backend_class->load_uri                = e_book_backend_file_load_uri;
+	backend_class->load_source             = e_book_backend_file_load_source;
 	backend_class->get_static_capabilities = e_book_backend_file_get_static_capabilities;
 	backend_class->start_book_view         = e_book_backend_file_start_book_view;
 	backend_class->stop_book_view          = e_book_backend_file_stop_book_view;
@@ -1135,7 +1133,6 @@ e_book_backend_file_init (EBookBackendFi
 	EBookBackendFilePrivate *priv;
 
 	priv             = g_new0 (EBookBackendFilePrivate, 1);
-	priv->uri        = NULL;
 
 	backend->priv = priv;
 }
Index: addressbook/backends/ldap/e-book-backend-ldap.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/ldap/e-book-backend-ldap.c,v
retrieving revision 1.6
diff -u -p -r1.6 e-book-backend-ldap.c
--- addressbook/backends/ldap/e-book-backend-ldap.c	22 Nov 2003 22:45:40 -0000	1.6
+++ addressbook/backends/ldap/e-book-backend-ldap.c	24 Nov 2003 03:51:21 -0000
@@ -81,7 +81,6 @@ typedef struct LDAPOp LDAPOp;
 
 
 struct _EBookBackendLDAPPrivate {
-	char     *uri;
 	gboolean connected;
 
 	gchar    *ldap_host;   /* the hostname of the server */
@@ -3037,9 +3036,9 @@ e_book_backend_ldap_get_supported_auth_m
 }
 
 static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_ldap_load_uri (EBookBackend             *backend,
-			   const char             *uri,
-			   gboolean                only_if_exists)
+e_book_backend_ldap_load_source (EBookBackend             *backend,
+				 ESource                  *source,
+				 gboolean                  only_if_exists)
 {
 	EBookBackendLDAP *bl = E_BOOK_BACKEND_LDAP (backend);
 	LDAPURLDesc    *lud;
@@ -3048,13 +3047,18 @@ e_book_backend_ldap_load_uri (EBookBacke
 	int i;
 	int limit = 100;
 	int timeout = 60; /* 1 minute */
+	gchar *uri;
 
 	g_assert (bl->priv->connected == FALSE);
 
+	uri = e_source_get_uri (source);
+
 	attributes = g_strsplit (uri, ";", 0);
 
-	if (attributes[0] == NULL)
+	if (attributes[0] == NULL) {
+		g_free (uri);
 		return FALSE;
+	}
 
 	for (i = 1; attributes[i]; i++) {
 		char *equals;
@@ -3098,9 +3102,9 @@ e_book_backend_ldap_load_uri (EBookBacke
 	ldap_error = ldap_url_parse ((char*)attributes[0], &lud);
 	g_strfreev (attributes);
 
+	g_free (uri);
+
 	if (ldap_error == LDAP_SUCCESS) {
-		g_free(bl->priv->uri);
-		bl->priv->uri = g_strdup (uri);
 		bl->priv->ldap_host = g_strdup(lud->lud_host);
 		bl->priv->ldap_port = lud->lud_port;
 		/* if a port wasn't specified, default to LDAP_PORT */
@@ -3191,8 +3195,6 @@ e_book_backend_ldap_dispose (GObject *ob
 			g_list_free (bl->priv->supported_auth_methods);
 		}
 
-		g_free (bl->priv->uri);
-
 		g_free (bl->priv);
 		bl->priv = NULL;
 	}
@@ -3215,7 +3217,7 @@ e_book_backend_ldap_class_init (EBookBac
 	parent_class = E_BOOK_BACKEND_CLASS (klass);
 
 	/* Set the virtual methods. */
-	parent_class->load_uri                = e_book_backend_ldap_load_uri;
+	parent_class->load_source             = e_book_backend_ldap_load_source;
 	parent_class->get_static_capabilities = e_book_backend_ldap_get_static_capabilities;
 
 	parent_class->create_contact          = e_book_backend_ldap_create_contact;
Index: addressbook/backends/vcf/e-book-backend-vcf.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/backends/vcf/e-book-backend-vcf.c,v
retrieving revision 1.5
diff -u -p -r1.5 e-book-backend-vcf.c
--- addressbook/backends/vcf/e-book-backend-vcf.c	10 Nov 2003 17:12:12 -0000	1.5
+++ addressbook/backends/vcf/e-book-backend-vcf.c	24 Nov 2003 03:51:23 -0000
@@ -34,7 +34,6 @@ typedef struct _EBookBackendVCFBookView 
 typedef struct _EBookBackendVCFSearchContext EBookBackendVCFSearchContext;
 
 struct _EBookBackendVCFPrivate {
-	char       *uri;
 	char       *filename;
 	GMutex     *mutex;
 	GHashTable *contacts;
@@ -471,17 +470,17 @@ e_book_backend_vcf_get_supported_fields 
 #include <libedata-book/ximian-vcard.h>
 
 static GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_vcf_load_uri (EBookBackend             *backend,
-			  const char             *uri,
-			  gboolean                only_if_exists)
+e_book_backend_vcf_load_source (EBookBackend             *backend,
+				ESource                  *source,
+				gboolean                  only_if_exists)
 {
 	EBookBackendVCF *bvcf = E_BOOK_BACKEND_VCF (backend);
 	char           *dirname;
 	gboolean        writable = FALSE;
+	gchar          *uri;
 	int fd;
 
-	g_free(bvcf->priv->uri);
-	bvcf->priv->uri = g_strdup (uri);
+	uri = e_source_get_uri (source);
 
 	dirname = e_book_backend_vcf_extract_path_from_uri (uri);
 	bvcf->priv->filename = g_build_filename (dirname, "addressbook.vcf", NULL);
@@ -516,6 +515,7 @@ e_book_backend_vcf_load_uri (EBookBacken
 	if (fd == -1) {
 		g_warning ("Failed to open addressbook at uri `%s'", uri);
 		g_warning ("error == %s", strerror(errno));
+		g_free (uri);
 		return GNOME_Evolution_Addressbook_OtherError;
 	}
 
@@ -524,6 +524,7 @@ e_book_backend_vcf_load_uri (EBookBacken
 	e_book_backend_set_is_loaded (backend, TRUE);
 	e_book_backend_set_is_writable (backend, writable);
 
+	g_free (uri);
 	return GNOME_Evolution_Addressbook_Success;
 }
 
@@ -591,7 +592,6 @@ e_book_backend_vcf_dispose (GObject *obj
 
 		g_hash_table_destroy (bvcf->priv->contacts);
 
-		g_free (bvcf->priv->uri);
 		g_free (bvcf->priv->filename);
 
 		g_mutex_unlock (bvcf->priv->mutex);
@@ -618,7 +618,7 @@ e_book_backend_vcf_class_init (EBookBack
 	backend_class = E_BOOK_BACKEND_CLASS (klass);
 
 	/* Set the virtual methods. */
-	backend_class->load_uri                = e_book_backend_vcf_load_uri;
+	backend_class->load_source             = e_book_backend_vcf_load_source;
 	backend_class->get_static_capabilities = e_book_backend_vcf_get_static_capabilities;
 	backend_class->start_book_view         = e_book_backend_vcf_start_book_view;
 	backend_class->stop_book_view          = e_book_backend_vcf_stop_book_view;
@@ -641,7 +641,6 @@ e_book_backend_vcf_init (EBookBackendVCF
 	EBookBackendVCFPrivate *priv;
 
 	priv                 = g_new0 (EBookBackendVCFPrivate, 1);
-	priv->uri            = NULL;
 	priv->mutex = g_mutex_new();
 
 	backend->priv = priv;
Index: addressbook/idl/Evolution-DataServer-Addressbook.idl
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/idl/Evolution-DataServer-Addressbook.idl,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Evolution-DataServer-Addressbook.idl
--- addressbook/idl/Evolution-DataServer-Addressbook.idl	3 Nov 2003 18:23:56 -0000	1.1.1.1
+++ addressbook/idl/Evolution-DataServer-Addressbook.idl	24 Nov 2003 03:51:24 -0000
@@ -179,7 +179,7 @@ module Addressbook {
 	interface BookFactory : Bonobo::Unknown {
 		exception ProtocolNotSupported {};
 
-		Book getBook (in string uri, in BookListener listener)
+		Book getBook (in string source, in BookListener listener)
 			raises (ProtocolNotSupported);
 	};
 };
Index: addressbook/libebook/e-book.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-book.c
--- addressbook/libebook/e-book.c	6 Nov 2003 18:20:46 -0000	1.4
+++ addressbook/libebook/e-book.c	24 Nov 2003 03:51:30 -0000
@@ -1614,25 +1614,29 @@ activate_factories_for_uri (EBook *book,
 	return factories;
 }
 
-gboolean
-e_book_load_uri (EBook        *book,
-		 const char   *uri,
-		 gboolean      only_if_exists,
-		 GError      **error)
+static gboolean
+fetch_corba_book (EBook       *book,
+		  ESource     *source,
+		  gboolean     only_if_exists,
+		  GError     **error)
 {
+	GNOME_Evolution_Addressbook_Book corba_book = CORBA_OBJECT_NIL;
+	gchar *uri;
+	gchar *source_xml;
 	GList *factories;
 	GList *l;
 	gboolean rv = FALSE;
-	GNOME_Evolution_Addressbook_Book corba_book = CORBA_OBJECT_NIL;
 
-	e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
-	e_return_error_if_fail (uri,                      E_BOOK_ERROR_INVALID_ARG);
-
-	/* XXX this needs to happen while holding the book's lock i would think... */
-	e_return_error_if_fail (book->priv->load_state == E_BOOK_URI_NOT_LOADED, E_BOOK_ERROR_URI_ALREADY_LOADED);
+	uri = e_source_get_uri (source);
+	if (!uri) {
+		g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_OTHER_ERROR,
+			     _("e_book_load_uri: Invalid source."));
+		return FALSE;
+	}
 
 	/* try to find a list of factories that can handle the protocol */
-	if (! (factories = activate_factories_for_uri (book, uri))) {
+	factories = activate_factories_for_uri (book, uri);
+	if (!factories) {
 		g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED,
 			     _("e_book_load_uri: no factories available for uri `%s'"), uri);
 		return FALSE;
@@ -1655,7 +1659,9 @@ e_book_load_uri (EBook        *book,
 							G_CALLBACK (e_book_handle_response), book);
 
 	g_free (book->priv->uri);
-	book->priv->uri = g_strdup (uri);
+	book->priv->uri = uri;
+
+	source_xml = e_source_to_standalone_xml (source);
 
 	for (l = factories; l; l = l->next) {
 		GNOME_Evolution_Addressbook_BookFactory factory = l->data;
@@ -1669,7 +1675,7 @@ e_book_load_uri (EBook        *book,
 
 		CORBA_exception_init (&ev);
 
-		corba_book = GNOME_Evolution_Addressbook_BookFactory_getBook (factory, book->priv->uri,
+		corba_book = GNOME_Evolution_Addressbook_BookFactory_getBook (factory, source_xml,
 								      bonobo_object_corba_objref (BONOBO_OBJECT (book->priv->listener)),
 								      &ev);
 
@@ -1714,6 +1720,8 @@ e_book_load_uri (EBook        *book,
 		}
 	}
 
+	g_free (source_xml);
+
 	/* free up the factories */
 	for (l = factories; l; l = l->next)
 		CORBA_Object_release ((CORBA_Object)l->data, NULL);
@@ -1732,6 +1740,49 @@ e_book_load_uri (EBook        *book,
 		return FALSE;
 	}
 		
+	return rv;
+}
+
+gboolean
+e_book_load_source (EBook *book,
+		    ESource *source,
+		    gboolean only_if_exists,
+		    GError **error)
+{
+	e_return_error_if_fail (book && E_IS_BOOK (book),       E_BOOK_ERROR_INVALID_ARG);
+	e_return_error_if_fail (source && E_IS_SOURCE (source), E_BOOK_ERROR_INVALID_ARG);
+
+	/* XXX this needs to happen while holding the book's lock i would think... */
+	e_return_error_if_fail (book->priv->load_state == E_BOOK_URI_NOT_LOADED, E_BOOK_ERROR_URI_ALREADY_LOADED);
+
+	return fetch_corba_book (book, source, only_if_exists, error);
+}
+
+gboolean
+e_book_load_uri (EBook        *book,
+		 const char   *uri,
+		 gboolean      only_if_exists,
+		 GError      **error)
+{
+	ESourceGroup *group;
+	ESource *source;
+	gboolean rv;
+
+	e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG);
+	e_return_error_if_fail (uri,                      E_BOOK_ERROR_INVALID_ARG);
+
+	/* XXX this needs to happen while holding the book's lock i would think... */
+	e_return_error_if_fail (book->priv->load_state == E_BOOK_URI_NOT_LOADED, E_BOOK_ERROR_URI_ALREADY_LOADED);
+
+	group = e_source_group_new ("", uri);
+	source = e_source_new ("", "");
+	e_source_set_group (source, group);
+
+	rv = e_book_load_source (book, source, only_if_exists, error);
+
+	g_object_unref (source);
+	g_object_unref (group);
+
 	return rv;
 }
 
Index: addressbook/libebook/e-book.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book.h,v
retrieving revision 1.2
diff -u -p -r1.2 e-book.h
--- addressbook/libebook/e-book.h	4 Nov 2003 14:30:17 -0000	1.2
+++ addressbook/libebook/e-book.h	24 Nov 2003 03:51:30 -0000
@@ -14,6 +14,7 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <libedataserver/e-source.h>
 #include <libebook/Evolution-DataServer-Addressbook.h>
 #include <libebook/e-contact.h>
 #include <libebook/e-book-query.h>
@@ -62,6 +63,11 @@ struct _EBookClass {
 EBook    *e_book_new                       (void);
 
 /* loading arbitrary addressbooks */
+gboolean e_book_load_source                (EBook       *book,
+					    ESource     *source,
+					    gboolean     only_if_exists,
+					    GError     **error);
+
 gboolean e_book_load_uri                   (EBook       *book,
 					    const char  *uri,
 					    gboolean     only_if_exists,
Index: addressbook/libedata-book/e-book-backend.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-book-backend.c,v
retrieving revision 1.2
diff -u -p -r1.2 e-book-backend.c
--- addressbook/libedata-book/e-book-backend.c	10 Nov 2003 17:12:13 -0000	1.2
+++ addressbook/libedata-book/e-book-backend.c	24 Nov 2003 03:51:32 -0000
@@ -18,7 +18,7 @@ struct _EBookBackendPrivate {
 	GMutex *clients_mutex;
 	GList *clients;
 
-	char *uri;
+	ESource *source;
 	gboolean loaded, writable, removed;
 
 	GMutex *views_mutex;
@@ -42,40 +42,42 @@ e_book_backend_construct (EBookBackend *
 }
 
 GNOME_Evolution_Addressbook_CallStatus
-e_book_backend_load_uri (EBookBackend           *backend,
-			 const char             *uri,
-			 gboolean                only_if_exists)
+e_book_backend_load_source (EBookBackend           *backend,
+			    ESource                *source,
+			    gboolean                only_if_exists)
 {
 	GNOME_Evolution_Addressbook_CallStatus status;
 
 	g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), FALSE);
-	g_return_val_if_fail (uri, FALSE);
+	g_return_val_if_fail (source, FALSE);
 	g_return_val_if_fail (backend->priv->loaded == FALSE, FALSE);
 
-	g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->load_uri);
+	g_assert (E_BOOK_BACKEND_GET_CLASS (backend)->load_source);
 
-	status = (* E_BOOK_BACKEND_GET_CLASS (backend)->load_uri) (backend, uri, only_if_exists);
+	status = (* E_BOOK_BACKEND_GET_CLASS (backend)->load_source) (backend, source, only_if_exists);
 
-	if (status == GNOME_Evolution_Addressbook_Success)
-		backend->priv->uri = g_strdup (uri);
+	if (status == GNOME_Evolution_Addressbook_Success) {
+		g_object_ref (source);
+		backend->priv->source = source;
+	}
 
 	return status;
 }
 
 /**
- * e_book_backend_get_uri:
+ * e_book_backend_get_source:
  * @backend: An addressbook backend.
  * 
- * Queries the URI that an addressbook backend is serving.
+ * Queries the source that an addressbook backend is serving.
  * 
- * Return value: URI for the backend.
+ * Return value: ESource for the backend.
  **/
-const char *
-e_book_backend_get_uri (EBookBackend *backend)
+ESource *
+e_book_backend_get_source (EBookBackend *backend)
 {
 	g_return_val_if_fail (E_IS_BOOK_BACKEND (backend), NULL);
 
-	return backend->priv->uri;
+	return backend->priv->source;
 }
 
 void
@@ -95,7 +97,7 @@ e_book_backend_open (EBookBackend *backe
 		e_data_book_report_writable (book, backend->priv->writable);
 	} else {
 		GNOME_Evolution_Addressbook_CallStatus status =
-			e_book_backend_load_uri (backend, e_data_book_get_uri (book), only_if_exists);
+			e_book_backend_load_source (backend, e_data_book_get_source (book), only_if_exists);
 
 		e_data_book_respond_open (book, status);
 
@@ -583,7 +585,6 @@ e_book_backend_init (EBookBackend *backe
 	EBookBackendPrivate *priv;
 
 	priv          = g_new0 (EBookBackendPrivate, 1);
-	priv->uri     = NULL;
 	priv->clients = NULL;
 	priv->views   = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL);
 	priv->open_mutex = g_mutex_new ();
@@ -602,9 +603,6 @@ e_book_backend_dispose (GObject *object)
 
 	if (backend->priv) {
 		g_list_free (backend->priv->clients);
-
-		if (backend->priv->uri)
-			g_free (backend->priv->uri);
 
 		if (backend->priv->views) {
 			g_object_unref (backend->priv->views);
Index: addressbook/libedata-book/e-book-backend.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-book-backend.h,v
retrieving revision 1.4
diff -u -p -r1.4 e-book-backend.h
--- addressbook/libedata-book/e-book-backend.h	10 Nov 2003 17:12:13 -0000	1.4
+++ addressbook/libedata-book/e-book-backend.h	24 Nov 2003 03:51:33 -0000
@@ -47,7 +47,7 @@ struct _EBookBackendClass {
 	GObjectClass parent_class;
 
 	/* Virtual methods */
-	GNOME_Evolution_Addressbook_CallStatus (*load_uri) (EBookBackend *backend, const char *uri, gboolean only_if_exists);
+	GNOME_Evolution_Addressbook_CallStatus (*load_source) (EBookBackend *backend, ESource *source, gboolean only_if_exists);
 	void (*remove) (EBookBackend *backend, EDataBook *book);
         char *(*get_static_capabilities) (EBookBackend *backend);
 
@@ -80,10 +80,10 @@ typedef EBookBackend * (*EBookBackendFac
 gboolean    e_book_backend_construct                (EBookBackend             *backend);
 
 GNOME_Evolution_Addressbook_CallStatus
-            e_book_backend_load_uri                 (EBookBackend             *backend,
-						  const char             *uri,
-						  gboolean                only_if_exists);
-const char *e_book_backend_get_uri                  (EBookBackend             *backend);
+            e_book_backend_load_source              (EBookBackend             *backend,
+						     ESource                  *source,
+						     gboolean                  only_if_exists);
+ESource    *e_book_backend_get_source               (EBookBackend             *backend);
 
 gboolean    e_book_backend_add_client               (EBookBackend             *backend,
 						  EDataBook                *book);
Index: addressbook/libedata-book/e-data-book-factory.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-data-book-factory.c,v
retrieving revision 1.3
diff -u -p -r1.3 e-data-book-factory.c
--- addressbook/libedata-book/e-data-book-factory.c	4 Nov 2003 21:53:00 -0000	1.3
+++ addressbook/libedata-book/e-data-book-factory.c	24 Nov 2003 03:51:34 -0000
@@ -153,13 +153,19 @@ static void
 backend_last_client_gone_cb (EBookBackend *backend, gpointer data)
 {
 	EDataBookFactory *factory;
-	const char *uri;
+	ESource *source;
+	gchar *uri;
 
 	factory = E_DATA_BOOK_FACTORY (data);
 
 	/* Remove the backend from the active server map */
 
-	uri = e_book_backend_get_uri (backend);
+	source = e_book_backend_get_source (backend);
+	if (source)
+		uri = e_source_get_uri (source);
+	else
+		uri = NULL;
+
 	if (uri) {
 		gpointer orig_key;
 		gboolean result;
@@ -185,6 +191,8 @@ backend_last_client_gone_cb (EBookBacken
 		/* Notify upstream if there are no more backends */
 		g_signal_emit (G_OBJECT (factory), factory_signals[LAST_BOOK_GONE], 0);
 	}
+
+	g_free (uri);
 }
 
 
@@ -244,16 +252,36 @@ e_data_book_factory_launch_backend (EDat
 
 static GNOME_Evolution_Addressbook_Book
 impl_GNOME_Evolution_Addressbook_BookFactory_getBook (PortableServer_Servant        servant,
-						      const CORBA_char             *uri,
+						      const CORBA_char             *source_xml,
 						      const GNOME_Evolution_Addressbook_BookListener listener,
 						      CORBA_Environment            *ev)
 {
 	EDataBookFactory      *factory = E_DATA_BOOK_FACTORY (bonobo_object (servant));
+	GNOME_Evolution_Addressbook_Book corba_book;
 	EBookBackend *backend;
 	EDataBook *book;
+	ESource *source;
+	gchar *uri;
 
 	printf ("impl_GNOME_Evolution_Addressbook_BookFactory_getBook\n");
 
+	source = e_source_new_from_standalone_xml (source_xml);
+	if (!source) {
+		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+				     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
+				     NULL);
+		return CORBA_OBJECT_NIL;
+	}
+
+	uri = e_source_get_uri (source);
+	if (!uri) {
+		g_object_unref (source);
+		CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+				     ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported,
+				     NULL);
+		return CORBA_OBJECT_NIL;
+	}
+
 	/* Look up the backend and create one if needed */
 	g_mutex_lock (factory->priv->map_mutex);
 
@@ -271,12 +299,15 @@ impl_GNOME_Evolution_Addressbook_BookFac
 
 			g_mutex_unlock (factory->priv->map_mutex);
 
+			g_free (uri);
 			return CORBA_OBJECT_NIL;
 		}
 
 		backend = e_data_book_factory_launch_backend (factory, backend_factory, listener, uri);
 	}
 
+	g_free (uri);
+
 	if (backend) {
 		GNOME_Evolution_Addressbook_BookListener listener_copy;
 
@@ -284,11 +315,11 @@ impl_GNOME_Evolution_Addressbook_BookFac
 
 		g_mutex_unlock (factory->priv->map_mutex);
 
-		book = e_data_book_new (backend, uri, listener);
+		book = e_data_book_new (backend, source, listener);
 
 		e_book_backend_add_client (backend, book);
 
-		return bonobo_object_corba_objref (BONOBO_OBJECT (book));
+		corba_book = bonobo_object_corba_objref (BONOBO_OBJECT (book));
 	}
 	else {
 		/* probably need a more descriptive exception here */
@@ -297,8 +328,11 @@ impl_GNOME_Evolution_Addressbook_BookFac
 				     NULL);
 		g_mutex_unlock (factory->priv->map_mutex);
 
-		return CORBA_OBJECT_NIL;
+		corba_book = CORBA_OBJECT_NIL;
 	}
+
+	g_object_unref (source);
+	return corba_book;
 }
 
 static void
Index: addressbook/libedata-book/e-data-book.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-data-book.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 e-data-book.c
--- addressbook/libedata-book/e-data-book.c	3 Nov 2003 18:23:59 -0000	1.1.1.1
+++ addressbook/libedata-book/e-data-book.c	24 Nov 2003 03:51:34 -0000
@@ -25,7 +25,7 @@ POA_GNOME_Evolution_Addressbook_Book__ve
 struct _EDataBookPrivate {
 	EBookBackend                               *backend;
 	GNOME_Evolution_Addressbook_BookListener  listener;
-	char                                     *uri;
+	ESource                                    *source;
 };
 
 static void
@@ -247,10 +247,10 @@ e_data_book_get_listener (EDataBook *boo
 	return book->priv->listener;
 }
 
-const char*
-e_data_book_get_uri (EDataBook *book)
+ESource *
+e_data_book_get_source (EDataBook *book)
 {
-	return book->priv->uri;
+	return book->priv->source;
 }
 
 /**
@@ -660,13 +660,14 @@ e_data_book_report_writable (EDataBook  
 static void
 e_data_book_construct (EDataBook                *book,
 		    EBookBackend             *backend,
-		    const char             *uri,
+		    ESource *source,
 		    GNOME_Evolution_Addressbook_BookListener listener)
 {
 	EDataBookPrivate *priv;
 	CORBA_Environment ev;
 
 	g_return_if_fail (book != NULL);
+	g_return_if_fail (source != NULL);
 
 	priv = book->priv;
 
@@ -681,9 +682,10 @@ e_data_book_construct (EDataBook        
 
 	CORBA_exception_free (&ev);
 
-	priv->backend   = backend;
-	priv->uri       = g_strdup (uri);
+	g_object_ref (source);
 
+	priv->backend   = backend;
+	priv->source    = source;
 }
 
 /**
@@ -691,7 +693,7 @@ e_data_book_construct (EDataBook        
  */
 EDataBook *
 e_data_book_new (EBookBackend                               *backend,
-	      const char                               *uri,
+		 ESource *source,
 	      GNOME_Evolution_Addressbook_BookListener  listener)
 {
 	EDataBook *book;
@@ -701,7 +703,7 @@ e_data_book_new (EBookBackend           
 			     "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
 			     NULL);
 
-	e_data_book_construct (book, backend, uri, listener);
+	e_data_book_construct (book, backend, source, listener);
 
 	g_free (caps);
 
@@ -724,7 +726,7 @@ e_data_book_dispose (GObject *object)
 
 		CORBA_exception_free (&ev);
 
-		g_free (book->priv->uri);
+		g_object_unref (book->priv->source);
 		g_free (book->priv);
 		book->priv = NULL;
 	}
Index: addressbook/libedata-book/e-data-book.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-data-book.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-data-book.h
--- addressbook/libedata-book/e-data-book.h	6 Nov 2003 01:37:37 -0000	1.3
+++ addressbook/libedata-book/e-data-book.h	24 Nov 2003 03:51:34 -0000
@@ -14,6 +14,7 @@
 
 #include <bonobo/bonobo-object.h>
 #include <libedataserver/e-list.h>
+#include <libedataserver/e-source.h>
 #include <libedata-book/Evolution-DataServer-Addressbook.h>
 #include <libedata-book/e-data-book-types.h>
 
@@ -46,11 +47,11 @@ struct _EDataBookClass {
 
 
 EDataBook                *e_data_book_new                    (EBookBackend                               *backend,
-							 const char                               *uri,
+							      ESource                                  *source,
 							 GNOME_Evolution_Addressbook_BookListener  listener);
 GNOME_Evolution_Addressbook_BookListener e_data_book_get_listener (EDataBook                         *book);
 EBookBackend             *e_data_book_get_backend            (EDataBook                                *book);
-const char             *e_data_book_get_uri                (EDataBook                                *book);
+ESource                *e_data_book_get_source             (EDataBook                                *book);
 
 void                    e_data_book_respond_open           (EDataBook                                *book,
 							 GNOME_Evolution_Addressbook_CallStatus  status);
Index: calendar/backends/file/e-cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/file/e-cal-backend-file.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-cal-backend-file.c
--- calendar/backends/file/e-cal-backend-file.c	20 Nov 2003 09:49:13 -0000	1.4
+++ calendar/backends/file/e-cal-backend-file.c	24 Nov 2003 03:51:38 -0000
@@ -587,7 +587,7 @@ get_uri_string_for_gnome_vfs (ECalBacken
 	priv = cbfile->priv;
 	
 	master_uri = e_cal_backend_get_uri (backend);
-	
+
 	/* FIXME Check the error conditions a little more elegantly here */
 	if (g_strrstr ("tasks.ics", master_uri) || g_strrstr ("calendar.ics", master_uri)) {
 		g_warning (G_STRLOC ": Existing file name %s", master_uri);
Index: calendar/idl/Evolution-DataServer-Calendar.idl
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/idl/Evolution-DataServer-Calendar.idl,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Evolution-DataServer-Calendar.idl
--- calendar/idl/Evolution-DataServer-Calendar.idl	3 Nov 2003 18:23:59 -0000	1.1.1.1
+++ calendar/idl/Evolution-DataServer-Calendar.idl	24 Nov 2003 03:51:40 -0000
@@ -265,7 +265,7 @@ module Calendar {
 		exception InvalidURI {};
 		exception UnsupportedMethod {};
 
-		Cal getCal (in string uri, in CalObjType type, in CalListener listener)
+		Cal getCal (in string source, in CalObjType type, in CalListener listener)
 			raises (NilListener, InvalidURI, UnsupportedMethod);
 	};
 };
Index: calendar/libecal/client-test.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/client-test.c,v
retrieving revision 1.2
diff -u -p -r1.2 client-test.c
--- calendar/libecal/client-test.c	11 Nov 2003 16:59:04 -0000	1.2
+++ calendar/libecal/client-test.c	24 Nov 2003 03:51:40 -0000
@@ -138,12 +138,12 @@ client_destroy_cb (gpointer data, GObjec
 
 /* Creates a calendar client and tries to load the specified URI into it */
 static void
-create_client (ECal **client, const char *uri, CalObjType type, gboolean only_if_exists)
+create_client (ECal **client, const gchar *uri, CalObjType type, gboolean only_if_exists)
 {
 	ECalView *query;
 	GError *error = NULL;
 	
-	*client = e_cal_new (uri, type);
+	*client = e_cal_new_from_uri (uri, type);
 	if (!*client) {
 		g_message (G_STRLOC ": could not create the client");
 		exit (1);
@@ -152,6 +152,7 @@ create_client (ECal **client, const char
 	g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL);
 
 	cl_printf (*client, "Calendar loading `%s'...\n", uri);
+
 	if (!e_cal_open (*client, only_if_exists, &error)) {
 		cl_printf (*client, "Load/create %s\n", error->message);
 		exit (1);
@@ -175,6 +176,7 @@ create_client (ECal **client, const char
 	e_cal_view_start (query);
 	
 	g_idle_add (list_uids, *client);
+
 }
 
 int
@@ -191,8 +193,10 @@ main (int argc, char **argv)
 		exit (1);
 	}
 
-	create_client (&client1, "file:///home/gnome24-evolution-new-calendar/evolution/local/Calendar", 
-		       CALOBJ_TYPE_EVENT, FALSE);
+#if 0
+	source = e_source_new ("test-source", "file:///home/gnome24-evolution-new-calendar/evolution/local/Calendar");
+#endif
+	create_client (&client1, "file:///home/hpj/.evolution/calendar/local/OnThisComputer/Pakk", CALOBJ_TYPE_EVENT, FALSE);
 //	create_client (&client2, "file:///tmp/tasks", TRUE);
 
 	bonobo_main ();
Index: calendar/libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.7
diff -u -p -r1.7 e-cal.c
--- calendar/libecal/e-cal.c	11 Nov 2003 16:59:04 -0000	1.7
+++ calendar/libecal/e-cal.c	24 Nov 2003 03:51:44 -0000
@@ -1196,45 +1196,58 @@ e_cal_get_type (void)
 
 
 static gboolean
-fetch_corba_cal (ECal *ecal, const char *str_uri, CalObjType type)
+fetch_corba_cal (ECal *ecal, ESource *source, CalObjType type)
 {
 	ECalPrivate *priv;
 	GList *f;
 	CORBA_Environment ev;
+	gchar *source_xml;
+	gchar *str_uri;
+	gboolean result = FALSE;
 	
 	priv = ecal->priv;
 	g_return_val_if_fail (priv->load_state == E_CAL_LOAD_NOT_LOADED, FALSE);
 	g_assert (priv->uri == NULL);
+	g_return_val_if_fail (source != NULL, FALSE);
 
-	g_return_val_if_fail (str_uri != NULL, FALSE);
+	str_uri = e_source_get_uri (source);
+	if (!str_uri)
+		return FALSE;
 
-	if (!get_factories (str_uri, &priv->factories))
+	if (!get_factories (str_uri, &priv->factories)) {
+		g_free (str_uri);
 		return FALSE;
+	}
 
 	priv->uri = g_strdup (str_uri);
 	priv->type = type;
 
+	source_xml = e_source_to_standalone_xml (source);
+
 	for (f = priv->factories; f; f = f->next) {
 		GNOME_Evolution_Calendar_Cal cal;
 
 		CORBA_exception_init (&ev);
 
-		cal = GNOME_Evolution_Calendar_CalFactory_getCal (f->data, priv->uri, priv->type,
+		cal = GNOME_Evolution_Calendar_CalFactory_getCal (f->data, source_xml, priv->type,
 								  BONOBO_OBJREF (priv->listener), &ev);
 		if (BONOBO_EX (&ev))
 			continue;
 		
 		priv->cal = cal;
 
-		return TRUE;
+		result = TRUE;
+		break;
 	}
 
-	return FALSE;
+	g_free (str_uri);
+	g_free (source_xml);
+	return result;
 }
 
 /**
  * e_cal_new:
- * @uri: 
+ * @source: 
  * @type: 
  *
  * Creates a new calendar ecal.  It should be initialized by calling
@@ -1244,19 +1257,49 @@ fetch_corba_cal (ECal *ecal, const char 
  * not be constructed because it could not contact the calendar server.
  **/
 ECal *
-e_cal_new (const char *uri, CalObjType type)
+e_cal_new (ESource *source, CalObjType type)
 {
 	ECal *ecal;
 
 	ecal = g_object_new (E_TYPE_CAL, NULL);
 
-	if (!fetch_corba_cal (ecal, uri, type)) {
+	if (!fetch_corba_cal (ecal, source, type)) {
 		g_object_unref (ecal);
 
 		return NULL;
 	}
 	
 	return ecal;
+}
+
+/**
+ * e_cal_new_from_uri:
+ * @uri: 
+ * @type: 
+ *
+ * Creates a new calendar ecal.  It should be initialized by calling
+ * e_cal_open().
+ *
+ * Return value: A newly-created calendar ecal, or NULL if the ecal could
+ * not be constructed because it could not contact the calendar server.
+ **/
+ECal *
+e_cal_new_from_uri (const gchar *uri, CalObjType type)
+{
+	ESourceGroup *group;
+	ESource *source;
+	ECal *cal;
+
+	group = e_source_group_new ("", uri);
+	source = e_source_new ("", "");
+	e_source_set_group (source, group);
+
+	cal = e_cal_new (source, type);
+
+	g_object_unref (source);
+	g_object_unref (group);
+
+	return cal;
 }
 
 /**
Index: calendar/libecal/e-cal.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.h,v
retrieving revision 1.6
diff -u -p -r1.6 e-cal.h
--- calendar/libecal/e-cal.h	11 Nov 2003 16:59:04 -0000	1.6
+++ calendar/libecal/e-cal.h	24 Nov 2003 03:51:57 -0000
@@ -22,6 +22,7 @@
 #define E_CAL_H
 
 #include <glib-object.h>
+#include <libedataserver/e-source.h>
 #include <libecal/e-cal-recur.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-view.h>
@@ -93,7 +94,8 @@ GType e_cal_open_status_enum_get_type (v
 GType e_cal_set_mode_status_enum_get_type (void);
 GType cal_mode_enum_get_type (void);
 
-ECal *e_cal_new (const char *uri, CalObjType type);
+ECal *e_cal_new (ESource *source, CalObjType type);
+ECal *e_cal_new_from_uri (const gchar *uri, CalObjType type);
 
 void e_cal_set_auth_func (ECal *ecal, ECalAuthFunc func, gpointer data);
 
Index: calendar/libedata-cal/e-cal-backend.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.c,v
retrieving revision 1.2
diff -u -p -r1.2 e-cal-backend.c
--- calendar/libedata-cal/e-cal-backend.c	4 Nov 2003 03:28:32 -0000	1.2
+++ calendar/libedata-cal/e-cal-backend.c	24 Nov 2003 03:51:59 -0000
@@ -42,7 +42,10 @@ typedef struct {
 
 /* Private part of the CalBackend structure */
 struct _ECalBackendPrivate {
-	/* The uri for this backend */
+	/* The source for this backend */
+	ESource *source;
+
+	/* URI, from source. This is cached, since we return const. */
 	char *uri;
 
 	/* The kind of components for this backend */
@@ -70,6 +73,7 @@ struct _ECalBackendPrivate {
 /* Property IDs */
 enum props {
 	PROP_0,
+	PROP_SOURCE,
 	PROP_URI,
 	PROP_KIND
 };
@@ -136,9 +140,31 @@ e_cal_backend_set_property (GObject *obj
 	priv = backend->priv;
 	
 	switch (property_id) {
+	case PROP_SOURCE:
+		{
+			ESource *new_source;
+
+			new_source = g_value_get_object (value);
+			if (new_source)
+				g_object_ref (new_source);
+
+			if (priv->source)
+				g_object_unref (priv->source);
+
+			priv->source = new_source;
+
+			/* Cache the URI */
+			if (new_source) {
+				g_free (priv->uri);
+				priv->uri = e_source_get_uri (priv->source);
+			}
+		}
+		break;
 	case PROP_URI:
-		g_free (priv->uri);
-		priv->uri = g_value_dup_string (value);
+		if (!priv->source) {
+			g_free (priv->uri);
+			priv->uri = g_value_dup_string (value);
+		}
 		break;
 	case PROP_KIND:
 		priv->kind = g_value_get_ulong (value);
@@ -159,6 +185,9 @@ e_cal_backend_get_property (GObject *obj
 	priv = backend->priv;
 
 	switch (property_id) {
+	case PROP_SOURCE:
+		g_value_set_object (value, e_cal_backend_get_source (backend));
+		break;
 	case PROP_URI:
 		g_value_set_string (value, e_cal_backend_get_uri (backend));
 		break;
@@ -185,6 +214,11 @@ e_cal_backend_class_init (ECalBackendCla
 	object_class->get_property = e_cal_backend_get_property;
 	object_class->finalize = e_cal_backend_finalize;
 
+	g_object_class_install_property (object_class, PROP_SOURCE, 
+					 g_param_spec_object ("source", NULL, NULL, E_TYPE_SOURCE,
+							      G_PARAM_READABLE | G_PARAM_WRITABLE
+							      | G_PARAM_CONSTRUCT_ONLY));
+
 	g_object_class_install_property (object_class, PROP_URI, 
 					 g_param_spec_string ("uri", NULL, NULL, "",
 							      G_PARAM_READABLE | G_PARAM_WRITABLE
@@ -322,6 +356,19 @@ e_cal_backend_finalize (GObject *object)
 }
 
 
+
+ESource *
+e_cal_backend_get_source (ECalBackend *backend)
+{
+	ECalBackendPrivate *priv;
+	
+	g_return_val_if_fail (backend != NULL, NULL);
+	g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
+
+	priv = backend->priv;
+	
+	return priv->source;
+}
 
 /**
  * e_cal_backend_get_uri:
Index: calendar/libedata-cal/e-cal-backend.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend.h,v
retrieving revision 1.4
diff -u -p -r1.4 e-cal-backend.h
--- calendar/libedata-cal/e-cal-backend.h	6 Nov 2003 00:33:17 -0000	1.4
+++ calendar/libedata-cal/e-cal-backend.h	24 Nov 2003 03:52:00 -0000
@@ -25,6 +25,7 @@
 #define E_CAL_BACKEND_H
 
 #include <libedataserver/e-list.h>
+#include <libedataserver/e-source.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-component.h>
 #include <libedata-cal/Evolution-DataServer-Calendar.h>
@@ -110,6 +111,7 @@ struct _ECalBackendClass {
 
 GType e_cal_backend_get_type (void);
 
+ESource *e_cal_backend_get_source (ECalBackend *backend);
 const char *e_cal_backend_get_uri (ECalBackend *backend);
 icalcomponent_kind e_cal_backend_get_kind (ECalBackend *backend);
 
Index: calendar/libedata-cal/e-data-cal-factory.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-data-cal-factory.c,v
retrieving revision 1.3
diff -u -p -r1.3 e-data-cal-factory.c
--- calendar/libedata-cal/e-data-cal-factory.c	4 Nov 2003 21:53:02 -0000	1.3
+++ calendar/libedata-cal/e-data-cal-factory.c	24 Nov 2003 03:52:02 -0000
@@ -24,6 +24,7 @@
 #include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-main.h>
 #include <libedataserver/e-url.h>
+#include <libedataserver/e-source.h>
 #include "e-cal-backend.h"
 #include "e-data-cal.h"
 #include "e-data-cal-factory.h"
@@ -148,7 +149,7 @@ backend_last_client_gone_cb (ECalBackend
 
 static GNOME_Evolution_Calendar_Cal
 impl_CalFactory_getCal (PortableServer_Servant servant,
-			const CORBA_char *str_uri,
+			const CORBA_char *source_xml,
 			const GNOME_Evolution_Calendar_CalObjType type,
 			const GNOME_Evolution_Calendar_CalListener listener,
 			CORBA_Environment *ev)
@@ -160,14 +161,34 @@ impl_CalFactory_getCal (PortableServer_S
 	CORBA_Environment ev2;
 	GNOME_Evolution_Calendar_CalListener listener_copy;
 	GType backend_type;
+	ESource *source;
+	char *str_uri;
 	EUri *uri;
 	char *uri_string;
 	
 	factory = E_DATA_CAL_FACTORY (bonobo_object_from_servant (servant));
 	priv = factory->priv;
 
+	source = e_source_new_from_standalone_xml (source_xml);
+	if (!source) {
+		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
+
+		return CORBA_OBJECT_NIL;
+	}
+
+	/* Get the URI so we can extract the protocol */
+	str_uri = e_source_get_uri (source);
+	if (!str_uri) {
+		g_object_unref (source);
+		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
+
+		return CORBA_OBJECT_NIL;
+	}
+
 	/* Parse the uri */
 	uri = e_uri_new (str_uri);
+	g_free (str_uri);
+
 	if (!uri) {
 		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI);
 
@@ -179,6 +200,7 @@ impl_CalFactory_getCal (PortableServer_S
 	backend_type = get_backend_type (priv->methods, uri->protocol, calobjtype_to_icalkind (type));
 	if (!backend_type) {
 		/* FIXME Distinguish between method and kind failures? */
+		g_print ("No backend type.\n");
 		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
 		goto cleanup;
 	}
@@ -199,7 +221,7 @@ impl_CalFactory_getCal (PortableServer_S
 	backend = lookup_backend (factory, uri_string);
 	if (!backend) {
 		/* There was no existing backend, create a new one */
-		backend = g_object_new (backend_type, "uri", uri_string, "kind", calobjtype_to_icalkind (type), NULL);
+		backend = g_object_new (backend_type, "source", source, "kind", calobjtype_to_icalkind (type), NULL);
 		if (!backend) {
 			g_warning (G_STRLOC ": could not instantiate backend");
 			bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod);
@@ -228,6 +250,7 @@ impl_CalFactory_getCal (PortableServer_S
  cleanup:
 	e_uri_free (uri);
 	g_free (uri_string);
+	g_object_unref (source);
 
 	return CORBA_Object_duplicate (BONOBO_OBJREF (cal), ev);
 }
@@ -373,7 +396,7 @@ e_data_cal_factory_register_storage (EDa
 		return TRUE;
 
 	case Bonobo_ACTIVATION_REG_NOT_LISTED:
-		g_warning (G_STRLOC ": cannot register the calendar factory (not listed)");
+		g_warning (G_STRLOC ": cannot register the calendar factory %s (not listed)", tmp_iid);
 		break;
 
 	case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
Index: libedataserver/e-source.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-source.c,v
retrieving revision 1.4
diff -u -p -r1.4 e-source.c
--- libedataserver/e-source.c	14 Nov 2003 22:02:10 -0000	1.4
+++ libedataserver/e-source.c	24 Nov 2003 03:52:12 -0000
@@ -46,6 +46,7 @@ struct _ESourcePrivate {
 	char *uid;
 	char *name;
 	char *relative_uri;
+	char *absolute_uri;
 
 	gboolean has_color;
 	guint32 color;
@@ -83,6 +84,7 @@ impl_finalize (GObject *object)
 	g_free (priv->uid);
 	g_free (priv->name);
 	g_free (priv->relative_uri);
+	g_free (priv->absolute_uri);
 	g_free (priv);
 
 	(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -213,15 +215,17 @@ e_source_update_from_xml_node (ESource *
 {
 	xmlChar *name;
 	xmlChar *relative_uri;
+	xmlChar *absolute_uri;
 	xmlChar *color_string;
 	gboolean retval;
 	gboolean changed = FALSE;
 
 	name = xmlGetProp (node, "name");
 	relative_uri = xmlGetProp (node, "relative_uri");
+	absolute_uri = xmlGetProp (node, "uri");
 	color_string = xmlGetProp (node, "color");
 
-	if (name == NULL || relative_uri == NULL) {
+	if (name == NULL || (relative_uri == NULL && absolute_uri == NULL)) {
 		retval = FALSE;
 		goto done;
 	}
@@ -239,6 +243,12 @@ e_source_update_from_xml_node (ESource *
 		changed = TRUE;
 	}
 
+	if (absolute_uri != NULL) {
+		g_free (source->priv->absolute_uri);
+		source->priv->absolute_uri = g_strdup (absolute_uri);
+		changed = TRUE;
+	}
+
 	if (color_string == NULL) {
 		if (source->priv->has_color) {
 			source->priv->has_color = FALSE;
@@ -268,6 +278,8 @@ e_source_update_from_xml_node (ESource *
 		xmlFree (name);
 	if (relative_uri != NULL)
 		xmlFree (relative_uri);
+	if (absolute_uri != NULL)
+		xmlFree (absolute_uri);
 	if (color_string != NULL)
 		xmlFree (color_string);
 
@@ -443,8 +455,12 @@ e_source_get_uri (ESource *source)
 
 	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
 
-	if (source->priv->group == NULL)
+	if (source->priv->group == NULL) {
+		if (source->priv->absolute_uri != NULL)
+			return g_strdup (source->priv->absolute_uri);
+
 		return NULL;
+	}
 
 	base_uri_str = e_source_group_peek_base_uri (source->priv->group);
 
@@ -461,16 +477,18 @@ e_source_get_uri (ESource *source)
 }
 
 
-void
-e_source_dump_to_xml_node (ESource *source,
-			   xmlNodePtr parent_node)
+static xmlNodePtr
+dump_common_to_xml_node (ESource *source,
+			 xmlNodePtr parent_node)
 {
 	gboolean has_color;
 	guint32 color;
-	xmlNodePtr node = xmlNewChild (parent_node, NULL, "source", NULL);
-
-	g_return_if_fail (E_IS_SOURCE (source));
+	xmlNodePtr node;
 
+	if (parent_node)
+		node = xmlNewChild (parent_node, NULL, "source", NULL);
+	else
+		node = xmlNewNode (NULL, "source");
 
 	xmlSetProp (node, "uid", e_source_peek_uid (source));
 	xmlSetProp (node, "name", e_source_peek_name (source));
@@ -482,4 +500,72 @@ e_source_dump_to_xml_node (ESource *sour
 		xmlSetProp (node, "color", color_string);
 		g_free (color_string);
 	}
+
+	return node;
+}
+
+
+void
+e_source_dump_to_xml_node (ESource *source,
+			   xmlNodePtr parent_node)
+{
+	g_return_if_fail (E_IS_SOURCE (source));
+
+	dump_common_to_xml_node (source, parent_node);
+}
+
+
+char *
+e_source_to_standalone_xml (ESource *source)
+{
+	xmlDocPtr doc;
+	xmlNodePtr node;
+	xmlChar *xml_buffer;
+	char *returned_buffer;
+	int xml_buffer_size;
+	gchar *uri;
+
+	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
+	g_return_val_if_fail (source->priv->group != NULL, NULL);
+
+	doc = xmlNewDoc ("1.0");
+	node = dump_common_to_xml_node (source, NULL);
+
+	xmlDocSetRootElement (doc, node);
+
+	uri = e_source_get_uri (source);
+	xmlSetProp (node, "uri", uri);
+	g_free (uri);
+
+	xmlDocDumpMemory (doc, &xml_buffer, &xml_buffer_size);
+	xmlFreeDoc (doc);
+
+	returned_buffer = g_malloc (xml_buffer_size + 1);
+	memcpy (returned_buffer, xml_buffer, xml_buffer_size);
+	returned_buffer [xml_buffer_size] = '\0';
+	xmlFree (xml_buffer);
+
+	return returned_buffer;
+}
+
+
+ESource *
+e_source_new_from_standalone_xml (const char *xml)
+{
+	xmlDocPtr doc;
+	xmlNodePtr root;
+	ESource *source;
+
+	doc = xmlParseDoc ((char *) xml);
+	if (doc == NULL)
+		return NULL;
+
+	root = doc->children;
+	if (strcmp (root->name, "source") != 0)
+		return NULL;
+
+	source = e_source_new_from_xml_node (root);
+	xmlFreeDoc (doc);
+
+	return source;
 }
Index: libedataserver/e-source.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-source.h,v
retrieving revision 1.2
diff -u -p -r1.2 e-source.h
--- libedataserver/e-source.h	21 Oct 2003 18:51:19 -0000	1.2
+++ libedataserver/e-source.h	24 Nov 2003 03:52:12 -0000
@@ -58,6 +58,7 @@ GType    e_source_get_type (void);
 ESource *e_source_new                (const char   *name,
 				      const char   *relative_uri);
 ESource *e_source_new_from_xml_node  (xmlNodePtr    node);
+ESource *e_source_new_from_standalone_xml (const char *xml);
 
 gboolean  e_source_update_from_xml_node  (ESource    *source,
 					  xmlNodePtr  node,
@@ -86,6 +87,7 @@ char *e_source_get_uri  (ESource *source
 
 void  e_source_dump_to_xml_node  (ESource    *source,
 				  xmlNodePtr  parent_node);
+char *e_source_to_standalone_xml (ESource *source);
 
 
 #endif /* _E_SOURCE_H_ */
? evolution-be-sources.diff
? my-autogen.sh
? my-env.sh
? addressbook/log.diff
Index: calendar/gui/calendar-offline-handler.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-offline-handler.c,v
retrieving revision 1.19
diff -u -p -r1.19 calendar-offline-handler.c
--- calendar/gui/calendar-offline-handler.c	18 Nov 2003 04:24:22 -0000	1.19
+++ calendar/gui/calendar-offline-handler.c	24 Nov 2003 03:51:24 -0000
@@ -183,7 +183,7 @@ backend_go_offline (gpointer data, gpoin
 	gboolean success;
 	GError *error = NULL;
 	
-	client = e_cal_new (uri, CALOBJ_TYPE_ANY);
+	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_ANY);
 	g_signal_connect (client, "cal_opened", G_CALLBACK (backend_cal_opened_offline), offline_handler);
 	success = e_cal_open (client, TRUE, &error);
 	if (!success) {
@@ -204,7 +204,7 @@ backend_go_online (gpointer data, gpoint
 	gboolean success;
 	GError *error = NULL;
 	
-	client = e_cal_new (uri, CALOBJ_TYPE_ANY);
+	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_ANY);
 	g_signal_connect (G_OBJECT (client), "cal_opened", 
 			  G_CALLBACK (backend_cal_opened_online), offline_handler);
 	success = e_cal_open (client, TRUE, &error);
@@ -327,7 +327,7 @@ calendar_offline_handler_init (CalendarO
 	offline_handler->priv = priv;
 
 	/* FIXME: what URI to use? */
-	priv->client = e_cal_new ("", CALOBJ_TYPE_ANY);
+	priv->client = e_cal_new_from_uri ("", CALOBJ_TYPE_ANY);
 	priv->listener_interface = CORBA_OBJECT_NIL;
 	priv->is_offline = FALSE;
 }
Index: calendar/gui/comp-editor-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/comp-editor-factory.c,v
retrieving revision 1.28
diff -u -p -r1.28 comp-editor-factory.c
--- calendar/gui/comp-editor-factory.c	11 Nov 2003 17:11:09 -0000	1.28
+++ calendar/gui/comp-editor-factory.c	24 Nov 2003 03:51:24 -0000
@@ -494,7 +494,7 @@ open_client (CompEditorFactory *factory,
 
 	priv = factory->priv;
 
-	client = e_cal_new (uristr, CALOBJ_TYPE_ANY);
+	client = e_cal_new_from_uri (uristr, CALOBJ_TYPE_ANY);
 	if (!client)
 		return NULL;
 
Index: calendar/gui/e-itip-control.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-itip-control.c,v
retrieving revision 1.132
diff -u -p -r1.132 e-itip-control.c
--- calendar/gui/e-itip-control.c	20 Nov 2003 15:11:37 -0000	1.132
+++ calendar/gui/e-itip-control.c	24 Nov 2003 03:51:32 -0000
@@ -135,7 +135,7 @@ start_calendar_server (EItipControl *iti
 	ECal *client;
 	GError *error = NULL;
 
-	client = e_cal_new (uri, CALOBJ_TYPE_EVENT);
+	client = e_cal_new_from_uri (uri, CALOBJ_TYPE_EVENT);
 
 	if (!e_cal_open (client, TRUE, &error)) {
 		g_warning (_("start_calendar_server(): %s"), error->message);
@@ -2209,11 +2209,11 @@ object_requested_cb (GtkHTML *html, GtkH
 
 	switch (vtype) {
 	case E_CAL_COMPONENT_EVENT:
-		context->client = e_cal_new ("", CALOBJ_TYPE_EVENT);
+		context->client = e_cal_new_from_uri ("", CALOBJ_TYPE_EVENT);
 		success = start_default_server (itip, context->client, FALSE);
 		break;
 	case E_CAL_COMPONENT_TODO:
-		context->client = e_cal_new ("", CALOBJ_TYPE_TODO);
+		context->client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO);
 		success = start_default_server (itip, context->client, TRUE);
 		break;
 	default:
Index: calendar/gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.62
diff -u -p -r1.62 e-tasks.c
--- calendar/gui/e-tasks.c	17 Nov 2003 01:20:38 -0000	1.62
+++ calendar/gui/e-tasks.c	24 Nov 2003 03:51:35 -0000
@@ -850,7 +850,7 @@ e_tasks_add_todo_uri (ETasks *tasks, con
 	if (client)
 		return TRUE;
 	
-	client = e_cal_new (str_uri, CALOBJ_TYPE_TODO);
+	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_TODO);
 	g_hash_table_insert (priv->clients, g_strdup (str_uri), client);
 	priv->clients_list = g_list_prepend (priv->clients_list, client);
 	
Index: calendar/gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.274
diff -u -p -r1.274 gnome-cal.c
--- calendar/gui/gnome-cal.c	18 Nov 2003 04:24:22 -0000	1.274
+++ calendar/gui/gnome-cal.c	24 Nov 2003 03:51:42 -0000
@@ -2032,7 +2032,7 @@ gnome_calendar_construct (GnomeCalendar 
 	/*
 	 * TaskPad Folder Client.
 	 */
-	priv->task_pad_client = e_cal_new ("", CALOBJ_TYPE_TODO); /* FIXME: use default tasks */
+	priv->task_pad_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME: use default tasks */
 	if (!priv->task_pad_client)
 		return NULL;
 
@@ -2161,7 +2161,7 @@ gnome_calendar_add_event_uri (GnomeCalen
 	if (client)
 		return TRUE;
 	
-	client = e_cal_new (str_uri, CALOBJ_TYPE_EVENT);
+	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_EVENT);
 	g_hash_table_insert (priv->clients, g_strdup (str_uri), client);
 	priv->clients_list = g_list_prepend (priv->clients_list, client);
 	
Index: calendar/gui/alarm-notify/alarm-notify.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-notify.c,v
retrieving revision 1.26
diff -u -p -r1.26 alarm-notify.c
--- calendar/gui/alarm-notify/alarm-notify.c	17 Nov 2003 13:13:13 -0000	1.26
+++ calendar/gui/alarm-notify/alarm-notify.c	24 Nov 2003 03:51:43 -0000
@@ -279,7 +279,7 @@ alarm_notify_add_calendar (AlarmNotify *
 	if (g_hash_table_lookup (priv->uri_client_hash, str_uri))
 		return;
 
-	client = e_cal_new (str_uri, CALOBJ_TYPE_EVENT);
+	client = e_cal_new_from_uri (str_uri, CALOBJ_TYPE_EVENT);
 
 	if (client) {
 		if (e_cal_open (client, FALSE, NULL)) {
Index: calendar/gui/dialogs/copy-source-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/copy-source-dialog.c,v
retrieving revision 1.2
diff -u -p -r1.2 copy-source-dialog.c
--- calendar/gui/dialogs/copy-source-dialog.c	23 Nov 2003 23:58:47 -0000	1.2
+++ calendar/gui/dialogs/copy-source-dialog.c	24 Nov 2003 03:51:44 -0000
@@ -62,9 +62,7 @@ copy_source (CopySourceDialogData *csdd)
 		return FALSE;
 
 	/* open the source */
-	uri = e_source_get_uri (csdd->orig_source);
-	source_client = e_cal_new (uri, csdd->obj_type);
-	g_free (uri);
+	source_client = e_cal_new (csdd->orig_source, csdd->obj_type);
 	if (!e_cal_open (source_client, TRUE, NULL)) {
 		g_object_unref (source_client);
 		g_warning (G_STRLOC ": Could not open source");
@@ -72,9 +70,7 @@ copy_source (CopySourceDialogData *csdd)
 	}
 
 	/* open the destination */
-	uri = e_source_get_uri (dest_source);
-	dest_client = e_cal_new (uri, csdd->obj_type);
-	g_free (uri);
+	dest_client = e_cal_new (dest_source, csdd->obj_type);
 	if (!e_cal_open (dest_client, FALSE, NULL)) {
 		g_object_unref (dest_client);
 		g_object_unref (source_client);
Index: calendar/importers/icalendar-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/importers/icalendar-importer.c,v
retrieving revision 1.25
diff -u -p -r1.25 icalendar-importer.c
--- calendar/importers/icalendar-importer.c	19 Nov 2003 11:43:42 -0000	1.25
+++ calendar/importers/icalendar-importer.c	24 Nov 2003 03:51:46 -0000
@@ -376,9 +376,9 @@ load_file_fn (EvolutionImporter *importe
 
 			/* create ECal's */
 			if (!ici->client)
-				ici->client = e_cal_new (real_uri, CALOBJ_TYPE_EVENT);
+				ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
 			if (!ici->tasks_client)
-				ici->tasks_client = e_cal_new ("", CALOBJ_TYPE_TODO); /* FIXME */
+				ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME */
 
 			if (e_cal_open (ici->client, TRUE, NULL)
 			    && e_cal_open (ici->tasks_client, FALSE, NULL)) {
@@ -528,9 +528,9 @@ vcal_load_file_fn (EvolutionImporter *im
 
 		/* create ECal's */
 		if (!ici->client)
-			ici->client = e_cal_new (real_uri, CALOBJ_TYPE_EVENT);
+			ici->client = e_cal_new_from_uri (real_uri, CALOBJ_TYPE_EVENT);
 		if (!ici->tasks_client)
-			ici->tasks_client = e_cal_new ("", CALOBJ_TYPE_TODO);
+			ici->tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO);
 
 		if (e_cal_open (ici->client, TRUE, NULL)
 		    && e_cal_open (ici->tasks_client, FALSE, NULL)) {
@@ -616,13 +616,13 @@ gnome_calendar_import_data_fn (Evolution
 
 	/* Try to open the default calendar & tasks folders. */
 	if (ici->do_calendar) {
-		calendar_client = e_cal_new ("", CALOBJ_TYPE_EVENT); /* FIXME: use default folder */
+		calendar_client = e_cal_new_from_uri ("", CALOBJ_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 ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */
+		tasks_client = e_cal_new_from_uri ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */
 		if (!e_cal_open (tasks_client, FALSE, NULL))
 			goto out;
 	}


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