[evolution/account-mgmt: 42/54] Add 'mail-config' module.



commit b5302ef0528f627193e237ccde2fef564a75e490
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Feb 17 10:47:06 2012 -0500

    Add 'mail-config' module.
    
    This breaks a good chunk of logic out of EMAccountEditor and hopefully
    makes it less brittle.  Because honestly, every time I fix one thing in
    EMAccountEditor it breaks three other things.  It's unmaintainable.

 configure.ac                                       |    1 +
 modules/Makefile.am                                |    1 +
 modules/mail-config/Makefile.am                    |   34 ++
 modules/mail-config/e-mail-config-google.c         |  372 ++++++++++++++
 modules/mail-config/e-mail-config-local-accounts.c |  424 ++++++++++++++++
 .../mail-config/e-mail-config-remote-accounts.c    |  524 ++++++++++++++++++++
 modules/mail-config/e-mail-config-transports.c     |  448 +++++++++++++++++
 modules/mail-config/e-mail-config-yahoo.c          |  353 +++++++++++++
 modules/mail-config/evolution-mail-config.c        |   47 ++
 9 files changed, 2204 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e08202e..eda6b89 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1630,6 +1630,7 @@ modules/cal-config-weather/Makefile
 modules/cal-config-webcal/Makefile
 modules/composer-autosave/Makefile
 modules/imap-features/Makefile
+modules/mail-config/Makefile
 modules/mailto-handler/Makefile
 modules/mdn/Makefile
 modules/online-accounts/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 67f7b3c..b26d161 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -36,6 +36,7 @@ SUBDIRS = \
 	cal-config-webcal \
 	composer-autosave \
 	imap-features \
+	mail-config \
 	mailto-handler \
 	mdn \
 	offline-alert \
diff --git a/modules/mail-config/Makefile.am b/modules/mail-config/Makefile.am
new file mode 100644
index 0000000..5591c66
--- /dev/null
+++ b/modules/mail-config/Makefile.am
@@ -0,0 +1,34 @@
+NULL =
+
+module_LTLIBRARIES = libevolution-module-mail-config.la
+
+libevolution_module_mail_config_la_CPPFLAGS =			\
+	$(AM_CPPFLAGS)						\
+	-I$(top_srcdir)						\
+	-I$(top_srcdir)/widgets					\
+	-DG_LOG_DOMAIN=\"evolution-mail-config\"		\
+	$(EVOLUTION_DATA_SERVER_CFLAGS)				\
+	$(GNOME_PLATFORM_CFLAGS)				\
+	$(NULL)
+
+libevolution_module_mail_config_la_SOURCES =			\
+	evolution-mail-config.c					\
+	e-mail-config-local-accounts.c				\
+	e-mail-config-remote-accounts.c				\
+	e-mail-config-transports.c				\
+	e-mail-config-google.c					\
+	e-mail-config-yahoo.c					\
+	$(NULL)
+
+libevolution_module_mail_config_la_LIBADD =			\
+	$(top_builddir)/mail/libevolution-mail.la		\
+	$(top_builddir)/widgets/misc/libemiscwidgets.la		\
+	$(top_builddir)/libemail-engine/libemail-engine.la	\
+	$(EVOLUTION_DATA_SERVER_LIBS)				\
+	$(GNOME_PLATFORM_LIBS)					\
+	$(NULL)
+
+libevolution_module_mail_config_la_LDFLAGS =			\
+	-module -avoid-version $(NO_UNDEFINED)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/mail-config/e-mail-config-google.c b/modules/mail-config/e-mail-config-google.c
new file mode 100644
index 0000000..b24e088
--- /dev/null
+++ b/modules/mail-config/e-mail-config-google.c
@@ -0,0 +1,372 @@
+/*
+ * e-mail-config-google.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libebackend/e-extension.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-collection.h>
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <mail/e-mail-config-summary-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_GOOGLE \
+	(e_mail_config_google_get_type ())
+#define E_MAIL_CONFIG_GOOGLE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_GOOGLE, EMailConfigGoogle))
+#define E_MAIL_CONFIG_GOOGLE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_GOOGLE, EMailConfigGoogleClass))
+#define E_IS_MAIL_CONFIG_GOOGLE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_GOOGLE))
+#define E_IS_MAIL_CONFIG_GOOGLE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_GOOGLE))
+#define E_MAIL_CONFIG_GOOGLE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_GOOGLE, EMailConfigGoogleClass))
+
+#define GOOGLE_HELP_URI \
+	"http://support.google.com/mail/bin/answer.py?hl=en&answer=77695";
+
+typedef struct _EMailConfigGoogle EMailConfigGoogle;
+typedef struct _EMailConfigGoogleClass EMailConfigGoogleClass;
+
+struct _EMailConfigGoogle {
+	EExtension parent;
+
+	/* Widgets (not referenced) */
+	GtkWidget *calendar_toggle;
+	GtkWidget *contacts_toggle;
+
+	gboolean applicable;
+};
+
+struct _EMailConfigGoogleClass {
+	EExtensionClass parent_class;
+};
+
+enum {
+	PROP_0,
+	PROP_APPLICABLE
+};
+
+/* Forward Declarations */
+void		e_mail_config_google_type_register
+						(GTypeModule *type_module);
+GType		e_mail_config_google_get_type	(void) G_GNUC_CONST;
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigGoogle,
+	e_mail_config_google,
+	E_TYPE_EXTENSION)
+
+static EMailConfigSummaryPage *
+mail_config_google_get_summary_page (EMailConfigGoogle *extension)
+{
+	EExtensible *extensible;
+
+	extensible = e_extension_get_extensible (E_EXTENSION (extension));
+
+	return E_MAIL_CONFIG_SUMMARY_PAGE (extensible);
+}
+
+static gboolean
+mail_config_google_is_applicable (EMailConfigSummaryPage *page)
+{
+	ESource *source;
+	const gchar *extension_name;
+	const gchar *host = NULL;
+
+	/* FIXME We should tie this into EMailAutoconfig to avoid
+	 *       hard-coding Google domain names.  Maybe retain the
+	 *       <emailProvider id="..."> it matched so we can just
+	 *       check for, in this case, "googlemail.com".
+	 *
+	 *       Source:
+	 *       http://api.gnome.org/evolution/autoconfig/1.1/google.com
+	 */
+
+	source = e_mail_config_summary_page_get_account_source (page);
+
+	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+	if (e_source_has_extension (source, extension_name)) {
+		ESourceAuthentication *extension;
+		extension = e_source_get_extension (source, extension_name);
+		host = e_source_authentication_get_host (extension);
+	}
+
+	if (host == NULL)
+		return FALSE;
+
+	if (e_util_utf8_strstrcase (host, "gmail.com") != NULL)
+		return TRUE;
+
+	if (e_util_utf8_strstrcase (host, "googlemail.com") != NULL)
+		return TRUE;
+
+	return FALSE;
+}
+
+static void
+mail_config_google_refresh_cb (EMailConfigSummaryPage *page,
+                               EMailConfigGoogle *extension)
+{
+	extension->applicable = mail_config_google_is_applicable (page);
+
+	g_object_notify (G_OBJECT (extension), "applicable");
+}
+
+static void
+mail_config_google_commit_changes_cb (EMailConfigPage *page,
+                                      GQueue *source_queue,
+                                      EMailConfigGoogle *extension)
+{
+	ESource *identity_source;
+	ESource *collection_source;
+	ESourceMailIdentity *identity_extension;
+	ESourceCollection *collection_extension;
+	GtkToggleButton *toggle_button;
+	GList *list, *link;
+	const gchar *address;
+	const gchar *parent_uid;
+	gboolean calendar_active;
+	gboolean contacts_active;
+
+	/* If this is not a Google account, do nothing (obviously). */
+	if (!extension->applicable)
+		return;
+
+	toggle_button = GTK_TOGGLE_BUTTON (extension->calendar_toggle);
+	calendar_active = gtk_toggle_button_get_active (toggle_button);
+
+	toggle_button = GTK_TOGGLE_BUTTON (extension->contacts_toggle);
+	contacts_active = gtk_toggle_button_get_active (toggle_button);
+
+	/* If the user declined both Calendar and Contacts, do nothing. */
+	if (!calendar_active && !contacts_active)
+		return;
+
+	/* Create a new collection source. */
+	collection_source = e_source_new (NULL, NULL, NULL);
+	parent_uid = e_source_get_uid (collection_source);
+
+	/* All queued sources become children of the collection source. */
+	list = g_queue_peek_head_link (source_queue);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		e_source_set_parent (source, parent_uid);
+	}
+
+	/* The source queue takes ownership of the collection source. */
+	g_queue_push_head (source_queue, collection_source);
+
+	identity_source = e_mail_config_summary_page_get_identity_source (
+		E_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	/* Synchronize display names. */
+	g_object_bind_property (
+		identity_source, "display-name",
+		collection_source, "display-name",
+		G_BINDING_SYNC_CREATE);
+
+	/* The collection identity is the user's email address. */
+	identity_extension = e_source_get_extension (
+		identity_source, E_SOURCE_EXTENSION_MAIL_IDENTITY);
+	address = e_source_mail_identity_get_address (identity_extension);
+
+	/* Configure the collection extension. */
+	collection_extension = e_source_get_extension (
+		collection_source, E_SOURCE_EXTENSION_COLLECTION);
+	g_object_set (
+		collection_extension,
+		"backend-name", "google",
+		"identity", address,
+		"mail-enabled", TRUE,
+		"calendar-enabled", calendar_active,
+		"contacts-enabled", contacts_active,
+		NULL);
+
+	/* The "google-backend" module in E-D-S will handle the rest. */
+}
+
+static void
+mail_config_google_set_property (GObject *object,
+                                 guint property_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+	EMailConfigGoogle *extension;
+
+	extension = E_MAIL_CONFIG_GOOGLE (object);
+
+	switch (property_id) {
+		case PROP_APPLICABLE:
+			extension->applicable = g_value_get_boolean (value);
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_google_get_property (GObject *object,
+                                 guint property_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+	EMailConfigGoogle *extension;
+
+	extension = E_MAIL_CONFIG_GOOGLE (object);
+
+	switch (property_id) {
+		case PROP_APPLICABLE:
+			g_value_set_boolean (value, extension->applicable);
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_google_constructed (GObject *object)
+{
+	EMailConfigGoogle *extension;
+	EMailConfigSummaryPage *page;
+	GtkWidget *container;
+	GtkWidget *widget;
+	const gchar *text;
+	gchar *markup;
+
+	extension = E_MAIL_CONFIG_GOOGLE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_google_parent_class)->
+		constructed (object);
+
+	page = mail_config_google_get_summary_page (extension);
+
+	/* Use g_signal_connect_after() so the EMailConfigSummaryPage
+	 * class methods run first.  They make changes to the sources
+	 * the we either want to utilize or override. */
+
+	g_signal_connect_after (
+		page, "refresh",
+		G_CALLBACK (mail_config_google_refresh_cb), extension);
+
+	g_signal_connect_after (
+		page, "commit-changes",
+		G_CALLBACK (mail_config_google_commit_changes_cb), extension);
+
+	container = GTK_WIDGET (page);
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+
+	g_object_bind_property (
+		extension, "applicable",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	container = widget;
+
+	text = _("Google Features");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Add Google Ca_lendar to this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	extension->calendar_toggle = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	text = _("Add Google Con_tacts to this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	extension->contacts_toggle = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	text = _("You may need to enable IMAP access");
+	widget = gtk_link_button_new_with_label (GOOGLE_HELP_URI, text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
+	gtk_widget_show (widget);
+}
+
+static void
+e_mail_config_google_class_init (EMailConfigGoogleClass *class)
+{
+	GObjectClass *object_class;
+	EExtensionClass *extension_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_google_set_property;
+	object_class->get_property = mail_config_google_get_property;
+	object_class->constructed = mail_config_google_constructed;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_MAIL_CONFIG_SUMMARY_PAGE;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_APPLICABLE,
+		g_param_spec_boolean (
+			"applicable",
+			"Applicable",
+			"Whether this extension is applicable "
+			"to the current mail account settings",
+			FALSE,
+			G_PARAM_READWRITE));
+}
+
+static void
+e_mail_config_google_class_finalize (EMailConfigGoogleClass *class)
+{
+}
+
+static void
+e_mail_config_google_init (EMailConfigGoogle *extension)
+{
+}
+
+void
+e_mail_config_google_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_mail_config_google_register_type (type_module);
+}
+
diff --git a/modules/mail-config/e-mail-config-local-accounts.c b/modules/mail-config/e-mail-config-local-accounts.c
new file mode 100644
index 0000000..482021d
--- /dev/null
+++ b/modules/mail-config/e-mail-config-local-accounts.c
@@ -0,0 +1,424 @@
+/*
+ * e-mail-config-local-accounts.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libebackend/e-extension.h>
+
+#include <mail/e-mail-config-service-backend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_LOCAL_BACKEND \
+	(e_mail_config_local_backend_get_type ())
+#define E_MAIL_CONFIG_LOCAL_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackend))
+#define E_MAIL_CONFIG_LOCAL_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackendClass))
+#define E_IS_MAIL_CONFIG_LOCAL_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND))
+#define E_IS_MAIL_CONFIG_LOCAL_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND))
+#define E_MAIL_CONFIG_LOCAL_BACKEND_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_LOCAL_BACKEND, EMailConfigLocalBackendClass))
+
+typedef struct _EMailConfigLocalBackend EMailConfigLocalBackend;
+typedef struct _EMailConfigLocalBackendClass EMailConfigLocalBackendClass;
+
+typedef EMailConfigLocalBackend EMailConfigMhBackend;
+typedef EMailConfigLocalBackendClass EMailConfigMhBackendClass;
+
+typedef EMailConfigLocalBackend EMailConfigMboxBackend;
+typedef EMailConfigLocalBackendClass EMailConfigMboxBackendClass;
+
+typedef EMailConfigLocalBackend EMailConfigMaildirBackend;
+typedef EMailConfigLocalBackendClass EMailConfigMaildirBackendClass;
+
+typedef EMailConfigLocalBackend EMailConfigSpoolDirBackend;
+typedef EMailConfigLocalBackendClass EMailConfigSpoolDirBackendClass;
+
+typedef EMailConfigLocalBackend EMailConfigSpoolFileBackend;
+typedef EMailConfigLocalBackendClass EMailConfigSpoolFileBackendClass;
+
+/* XXX For lack of a better place for this... */
+typedef EMailConfigServiceBackend EMailConfigNoneBackend;
+typedef EMailConfigServiceBackendClass EMailConfigNoneBackendClass;
+
+typedef struct _Context Context;
+
+struct _EMailConfigLocalBackend {
+	EMailConfigServiceBackend parent;
+};
+
+struct _EMailConfigLocalBackendClass {
+	EMailConfigServiceBackendClass parent_class;
+
+	const gchar *file_chooser_label;
+	const gchar *file_chooser_title;
+	GtkFileChooserAction file_chooser_action;
+};
+
+struct _Context {
+	GtkWidget *file_chooser_label;
+	GtkWidget *file_chooser_button;
+};
+
+/* Forward Declarations */
+void		e_mail_config_local_accounts_register_types
+						(GTypeModule *type_module);
+GType		e_mail_config_local_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_mh_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_mbox_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_maildir_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_spool_dir_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_spool_file_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_none_backend_get_type
+						(void) G_GNUC_CONST;
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (
+	EMailConfigLocalBackend,
+	e_mail_config_local_backend,
+	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
+	G_TYPE_FLAG_ABSTRACT,
+	/* no custom code */)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigMhBackend,
+	e_mail_config_mh_backend,
+	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigMboxBackend,
+	e_mail_config_mbox_backend,
+	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigMaildirBackend,
+	e_mail_config_maildir_backend,
+	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigSpoolDirBackend,
+	e_mail_config_spool_dir_backend,
+	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigSpoolFileBackend,
+	e_mail_config_spool_file_backend,
+	E_TYPE_MAIL_CONFIG_LOCAL_BACKEND)
+
+/* XXX For lack of a better place for this... */
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigNoneBackend,
+	e_mail_config_none_backend,
+	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND)
+
+static void
+mail_config_local_backend_context_free (Context *context)
+{
+	g_object_unref (context->file_chooser_label);
+	g_object_unref (context->file_chooser_button);
+
+	g_slice_free (Context, context);
+}
+
+static void
+mail_config_local_backend_file_set_cb (GtkFileChooserButton *file_chooser_button,
+                                       CamelLocalSettings *local_settings)
+{
+	GtkFileChooser *file_chooser;
+	gchar *path;
+
+	file_chooser = GTK_FILE_CHOOSER (file_chooser_button);
+
+	path = gtk_file_chooser_get_filename (file_chooser);
+	camel_local_settings_set_path (local_settings, path);
+	g_free (path);
+}
+
+static void
+mail_config_local_backend_insert_widgets (EMailConfigServiceBackend *backend,
+                                          ESource *scratch_source,
+                                          GtkBox *parent)
+{
+	CamelSettings *settings;
+	EMailConfigServicePage *page;
+	EMailConfigLocalBackendClass *class;
+	GtkFileChooser *file_chooser;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	Context *context;
+	const gchar *path;
+	const gchar *uid;
+
+	class = E_MAIL_CONFIG_LOCAL_BACKEND_GET_CLASS (backend);
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	context = g_slice_new0 (Context);
+	uid = e_source_get_uid (scratch_source);
+
+	g_object_set_data_full (
+		G_OBJECT (backend), uid, context,
+		(GDestroyNotify) mail_config_local_backend_context_free);
+
+	widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+	gtk_box_pack_start (parent, widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (class->file_chooser_label);
+	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	context->file_chooser_label = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_file_chooser_button_new (
+		class->file_chooser_title,
+		class->file_chooser_action);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+	context->file_chooser_button = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "file-set",
+		G_CALLBACK (mail_config_local_backend_file_set_cb),
+		CAMEL_LOCAL_SETTINGS (settings));
+
+	file_chooser = GTK_FILE_CHOOSER (context->file_chooser_button);
+	path = camel_local_settings_get_path (CAMEL_LOCAL_SETTINGS (settings));
+	if (path != NULL)
+		gtk_file_chooser_set_filename (file_chooser, path);
+}
+
+static gboolean
+mail_config_local_backend_check_complete (EMailConfigServiceBackend *backend,
+                                          ESource *scratch_source)
+{
+	CamelSettings *settings;
+	EMailConfigServicePage *page;
+	CamelLocalSettings *local_settings;
+	const gchar *path;
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	local_settings = CAMEL_LOCAL_SETTINGS (settings);
+	path = camel_local_settings_get_path (local_settings);
+
+	return (path != NULL && *path != '\0');
+}
+
+static void
+mail_config_local_backend_commit_changes (EMailConfigServiceBackend *backend,
+                                          ESource *scratch_source)
+{
+	/* CamelLocalSettings "path" property is already up-to-date,
+	 * and it's bound to the appropriate ESourceExtension property,
+	 * so nothing to do here. */
+}
+
+static void
+e_mail_config_local_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->insert_widgets = mail_config_local_backend_insert_widgets;
+	backend_class->check_complete = mail_config_local_backend_check_complete;
+	backend_class->commit_changes = mail_config_local_backend_commit_changes;
+}
+
+static void
+e_mail_config_local_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_local_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_mh_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "mh";
+
+	class->file_chooser_label = _("Mail _Directory:");
+	class->file_chooser_title = _("Choose a MH mail directory");
+	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+}
+
+static void
+e_mail_config_mh_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_mh_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_mbox_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "mbox";
+
+	class->file_chooser_label = _("Local Delivery _File:");
+	class->file_chooser_title = _("Choose a local delivery file");
+	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_OPEN;
+}
+
+static void
+e_mail_config_mbox_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_mbox_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_maildir_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "maildir";
+
+	class->file_chooser_label = _("Mail _Directory:");
+	class->file_chooser_title = _("Choose a Maildir mail directory");
+	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+}
+
+static void
+e_mail_config_maildir_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_maildir_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_spool_dir_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "spool";
+
+	class->file_chooser_label = _("Spool _File:");
+	class->file_chooser_title = _("Choose a mbox spool file");
+	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_OPEN;
+}
+
+static void
+e_mail_config_spool_dir_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_spool_dir_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_spool_file_backend_class_init (EMailConfigLocalBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "spooldir";
+
+	class->file_chooser_label = _("Spool _Directory:");
+	class->file_chooser_title = _("Choose a mbox spool directory");
+	class->file_chooser_action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
+}
+
+static void
+e_mail_config_spool_file_backend_class_finalize (EMailConfigLocalBackendClass *class)
+{
+}
+
+static void
+e_mail_config_spool_file_backend_init (EMailConfigLocalBackend *backend)
+{
+}
+
+static void
+e_mail_config_none_backend_class_init (EMailConfigServiceBackendClass *class)
+{
+	class->backend_name = "none";
+}
+
+static void
+e_mail_config_none_backend_class_finalize (EMailConfigServiceBackendClass *class)
+{
+}
+
+static void
+e_mail_config_none_backend_init (EMailConfigServiceBackend *backend)
+{
+}
+
+void
+e_mail_config_local_accounts_register_types (GTypeModule *type_module)
+{
+	/* Abstract base type */
+	e_mail_config_local_backend_register_type (type_module);
+
+	/* Concrete sub-types */
+	e_mail_config_mh_backend_register_type (type_module);
+	e_mail_config_mbox_backend_register_type (type_module);
+	e_mail_config_maildir_backend_register_type (type_module);
+	e_mail_config_spool_dir_backend_register_type (type_module);
+	e_mail_config_spool_file_backend_register_type (type_module);
+
+	/* XXX For lack of a better place for this... */
+	e_mail_config_none_backend_register_type (type_module);
+}
+
diff --git a/modules/mail-config/e-mail-config-remote-accounts.c b/modules/mail-config/e-mail-config-remote-accounts.c
new file mode 100644
index 0000000..a68673b
--- /dev/null
+++ b/modules/mail-config/e-mail-config-remote-accounts.c
@@ -0,0 +1,524 @@
+/*
+ * e-mail-config-remote-accounts.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libebackend/e-extension.h>
+#include <libedataserver/e-source-backend.h>
+#include <libedataserver/e-data-server-util.h>
+
+#include <misc/e-port-entry.h>
+
+#include <mail/e-mail-config-auth-check.h>
+#include <mail/e-mail-config-service-backend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_REMOTE_BACKEND \
+	(e_mail_config_remote_backend_get_type ())
+#define E_MAIL_CONFIG_REMOTE_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackend))
+#define E_MAIL_CONFIG_REMOTE_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackendClass))
+#define E_IS_MAIL_CONFIG_REMOTE_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND))
+#define E_IS_MAIL_CONFIG_REMOTE_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND))
+#define E_MAIL_CONFIG_REMOTE_BACKEND_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_REMOTE_BACKEND, EMailConfigRemoteBackendClass))
+
+typedef struct _EMailConfigRemoteBackend EMailConfigRemoteBackend;
+typedef struct _EMailConfigRemoteBackendClass EMailConfigRemoteBackendClass;
+
+typedef EMailConfigRemoteBackend EMailConfigPopBackend;
+typedef EMailConfigRemoteBackendClass EMailConfigPopBackendClass;
+
+typedef EMailConfigRemoteBackend EMailConfigNntpBackend;
+typedef EMailConfigRemoteBackendClass EMailConfigNntpBackendClass;
+
+typedef EMailConfigRemoteBackend EMailConfigImapBackend;
+typedef EMailConfigRemoteBackendClass EMailConfigImapBackendClass;
+
+typedef EMailConfigRemoteBackend EMailConfigImapxBackend;
+typedef EMailConfigRemoteBackendClass EMailConfigImapxBackendClass;
+
+typedef struct _Context Context;
+
+struct _EMailConfigRemoteBackend {
+	EMailConfigServiceBackend parent;
+};
+
+struct _EMailConfigRemoteBackendClass {
+	EMailConfigServiceBackendClass parent_class;
+};
+
+struct _Context {
+	GtkWidget *host_entry;
+	GtkWidget *port_entry;
+	GtkWidget *user_entry;
+	GtkWidget *security_combo_box;
+	GtkWidget *auth_check;
+};
+
+/* Forward Declarations */
+void		e_mail_config_remote_accounts_register_types
+						(GTypeModule *type_module);
+GType		e_mail_config_remote_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_pop_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_nntp_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_imap_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_imapx_backend_get_type
+						(void) G_GNUC_CONST;
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (
+	EMailConfigRemoteBackend,
+	e_mail_config_remote_backend,
+	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
+	G_TYPE_FLAG_ABSTRACT,
+	/* no custom code */)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigPopBackend,
+	e_mail_config_pop_backend,
+	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigNntpBackend,
+	e_mail_config_nntp_backend,
+	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigImapBackend,
+	e_mail_config_imap_backend,
+	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigImapxBackend,
+	e_mail_config_imapx_backend,
+	E_TYPE_MAIL_CONFIG_REMOTE_BACKEND)
+
+static void
+mail_config_remote_backend_context_free (Context *context)
+{
+	g_object_unref (context->host_entry);
+	g_object_unref (context->port_entry);
+	g_object_unref (context->user_entry);
+	g_object_unref (context->security_combo_box);
+	g_object_unref (context->auth_check);
+
+	g_slice_free (Context, context);
+}
+
+static void
+mail_config_remote_backend_insert_widgets (EMailConfigServiceBackend *backend,
+                                           ESource *scratch_source,
+                                           GtkBox *parent)
+{
+	CamelProvider *provider;
+	CamelSettings *settings;
+	ESourceBackend *extension;
+	EMailConfigServicePage *page;
+	EMailConfigServicePageClass *class;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	Context *context;
+	const gchar *backend_name;
+	const gchar *extension_name;
+	const gchar *text;
+	const gchar *uid;
+	gchar *markup;
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	extension_name = class->extension_name;
+	extension = e_source_get_extension (scratch_source, extension_name);
+	backend_name = e_source_backend_get_backend_name (extension);
+
+	context = g_slice_new0 (Context);
+	uid = e_source_get_uid (scratch_source);
+
+	g_object_set_data_full (
+		G_OBJECT (backend), uid, context,
+		(GDestroyNotify) mail_config_remote_backend_context_free);
+
+	text = _("Configuration");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	widget = gtk_grid_new ();
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("_Server:"));
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	context->host_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new_with_mnemonic (_("_Port:"));
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = e_port_entry_new ();
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 3, 0, 1, 1);
+	context->port_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new_with_mnemonic (_("User_name:"));
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 3, 1);
+	context->user_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	text = _("Security");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	widget = gtk_grid_new ();
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("Encryption _method:"));
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	/* The IDs correspond to the CamelNetworkSecurityMethod enum. */
+	widget = gtk_combo_box_text_new ();
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"none",
+		_("No encryption"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"starttls-on-standard-port",
+		_("STARTTLS after connecting"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"ssl-on-alternate-port",
+		_("SSL on a dedicated port"));
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	context->security_combo_box = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	provider = camel_provider_get (backend_name, NULL);
+	if (provider != NULL && provider->port_entries != NULL)
+		e_port_entry_set_camel_entries (
+			E_PORT_ENTRY (context->port_entry),
+			provider->port_entries);
+
+	text = _("Authentication");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	widget = e_mail_config_auth_check_new (backend, scratch_source);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	context->auth_check = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		settings, "host",
+		context->host_entry, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property_full (
+		settings, "security-method",
+		context->security_combo_box, "active-id",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		e_binding_transform_enum_value_to_nick,
+		e_binding_transform_enum_nick_to_value,
+		NULL, (GDestroyNotify) NULL);
+
+	g_object_bind_property (
+		settings, "port",
+		context->port_entry, "port",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		settings, "security-method",
+		context->port_entry, "security-method",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		settings, "user",
+		context->user_entry, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* Don't use G_BINDING_SYNC_CREATE here since the widget
+	 * chooses its initial mechanism more intelligently than
+	 * a simple property binding would. */
+	g_object_bind_property (
+		settings, "auth-mechanism",
+		context->auth_check, "active-mechanism",
+		G_BINDING_BIDIRECTIONAL);
+}
+
+static gboolean
+mail_config_remote_backend_check_complete (EMailConfigServiceBackend *backend,
+                                           ESource *scratch_source)
+{
+	CamelSettings *settings;
+	EMailConfigServicePage *page;
+	CamelNetworkSettings *network_settings;
+	EPortEntry *port_entry;
+	Context *context;
+	const gchar *host;
+	const gchar *user;
+	const gchar *uid;
+
+	uid = e_source_get_uid (scratch_source);
+	context = g_object_get_data (G_OBJECT (backend), uid);
+	g_return_val_if_fail (context != NULL, FALSE);
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+	host = camel_network_settings_get_host (network_settings);
+	user = camel_network_settings_get_user (network_settings);
+
+	if (host == NULL || *host == '\0')
+		return FALSE;
+
+	port_entry = E_PORT_ENTRY (context->port_entry);
+	if (!e_port_entry_is_valid (port_entry))
+		return FALSE;
+
+	if (user == NULL || *user == '\0')
+		return FALSE;
+
+	return TRUE;
+}
+
+static void
+mail_config_remote_backend_commit_changes (EMailConfigServiceBackend *backend,
+                                           ESource *scratch_source)
+{
+	/* All CamelNetworkSettings properties are already up-to-date,
+	 * and these properties are bound to ESourceExtension properties,
+	 * so nothing to do here. */
+}
+
+static void
+e_mail_config_remote_backend_class_init (EMailConfigRemoteBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->insert_widgets = mail_config_remote_backend_insert_widgets;
+	backend_class->check_complete = mail_config_remote_backend_check_complete;
+	backend_class->commit_changes = mail_config_remote_backend_commit_changes;
+}
+
+static void
+e_mail_config_remote_backend_class_finalize (EMailConfigRemoteBackendClass *class)
+{
+}
+
+static void
+e_mail_config_remote_backend_init (EMailConfigRemoteBackend *backend)
+{
+}
+
+static gboolean
+mail_config_pop_backend_auto_configure (EMailConfigServiceBackend *backend,
+                                        EMailAutoconfig *autoconfig,
+                                        ESource *scratch_source)
+{
+	return e_mail_autoconfig_set_pop3_details (autoconfig, scratch_source);
+}
+
+static void
+e_mail_config_pop_backend_class_init (EMailConfigRemoteBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "pop";
+	backend_class->auto_configure = mail_config_pop_backend_auto_configure;
+}
+
+static void
+e_mail_config_pop_backend_class_finalize (EMailConfigRemoteBackendClass *class)
+{
+}
+
+static void
+e_mail_config_pop_backend_init (EMailConfigRemoteBackend *backend)
+{
+}
+
+static void
+e_mail_config_nntp_backend_class_init (EMailConfigRemoteBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "nntp";
+}
+
+static void
+e_mail_config_nntp_backend_class_finalize (EMailConfigRemoteBackendClass *class)
+{
+}
+
+static void
+e_mail_config_nntp_backend_init (EMailConfigRemoteBackend *backend)
+{
+}
+
+static gboolean
+mail_config_imap_backend_auto_configure (EMailConfigServiceBackend *backend,
+                                         EMailAutoconfig *autoconfig,
+                                         ESource *scratch_source)
+{
+	return e_mail_autoconfig_set_imap_details (autoconfig, scratch_source);
+}
+
+static void
+e_mail_config_imap_backend_class_init (EMailConfigRemoteBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "imap";
+	backend_class->auto_configure = mail_config_imap_backend_auto_configure;
+}
+
+static void
+e_mail_config_imap_backend_class_finalize (EMailConfigRemoteBackendClass *class)
+{
+}
+
+static void
+e_mail_config_imap_backend_init (EMailConfigRemoteBackend *backend)
+{
+}
+
+static gboolean
+mail_config_imapx_backend_auto_configure (EMailConfigServiceBackend *backend,
+                                          EMailAutoconfig *autoconfig,
+                                          ESource *scratch_source)
+{
+	return e_mail_autoconfig_set_imap_details (autoconfig, scratch_source);
+}
+
+static void
+e_mail_config_imapx_backend_class_init (EMailConfigRemoteBackendClass *class)
+{
+	EMailConfigServiceBackendClass *backend_class;
+
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_CLASS (class);
+	backend_class->backend_name = "imapx";
+	backend_class->auto_configure = mail_config_imapx_backend_auto_configure;
+}
+
+static void
+e_mail_config_imapx_backend_class_finalize (EMailConfigRemoteBackendClass *class)
+{
+}
+
+static void
+e_mail_config_imapx_backend_init (EMailConfigRemoteBackend *backend)
+{
+}
+
+void
+e_mail_config_remote_accounts_register_types (GTypeModule *type_module)
+{
+	/* Abstract base type */
+	e_mail_config_remote_backend_register_type (type_module);
+
+	/* Concrete sub-types */
+	e_mail_config_pop_backend_register_type (type_module);
+	e_mail_config_nntp_backend_register_type (type_module);
+	e_mail_config_imap_backend_register_type (type_module);
+	e_mail_config_imapx_backend_register_type (type_module);
+}
+
diff --git a/modules/mail-config/e-mail-config-transports.c b/modules/mail-config/e-mail-config-transports.c
new file mode 100644
index 0000000..06c4b93
--- /dev/null
+++ b/modules/mail-config/e-mail-config-transports.c
@@ -0,0 +1,448 @@
+/*
+ * e-mail-config-transports.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libebackend/e-extension.h>
+#include <libedataserver/e-source-backend.h>
+#include <libedataserver/e-data-server-util.h>
+
+#include <misc/e-port-entry.h>
+
+#include <mail/e-mail-config-auth-check.h>
+#include <mail/e-mail-config-service-backend.h>
+
+typedef EMailConfigServiceBackend EMailConfigSmtpBackend;
+typedef EMailConfigServiceBackendClass EMailConfigSmtpBackendClass;
+
+typedef EMailConfigServiceBackend EMailConfigSendmailBackend;
+typedef EMailConfigServiceBackendClass EMailConfigSendmailBackendClass;
+
+typedef struct _Context Context;
+
+struct _Context {
+	GtkWidget *host_entry;
+	GtkWidget *port_entry;
+	GtkWidget *user_entry;
+	GtkWidget *security_combo_box;
+	GtkWidget *auth_required_toggle;
+	GtkWidget *auth_check;
+};
+
+/* Forward Declarations */
+void		e_mail_config_transports_register_types
+						(GTypeModule *type_module);
+GType		e_mail_config_smtp_backend_get_type
+						(void) G_GNUC_CONST;
+GType		e_mail_config_sendmail_backend_get_type
+						(void) G_GNUC_CONST;
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigSmtpBackend,
+	e_mail_config_smtp_backend,
+	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigSendmailBackend,
+	e_mail_config_sendmail_backend,
+	E_TYPE_MAIL_CONFIG_SERVICE_BACKEND)
+
+static void
+mail_config_smtp_backend_context_free (Context *context)
+{
+	g_object_unref (context->host_entry);
+	g_object_unref (context->port_entry);
+	g_object_unref (context->user_entry);
+	g_object_unref (context->security_combo_box);
+	g_object_unref (context->auth_required_toggle);
+	g_object_unref (context->auth_check);
+
+	g_slice_free (Context, context);
+}
+
+static void
+mail_config_smtp_backend_insert_widgets (EMailConfigServiceBackend *backend,
+                                         ESource *scratch_source,
+                                         GtkBox *parent)
+{
+	CamelProvider *provider;
+	CamelSettings *settings;
+	ESourceBackend *extension;
+	EMailConfigServicePage *page;
+	EMailConfigServicePageClass *class;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	Context *context;
+	const gchar *backend_name;
+	const gchar *extension_name;
+	const gchar *mechanism;
+	const gchar *text;
+	const gchar *uid;
+	gchar *markup;
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	extension_name = class->extension_name;
+	extension = e_source_get_extension (scratch_source, extension_name);
+	backend_name = e_source_backend_get_backend_name (extension);
+
+	context = g_slice_new0 (Context);
+	uid = e_source_get_uid (scratch_source);
+
+	g_object_set_data_full (
+		G_OBJECT (backend), uid, context,
+		(GDestroyNotify) mail_config_smtp_backend_context_free);
+
+	text = _("Configuration");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	widget = gtk_grid_new ();
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("_Server:"));
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	context->host_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new_with_mnemonic (_("_Port:"));
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = e_port_entry_new ();
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 3, 0, 1, 1);
+	context->port_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	text = _("Ser_ver requires authentication");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 3, 1);
+	context->auth_required_toggle = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	text = _("Security");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	widget = gtk_grid_new ();
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("Encryption _method:"));
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	/* The IDs correspond to the CamelNetworkSecurityMethod enum. */
+	widget = gtk_combo_box_text_new ();
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"none",
+		_("No encryption"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"starttls-on-standard-port",
+		_("STARTTLS after connecting"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"ssl-on-alternate-port",
+		_("SSL on a dedicated port"));
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	context->security_combo_box = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	provider = camel_provider_get (backend_name, NULL);
+	if (provider != NULL && provider->port_entries != NULL)
+		e_port_entry_set_camel_entries (
+			E_PORT_ENTRY (context->port_entry),
+			provider->port_entries);
+
+	text = _("Authentication");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	g_object_bind_property (
+		context->auth_required_toggle, "active",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	widget = gtk_grid_new ();
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (parent), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		context->auth_required_toggle, "active",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	container = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("T_ype:"));
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	/* We can't bind GSettings:auth-mechanism directly to this
+	 * because the toggle button above influences the value we
+	 * choose: "none" if the toggle button is inactive or else
+	 * the active mechanism name from this widget. */
+	widget = e_mail_config_auth_check_new (backend, scratch_source);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	context->auth_check = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new_with_mnemonic (_("User_name:"));
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+	context->user_entry = g_object_ref (widget);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		settings, "host",
+		context->host_entry, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property_full (
+		settings, "security-method",
+		context->security_combo_box, "active-id",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		e_binding_transform_enum_value_to_nick,
+		e_binding_transform_enum_nick_to_value,
+		NULL, (GDestroyNotify) NULL);
+
+	g_object_bind_property (
+		settings, "port",
+		context->port_entry, "port",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		settings, "security-method",
+		context->port_entry, "security-method",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		settings, "user",
+		context->user_entry, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* Enable the auth-required toggle button if
+	 * we have an authentication mechanism name. */
+	mechanism = camel_network_settings_get_auth_mechanism (
+		CAMEL_NETWORK_SETTINGS (settings));
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (context->auth_required_toggle),
+		(mechanism != NULL && *mechanism != '\0'));
+}
+
+static gboolean
+mail_config_smtp_backend_auto_configure (EMailConfigServiceBackend *backend,
+                                         EMailAutoconfig *autoconfig,
+                                         ESource *scratch_source)
+{
+	return e_mail_autoconfig_set_smtp_details (autoconfig, scratch_source);
+}
+
+static gboolean
+mail_config_smtp_backend_check_complete (EMailConfigServiceBackend *backend,
+                                         ESource *scratch_source)
+{
+	CamelSettings *settings;
+	EMailConfigServicePage *page;
+	CamelNetworkSettings *network_settings;
+	GtkToggleButton *toggle_button;
+	EPortEntry *port_entry;
+	Context *context;
+	const gchar *host;
+	const gchar *user;
+	const gchar *uid;
+
+	uid = e_source_get_uid (scratch_source);
+	context = g_object_get_data (G_OBJECT (backend), uid);
+	g_return_val_if_fail (context != NULL, FALSE);
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+	host = camel_network_settings_get_host (network_settings);
+	user = camel_network_settings_get_user (network_settings);
+
+	if (host == NULL || *host == '\0')
+		return FALSE;
+
+	port_entry = E_PORT_ENTRY (context->port_entry);
+	if (!e_port_entry_is_valid (port_entry))
+		return FALSE;
+
+	toggle_button = GTK_TOGGLE_BUTTON (context->auth_required_toggle);
+	if (gtk_toggle_button_get_active (toggle_button))
+		if (user == NULL || *user == '\0')
+			return FALSE;
+
+	return TRUE;
+}
+
+static void
+mail_config_smtp_backend_commit_changes (EMailConfigServiceBackend *backend,
+                                         ESource *scratch_source)
+{
+	EMailConfigServicePage *page;
+	GtkToggleButton *toggle_button;
+	CamelSettings *settings;
+	Context *context;
+	const gchar *mechanism = NULL;
+	const gchar *uid;
+
+	/* The authentication mechanism name depends on both the
+	 * toggle button and the EMailConfigAuthCheck widget, so
+	 * we have to set it manually here. */
+
+	uid = e_source_get_uid (scratch_source);
+	context = g_object_get_data (G_OBJECT (backend), uid);
+	g_return_if_fail (context != NULL);
+
+	page = e_mail_config_service_backend_get_page (backend);
+
+	settings = e_mail_config_service_page_get_settings (
+		page, scratch_source);
+
+	toggle_button = GTK_TOGGLE_BUTTON (context->auth_required_toggle);
+
+	if (gtk_toggle_button_get_active (toggle_button))
+		mechanism = e_mail_config_auth_check_get_active_mechanism (
+			E_MAIL_CONFIG_AUTH_CHECK (context->auth_check));
+
+	camel_network_settings_set_auth_mechanism (
+		CAMEL_NETWORK_SETTINGS (settings), mechanism);
+}
+
+static void
+e_mail_config_smtp_backend_class_init (EMailConfigServiceBackendClass *class)
+{
+	class->backend_name = "smtp";
+	class->insert_widgets = mail_config_smtp_backend_insert_widgets;
+	class->auto_configure = mail_config_smtp_backend_auto_configure;
+	class->check_complete = mail_config_smtp_backend_check_complete;
+	class->commit_changes = mail_config_smtp_backend_commit_changes;
+}
+
+static void
+e_mail_config_smtp_backend_class_finalize (EMailConfigServiceBackendClass *class)
+{
+}
+
+static void
+e_mail_config_smtp_backend_init (EMailConfigServiceBackend *backend)
+{
+}
+
+static void
+e_mail_config_sendmail_backend_class_init (EMailConfigServiceBackendClass *class)
+{
+	class->backend_name = "sendmail";
+
+	/* No extra widgets for this backend. */
+}
+
+static void
+e_mail_config_sendmail_backend_class_finalize (EMailConfigServiceBackendClass *class)
+{
+}
+
+static void
+e_mail_config_sendmail_backend_init (EMailConfigServiceBackend *backend)
+{
+}
+
+void
+e_mail_config_transports_register_types (GTypeModule *type_module)
+{
+	e_mail_config_smtp_backend_register_type (type_module);
+	e_mail_config_sendmail_backend_register_type (type_module);
+}
+
diff --git a/modules/mail-config/e-mail-config-yahoo.c b/modules/mail-config/e-mail-config-yahoo.c
new file mode 100644
index 0000000..d252d7f
--- /dev/null
+++ b/modules/mail-config/e-mail-config-yahoo.c
@@ -0,0 +1,353 @@
+/*
+ * e-mail-config-yahoo.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libebackend/e-extension.h>
+
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-collection.h>
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <mail/e-mail-config-summary-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_YAHOO \
+	(e_mail_config_yahoo_get_type ())
+#define E_MAIL_CONFIG_YAHOO(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_YAHOO, EMailConfigYahoo))
+#define E_MAIL_CONFIG_YAHOO_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_YAHOO, EMailConfigYahooClass))
+#define E_IS_MAIL_CONFIG_YAHOO(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_YAHOO))
+#define E_IS_MAIL_CONFIG_YAHOO_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_YAHOO))
+#define E_MAIL_CONFIG_YAHOO_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_YAHOO, EMailConfigYahooClass))
+
+typedef struct _EMailConfigYahoo EMailConfigYahoo;
+typedef struct _EMailConfigYahooClass EMailConfigYahooClass;
+
+struct _EMailConfigYahoo {
+	EExtension parent;
+
+	/* Widgets (not referenced) */
+	GtkWidget *calendar_toggle;
+
+	gboolean applicable;
+};
+
+struct _EMailConfigYahooClass {
+	EExtensionClass parent_class;
+};
+
+enum {
+	PROP_0,
+	PROP_APPLICABLE
+};
+
+/* Forward Declarations */
+void		e_mail_config_yahoo_type_register
+						(GTypeModule *type_module);
+GType		e_mail_config_yahoo_get_type	(void) G_GNUC_CONST;
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigYahoo,
+	e_mail_config_yahoo,
+	E_TYPE_EXTENSION)
+
+static EMailConfigSummaryPage *
+mail_config_yahoo_get_summary_page (EMailConfigYahoo *extension)
+{
+	EExtensible *extensible;
+
+	extensible = e_extension_get_extensible (E_EXTENSION (extension));
+
+	return E_MAIL_CONFIG_SUMMARY_PAGE (extensible);
+}
+
+static gboolean
+mail_config_yahoo_is_applicable (EMailConfigSummaryPage *page)
+{
+	ESource *source;
+	const gchar *extension_name;
+	const gchar *host = NULL;
+
+	/* FIXME We should tie this into EMailAutoconfig to avoid
+	 *       hard-coding Yahoo domain names.  Maybe retain the
+	 *       <emailProvider id="..."> it matched so we can just
+	 *       check for, in this case, "yahoo.com".
+	 *
+	 *       Source:
+	 *       http://api.gnome.org/evolution/autoconfig/1.1/yahoo.com
+	 */
+
+	source = e_mail_config_summary_page_get_account_source (page);
+
+	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+	if (e_source_has_extension (source, extension_name)) {
+		ESourceAuthentication *extension;
+		extension = e_source_get_extension (source, extension_name);
+		host = e_source_authentication_get_host (extension);
+	}
+
+	if (host == NULL)
+		return FALSE;
+
+	if (e_util_utf8_strstrcase (host, "yahoo.com") != NULL)
+		return TRUE;
+
+	if (e_util_utf8_strstrcase (host, "ymail.com") != NULL)
+		return TRUE;
+
+	if (e_util_utf8_strstrcase (host, "rocketmail.com") != NULL)
+		return TRUE;
+
+	return FALSE;
+}
+
+static void
+mail_config_yahoo_refresh_cb (EMailConfigSummaryPage *page,
+                              EMailConfigYahoo *extension)
+{
+	extension->applicable = mail_config_yahoo_is_applicable (page);
+
+	g_object_notify (G_OBJECT (extension), "applicable");
+}
+
+static void
+mail_config_yahoo_commit_changes_cb (EMailConfigPage *page,
+                                     GQueue *source_queue,
+                                     EMailConfigYahoo *extension)
+{
+	ESource *identity_source;
+	ESource *collection_source;
+	ESourceMailIdentity *identity_extension;
+	ESourceCollection *collection_extension;
+	GtkToggleButton *toggle_button;
+	GList *list, *link;
+	const gchar *address;
+	const gchar *parent_uid;
+	gboolean calendar_active;
+
+	/* If this is not a Yahoo! account, do nothing (obviously). */
+	if (!extension->applicable)
+		return;
+
+	toggle_button = GTK_TOGGLE_BUTTON (extension->calendar_toggle);
+	calendar_active = gtk_toggle_button_get_active (toggle_button);
+
+	/* If the user declined to add a Calendar, do nothing. */
+	if (!calendar_active)
+		return;
+
+	/* Create a new collection source. */
+	collection_source = e_source_new (NULL, NULL, NULL);
+	parent_uid = e_source_get_uid (collection_source);
+
+	/* All queued sources become children of the collection source. */
+	list = g_queue_peek_head_link (source_queue);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		e_source_set_parent (source, parent_uid);
+	}
+
+	/* The source queue takes ownership of the collection source. */
+	g_queue_push_head (source_queue, collection_source);
+
+	identity_source = e_mail_config_summary_page_get_identity_source (
+		E_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	/* Synchronize display names. */
+	g_object_bind_property (
+		identity_source, "display-name",
+		collection_source, "display-name",
+		G_BINDING_SYNC_CREATE);
+
+	/* The collection identity is the user's email address. */
+	identity_extension = e_source_get_extension (
+		identity_source, E_SOURCE_EXTENSION_MAIL_IDENTITY);
+	address = e_source_mail_identity_get_address (identity_extension);
+
+	/* Configure the collection extension. */
+	collection_extension = e_source_get_extension (
+		collection_source, E_SOURCE_EXTENSION_COLLECTION);
+	g_object_set (
+		collection_extension,
+		"backend-name", "yahoo",
+		"identity", address,
+		"mail-enabled", TRUE,
+		"calendar-enabled", calendar_active,
+		"contacts-enabled", FALSE,
+		NULL);
+
+	/* The "yahoo-backend" module in E-D-S will handle the rest. */
+}
+
+static void
+mail_config_yahoo_set_property (GObject *object,
+                                guint property_id,
+                                const GValue *value,
+                                GParamSpec *pspec)
+{
+	EMailConfigYahoo *extension;
+
+	extension = E_MAIL_CONFIG_YAHOO (object);
+
+	switch (property_id) {
+		case PROP_APPLICABLE:
+			extension->applicable = g_value_get_boolean (value);
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_yahoo_get_property (GObject *object,
+                                guint property_id,
+                                GValue *value,
+                                GParamSpec *pspec)
+{
+	EMailConfigYahoo *extension;
+
+	extension = E_MAIL_CONFIG_YAHOO (object);
+
+	switch (property_id) {
+		case PROP_APPLICABLE:
+			g_value_set_boolean (value, extension->applicable);
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_yahoo_constructed (GObject *object)
+{
+	EMailConfigYahoo *extension;
+	EMailConfigSummaryPage *page;
+	GtkWidget *container;
+	GtkWidget *widget;
+	const gchar *text;
+	gchar *markup;
+
+	extension = E_MAIL_CONFIG_YAHOO (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_yahoo_parent_class)->
+		constructed (object);
+
+	page = mail_config_yahoo_get_summary_page (extension);
+
+	/* Use g_signal_connect_after() so the EMailConfigSummaryPage
+	 * class methods run first.  They make changes to the sources
+	 * that we either want to utilize or override. */
+
+	g_signal_connect_after (
+		page, "refresh",
+		G_CALLBACK (mail_config_yahoo_refresh_cb), extension);
+
+	g_signal_connect_after (
+		page, "commit-changes",
+		G_CALLBACK (mail_config_yahoo_commit_changes_cb), extension);
+
+	container = GTK_WIDGET (page);
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+
+	g_object_bind_property (
+		extension, "applicable",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	container = widget;
+
+	text = _("Yahoo! Features");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Add Yahoo! Ca_lendar to this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 2, 1);
+	extension->calendar_toggle = widget;  /* not referenced */
+	gtk_widget_show (widget);
+}
+
+static void
+e_mail_config_yahoo_class_init (EMailConfigYahooClass *class)
+{
+	GObjectClass *object_class;
+	EExtensionClass *extension_class;
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_yahoo_set_property;
+	object_class->get_property = mail_config_yahoo_get_property;
+	object_class->constructed = mail_config_yahoo_constructed;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_MAIL_CONFIG_SUMMARY_PAGE;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_APPLICABLE,
+		g_param_spec_boolean (
+			"applicable",
+			"Applicable",
+			"Whether this extension is applicable "
+			"to the current mail account settings",
+			FALSE,
+			G_PARAM_READWRITE));
+}
+
+static void
+e_mail_config_yahoo_class_finalize (EMailConfigYahooClass *class)
+{
+}
+
+static void
+e_mail_config_yahoo_init (EMailConfigYahoo *extension)
+{
+}
+
+void
+e_mail_config_yahoo_type_register (GTypeModule *type_module)
+{
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_mail_config_yahoo_register_type (type_module);
+}
+
diff --git a/modules/mail-config/evolution-mail-config.c b/modules/mail-config/evolution-mail-config.c
new file mode 100644
index 0000000..1d9ad9e
--- /dev/null
+++ b/modules/mail-config/evolution-mail-config.c
@@ -0,0 +1,47 @@
+/*
+ * evolution-mail-config.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include <gmodule.h>
+#include <glib-object.h>
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+void e_mail_config_local_accounts_register_types (GTypeModule *type_module);
+void e_mail_config_remote_accounts_register_types (GTypeModule *type_module);
+void e_mail_config_transports_register_types (GTypeModule *type_module);
+
+void e_mail_config_google_type_register (GTypeModule *type_module);
+void e_mail_config_yahoo_type_register (GTypeModule *type_module);
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_mail_config_local_accounts_register_types (type_module);
+	e_mail_config_remote_accounts_register_types (type_module);
+	e_mail_config_transports_register_types (type_module);
+
+	e_mail_config_google_type_register (type_module);
+	e_mail_config_yahoo_type_register (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}



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