[evolution] Prefer e_source_registry_check_enabled().



commit aded0858c49c3b729564a35427e3affb514fffb9
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Oct 25 11:05:02 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/gui/itip-utils.c                |    6 ++--
 libemail-engine/e-mail-folder-utils.c    |    2 +-
 libemail-engine/e-mail-utils.c           |   39 +----------------------------
 libemail-engine/e-mail-utils.h           |    3 --
 mail/em-composer-utils.c                 |   12 +++++----
 mail/em-utils.c                          |    3 +-
 modules/itip-formatter/itip-view.c       |    6 ++--
 widgets/misc/e-mail-identity-combo-box.c |    3 +-
 8 files changed, 20 insertions(+), 54 deletions(-)
---
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index b7b31db..738baa3 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -188,7 +188,7 @@ itip_get_fallback_identity (ESourceRegistry *registry)
 	if (source == NULL)
 		return NULL;
 
-	if (!e_source_get_enabled (source)) {
+	if (!e_source_registry_check_enabled (registry, source)) {
 		g_object_unref (source);
 		return NULL;
 	}
@@ -439,7 +439,7 @@ itip_get_comp_attendee (ESourceRegistry *registry,
 
 		source = E_SOURCE (link->data);
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
@@ -1583,7 +1583,7 @@ find_enabled_identity (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/libemail-engine/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c
index 971a672..5f9ea6a 100644
--- a/libemail-engine/e-mail-folder-utils.c
+++ b/libemail-engine/e-mail-folder-utils.c
@@ -306,7 +306,7 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
 		extension = e_source_get_extension (source, extension_name);
 		backend_name = e_source_backend_get_backend_name (extension);
 
-		if (!em_utils_is_source_enabled_with_parents (registry, source) ||
+		if (!e_source_registry_check_enabled (registry, source) ||
 		    g_strcmp0 (backend_name, "pop") != 0)
 			continue;
 
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index 8f91971..d8a372e 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -1064,7 +1064,7 @@ mail_account_in_recipients (ESourceRegistry *registry,
 	gchar *address;
 
 	/* Disregard disabled mail accounts. */
-	if (!e_source_get_enabled (source))
+	if (!e_source_registry_check_enabled (registry, source))
 		return FALSE;
 
 	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
@@ -1176,7 +1176,7 @@ second_preference:
 	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
 		ESource *temp = E_SOURCE (iter->data);
 
-		if (em_utils_is_source_enabled_with_parents (registry, temp) &&
+		if (e_source_registry_check_enabled (registry, temp) &&
 		    mail_account_in_recipients (registry, temp, recipients)) {
 			source = g_object_ref (temp);
 			break;
@@ -1273,41 +1273,6 @@ em_utils_ref_mail_identity_for_store (ESourceRegistry *registry,
 	return source;
 }
 
-gboolean
-em_utils_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;
-}
-
 /**
  * em_utils_uids_free:
  * @uids: array of uids
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index e7521d6..1844b49 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -62,9 +62,6 @@ ESource *	em_utils_guess_mail_identity_with_recipients
 ESource *	em_utils_ref_mail_identity_for_store
 						(ESourceRegistry *registry,
 						 CamelStore *store);
-gboolean	em_utils_is_source_enabled_with_parents
-						(ESourceRegistry *registry,
-						 ESource *source);
 void		emu_remove_from_mail_cache	(const GSList *addresses);
 void		emu_remove_from_mail_cache_1	(const gchar *address);
 void		emu_free_mail_cache		(GDestroyNotify done_cb,
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index b978830..1978435 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -378,7 +378,7 @@ composer_presend_check_identity (EMsgComposer *composer,
 	source = e_source_registry_ref_source (registry, uid);
 	g_return_val_if_fail (source != NULL, FALSE);
 
-	if (!e_source_get_enabled (source)) {
+	if (!e_source_registry_check_enabled (registry, source)) {
 		e_alert_submit (
 			E_ALERT_SINK (composer),
 			"mail:send-no-account-enabled", NULL);
@@ -2450,8 +2450,10 @@ generate_recipient_hash (ESourceRegistry *registry)
 		 * identities at all and so we should never get here. */
 		g_warn_if_fail (default_source != NULL);
 
-		source_is_default = e_source_equal (source, default_source);
-		source_is_enabled = e_source_get_enabled (source);
+		source_is_default =
+			e_source_equal (source, default_source);
+		source_is_enabled =
+			e_source_registry_check_enabled (registry, source);
 
 		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
 		extension = e_source_get_extension (source, extension_name);
@@ -2466,8 +2468,8 @@ generate_recipient_hash (ESourceRegistry *registry)
 		if (cached_source != NULL) {
 			cached_is_default = e_source_equal (
 				cached_source, default_source);
-			cached_is_enabled =
-				e_source_get_enabled (cached_source);
+			cached_is_enabled = e_source_registry_check_enabled (
+				registry, cached_source);
 		} else {
 			cached_is_default = FALSE;
 			cached_is_enabled = FALSE;
diff --git a/mail/em-utils.c b/mail/em-utils.c
index f7f12e5..80967f1 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1424,7 +1424,8 @@ em_utils_empty_trash (GtkWidget *parent,
 		source = e_source_registry_ref_source (registry, uid);
 
 		if (source != NULL) {
-			enabled = e_source_get_enabled (source);
+			enabled = e_source_registry_check_enabled (
+				registry, source);
 			g_object_unref (source);
 		}
 
diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c
index 7e91f34..0b2565c 100644
--- a/modules/itip-formatter/itip-view.c
+++ b/modules/itip-formatter/itip-view.c
@@ -3265,7 +3265,7 @@ find_to_address (EMailPartItip *itip_part,
 		const gchar *address;
 		gchar *text;
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension = e_source_get_extension (source, extension_name);
@@ -3326,7 +3326,7 @@ find_to_address (EMailPartItip *itip_part,
 		const gchar *address;
 		gchar *text;
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension = e_source_get_extension (source, extension_name);
@@ -3415,7 +3415,7 @@ find_from_address (EMailPartItip *pitip,
 		ESourceMailIdentity *extension;
 		const gchar *address;
 
-		if (!e_source_get_enabled (source))
+		if (!e_source_registry_check_enabled (pitip->registry, source))
 			continue;
 
 		extension = e_source_get_extension (source, extension_name);
diff --git a/widgets/misc/e-mail-identity-combo-box.c b/widgets/misc/e-mail-identity-combo-box.c
index 465ef35..b76e0ee 100644
--- a/widgets/misc/e-mail-identity-combo-box.c
+++ b/widgets/misc/e-mail-identity-combo-box.c
@@ -325,7 +325,8 @@ e_mail_identity_combo_box_refresh (EMailIdentityComboBox *combo_box)
 		const gchar *uid;
 
 		source = E_SOURCE (link->data);
-		if (!e_source_get_enabled (source))
+
+		if (!e_source_registry_check_enabled (registry, source))
 			continue;
 
 		extension = e_source_get_extension (source, extension_name);



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