[evolution-data-server] Prefer e_source_registry_check_enabled().



commit fd738f119636cdaacfb44bf7fa64e93008f31198
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Oct 25 10:59:59 2012 -0400

    Prefer e_source_registry_check_enabled().
    
    Prefer e_source_registry_check_enabled() over e_source_get_enabled()
    for most instances where we want to exclude disabled data sources.

 calendar/libedata-cal/e-cal-backend-util.c |    4 +-
 libedataserver/e-source-registry.c         |    2 +-
 libedataserverui/e-name-selector-entry.c   |   37 +---------------------------
 libedataserverui/e-name-selector.c         |   37 +---------------------------
 4 files changed, 5 insertions(+), 75 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-util.c b/calendar/libedata-cal/e-cal-backend-util.c
index 407f230..fb2376c 100644
--- a/calendar/libedata-cal/e-cal-backend-util.c
+++ b/calendar/libedata-cal/e-cal-backend-util.c
@@ -102,7 +102,7 @@ e_cal_backend_mail_account_is_valid (ESourceRegistry *registry,
 		gboolean match = FALSE;
 		gchar *address;
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
@@ -227,7 +227,7 @@ e_cal_backend_user_declined (ESourceRegistry *registry,
 		ESourceMailIdentity *extension;
 		const gchar *address;
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension = e_source_get_extension (source, extension_name);
diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index d37a84f..5664135 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -2918,7 +2918,7 @@ source_registry_ref_any_mail_identity (ESourceRegistry *registry)
 	for (link = list; link != NULL; link = g_list_next (link)) {
 		ESource *candidate = E_SOURCE (link->data);
 
-		if (e_source_get_enabled (candidate)) {
+		if (e_source_registry_check_enabled (registry, candidate)) {
 			source = g_object_ref (candidate);
 			break;
 		}
diff --git a/libedataserverui/e-name-selector-entry.c b/libedataserverui/e-name-selector-entry.c
index 380f6a5..cd8cc79 100644
--- a/libedataserverui/e-name-selector-entry.c
+++ b/libedataserverui/e-name-selector-entry.c
@@ -2169,41 +2169,6 @@ ensure_type_ahead_complete_on_timeout (ENameSelectorEntry *name_selector_entry)
 		type_ahead_complete_on_timeout_cb, name_selector_entry);
 }
 
-static gboolean
-is_source_enabled_with_parents (ESourceRegistry *registry,
-                                ESource *source)
-{
-	ESource *parent;
-	const gchar *parent_uid;
-
-	g_return_val_if_fail (registry != NULL, FALSE);
-	g_return_val_if_fail (source != NULL, FALSE);
-
-	if (!e_source_get_enabled (source))
-		return FALSE;
-
-	parent = g_object_ref (source);
-	while (parent_uid = e_source_get_parent (parent), parent_uid) {
-		ESource *next = e_source_registry_ref_source (registry, parent_uid);
-
-		if (!next)
-			break;
-
-		g_object_unref (parent);
-
-		if (!e_source_get_enabled (next)) {
-			g_object_unref (next);
-			return FALSE;
-		}
-
-		parent = next;
-	}
-
-	g_object_unref (parent);
-
-	return TRUE;
-}
-
 static void
 setup_contact_store (ENameSelectorEntry *name_selector_entry)
 {
@@ -2310,7 +2275,7 @@ setup_default_contact_store (ENameSelectorEntry *name_selector_entry)
 		extension = e_source_get_extension (source, extension_name);
 
 		/* Skip disabled address books. */
-		if (!is_source_enabled_with_parents (registry, source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		/* Skip non-completion address books. */
diff --git a/libedataserverui/e-name-selector.c b/libedataserverui/e-name-selector.c
index ddbb067..90575df 100644
--- a/libedataserverui/e-name-selector.c
+++ b/libedataserverui/e-name-selector.c
@@ -69,41 +69,6 @@ enum {
 
 G_DEFINE_TYPE (ENameSelector, e_name_selector, G_TYPE_OBJECT)
 
-static gboolean
-is_source_enabled_with_parents (ESourceRegistry *registry,
-                                ESource *source)
-{
-	ESource *parent;
-	const gchar *parent_uid;
-
-	g_return_val_if_fail (registry != NULL, FALSE);
-	g_return_val_if_fail (source != NULL, FALSE);
-
-	if (!e_source_get_enabled (source))
-		return FALSE;
-
-	parent = g_object_ref (source);
-	while (parent_uid = e_source_get_parent (parent), parent_uid) {
-		ESource *next = e_source_registry_ref_source (registry, parent_uid);
-
-		if (!next)
-			break;
-
-		g_object_unref (parent);
-
-		if (!e_source_get_enabled (next)) {
-			g_object_unref (next);
-			return FALSE;
-		}
-
-		parent = next;
-	}
-
-	g_object_unref (parent);
-
-	return TRUE;
-}
-
 static void
 reset_pointer_cb (gpointer data,
                   GObject *where_was)
@@ -213,7 +178,7 @@ e_name_selector_load_books (ENameSelector *name_selector)
 		extension = e_source_get_extension (source, extension_name);
 
 		/* Skip disabled address books. */
-		if (!is_source_enabled_with_parents (registry, source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		/* Only load address books with autocomplete enabled,



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