[evolution] Incorporate ESourceUOA.



commit fd43cd692ad12e7f9c70386c1b0867b16f9ec15d
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jan 31 16:14:49 2013 -0500

    Incorporate ESourceUOA.
    
    Where we make exceptions for GNOME Online Accounts, so too shall we for
    Ubuntu Online Accounts.

 libemail-engine/e-mail-session.c |   59 ++++++++++++++++++++++++++++++++-----
 mail/e-mail-account-store.c      |    7 ++++
 mail/e-mail-config-notebook.c    |   18 ++++++++---
 mail/e-mail-sidebar.c            |    9 +++++-
 4 files changed, 79 insertions(+), 14 deletions(-)
---
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 82c73c5..53d2e79 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -506,6 +506,27 @@ mail_session_check_goa_mail_disabled (EMailSession *session,
 	return goa_mail_disabled;
 }
 
+static gboolean
+mail_session_check_uoa_mail_disabled (EMailSession *session,
+                                      ESource *source)
+{
+	ESource *uoa_source;
+	ESourceRegistry *registry;
+	gboolean uoa_mail_disabled = FALSE;
+
+	registry = e_mail_session_get_registry (session);
+
+	uoa_source = e_source_registry_find_extension (
+		registry, source, E_SOURCE_EXTENSION_UOA);
+
+	if (uoa_source != NULL) {
+		uoa_mail_disabled = !e_source_get_enabled (source);
+		g_object_unref (uoa_source);
+	}
+
+	return uoa_mail_disabled;
+}
+
 static void
 mail_session_add_from_source (EMailSession *session,
                               CamelProviderType type,
@@ -547,6 +568,10 @@ mail_session_add_from_source (EMailSession *session,
 	if (mail_session_check_goa_mail_disabled (session, source))
 		return;
 
+	/* Same deal for the [Ubuntu Online Accounts] extension. */
+	if (mail_session_check_uoa_mail_disabled (session, source))
+		return;
+
 	service = camel_session_add_service (
 		CAMEL_SESSION (session), uid,
 		backend_name, type, &error);
@@ -630,17 +655,26 @@ mail_session_source_enabled_cb (ESourceRegistry *registry,
                                 EMailSession *session)
 {
 	ESource *goa_source;
+	ESource *uoa_source;
 
-	/* If the source is linked to a GNOME Online Account,
-	 * enabling the source is equivalent to adding it. */
+	/* If the source is linked to a GNOME Online Account
+	 * or Ubuntu Online Account, enabling the source is
+	 * equivalent to adding it. */
 
 	goa_source = e_source_registry_find_extension (
 		registry, source, E_SOURCE_EXTENSION_GOA);
 
-	if (goa_source != NULL) {
+	uoa_source = e_source_registry_find_extension (
+		registry, source, E_SOURCE_EXTENSION_UOA);
+
+	if (goa_source != NULL || uoa_source != NULL)
 		mail_session_source_added_cb (registry, source, session);
+
+	if (goa_source != NULL)
 		g_object_unref (goa_source);
-	}
+
+	if (uoa_source != NULL)
+		g_object_unref (uoa_source);
 }
 
 static void
@@ -649,17 +683,26 @@ mail_session_source_disabled_cb (ESourceRegistry *registry,
                                  EMailSession *session)
 {
 	ESource *goa_source;
+	ESource *uoa_source;
 
-	/* If the source is linked to a GNOME Online Account,
-	 * disabling the source is equivalent to removing it. */
+	/* If the source is linked to a GNOME Online Account
+	 * or Ubuntu Online Account, disabling the source is
+	 * equivalent to removing it. */
 
 	goa_source = e_source_registry_find_extension (
 		registry, source, E_SOURCE_EXTENSION_GOA);
 
-	if (goa_source != NULL) {
+	uoa_source = e_source_registry_find_extension (
+		registry, source, E_SOURCE_EXTENSION_UOA);
+
+	if (goa_source != NULL || uoa_source != NULL)
 		mail_session_source_removed_cb (registry, source, session);
+
+	if (goa_source != NULL)
 		g_object_unref (goa_source);
-	}
+
+	if (uoa_source != NULL)
+		g_object_unref (uoa_source);
 }
 
 static void
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index a2a639d..cb1f4e0 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -1153,6 +1153,13 @@ e_mail_account_store_add_service (EMailAccountStore *store,
 			enabled_visible = FALSE;
 		}
 
+		/* Check for Ubuntu Online Accounts linkage. */
+		extension_name = E_SOURCE_EXTENSION_UOA;
+		if (e_source_has_extension (collection, extension_name)) {
+			online_account = TRUE;
+			enabled_visible = FALSE;
+		}
+
 		g_object_unref (collection);
 	} else {
 		enabled = e_source_get_enabled (source);
diff --git a/mail/e-mail-config-notebook.c b/mail/e-mail-config-notebook.c
index 0aff802..fd43b20 100644
--- a/mail/e-mail-config-notebook.c
+++ b/mail/e-mail-config-notebook.c
@@ -311,7 +311,7 @@ mail_config_notebook_constructed (GObject *object)
 	gboolean add_receiving_page = TRUE;
 	gboolean add_sending_page = TRUE;
 	gboolean add_transport_source;
-	gboolean gnome_online_account = FALSE;
+	gboolean online_account = FALSE;
 
 	notebook = E_MAIL_CONFIG_NOTEBOOK (object);
 
@@ -328,13 +328,21 @@ mail_config_notebook_constructed (GObject *object)
 	mail_identity_extension = E_SOURCE_MAIL_IDENTITY (extension);
 
 	/* If we have a collection source and the collection source
-	 * has a [GNOME Online Accounts] extension, skip the Receiving
-	 * and Sending pages since GOA dictates those settings. */
+	 * has a [GNOME Online Accounts] or [Ubuntu Online Accounts]
+	 * extension, skip the Receiving and Sending pages since GOA
+	 * and UOA dictates those settings. */
 	source = notebook->priv->collection_source;
 	if (source != NULL) {
 		extension_name = E_SOURCE_EXTENSION_GOA;
 		if (e_source_has_extension (source, extension_name)) {
-			gnome_online_account = TRUE;
+			online_account = TRUE;
+			add_receiving_page = FALSE;
+			add_sending_page = FALSE;
+		}
+
+		extension_name = E_SOURCE_EXTENSION_UOA;
+		if (e_source_has_extension (source, extension_name)) {
+			online_account = TRUE;
 			add_receiving_page = FALSE;
 			add_sending_page = FALSE;
 		}
@@ -367,7 +375,7 @@ mail_config_notebook_constructed (GObject *object)
 		registry, notebook->priv->identity_source);
 	e_mail_config_identity_page_set_show_instructions (
 		E_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
-	if (gnome_online_account) {
+	if (online_account) {
 		e_mail_config_identity_page_set_show_account_info (
 			E_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
 		e_mail_config_identity_page_set_show_email_address (
diff --git a/mail/e-mail-sidebar.c b/mail/e-mail-sidebar.c
index aafa6cd..20cf414 100644
--- a/mail/e-mail-sidebar.c
+++ b/mail/e-mail-sidebar.c
@@ -485,7 +485,7 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
 		can_delete &= !(folder_flags & CAMEL_FOLDER_SYSTEM);
 	}
 
-	/* GOA-based accounts cannot be disabled from Evolution. */
+	/* GOA and UOA-based accounts cannot be disabled from Evolution. */
 	if (is_store && !store_is_local && !store_is_vfolder) {
 		EMFolderTree *folder_tree;
 		EMailSession *session;
@@ -505,6 +505,13 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
 			g_object_unref (ancestor);
 		}
 
+		ancestor = e_source_registry_find_extension (
+			registry, source, E_SOURCE_EXTENSION_UOA);
+		if (ancestor != NULL) {
+			can_disable = FALSE;
+			g_object_unref (ancestor);
+		}
+
 		g_object_unref (source);
 	}
 



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