[evolution/account-mgmt] EMailConfigServiceBackend: Change get_settings() semantics.



commit f6b2d682064f91a50a90a7c52116d3a60e4f94f5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed May 30 10:27:10 2012 -0400

    EMailConfigServiceBackend: Change get_settings() semantics.

 mail/e-mail-config-service-backend.c |   71 +++++++++++++++++++++++++--------
 1 files changed, 54 insertions(+), 17 deletions(-)
---
diff --git a/mail/e-mail-config-service-backend.c b/mail/e-mail-config-service-backend.c
index fb86db2..a4c97fc 100644
--- a/mail/e-mail-config-service-backend.c
+++ b/mail/e-mail-config-service-backend.c
@@ -358,37 +358,74 @@ CamelSettings *
 e_mail_config_service_backend_get_settings (EMailConfigServiceBackend *backend)
 {
 	ESource *source;
-	ESourceCamel *camel_extension;
-	ESourceBackend *backend_extension;
+	ESourceCamel *camel_extension = NULL;
 	EMailConfigServicePage *page;
 	EMailConfigServicePageClass *page_class;
-	const gchar *backend_name;
-	const gchar *extension_name;
 
 	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), NULL);
 
-	source = e_mail_config_service_backend_get_source (backend);
-
 	page = e_mail_config_service_backend_get_page (backend);
 	page_class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
 
-	/* The provider-specific settings live in the collection source
-	 * if the service backend defines one, or else they live in the
-	 * scratch source we were given. */
+	/* Which ESource do we pull the CamelSettings from?  This is a
+	 * little tricky because we have to handle the following cases:
+	 *
+	 *   1) A stand-alone mail account.
+	 *
+	 *   2) A collection with a specialized backend (e.g. ews).
+	 *
+	 *   3) A collection that uses standard backends (e.g. yahoo).
+	 *
+	 * So the semantics are as follows.  They work for now but may
+	 * need further tweaking as we support more collection types.
+	 *
+	 *   1) If the service backend defines a collection source,
+	 *      assume the CamelSettings will be pulled from there.
+	 *
+	 *   2) If we have a collection source, try extracting the
+	 *      ESourceCamel extension for the collection source's
+	 *      backend name.
+	 *
+	 *   3) If steps 1 or 2 fail, pull the CamelSettings from
+	 *      the service backend's own scratch source.
+	 */
+
 	source = e_mail_config_service_backend_get_collection (backend);
 	if (source != NULL) {
+		ESourceBackend *backend_extension;
+		const gchar *backend_name;
+		const gchar *extension_name;
+
 		extension_name = E_SOURCE_EXTENSION_COLLECTION;
-	} else {
-		extension_name = page_class->extension_name;
-		source = e_mail_config_service_backend_get_source (backend);
+		backend_extension =
+			e_source_get_extension (source, extension_name);
+		backend_name =
+			e_source_backend_get_backend_name (backend_extension);
+
+		extension_name =
+			e_source_camel_get_extension_name (backend_name);
+		camel_extension =
+			e_source_get_extension (source, extension_name);
 	}
-	g_return_val_if_fail (source != NULL, NULL);
 
-	backend_extension = e_source_get_extension (source, extension_name);
-	backend_name = e_source_backend_get_backend_name (backend_extension);
+	if (camel_extension == NULL) {
+		ESourceBackend *backend_extension;
+		const gchar *backend_name;
+		const gchar *extension_name;
 
-	extension_name = e_source_camel_get_extension_name (backend_name);
-	camel_extension = e_source_get_extension (source, extension_name);
+		source = e_mail_config_service_backend_get_source (backend);
+
+		extension_name = page_class->extension_name;
+		backend_extension =
+			e_source_get_extension (source, extension_name);
+		backend_name =
+			e_source_backend_get_backend_name (backend_extension);
+
+		extension_name =
+			e_source_camel_get_extension_name (backend_name);
+		camel_extension =
+			e_source_get_extension (source, extension_name);
+	}
 
 	return e_source_camel_get_settings (camel_extension);
 }



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