[evolution-data-server/openismus-work-master: 13/18] ESourceRegistry: Do not mandate builtin sources.



commit a933b331325405f77c9451892a65982cb2f52745
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Thu Dec 13 16:14:19 2012 +0900

    ESourceRegistry: Do not mandate builtin sources.
    
    This patch removes return_if_fail() critical warnings from
    e_source_registry_ref_[default,builtin]_address_book() and
    e_source_registry_ref_[default,builtin]_calendar(). This
    avoids the console warnings when running make check.
    
    Also, this patch fixes several locations in EDS where the
    above functions blindly expect an #ESource to be returned.

 addressbook/backends/file/e-book-backend-file.c |    5 +++--
 addressbook/libebook/e-book-client.c            |    1 +
 calendar/backends/file/e-cal-backend-file.c     |    5 +++--
 libedataserver/e-source-registry.c              |   10 ++--------
 tests/libebook/client/client-test-utils.c       |    1 +
 5 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index e29c73a..891b962 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -243,7 +243,7 @@ e_book_backend_file_extract_path_from_source (ESourceRegistry *registry,
 	 * "system-$COMPONENT" but since the data directories are already
 	 * split out by component, we'll continue to use the old "system"
 	 * directories for these particular data sources. */
-	if (e_source_equal (source, builtin_source))
+	if (builtin_source != NULL && e_source_equal (source, builtin_source))
 		uid = "system";
 
 	switch (path_type) {
@@ -259,7 +259,8 @@ e_book_backend_file_extract_path_from_source (ESourceRegistry *registry,
 			g_warn_if_reached ();
 	}
 
-	g_object_unref (builtin_source);
+	if (builtin_source)
+		g_object_unref (builtin_source);
 
 	return filename;
 }
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 3d7a949..c83f67a 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -1232,6 +1232,7 @@ e_book_client_get_self (ESourceRegistry *registry,
 	g_return_val_if_fail (E_IS_BOOK_CLIENT (client), FALSE);
 
 	source = e_source_registry_ref_builtin_address_book (registry);
+	g_return_val_if_fail (source != NULL, FALSE);
 	*client = e_book_client_new (source, &local_error);
 	g_object_unref (source);
 
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 00fa8d0..cd4ac34 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -3431,14 +3431,15 @@ cal_backend_file_constructed (GObject *object)
 	 * "system-$COMPONENT" but since the data directories are already
 	 * split out by component, we'll continue to use the old "system"
 	 * directories for these particular data sources. */
-	if (e_source_equal (source, builtin_source))
+	if (builtin_source != NULL && e_source_equal (source, builtin_source))
 		uid = "system";
 
 	filename = g_build_filename (user_data_dir, component_type, uid, NULL);
 	e_cal_backend_set_cache_dir (backend, filename);
 	g_free (filename);
 
-	g_object_unref (builtin_source);
+	if (builtin_source)
+		g_object_unref (builtin_source);
 }
 
 /* Class initialization function for the file backend */
diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index 93ae50b..5d2c553 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -2743,7 +2743,6 @@ e_source_registry_ref_builtin_address_book (ESourceRegistry *registry)
 
 	uid = E_SOURCE_BUILTIN_ADDRESS_BOOK_UID;
 	source = e_source_registry_ref_source (registry, uid);
-	g_return_val_if_fail (source != NULL, NULL);
 
 	return source;
 }
@@ -2777,12 +2776,10 @@ e_source_registry_ref_default_address_book (ESourceRegistry *registry)
 	source = e_source_registry_ref_source (registry, uid);
 	g_free (uid);
 
-	/* The built-in source is always present. */
+	/* The built-in source is present in normal EDS installations. */
 	if (source == NULL)
 		source = e_source_registry_ref_builtin_address_book (registry);
 
-	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
-
 	return source;
 }
 
@@ -2845,7 +2842,6 @@ e_source_registry_ref_builtin_calendar (ESourceRegistry *registry)
 
 	uid = E_SOURCE_BUILTIN_CALENDAR_UID;
 	source = e_source_registry_ref_source (registry, uid);
-	g_return_val_if_fail (source != NULL, NULL);
 
 	return source;
 }
@@ -2879,12 +2875,10 @@ e_source_registry_ref_default_calendar (ESourceRegistry *registry)
 	source = e_source_registry_ref_source (registry, uid);
 	g_free (uid);
 
-	/* The built-in source is always present. */
+	/* The built-in source is present in normal EDS installations. */
 	if (source == NULL)
 		source = e_source_registry_ref_builtin_calendar (registry);
 
-	g_return_val_if_fail (E_IS_SOURCE (source), NULL);
-
 	return source;
 }
 
diff --git a/tests/libebook/client/client-test-utils.c b/tests/libebook/client/client-test-utils.c
index 1da94dc..7a8bcb7 100644
--- a/tests/libebook/client/client-test-utils.c
+++ b/tests/libebook/client/client-test-utils.c
@@ -77,6 +77,7 @@ open_system_book (ESourceRegistry *registry,
 	main_initialize ();
 
 	source = e_source_registry_ref_builtin_address_book (registry);
+	g_return_val_if_fail (source != NULL, NULL);
 	book_client = e_book_client_new (source, &error);
 	g_object_unref (source);
 



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