[evolution-data-server] Pass the source XML instead of URL when opening books



commit 4046744ffdf5c3400f46ebc97a2deb73e499099d
Author: Ross Burton <ross linux intel com>
Date:   Mon Jul 6 15:44:26 2009 +0100

    Pass the source XML instead of URL when opening books

 addressbook/libebook/e-book.c                   |    8 ++++++--
 addressbook/libedata-book/e-data-book-factory.c |   19 ++++++++++++-------
 2 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 3939b2b..e51e5f7 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -2031,7 +2031,7 @@ e_book_new (ESource *source, GError **error)
 {
 	GError *err = NULL;
 	EBook *book;
-	char *path;
+	char *path, *xml;
 
 	e_return_error_if_fail (E_IS_SOURCE (source), E_BOOK_ERROR_INVALID_ARG);
 
@@ -2046,12 +2046,16 @@ e_book_new (ESource *source, GError **error)
 	book->priv->source = g_object_ref (source);
 	book->priv->uri = e_source_get_uri (source);
 
-	if (!org_gnome_evolution_dataserver_addressbook_BookFactory_get_book (factory_proxy, book->priv->uri, &path, &err)) {
+	xml = e_source_to_standalone_xml (source);
+
+	if (!org_gnome_evolution_dataserver_addressbook_BookFactory_get_book (factory_proxy, xml, &path, &err)) {
+		g_free (xml);
 		g_warning (G_STRLOC ": cannot get book from factory: %s", err ? err->message : "[no error]");
 		g_propagate_error (error, err);
 		g_object_unref (book);
 		return NULL;
 	}
+	g_free (xml);
 
 	book->priv->proxy = dbus_g_proxy_new_for_name_owner (connection,
 							     E_DATA_BOOK_FACTORY_SERVICE_NAME, path,
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index a3bd588..b05234e 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -232,15 +232,15 @@ book_closed_cb (EDataBook *book, const char *client)
 }
 
 static void
-impl_BookFactory_getBook(EDataBookFactory *factory, const char *IN_uri, DBusGMethodInvocation *context)
+impl_BookFactory_getBook(EDataBookFactory *factory, const char *IN_source, DBusGMethodInvocation *context)
 {
 	EDataBook *book;
 	EDataBookFactoryPrivate *priv = factory->priv;
 	ESource *source;
-	char *path, *sender;
+	char *uri, *path, *sender;
 	GList *list;
 
-	if (IN_uri == NULL || IN_uri[0] == '\0') {
+	if (IN_source == NULL || IN_source[0] == '\0') {
 		dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Empty URI")));
 		return;
 	}
@@ -253,15 +253,20 @@ impl_BookFactory_getBook(EDataBookFactory *factory, const char *IN_uri, DBusGMet
 
 	g_mutex_lock (priv->books_lock);
 
-	source = e_source_new_with_absolute_uri ("", IN_uri);
-	path = make_path_name (IN_uri);
+	source = e_source_new_from_standalone_xml (IN_source);
+	if (!source) {
+		dbus_g_method_return_error (context, g_error_new (E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Invalid source")));
+	}
+
+	uri = e_source_get_uri (source);
+	path = make_path_name (uri);
 	book = g_hash_table_lookup (priv->books, path);
 	if (book == NULL) {
 		EBookBackend *backend = NULL;
-		backend = e_book_backend_factory_new_backend (e_data_book_factory_lookup_backend_factory (factory, IN_uri));
+		backend = e_book_backend_factory_new_backend (e_data_book_factory_lookup_backend_factory (factory, uri));
 		book = e_data_book_new (backend, source, book_closed_cb);
 		e_book_backend_set_mode (backend, 2); /* TODO: very odd */
-		g_hash_table_insert (priv->books, g_strdup(path), book);
+		g_hash_table_insert (priv->books, g_strdup (path), book);
 		dbus_g_connection_register_g_object (connection, path, G_OBJECT (book));
 		g_object_weak_ref (G_OBJECT (book), (GWeakNotify)my_remove, g_strdup (path));
 		g_object_unref (backend); /* The book takes a reference to the backend */



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