[evolution/account-mgmt: 40/52] Add 'mail-config' module.



commit e0e24027e0f15d98e5702b95118c240794d5a229
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                    |   32 ++
 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/evolution-mail-config.c        |   41 ++
 7 files changed, 1471 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ce04fa8..e45ffe9 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..55b3138
--- /dev/null
+++ b/modules/mail-config/Makefile.am
@@ -0,0 +1,32 @@
+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				\
+	$(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-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..0b54a8e
--- /dev/null
+++ b/modules/mail-config/e-mail-config-remote-accounts.c
@@ -0,0 +1,524 @@
+/*
+ * 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>
+
+/* 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..7d04af8
--- /dev/null
+++ b/modules/mail-config/e-mail-config-transports.c
@@ -0,0 +1,448 @@
+/*
+ * e-mail-config-transport-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>
+
+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/evolution-mail-config.c b/modules/mail-config/evolution-mail-config.c
new file mode 100644
index 0000000..065ff08
--- /dev/null
+++ b/modules/mail-config/evolution-mail-config.c
@@ -0,0 +1,41 @@
+/*
+ * 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);
+
+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);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}



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