Prefer e_source_registry_check_enabled().
authorMatthew Barnes <mbarnes@redhat.com>
Thu, 25 Oct 2012 14:59:59 +0000 (10:59 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Thu, 25 Oct 2012 17:03:08 +0000 (13:03 -0400)
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
libedataserver/e-source-registry.c
libedataserverui/e-name-selector-entry.c
libedataserverui/e-name-selector.c

index 407f230..fb2376c 100644 (file)
@@ -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);
index d37a84f..5664135 100644 (file)
@@ -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;
                }
index 380f6a5..cd8cc79 100644 (file)
@@ -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. */
index ddbb067..90575df 100644 (file)
@@ -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,