[evolution/account-mgmt: 20/50] Adapt composer to the new ESource API.



commit 7f7eb5a30f3e232fc8676f23f873620c9b6f33a6
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Apr 13 10:31:31 2011 -0400

    Adapt composer to the new ESource API.

 composer/e-composer-from-header.c  |  130 ++----
 composer/e-composer-from-header.h  |   24 +-
 composer/e-composer-header-table.c |  876 +++++++++++++++++-------------------
 composer/e-composer-header-table.h |   41 +--
 composer/e-composer-header.c       |  158 ++++---
 composer/e-composer-header.h       |    3 +
 composer/e-composer-name-header.c  |    6 +-
 composer/e-composer-name-header.h  |    3 +-
 composer/e-composer-post-header.c  |  115 +++---
 composer/e-composer-post-header.h  |   15 +-
 composer/e-composer-private.c      |    4 +-
 composer/e-composer-private.h      |    5 +-
 composer/e-composer-text-header.c  |   14 +-
 composer/e-composer-text-header.h  |    6 +-
 composer/e-msg-composer.c          |  309 ++++++++-----
 composer/e-msg-composer.h          |    3 +-
 16 files changed, 849 insertions(+), 863 deletions(-)
---
diff --git a/composer/e-composer-from-header.c b/composer/e-composer-from-header.c
index 0b56971..aaed429 100644
--- a/composer/e-composer-from-header.c
+++ b/composer/e-composer-from-header.c
@@ -24,16 +24,7 @@
 
 #include "e-composer-from-header.h"
 
-/* Convenience macro */
-#define E_COMPOSER_FROM_HEADER_GET_COMBO_BOX(header) \
-	(E_ACCOUNT_COMBO_BOX (E_COMPOSER_HEADER (header)->input_widget))
-
-enum {
-	REFRESHED,
-	LAST_SIGNAL
-};
-
-static guint signal_ids[LAST_SIGNAL];
+#include <misc/e-mail-identity-combo-box.h>
 
 G_DEFINE_TYPE (
 	EComposerFromHeader,
@@ -41,119 +32,80 @@ G_DEFINE_TYPE (
 	E_TYPE_COMPOSER_HEADER)
 
 static void
-composer_from_header_changed_cb (EAccountComboBox *combo_box,
+composer_from_header_changed_cb (EMailIdentityComboBox *combo_box,
                                  EComposerFromHeader *header)
 {
 	g_signal_emit_by_name (header, "changed");
 }
 
 static void
-composer_from_header_refreshed_cb (EAccountComboBox *combo_box,
-                                   EComposerFromHeader *header)
-{
-	g_signal_emit (header, signal_ids[REFRESHED], 0);
-}
-
-static void
-e_composer_from_header_class_init (EComposerFromHeaderClass *class)
-{
-	signal_ids[REFRESHED] = g_signal_new (
-		"refreshed",
-		G_TYPE_FROM_CLASS (class),
-		G_SIGNAL_RUN_LAST,
-		0, NULL, NULL,
-		g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-}
-
-static void
-e_composer_from_header_init (EComposerFromHeader *header)
+composer_from_header_constructed (GObject *object)
 {
+	ESourceRegistry *registry;
+	EComposerHeader *header;
 	GtkWidget *widget;
 
-	widget = g_object_ref_sink (e_account_combo_box_new ());
+	header = E_COMPOSER_HEADER (object);
+	registry = e_composer_header_get_registry (header);
+
+	widget = e_mail_identity_combo_box_new (registry);
 	g_signal_connect (
 		widget, "changed",
 		G_CALLBACK (composer_from_header_changed_cb), header);
-	g_signal_connect (
-		widget, "refreshed",
-		G_CALLBACK (composer_from_header_refreshed_cb), header);
-	E_COMPOSER_HEADER (header)->input_widget = widget;
-}
+	header->input_widget = g_object_ref_sink (widget);
 
-EComposerHeader *
-e_composer_from_header_new (const gchar *label)
-{
-	return g_object_new (
-		E_TYPE_COMPOSER_FROM_HEADER, "label", label,
-		"button", FALSE, NULL);
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_composer_from_header_parent_class)->
+		constructed (object);
 }
 
-EAccountList *
-e_composer_from_header_get_account_list (EComposerFromHeader *header)
-{
-	EAccountComboBox *combo_box;
-
-	g_return_val_if_fail (E_IS_COMPOSER_FROM_HEADER (header), NULL);
-
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	return e_account_combo_box_get_account_list (combo_box);
-}
-
-void
-e_composer_from_header_set_account_list (EComposerFromHeader *header,
-                                         EAccountList *account_list)
+static void
+e_composer_from_header_class_init (EComposerFromHeaderClass *class)
 {
-	EAccountComboBox *combo_box;
-
-	g_return_if_fail (E_IS_COMPOSER_FROM_HEADER (header));
+	GObjectClass *object_class;
 
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	e_account_combo_box_set_account_list (combo_box, account_list);
+	object_class = G_OBJECT_CLASS (class);
+	object_class->constructed = composer_from_header_constructed;
 }
 
-EAccount *
-e_composer_from_header_get_active (EComposerFromHeader *header)
+static void
+e_composer_from_header_init (EComposerFromHeader *from_header)
 {
-	EAccountComboBox *combo_box;
-
-	g_return_val_if_fail (E_IS_COMPOSER_FROM_HEADER (header), NULL);
-
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	return e_account_combo_box_get_active (combo_box);
 }
 
-gboolean
-e_composer_from_header_set_active (EComposerFromHeader *header,
-                                   EAccount *account)
+EComposerHeader *
+e_composer_from_header_new (ESourceRegistry *registry,
+                            const gchar *label)
 {
-	EAccountComboBox *combo_box;
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 
-	g_return_val_if_fail (E_IS_COMPOSER_FROM_HEADER (header), FALSE);
-
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	return e_account_combo_box_set_active (combo_box, account);
+	return g_object_new (
+		E_TYPE_COMPOSER_FROM_HEADER,
+		"label", label, "button", FALSE,
+		"registry", registry, NULL);
 }
 
 const gchar *
-e_composer_from_header_get_active_name (EComposerFromHeader *header)
+e_composer_from_header_get_active_id (EComposerFromHeader *header)
 {
-	EAccountComboBox *combo_box;
+	GtkComboBox *combo_box;
 
 	g_return_val_if_fail (E_IS_COMPOSER_FROM_HEADER (header), NULL);
 
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	return e_account_combo_box_get_active_name (combo_box);
+	combo_box = GTK_COMBO_BOX (E_COMPOSER_HEADER (header)->input_widget);
+
+	return gtk_combo_box_get_active_id (combo_box);
 }
 
-gboolean
-e_composer_from_header_set_active_name (EComposerFromHeader *header,
-                                        const gchar *account_name)
+void
+e_composer_from_header_set_active_id (EComposerFromHeader *header,
+                                      const gchar *active_id)
 {
-	EAccountComboBox *combo_box;
+	GtkComboBox *combo_box;
+
+	g_return_if_fail (E_IS_COMPOSER_FROM_HEADER (header));
 
-	g_return_val_if_fail (E_IS_COMPOSER_FROM_HEADER (header), FALSE);
+	combo_box = GTK_COMBO_BOX (E_COMPOSER_HEADER (header)->input_widget);
 
-	combo_box = E_COMPOSER_FROM_HEADER_GET_COMBO_BOX (header);
-	return e_account_combo_box_set_active_name (combo_box, account_name);
+	gtk_combo_box_set_active_id (combo_box, active_id);
 }
diff --git a/composer/e-composer-from-header.h b/composer/e-composer-from-header.h
index 182a751..b4116e6 100644
--- a/composer/e-composer-from-header.h
+++ b/composer/e-composer-from-header.h
@@ -21,10 +21,6 @@
 #ifndef E_COMPOSER_FROM_HEADER_H
 #define E_COMPOSER_FROM_HEADER_H
 
-#include <libedataserver/e-account.h>
-#include <libedataserver/e-account-list.h>
-
-#include <misc/e-account-combo-box.h>
 #include <composer/e-composer-header.h>
 
 /* Standard GObject macros */
@@ -60,22 +56,14 @@ struct _EComposerFromHeaderClass {
 };
 
 GType		e_composer_from_header_get_type	(void);
-EComposerHeader * e_composer_from_header_new	(const gchar *label);
-EAccountList *	e_composer_from_header_get_account_list
-						(EComposerFromHeader *header);
-void		e_composer_from_header_set_account_list
-						(EComposerFromHeader *header,
-						 EAccountList *account_list);
-EAccount *	e_composer_from_header_get_active
-						(EComposerFromHeader *header);
-gboolean	e_composer_from_header_set_active
-						(EComposerFromHeader *header,
-						 EAccount *account);
-const gchar *	e_composer_from_header_get_active_name
+EComposerHeader *
+		e_composer_from_header_new	(ESourceRegistry *registry,
+						 const gchar *label);
+const gchar *	e_composer_from_header_get_active_id
 						(EComposerFromHeader *header);
-gboolean	e_composer_from_header_set_active_name
+void		e_composer_from_header_set_active_id
 						(EComposerFromHeader *header,
-						 const gchar *account_name);
+						 const gchar *active_id);
 
 G_END_DECLS
 
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index 2dd94eb..4cc93e2 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -23,10 +23,12 @@
 
 #include <glib/gi18n-lib.h>
 #include <libedataserverui/e-name-selector.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
 
 #include <shell/e-shell.h>
 #include <e-util/gconf-bridge.h>
-#include <misc/e-signature-combo-box.h>
+#include <misc/e-mail-signature-combo-box.h>
 
 #include "e-msg-composer.h"
 #include "e-composer-private.h"
@@ -45,31 +47,34 @@
 	  "carbon copy of the message without appearing " \
 	  "in the recipient list of the message")
 
+#define E_COMPOSER_HEADER_TABLE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_COMPOSER_HEADER_TABLE, EComposerHeaderTablePrivate))
+
+struct _EComposerHeaderTablePrivate {
+	EComposerHeader *headers[E_COMPOSER_NUM_HEADERS];
+	guint gconf_bindings[E_COMPOSER_NUM_HEADERS];
+	GtkWidget *signature_label;
+	GtkWidget *signature_combo_box;
+	ENameSelector *name_selector;
+	ESourceRegistry *registry;
+	EShell *shell;
+};
+
 enum {
 	PROP_0,
-	PROP_ACCOUNT,
-	PROP_ACCOUNT_LIST,
-	PROP_ACCOUNT_NAME,
 	PROP_DESTINATIONS_BCC,
 	PROP_DESTINATIONS_CC,
 	PROP_DESTINATIONS_TO,
+	PROP_IDENTITY_UID,
 	PROP_POST_TO,
+	PROP_REGISTRY,
 	PROP_REPLY_TO,
 	PROP_SHELL,
-	PROP_SIGNATURE,
-	PROP_SIGNATURE_LIST,
+	PROP_SIGNATURE_UID,
 	PROP_SUBJECT
 };
 
-struct _EComposerHeaderTablePrivate {
-	EComposerHeader *headers[E_COMPOSER_NUM_HEADERS];
-	guint gconf_bindings[E_COMPOSER_NUM_HEADERS];
-	GtkWidget *signature_label;
-	GtkWidget *signature_combo_box;
-	ENameSelector *name_selector;
-	EShell *shell;
-};
-
 G_DEFINE_TYPE (
 	EComposerHeaderTable,
 	e_composer_header_table,
@@ -210,13 +215,13 @@ composer_header_table_bind_widget (const gchar *property_name,
 
 static EDestination **
 composer_header_table_update_destinations (EDestination **old_destinations,
-                                           const gchar *auto_addresses)
+                                           const gchar * const *auto_addresses)
 {
 	CamelAddress *address;
 	CamelInternetAddress *inet_address;
 	EDestination **new_destinations;
 	EDestination *destination;
-	GList *list = NULL;
+	GQueue queue = G_QUEUE_INIT;
 	guint length;
 	gint ii;
 
@@ -228,25 +233,29 @@ composer_header_table_update_destinations (EDestination **old_destinations,
 	inet_address = camel_internet_address_new ();
 	address = CAMEL_ADDRESS (inet_address);
 
-	if (camel_address_decode (address, auto_addresses) != -1) {
-		for (ii = 0; ii < camel_address_length (address); ii++) {
-			const gchar *name, *email;
+	/* XXX Calling camel_address_decode() multiple times on the same
+	 *     CamelInternetAddress has a cumulative effect, which isn't
+	 *     well documented. */
+	for (ii = 0; auto_addresses[ii] != NULL; ii++)
+		camel_address_decode (address, auto_addresses[ii]);
+
+	for (ii = 0; ii < camel_address_length (address); ii++) {
+		const gchar *name, *email;
 
-			if (!camel_internet_address_get (
-				inet_address, ii, &name, &email))
-				continue;
+		if (!camel_internet_address_get (
+			inet_address, ii, &name, &email))
+			continue;
 
-			destination = e_destination_new ();
-			e_destination_set_auto_recipient (destination, TRUE);
+		destination = e_destination_new ();
+		e_destination_set_auto_recipient (destination, TRUE);
 
-			if (name != NULL)
-				e_destination_set_name (destination, name);
+		if (name != NULL)
+			e_destination_set_name (destination, name);
 
-			if (email != NULL)
-				e_destination_set_email (destination, email);
+		if (email != NULL)
+			e_destination_set_email (destination, email);
 
-			list = g_list_prepend (list, destination);
-		}
+		g_queue_push_tail (&queue, destination);
 	}
 
 	g_object_unref (inet_address);
@@ -263,20 +272,19 @@ skip_auto:
 			continue;
 
 		destination = e_destination_copy (old_destinations[ii]);
-		list = g_list_prepend (list, destination);
+		g_queue_push_tail (&queue, destination);
 	}
 
 skip_custom:
 
-	list = g_list_reverse (list);
-	length = g_list_length (list);
-
+	length = g_queue_get_length (&queue);
 	new_destinations = g_new0 (EDestination *, length + 1);
 
-	for (ii = 0; list != NULL; ii++) {
-		new_destinations[ii] = E_DESTINATION (list->data);
-		list = g_list_delete_link (list, list);
-	}
+	for (ii = 0; ii < length; ii++)
+		new_destinations[ii] = g_queue_pop_head (&queue);
+
+	/* Sanity check. */
+	g_warn_if_fail (g_queue_is_empty (&queue));
 
 	return new_destinations;
 }
@@ -287,7 +295,8 @@ from_header_should_be_visible (EComposerHeaderTable *table)
 	EShell *shell;
 	EComposerHeader *header;
 	EComposerHeaderType type;
-	EAccountComboBox *combo_box;
+	GtkComboBox *combo_box;
+	GtkTreeModel *tree_model;
 
 	shell = e_composer_header_table_get_shell (table);
 
@@ -297,9 +306,11 @@ from_header_should_be_visible (EComposerHeaderTable *table)
 
 	type = E_COMPOSER_HEADER_FROM;
 	header = e_composer_header_table_get_header (table, type);
-	combo_box = E_ACCOUNT_COMBO_BOX (header->input_widget);
 
-	return (e_account_combo_box_count_displayed_accounts (combo_box) > 1);
+	combo_box = GTK_COMBO_BOX (header->input_widget);
+	tree_model = gtk_combo_box_get_model (combo_box);
+
+	return (gtk_tree_model_iter_n_children (tree_model, NULL) > 1);
 }
 
 static void
@@ -436,43 +447,86 @@ composer_header_table_setup_post_headers (EComposerHeaderTable *table)
 static void
 composer_header_table_from_changed_cb (EComposerHeaderTable *table)
 {
-	EAccount *account;
+	ESource *source;
+	ESource *mail_account = NULL;
+	ESourceRegistry *registry;
 	EComposerHeader *header;
 	EComposerHeaderType type;
 	EComposerPostHeader *post_header;
 	EComposerTextHeader *text_header;
 	EDestination **old_destinations;
 	EDestination **new_destinations;
-	const gchar *reply_to;
-	const gchar *source_url;
-	gboolean always_cc;
-	gboolean always_bcc;
+	const gchar *reply_to = NULL;
+	const gchar * const *bcc = NULL;
+	const gchar * const *cc = NULL;
+	const gchar *uid;
+	gboolean post_headers = FALSE;
 
 	/* Keep "Post-To" and "Reply-To" synchronized with "From" */
 
-	account = e_composer_header_table_get_account (table);
-	source_url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
+	registry = e_composer_header_table_get_registry (table);
+	uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+
+	/* Make sure this is really a mail identity source. */
+	if (source != NULL) {
+		const gchar *extension_name;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		if (!e_source_has_extension (source, extension_name))
+			source = NULL;
+	}
+
+	/* Fetch the backend name of the mail identity's parent source,
+	 * which should be a mail account source.  If the backend name
+	 * is "nntp", show the post headers instead of the mail headers.
+	 *
+	 * XXX We should not be checking specific backend names here,
+	 *     but this is a corner case and I don't want to complicate
+	 *     the mail identity design over this. */
+
+	if (source != NULL) {
+		GNode *node;
+		ESourceMailIdentity *mi;
+		ESourceMailComposition *mc;
+		const gchar *extension_name;
+
+		node = e_source_get_node (source);
+		if (node != NULL && node->parent != NULL) {
+			const gchar *backend_name;
+
+			mail_account = E_SOURCE (node->parent);
+			backend_name = e_source_get_backend_name (mail_account);
+			post_headers = (g_strcmp0 (backend_name, "nntp") == 0);
+		}
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		mi = e_source_get_extension (source, extension_name);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+		mc = e_source_get_extension (source, extension_name);
+
+		reply_to = e_source_mail_identity_get_reply_to (mi);
+		bcc = e_source_mail_composition_get_bcc (mc);
+		cc = e_source_mail_composition_get_cc (mc);
+	}
 
 	type = E_COMPOSER_HEADER_POST_TO;
 	header = e_composer_header_table_get_header (table, type);
 	post_header = E_COMPOSER_POST_HEADER (header);
-	e_composer_post_header_set_account (post_header, account);
+	e_composer_post_header_set_mail_account (post_header, mail_account);
 
 	type = E_COMPOSER_HEADER_REPLY_TO;
 	header = e_composer_header_table_get_header (table, type);
-	reply_to = (account != NULL) ? account->id->reply_to : NULL;
 	text_header = E_COMPOSER_TEXT_HEADER (header);
 	e_composer_text_header_set_text (text_header, reply_to);
 
-	always_cc = (account != NULL && account->always_cc);
-	always_bcc = (account != NULL && account->always_bcc);
-
 	/* Update automatic CC destinations. */
 	old_destinations =
 		e_composer_header_table_get_destinations_cc (table);
 	new_destinations =
 		composer_header_table_update_destinations (
-		old_destinations, always_cc ? account->cc_addrs : NULL);
+		old_destinations, cc);
 	e_composer_header_table_set_destinations_cc (table, new_destinations);
 	e_destination_freev (old_destinations);
 	e_destination_freev (new_destinations);
@@ -482,34 +536,28 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table)
 		e_composer_header_table_get_destinations_bcc (table);
 	new_destinations =
 		composer_header_table_update_destinations (
-		old_destinations, always_bcc ? account->bcc_addrs : NULL);
+		old_destinations, bcc);
 	e_composer_header_table_set_destinations_bcc (table, new_destinations);
 	e_destination_freev (old_destinations);
 	e_destination_freev (new_destinations);
 
-	/* XXX We should NOT be checking specific account types here.
-	 *     Would prefer EAccount have a "send_method" enum item:
-	 *
-	 *         E_ACCOUNT_SEND_METHOD_MAIL
-	 *         E_ACCOUNT_SEND_METHOD_POST
-	 *
-	 *     And that would dictate which set of headers we show
-	 *     in the composer when an account is selected.  Alas,
-	 *     EAccount has no private storage, so it would require
-	 *     an ABI break and I don't want to deal with that now.
-	 *     (But would anything besides Evolution be affected?)
-	 *
-	 *     Currently only NNTP accounts use the "POST" fields.
-	 */
-	if (source_url == NULL)
-		composer_header_table_setup_mail_headers (table);
-	else if (g_ascii_strncasecmp (source_url, "nntp:";, 5) == 0)
+	if (post_headers)
 		composer_header_table_setup_post_headers (table);
 	else
 		composer_header_table_setup_mail_headers (table);
 }
 
 static void
+composer_header_table_set_registry (EComposerHeaderTable *table,
+                                    ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (table->priv->registry == NULL);
+
+	table->priv->registry = g_object_ref (registry);
+}
+
+static void
 composer_header_table_set_shell (EComposerHeaderTable *table,
                                  EShell *shell)
 {
@@ -519,92 +567,6 @@ composer_header_table_set_shell (EComposerHeaderTable *table,
 	table->priv->shell = g_object_ref (shell);
 }
 
-static GObject *
-composer_header_table_constructor (GType type,
-                                   guint n_construct_properties,
-                                   GObjectConstructParam *construct_properties)
-{
-	GObject *object;
-	EComposerHeaderTablePrivate *priv;
-	guint rows, ii;
-	gint row_padding;
-	gboolean small_screen_mode;
-
-	/* Chain up to parent's constructor() method. */
-	object = G_OBJECT_CLASS (
-		e_composer_header_table_parent_class)->constructor (
-		type, n_construct_properties, construct_properties);
-
-	priv = E_COMPOSER_HEADER_TABLE (object)->priv;
-
-	small_screen_mode = e_shell_get_small_screen_mode (priv->shell);
-
-	rows = G_N_ELEMENTS (priv->headers);
-	gtk_table_resize (GTK_TABLE (object), rows, 4);
-	gtk_table_set_row_spacings (GTK_TABLE (object), 0);
-	gtk_table_set_col_spacings (GTK_TABLE (object), 6);
-
-	/* Use "ypadding" instead of "row-spacing" because some rows may
-	 * be invisible and we don't want spacing around them. */
-
-	/* For small screens, pack the table's rows closely together. */
-	row_padding = small_screen_mode ? 0 : 3;
-
-	for (ii = 0; ii < rows; ii++) {
-		gtk_table_attach (
-			GTK_TABLE (object), priv->headers[ii]->title_widget,
-			0, 1, ii, ii + 1, GTK_FILL, GTK_FILL, 0, row_padding);
-		gtk_table_attach (
-			GTK_TABLE (object),
-			priv->headers[ii]->input_widget, 1, 4,
-			ii, ii + 1, GTK_FILL | GTK_EXPAND, 0, 0, row_padding);
-	}
-
-	ii = E_COMPOSER_HEADER_FROM;
-
-	/* Leave room in the "From" row for signature stuff. */
-	gtk_container_child_set (
-		GTK_CONTAINER (object),
-		priv->headers[ii]->input_widget,
-		"right-attach", 2, NULL);
-
-	g_object_bind_property (
-		priv->headers[ii]->input_widget, "visible",
-		priv->signature_label, "visible",
-		G_BINDING_SYNC_CREATE);
-
-	g_object_bind_property (
-		priv->headers[ii]->input_widget, "visible",
-		priv->signature_combo_box, "visible",
-		G_BINDING_SYNC_CREATE);
-
-	/* Now add the signature stuff. */
-	if (!small_screen_mode) {
-		gtk_table_attach (
-			GTK_TABLE (object), priv->signature_label,
-			2, 3, ii, ii + 1, 0, 0, 0, row_padding);
-		gtk_table_attach (
-			GTK_TABLE (object), priv->signature_combo_box,
-			3, 4, ii, ii + 1, 0, 0, 0, row_padding);
-	} else {
-		GtkWidget *box = gtk_hbox_new (FALSE, 0);
-
-		gtk_box_pack_start (
-			GTK_BOX (box), priv->signature_label,
-			FALSE, FALSE, 4);
-		gtk_box_pack_end (
-			GTK_BOX (box), priv->signature_combo_box,
-			TRUE, TRUE, 0);
-		g_object_set_data (G_OBJECT (box), "pdata", object);
-		gtk_table_attach (
-			GTK_TABLE (object), box,
-			3, 4, ii, ii + 1, GTK_FILL, 0, 0, row_padding);
-		gtk_widget_hide (box);
-	}
-
-	return object;
-}
-
 static void
 composer_header_table_set_property (GObject *object,
                                     guint property_id,
@@ -615,24 +577,6 @@ composer_header_table_set_property (GObject *object,
 	GList *list;
 
 	switch (property_id) {
-		case PROP_ACCOUNT:
-			e_composer_header_table_set_account (
-				E_COMPOSER_HEADER_TABLE (object),
-				g_value_get_object (value));
-			return;
-
-		case PROP_ACCOUNT_LIST:
-			e_composer_header_table_set_account_list (
-				E_COMPOSER_HEADER_TABLE (object),
-				g_value_get_object (value));
-			return;
-
-		case PROP_ACCOUNT_NAME:
-			e_composer_header_table_set_account_name (
-				E_COMPOSER_HEADER_TABLE (object),
-				g_value_get_string (value));
-			return;
-
 		case PROP_DESTINATIONS_BCC:
 			destinations = g_value_dup_destinations (value);
 			e_composer_header_table_set_destinations_bcc (
@@ -657,6 +601,12 @@ composer_header_table_set_property (GObject *object,
 			e_destination_freev (destinations);
 			return;
 
+		case PROP_IDENTITY_UID:
+			e_composer_header_table_set_identity_uid (
+				E_COMPOSER_HEADER_TABLE (object),
+				g_value_get_string (value));
+			return;
+
 		case PROP_POST_TO:
 			list = g_value_dup_string_list (value);
 			e_composer_header_table_set_post_to_list (
@@ -665,6 +615,12 @@ composer_header_table_set_property (GObject *object,
 			g_list_free (list);
 			return;
 
+		case PROP_REGISTRY:
+			composer_header_table_set_registry (
+				E_COMPOSER_HEADER_TABLE (object),
+				g_value_get_object (value));
+			return;
+
 		case PROP_REPLY_TO:
 			e_composer_header_table_set_reply_to (
 				E_COMPOSER_HEADER_TABLE (object),
@@ -677,16 +633,10 @@ composer_header_table_set_property (GObject *object,
 				g_value_get_object (value));
 			return;
 
-		case PROP_SIGNATURE:
-			e_composer_header_table_set_signature (
-				E_COMPOSER_HEADER_TABLE (object),
-				g_value_get_object (value));
-			return;
-
-		case PROP_SIGNATURE_LIST:
-			e_composer_header_table_set_signature_list (
+		case PROP_SIGNATURE_UID:
+			e_composer_header_table_set_signature_uid (
 				E_COMPOSER_HEADER_TABLE (object),
-				g_value_get_object (value));
+				g_value_get_string (value));
 			return;
 
 		case PROP_SUBJECT:
@@ -709,27 +659,6 @@ composer_header_table_get_property (GObject *object,
 	GList *list;
 
 	switch (property_id) {
-		case PROP_ACCOUNT:
-			g_value_set_object (
-				value,
-				e_composer_header_table_get_account (
-				E_COMPOSER_HEADER_TABLE (object)));
-			return;
-
-		case PROP_ACCOUNT_LIST:
-			g_value_set_object (
-				value,
-				e_composer_header_table_get_account_list (
-				E_COMPOSER_HEADER_TABLE (object)));
-			return;
-
-		case PROP_ACCOUNT_NAME:
-			g_value_set_string (
-				value,
-				e_composer_header_table_get_account_name (
-				E_COMPOSER_HEADER_TABLE (object)));
-			return;
-
 		case PROP_DESTINATIONS_BCC:
 			destinations =
 				e_composer_header_table_get_destinations_bcc (
@@ -754,6 +683,13 @@ composer_header_table_get_property (GObject *object,
 			e_destination_freev (destinations);
 			return;
 
+		case PROP_IDENTITY_UID:
+			g_value_set_string (
+				value,
+				e_composer_header_table_get_identity_uid (
+				E_COMPOSER_HEADER_TABLE (object)));
+			return;
+
 		case PROP_POST_TO:
 			list = e_composer_header_table_get_post_to (
 				E_COMPOSER_HEADER_TABLE (object));
@@ -762,6 +698,13 @@ composer_header_table_get_property (GObject *object,
 			g_list_free (list);
 			return;
 
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_composer_header_table_get_registry (
+				E_COMPOSER_HEADER_TABLE (object)));
+			return;
+
 		case PROP_REPLY_TO:
 			g_value_set_string (
 				value,
@@ -776,17 +719,10 @@ composer_header_table_get_property (GObject *object,
 				E_COMPOSER_HEADER_TABLE (object)));
 			return;
 
-		case PROP_SIGNATURE:
-			g_value_set_object (
-				value,
-				e_composer_header_table_get_signature (
-				E_COMPOSER_HEADER_TABLE (object)));
-			return;
-
-		case PROP_SIGNATURE_LIST:
-			g_value_set_object (
+		case PROP_SIGNATURE_UID:
+			g_value_set_string (
 				value,
-				e_composer_header_table_get_signature_list (
+				e_composer_header_table_get_signature_uid (
 				E_COMPOSER_HEADER_TABLE (object)));
 			return;
 
@@ -827,6 +763,11 @@ composer_header_table_dispose (GObject *object)
 		priv->name_selector = NULL;
 	}
 
+	if (priv->registry != NULL) {
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
+	}
+
 	if (priv->shell != NULL) {
 		g_object_unref (priv->shell);
 		priv->shell = NULL;
@@ -837,6 +778,142 @@ composer_header_table_dispose (GObject *object)
 }
 
 static void
+composer_header_table_constructed (GObject *object)
+{
+	EComposerHeaderTable *table;
+	ENameSelector *name_selector;
+	ESourceRegistry *registry;
+	EComposerHeader *header;
+	GtkWidget *widget;
+	EShell *shell;
+	guint ii;
+	gint row_padding;
+	gboolean small_screen_mode;
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_composer_header_table_parent_class)->
+		constructed (object);
+
+	table = E_COMPOSER_HEADER_TABLE (object);
+	shell = e_composer_header_table_get_shell (table);
+	registry = e_composer_header_table_get_registry (table);
+
+	small_screen_mode = e_shell_get_small_screen_mode (shell);
+
+	name_selector = e_name_selector_new (registry);
+	table->priv->name_selector = name_selector;
+
+	header = e_composer_from_header_new (registry, _("Fr_om:"));
+	composer_header_table_bind_header ("account", "changed", header);
+	g_signal_connect_swapped (
+		header, "changed", G_CALLBACK (
+		composer_header_table_from_changed_cb), table);
+	table->priv->headers[E_COMPOSER_HEADER_FROM] = header;
+
+	header = e_composer_text_header_new_label (registry, _("_Reply-To:"));
+	composer_header_table_bind_header ("reply-to", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_REPLY_TO] = header;
+
+	header = e_composer_name_header_new (
+		registry, _("_To:"), name_selector);
+	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_TO);
+	composer_header_table_bind_header ("destinations-to", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_TO] = header;
+
+	header = e_composer_name_header_new (
+		registry, _("_Cc:"), name_selector);
+	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_CC);
+	composer_header_table_bind_header ("destinations-cc", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_CC] = header;
+
+	header = e_composer_name_header_new (
+		registry, _("_Bcc:"), name_selector);
+	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_BCC);
+	composer_header_table_bind_header ("destinations-bcc", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_BCC] = header;
+
+	header = e_composer_post_header_new (registry, _("_Post To:"));
+	composer_header_table_bind_header ("post-to", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_POST_TO] = header;
+
+	header = e_composer_text_header_new_label (registry, _("S_ubject:"));
+	composer_header_table_bind_header ("subject", "changed", header);
+	table->priv->headers[E_COMPOSER_HEADER_SUBJECT] = header;
+
+	widget = e_mail_signature_combo_box_new (registry);
+	composer_header_table_bind_widget ("signature", "changed", widget);
+	table->priv->signature_combo_box = g_object_ref_sink (widget);
+
+	widget = gtk_label_new_with_mnemonic (_("Si_gnature:"));
+	gtk_label_set_mnemonic_widget (
+		GTK_LABEL (widget), table->priv->signature_combo_box);
+	table->priv->signature_label = g_object_ref_sink (widget);
+
+	/* Use "ypadding" instead of "row-spacing" because some rows may
+	 * be invisible and we don't want spacing around them. */
+
+	/* For small screens, pack the table's rows closely together. */
+	row_padding = small_screen_mode ? 0 : 3;
+
+	for (ii = 0; ii < G_N_ELEMENTS (table->priv->headers); ii++) {
+		gtk_table_attach (
+			GTK_TABLE (object),
+			table->priv->headers[ii]->title_widget, 0, 1,
+			ii, ii + 1, GTK_FILL, GTK_FILL, 0, row_padding);
+		gtk_table_attach (
+			GTK_TABLE (object),
+			table->priv->headers[ii]->input_widget, 1, 4,
+			ii, ii + 1, GTK_FILL | GTK_EXPAND, 0, 0, row_padding);
+	}
+
+	ii = E_COMPOSER_HEADER_FROM;
+
+	/* Leave room in the "From" row for signature stuff. */
+	gtk_container_child_set (
+		GTK_CONTAINER (object),
+		table->priv->headers[ii]->input_widget,
+		"right-attach", 2, NULL);
+
+	g_object_bind_property (
+		table->priv->headers[ii]->input_widget, "visible",
+		table->priv->signature_label, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		table->priv->headers[ii]->input_widget, "visible",
+		table->priv->signature_combo_box, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	/* Now add the signature stuff. */
+	if (!small_screen_mode) {
+		gtk_table_attach (
+			GTK_TABLE (object),
+			table->priv->signature_label,
+			2, 3, ii, ii + 1, 0, 0, 0, row_padding);
+		gtk_table_attach (
+			GTK_TABLE (object),
+			table->priv->signature_combo_box,
+			3, 4, ii, ii + 1, 0, 0, 0, row_padding);
+	} else {
+		GtkWidget *box = gtk_hbox_new (FALSE, 0);
+
+		gtk_box_pack_start (
+			GTK_BOX (box),
+			table->priv->signature_label,
+			FALSE, FALSE, 4);
+		gtk_box_pack_end (
+			GTK_BOX (box),
+			table->priv->signature_combo_box,
+			TRUE, TRUE, 0);
+		g_object_set_data (G_OBJECT (box), "pdata", object);
+		gtk_table_attach (
+			GTK_TABLE (object), box,
+			3, 4, ii, ii + 1, GTK_FILL, 0, 0, row_padding);
+		gtk_widget_hide (box);
+	}
+}
+
+static void
 e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 {
 	GObjectClass *object_class;
@@ -845,40 +922,10 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 	g_type_class_add_private (class, sizeof (EComposerHeaderTablePrivate));
 
 	object_class = G_OBJECT_CLASS (class);
-	object_class->constructor = composer_header_table_constructor;
 	object_class->set_property = composer_header_table_set_property;
 	object_class->get_property = composer_header_table_get_property;
 	object_class->dispose = composer_header_table_dispose;
-
-	g_object_class_install_property (
-		object_class,
-		PROP_ACCOUNT,
-		g_param_spec_object (
-			"account",
-			NULL,
-			NULL,
-			E_TYPE_ACCOUNT,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property (
-		object_class,
-		PROP_ACCOUNT_LIST,
-		g_param_spec_object (
-			"account-list",
-			NULL,
-			NULL,
-			E_TYPE_ACCOUNT_LIST,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property (
-		object_class,
-		PROP_ACCOUNT_NAME,
-		g_param_spec_string (
-			"account-name",
-			NULL,
-			NULL,
-			NULL,
-			G_PARAM_READWRITE));
+	object_class->constructed = composer_header_table_constructed;
 
 	/* floating reference */
 	element_spec = g_param_spec_object (
@@ -886,7 +933,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 		NULL,
 		NULL,
 		E_TYPE_DESTINATION,
-		G_PARAM_READWRITE);
+		G_PARAM_READWRITE |
+		G_PARAM_STATIC_STRINGS);
 
 	g_object_class_install_property (
 		object_class,
@@ -896,7 +944,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			element_spec,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
@@ -906,7 +955,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			element_spec,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
@@ -916,7 +966,19 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			element_spec,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_UID,
+		g_param_spec_string (
+			"identity-uid",
+			NULL,
+			NULL,
+			NULL,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 
 	/* floating reference */
 	element_spec = g_param_spec_string (
@@ -924,7 +986,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 		NULL,
 		NULL,
 		NULL,
-		G_PARAM_READWRITE);
+		G_PARAM_READWRITE |
+		G_PARAM_STATIC_STRINGS);
 
 	g_object_class_install_property (
 		object_class,
@@ -934,7 +997,20 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			element_spec,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			NULL,
+			NULL,
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
@@ -944,7 +1020,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			NULL,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
@@ -955,27 +1032,19 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			E_TYPE_SHELL,
 			G_PARAM_READWRITE |
-			G_PARAM_CONSTRUCT_ONLY));
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
-		PROP_SIGNATURE,
-		g_param_spec_object (
-			"signature",
+		PROP_SIGNATURE_UID,
+		g_param_spec_string (
+			"signature-uid",
 			NULL,
 			NULL,
-			E_TYPE_SIGNATURE,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property (
-		object_class,
-		PROP_SIGNATURE_LIST,
-		g_param_spec_object (
-			"signature-list",
-			NULL,
 			NULL,
-			E_TYPE_SIGNATURE_LIST,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 
 	g_object_class_install_property (
 		object_class,
@@ -985,7 +1054,8 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
 			NULL,
 			NULL,
 			NULL,
-			G_PARAM_READWRITE));
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
 }
 
 static void
@@ -1003,77 +1073,14 @@ composer_header_table_realize_cb (EComposerHeaderTable *table)
 static void
 e_composer_header_table_init (EComposerHeaderTable *table)
 {
-	EComposerHeader *header;
-	ENameSelector *name_selector;
-	GtkWidget *widget;
-	gint ii;
-
-	table->priv = G_TYPE_INSTANCE_GET_PRIVATE (
-		table, E_TYPE_COMPOSER_HEADER_TABLE,
-		EComposerHeaderTablePrivate);
+	gint rows;
 
-	name_selector = e_name_selector_new ();
-	table->priv->name_selector = name_selector;
+	table->priv = E_COMPOSER_HEADER_TABLE_GET_PRIVATE (table);
 
-	header = e_composer_from_header_new (_("Fr_om:"));
-	composer_header_table_bind_header ("account", "changed", header);
-	composer_header_table_bind_header ("account-list", "refreshed", header);
-	composer_header_table_bind_header ("account-name", "changed", header);
-	g_signal_connect_swapped (
-		header, "changed", G_CALLBACK (
-		composer_header_table_from_changed_cb), table);
-	table->priv->headers[E_COMPOSER_HEADER_FROM] = header;
-
-	header = e_composer_text_header_new_label (_("_Reply-To:"));
-	composer_header_table_bind_header ("reply-to", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_REPLY_TO] = header;
-
-	header = e_composer_name_header_new (_("_To:"), name_selector);
-	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_TO);
-	composer_header_table_bind_header ("destinations-to", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_TO] = header;
-
-	header = e_composer_name_header_new (_("_Cc:"), name_selector);
-	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_CC);
-	composer_header_table_bind_header ("destinations-cc", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_CC] = header;
-
-	header = e_composer_name_header_new (_("_Bcc:"), name_selector);
-	e_composer_header_set_input_tooltip (header, HEADER_TOOLTIP_BCC);
-	composer_header_table_bind_header ("destinations-bcc", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_BCC] = header;
-
-	header = e_composer_post_header_new (_("_Post To:"));
-	composer_header_table_bind_header ("post-to", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_POST_TO] = header;
-
-	header = e_composer_text_header_new_label (_("S_ubject:"));
-	composer_header_table_bind_header ("subject", "changed", header);
-	table->priv->headers[E_COMPOSER_HEADER_SUBJECT] = header;
-
-	widget = e_signature_combo_box_new ();
-	composer_header_table_bind_widget ("signature", "changed", widget);
-	composer_header_table_bind_widget ("signature-list", "refreshed", widget);
-	table->priv->signature_combo_box = g_object_ref_sink (widget);
-
-	widget = gtk_label_new_with_mnemonic (_("Si_gnature:"));
-	gtk_label_set_mnemonic_widget (
-		GTK_LABEL (widget), table->priv->signature_combo_box);
-	table->priv->signature_label = g_object_ref_sink (widget);
-
-	/* XXX EComposerHeader ought to do this itself, but I need to
-	 *     make the title_widget and input_widget members private. */
-	for (ii = 0; ii < E_COMPOSER_NUM_HEADERS; ii++) {
-		header = table->priv->headers[ii];
-		g_object_bind_property (
-			header, "visible",
-			header->title_widget, "visible",
-			G_BINDING_SYNC_CREATE);
-		g_object_bind_property (
-			header, "visible",
-			header->input_widget, "visible",
-			G_BINDING_SYNC_CREATE);
-	}
+	rows = G_N_ELEMENTS (table->priv->headers);
+	gtk_table_resize (GTK_TABLE (table), rows, 4);
+	gtk_table_set_row_spacings (GTK_TABLE (table), 0);
+	gtk_table_set_col_spacings (GTK_TABLE (table), 6);
 
 	/* postpone name_selector loading, do that only when really needed */
 	g_signal_connect (
@@ -1082,13 +1089,15 @@ e_composer_header_table_init (EComposerHeaderTable *table)
 }
 
 GtkWidget *
-e_composer_header_table_new (EShell *shell)
+e_composer_header_table_new (EShell *shell,
+                             ESourceRegistry *registry)
 {
 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 
 	return g_object_new (
 		E_TYPE_COMPOSER_HEADER_TABLE,
-		"shell", shell, NULL);
+		"shell", shell, "registry", registry, NULL);
 }
 
 EShell *
@@ -1099,113 +1108,22 @@ e_composer_header_table_get_shell (EComposerHeaderTable *table)
 	return table->priv->shell;
 }
 
-EComposerHeader *
-e_composer_header_table_get_header (EComposerHeaderTable *table,
-                                    EComposerHeaderType type)
-{
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
-	g_return_val_if_fail (type < E_COMPOSER_NUM_HEADERS, NULL);
-
-	return table->priv->headers[type];
-}
-
-EAccount *
-e_composer_header_table_get_account (EComposerHeaderTable *table)
+ESourceRegistry *
+e_composer_header_table_get_registry (EComposerHeaderTable *table)
 {
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
 	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
 
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	return e_composer_from_header_get_active (from_header);
-}
-
-gboolean
-e_composer_header_table_set_account (EComposerHeaderTable *table,
-                                     EAccount *account)
-{
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), FALSE);
-
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	return e_composer_from_header_set_active (from_header, account);
+	return table->priv->registry;
 }
 
-EAccountList *
-e_composer_header_table_get_account_list (EComposerHeaderTable *table)
+EComposerHeader *
+e_composer_header_table_get_header (EComposerHeaderTable *table,
+                                    EComposerHeaderType type)
 {
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
 	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
+	g_return_val_if_fail (type < E_COMPOSER_NUM_HEADERS, NULL);
 
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	return e_composer_from_header_get_account_list (from_header);
-}
-
-void
-e_composer_header_table_set_account_list (EComposerHeaderTable *table,
-                                          EAccountList *account_list)
-{
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
-	g_return_if_fail (E_IS_COMPOSER_HEADER_TABLE (table));
-
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	e_composer_from_header_set_account_list (from_header, account_list);
-}
-
-const gchar *
-e_composer_header_table_get_account_name (EComposerHeaderTable *table)
-{
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
-
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	return e_composer_from_header_get_active_name (from_header);
-}
-
-gboolean
-e_composer_header_table_set_account_name (EComposerHeaderTable *table,
-                                          const gchar *account_name)
-{
-	EComposerHeader *header;
-	EComposerHeaderType type;
-	EComposerFromHeader *from_header;
-
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), FALSE);
-
-	type = E_COMPOSER_HEADER_FROM;
-	header = e_composer_header_table_get_header (table, type);
-	from_header = E_COMPOSER_FROM_HEADER (header);
-
-	return e_composer_from_header_set_active_name (from_header, account_name);
+	return table->priv->headers[type];
 }
 
 EDestination **
@@ -1410,6 +1328,39 @@ e_composer_header_table_set_destinations_to (EComposerHeaderTable *table,
 	e_composer_name_header_set_destinations (name_header, destinations);
 }
 
+const gchar *
+e_composer_header_table_get_identity_uid (EComposerHeaderTable *table)
+{
+	EComposerHeader *header;
+	EComposerHeaderType type;
+	EComposerFromHeader *from_header;
+
+	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
+
+	type = E_COMPOSER_HEADER_FROM;
+	header = e_composer_header_table_get_header (table, type);
+	from_header = E_COMPOSER_FROM_HEADER (header);
+
+	return e_composer_from_header_get_active_id (from_header);
+}
+
+void
+e_composer_header_table_set_identity_uid (EComposerHeaderTable *table,
+                                          const gchar *identity_uid)
+{
+	EComposerHeader *header;
+	EComposerHeaderType type;
+	EComposerFromHeader *from_header;
+
+	g_return_if_fail (E_IS_COMPOSER_HEADER_TABLE (table));
+
+	type = E_COMPOSER_HEADER_FROM;
+	header = e_composer_header_table_get_header (table, type);
+	from_header = E_COMPOSER_FROM_HEADER (header);
+
+	e_composer_from_header_set_active_id (from_header, identity_uid);
+}
+
 GList *
 e_composer_header_table_get_post_to (EComposerHeaderTable *table)
 {
@@ -1497,50 +1448,29 @@ e_composer_header_table_set_reply_to (EComposerHeaderTable *table,
 		e_composer_header_set_visible (header, TRUE);
 }
 
-ESignature *
-e_composer_header_table_get_signature (EComposerHeaderTable *table)
+const gchar *
+e_composer_header_table_get_signature_uid (EComposerHeaderTable *table)
 {
-	ESignatureComboBox *combo_box;
+	GtkComboBox *combo_box;
 
 	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
 
-	combo_box = E_SIGNATURE_COMBO_BOX (table->priv->signature_combo_box);
-	return e_signature_combo_box_get_active (combo_box);
-}
-
-gboolean
-e_composer_header_table_set_signature (EComposerHeaderTable *table,
-                                       ESignature *signature)
-{
-	ESignatureComboBox *combo_box;
-
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), FALSE);
+	combo_box = GTK_COMBO_BOX (table->priv->signature_combo_box);
 
-	combo_box = E_SIGNATURE_COMBO_BOX (table->priv->signature_combo_box);
-	return e_signature_combo_box_set_active (combo_box, signature);
-}
-
-ESignatureList *
-e_composer_header_table_get_signature_list (EComposerHeaderTable *table)
-{
-	ESignatureComboBox *combo_box;
-
-	g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL);
-
-	combo_box = E_SIGNATURE_COMBO_BOX (table->priv->signature_combo_box);
-	return e_signature_combo_box_get_signature_list (combo_box);
+	return gtk_combo_box_get_active_id (combo_box);
 }
 
 void
-e_composer_header_table_set_signature_list (EComposerHeaderTable *table,
-                                            ESignatureList *signature_list)
+e_composer_header_table_set_signature_uid (EComposerHeaderTable *table,
+                                           const gchar *signature_uid)
 {
-	ESignatureComboBox *combo_box;
+	GtkComboBox *combo_box;
 
 	g_return_if_fail (E_IS_COMPOSER_HEADER_TABLE (table));
 
-	combo_box = E_SIGNATURE_COMBO_BOX (table->priv->signature_combo_box);
-	e_signature_combo_box_set_signature_list (combo_box, signature_list);
+	combo_box = GTK_COMBO_BOX (table->priv->signature_combo_box);
+
+	gtk_combo_box_set_active_id (combo_box, signature_uid);
 }
 
 const gchar *
diff --git a/composer/e-composer-header-table.h b/composer/e-composer-header-table.h
index f7edec0..432128e 100644
--- a/composer/e-composer-header-table.h
+++ b/composer/e-composer-header-table.h
@@ -18,13 +18,9 @@
 #ifndef E_COMPOSER_HEADER_TABLE_H
 #define E_COMPOSER_HEADER_TABLE_H
 
-#include <libedataserver/e-account.h>
-#include <libedataserver/e-account-list.h>
 #include <libebook/e-destination.h>
 
 #include <shell/e-shell.h>
-#include <e-util/e-signature.h>
-#include <e-util/e-signature-list.h>
 #include <composer/e-composer-header.h>
 
 /* Standard GObject macros */
@@ -74,28 +70,17 @@ struct _EComposerHeaderTableClass {
 };
 
 GType		e_composer_header_table_get_type (void);
-GtkWidget *	e_composer_header_table_new	(EShell *shell);
+GtkWidget *	e_composer_header_table_new	(EShell *shell,
+						 ESourceRegistry *registry);
 EShell *	e_composer_header_table_get_shell
 						(EComposerHeaderTable *table);
+ESourceRegistry *
+		e_composer_header_table_get_registry
+						(EComposerHeaderTable *table);
 EComposerHeader *
 		e_composer_header_table_get_header
 						(EComposerHeaderTable *table,
 						 EComposerHeaderType type);
-EAccount *	e_composer_header_table_get_account
-						(EComposerHeaderTable *table);
-gboolean	e_composer_header_table_set_account
-						(EComposerHeaderTable *table,
-						 EAccount *account);
-EAccountList *	e_composer_header_table_get_account_list
-						(EComposerHeaderTable *table);
-void		e_composer_header_table_set_account_list
-						(EComposerHeaderTable *table,
-						 EAccountList *account_list);
-const gchar *	e_composer_header_table_get_account_name
-						(EComposerHeaderTable *table);
-gboolean	e_composer_header_table_set_account_name
-						(EComposerHeaderTable *table,
-						 const gchar *account_name);
 EDestination ** e_composer_header_table_get_destinations
 						(EComposerHeaderTable *table);
 EDestination **	e_composer_header_table_get_destinations_bcc
@@ -122,6 +107,11 @@ void		e_composer_header_table_add_destinations_to
 void		e_composer_header_table_set_destinations_to
 						(EComposerHeaderTable *table,
 						 EDestination **destinations);
+const gchar *	e_composer_header_table_get_identity_uid
+						(EComposerHeaderTable *table);
+void		e_composer_header_table_set_identity_uid
+						(EComposerHeaderTable *table,
+						 const gchar *identity_uid);
 GList *		e_composer_header_table_get_post_to
 						(EComposerHeaderTable *table);
 void		e_composer_header_table_set_post_to_base
@@ -136,16 +126,11 @@ const gchar *	e_composer_header_table_get_reply_to
 void		e_composer_header_table_set_reply_to
 						(EComposerHeaderTable *table,
 						 const gchar *reply_to);
-ESignature *	e_composer_header_table_get_signature
-						(EComposerHeaderTable *table);
-gboolean	e_composer_header_table_set_signature
-						(EComposerHeaderTable *table,
-						 ESignature *signature);
-ESignatureList *e_composer_header_table_get_signature_list
+const gchar *	e_composer_header_table_get_signature_uid
 						(EComposerHeaderTable *table);
-void		e_composer_header_table_set_signature_list
+void		e_composer_header_table_set_signature_uid
 						(EComposerHeaderTable *table,
-						 ESignatureList *signature_list);
+						 const gchar *signature_uid);
 const gchar *	e_composer_header_table_get_subject
 						(EComposerHeaderTable *table);
 void		e_composer_header_table_set_subject
diff --git a/composer/e-composer-header.c b/composer/e-composer-header.c
index 29a9a5c..356154a 100644
--- a/composer/e-composer-header.c
+++ b/composer/e-composer-header.c
@@ -36,12 +36,8 @@
 struct _EComposerHeaderPrivate {
 	gchar *label;
 	gboolean button;
-	GtkWidget *action_label;
 
-	GtkWidget *add_icon;
-	GtkWidget *remove_icon;
-	GtkWidget *show_label;
-	GtkWidget *hide_label;
+	ESourceRegistry *registry;
 
 	guint sensitive : 1;
 	guint visible   : 1;
@@ -51,6 +47,7 @@ enum {
 	PROP_0,
 	PROP_BUTTON,
 	PROP_LABEL,
+	PROP_REGISTRY,
 	PROP_SENSITIVE,
 	PROP_VISIBLE
 };
@@ -76,48 +73,14 @@ composer_header_button_clicked_cb (GtkButton *button,
 	g_signal_emit (header, signal_ids[CLICKED], 0);
 }
 
-static GObject *
-composer_header_constructor (GType type,
-                             guint n_construct_properties,
-                             GObjectConstructParam *construct_properties)
+static void
+composer_header_set_registry (EComposerHeader *header,
+                              ESourceRegistry *registry)
 {
-	GObject *object;
-	GtkWidget *widget;
-	EComposerHeader *header;
-	GtkWidget *label;
-
-	/* Chain up to parent's constructor() method. */
-	object = G_OBJECT_CLASS (
-		e_composer_header_parent_class)->constructor (
-		type, n_construct_properties, construct_properties);
-
-	header = E_COMPOSER_HEADER (object);
-
-	if (header->priv->button) {
-		widget = gtk_button_new_with_mnemonic (header->priv->label);
-		gtk_widget_set_can_focus (widget, FALSE);
-		g_signal_connect (
-			widget, "clicked",
-			G_CALLBACK (composer_header_button_clicked_cb),
-			header);
-		label = gtk_bin_get_child (GTK_BIN (widget));
-	} else {
-		widget = gtk_label_new_with_mnemonic (header->priv->label);
-		gtk_label_set_mnemonic_widget (
-			GTK_LABEL (widget), header->input_widget);
-		label = widget;
-	}
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (header->priv->registry == NULL);
 
-	gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
-
-	header->priv->action_label = NULL;
-
-	header->title_widget = g_object_ref_sink (widget);
-
-	g_free (header->priv->label);
-	header->priv->label = NULL;
-
-	return object;
+	header->priv->registry = g_object_ref (registry);
 }
 
 static void
@@ -139,6 +102,12 @@ composer_header_set_property (GObject *object,
 			priv->label = g_value_dup_string (value);
 			return;
 
+		case PROP_REGISTRY:
+			composer_header_set_registry (
+				E_COMPOSER_HEADER (object),
+				g_value_get_object (value));
+			return;
+
 		case PROP_SENSITIVE:
 			e_composer_header_set_sensitive (
 				E_COMPOSER_HEADER (object),
@@ -176,6 +145,12 @@ composer_header_get_property (GObject *object,
 				E_COMPOSER_HEADER (object)));
 			return;
 
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value, e_composer_header_get_registry (
+				E_COMPOSER_HEADER (object)));
+			return;
+
 		case PROP_SENSITIVE:
 			g_value_set_boolean (
 				value, e_composer_header_get_sensitive (
@@ -207,11 +182,65 @@ composer_header_dispose (GObject *object)
 		header->input_widget = NULL;
 	}
 
+	if (header->priv->registry != NULL) {
+		g_object_unref (header->priv->registry);
+		header->priv->registry = NULL;
+	}
+
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (e_composer_header_parent_class)->dispose (object);
 }
 
 static void
+composer_header_constructed (GObject *object)
+{
+	EComposerHeader *header;
+	GtkWidget *widget;
+	GtkWidget *label;
+
+	header = E_COMPOSER_HEADER (object);
+
+	if (header->input_widget) {
+		g_critical (
+			"EComposerHeader's input_widget "
+			"must be set before chaining up");
+		return;
+	}
+
+	if (header->priv->button) {
+		widget = gtk_button_new_with_mnemonic (header->priv->label);
+		gtk_widget_set_can_focus (widget, FALSE);
+		g_signal_connect (
+			widget, "clicked",
+			G_CALLBACK (composer_header_button_clicked_cb),
+			header);
+		label = gtk_bin_get_child (GTK_BIN (widget));
+	} else {
+		widget = gtk_label_new_with_mnemonic (header->priv->label);
+		gtk_label_set_mnemonic_widget (
+			GTK_LABEL (widget), header->input_widget);
+		label = widget;
+	}
+
+	gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+
+	header->title_widget = g_object_ref_sink (widget);
+
+	g_object_bind_property (
+		header, "visible",
+		header->title_widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		header, "visible",
+		header->input_widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	g_free (header->priv->label);
+	header->priv->label = NULL;
+}
+
+static void
 e_composer_header_class_init (EComposerHeaderClass *class)
 {
 	GObjectClass *object_class;
@@ -219,10 +248,10 @@ e_composer_header_class_init (EComposerHeaderClass *class)
 	g_type_class_add_private (class, sizeof (EComposerHeaderPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
-	object_class->constructor = composer_header_constructor;
 	object_class->set_property = composer_header_set_property;
 	object_class->get_property = composer_header_get_property;
 	object_class->dispose = composer_header_dispose;
+	object_class->constructed = composer_header_constructed;
 
 	g_object_class_install_property (
 		object_class,
@@ -250,6 +279,18 @@ e_composer_header_class_init (EComposerHeaderClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			NULL,
+			NULL,
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_SENSITIVE,
 		g_param_spec_boolean (
 			"sensitive",
@@ -292,8 +333,7 @@ e_composer_header_class_init (EComposerHeaderClass *class)
 static void
 e_composer_header_init (EComposerHeader *header)
 {
-	header->priv = G_TYPE_INSTANCE_GET_PRIVATE (
-		header, E_TYPE_COMPOSER_HEADER, EComposerHeaderPrivate);
+	header->priv = E_COMPOSER_HEADER_GET_PRIVATE (header);
 }
 
 gchar *
@@ -309,6 +349,14 @@ e_composer_header_get_label (EComposerHeader *header)
 	return label;
 }
 
+ESourceRegistry *
+e_composer_header_get_registry (EComposerHeader *header)
+{
+	g_return_val_if_fail (E_IS_COMPOSER_HEADER (header), NULL);
+
+	return header->priv->registry;
+}
+
 gboolean
 e_composer_header_get_sensitive (EComposerHeader *header)
 {
@@ -344,20 +392,6 @@ e_composer_header_set_visible (EComposerHeader *header,
 
 	header->priv->visible = visible;
 
-	if (header->priv->action_label) {
-		if (!visible) {
-			gtk_widget_show (header->priv->add_icon);
-			gtk_widget_show (header->priv->show_label);
-			gtk_widget_hide (header->priv->remove_icon);
-			gtk_widget_hide (header->priv->hide_label);
-		} else {
-			gtk_widget_hide (header->priv->add_icon);
-			gtk_widget_hide (header->priv->show_label);
-			gtk_widget_show (header->priv->remove_icon);
-			gtk_widget_show (header->priv->hide_label);
-		}
-	}
-
 	g_object_notify (G_OBJECT (header), "visible");
 }
 
diff --git a/composer/e-composer-header.h b/composer/e-composer-header.h
index 08db97a..0c56cf9 100644
--- a/composer/e-composer-header.h
+++ b/composer/e-composer-header.h
@@ -19,6 +19,7 @@
 #define E_COMPOSER_HEADER_H
 
 #include <composer/e-composer-common.h>
+#include <libedataserver/e-source-registry.h>
 
 /* Standard GObject macros */
 #define E_TYPE_COMPOSER_HEADER \
@@ -62,6 +63,8 @@ struct _EComposerHeaderClass {
 
 GType		e_composer_header_get_type	(void);
 gchar *		e_composer_header_get_label	(EComposerHeader *header);
+ESourceRegistry *
+		e_composer_header_get_registry	(EComposerHeader *header);
 gboolean	e_composer_header_get_sensitive	(EComposerHeader *header);
 void		e_composer_header_set_sensitive	(EComposerHeader *header,
 						 gboolean sensitive);
diff --git a/composer/e-composer-name-header.c b/composer/e-composer-name-header.c
index b17cb4a..f493833 100644
--- a/composer/e-composer-name-header.c
+++ b/composer/e-composer-name-header.c
@@ -271,16 +271,18 @@ e_composer_name_header_init (EComposerNameHeader *header)
 }
 
 EComposerHeader *
-e_composer_name_header_new (const gchar *label,
+e_composer_name_header_new (ESourceRegistry *registry,
+                            const gchar *label,
                             ENameSelector *name_selector)
 {
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 	g_return_val_if_fail (E_IS_NAME_SELECTOR (name_selector), NULL);
 
 	return g_object_new (
 		E_TYPE_COMPOSER_NAME_HEADER,
 		"label", label, "button", TRUE,
 		"name-selector", name_selector,
-		 NULL);
+		"registry", registry, NULL);
 }
 
 ENameSelector *
diff --git a/composer/e-composer-name-header.h b/composer/e-composer-name-header.h
index e2f5e00..cb4dc03 100644
--- a/composer/e-composer-name-header.h
+++ b/composer/e-composer-name-header.h
@@ -58,7 +58,8 @@ struct _EComposerNameHeaderClass {
 };
 
 GType		e_composer_name_header_get_type	(void);
-EComposerHeader * e_composer_name_header_new	(const gchar *label,
+EComposerHeader * e_composer_name_header_new	(ESourceRegistry *registry,
+						 const gchar *label,
 						 ENameSelector *name_selector);
 ENameSelector *	e_composer_name_header_get_name_selector
 						(EComposerNameHeader *header);
diff --git a/composer/e-composer-post-header.c b/composer/e-composer-post-header.c
index fd08c67..1b017d4 100644
--- a/composer/e-composer-post-header.c
+++ b/composer/e-composer-post-header.c
@@ -30,11 +30,11 @@
 
 enum {
 	PROP_0,
-	PROP_ACCOUNT
+	PROP_MAIL_ACCOUNT
 };
 
 struct _EComposerPostHeaderPrivate {
-	EAccount *account;
+	ESource *mail_account;
 	gchar *base_url;  /* derived from account */
 	gboolean custom;
 };
@@ -73,6 +73,7 @@ composer_post_header_folder_name_to_string (EComposerPostHeader *header,
 static void
 composer_post_header_set_base_url (EComposerPostHeader *header)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EAccount *account = header->priv->account;
 	CamelURL *camel_url;
 	gchar *url;
@@ -93,6 +94,7 @@ composer_post_header_set_base_url (EComposerPostHeader *header)
 
 	g_free (header->priv->base_url);
 	header->priv->base_url = url;
+#endif  /* ACCOUNT_MGMT */
 }
 
 static GList *
@@ -140,8 +142,8 @@ composer_post_header_set_property (GObject *object,
                                    GParamSpec *pspec)
 {
 	switch (property_id) {
-		case PROP_ACCOUNT:
-			e_composer_post_header_set_account (
+		case PROP_MAIL_ACCOUNT:
+			e_composer_post_header_set_mail_account (
 				E_COMPOSER_POST_HEADER (object),
 				g_value_get_object (value));
 			return;
@@ -157,9 +159,10 @@ composer_post_header_get_property (GObject *object,
                                    GParamSpec *pspec)
 {
 	switch (property_id) {
-		case PROP_ACCOUNT:
+		case PROP_MAIL_ACCOUNT:
 			g_value_set_object (
-				value, e_composer_post_header_get_account (
+				value,
+				e_composer_post_header_get_mail_account (
 				E_COMPOSER_POST_HEADER (object)));
 			return;
 	}
@@ -174,9 +177,9 @@ composer_post_header_dispose (GObject *object)
 
 	priv = E_COMPOSER_POST_HEADER (object)->priv;
 
-	if (priv->account != NULL) {
-		g_object_unref (priv->account);
-		priv->account = NULL;
+	if (priv->mail_account != NULL) {
+		g_object_unref (priv->mail_account);
+		priv->mail_account = NULL;
 	}
 
 	/* Chain up to parent's dispose() method. */
@@ -237,12 +240,12 @@ e_composer_post_header_class_init (EComposerPostHeaderClass *class)
 
 	g_object_class_install_property (
 		object_class,
-		PROP_ACCOUNT,
+		PROP_MAIL_ACCOUNT,
 		g_param_spec_object (
-			"account",
+			"mail-account",
 			NULL,
 			NULL,
-			E_TYPE_ACCOUNT,
+			E_TYPE_SOURCE,
 			G_PARAM_READWRITE));
 }
 
@@ -255,51 +258,15 @@ e_composer_post_header_init (EComposerPostHeader *header)
 }
 
 EComposerHeader *
-e_composer_post_header_new (const gchar *label)
+e_composer_post_header_new (ESourceRegistry *registry,
+                            const gchar *label)
 {
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	return g_object_new (
 		E_TYPE_COMPOSER_POST_HEADER,
-		"label", label, "button", TRUE, NULL);
-}
-
-EAccount *
-e_composer_post_header_get_account (EComposerPostHeader *header)
-{
-	g_return_val_if_fail (E_IS_COMPOSER_POST_HEADER (header), NULL);
-
-	return header->priv->account;
-}
-
-void
-e_composer_post_header_set_account (EComposerPostHeader *header,
-                                    EAccount *account)
-{
-	GList *folders = NULL;
-
-	g_return_if_fail (E_IS_COMPOSER_POST_HEADER (header));
-
-	if (account != NULL) {
-		g_return_if_fail (E_IS_ACCOUNT (account));
-		g_object_ref (account);
-	}
-
-	if (!header->priv->custom)
-		folders = e_composer_post_header_get_folders (header);
-
-	if (header->priv->account != NULL)
-		g_object_unref (header->priv->account);
-
-	header->priv->account = account;
-	composer_post_header_set_base_url (header);
-
-	/* Make folders relative to the new account. */
-	if (!header->priv->custom) {
-		e_composer_post_header_set_folders (header, folders);
-		g_list_foreach (folders, (GFunc) g_free, NULL);
-		g_list_free (folders);
-	}
-
-	g_object_notify (G_OBJECT (header), "account");
+		"label", label, "button", TRUE,
+		"registry", registry, NULL);
 }
 
 GList *
@@ -383,3 +350,43 @@ e_composer_post_header_set_folders_base (EComposerPostHeader *header,
 	g_list_foreach (list, (GFunc) g_free, NULL);
 	g_list_free (list);
 }
+
+ESource *
+e_composer_post_header_get_mail_account (EComposerPostHeader *header)
+{
+	g_return_val_if_fail (E_IS_COMPOSER_POST_HEADER (header), NULL);
+
+	return header->priv->mail_account;
+}
+
+void
+e_composer_post_header_set_mail_account (EComposerPostHeader *header,
+                                         ESource *mail_account)
+{
+	GList *folders = NULL;
+
+	g_return_if_fail (E_IS_COMPOSER_POST_HEADER (header));
+
+	if (mail_account != NULL) {
+		g_return_if_fail (E_IS_SOURCE (mail_account));
+		g_object_ref (mail_account);
+	}
+
+	if (!header->priv->custom)
+		folders = e_composer_post_header_get_folders (header);
+
+	if (header->priv->mail_account != NULL)
+		g_object_unref (header->priv->mail_account);
+
+	header->priv->mail_account = mail_account;
+	composer_post_header_set_base_url (header);
+
+	/* Make folders relative to the new account. */
+	if (!header->priv->custom) {
+		e_composer_post_header_set_folders (header, folders);
+		g_list_foreach (folders, (GFunc) g_free, NULL);
+		g_list_free (folders);
+	}
+
+	g_object_notify (G_OBJECT (header), "mail-account");
+}
diff --git a/composer/e-composer-post-header.h b/composer/e-composer-post-header.h
index c6fff3e..999f1eb 100644
--- a/composer/e-composer-post-header.h
+++ b/composer/e-composer-post-header.h
@@ -21,8 +21,6 @@
 #ifndef E_COMPOSER_POST_HEADER_H
 #define E_COMPOSER_POST_HEADER_H
 
-#include <libedataserver/e-account.h>
-
 #include <composer/e-composer-text-header.h>
 
 /* Standard GObject macros */
@@ -63,12 +61,8 @@ struct _EComposerPostHeaderClass {
 
 GType		e_composer_post_header_get_type	(void);
 EComposerHeader *
-		e_composer_post_header_new	(const gchar *label);
-EAccount *	e_composer_post_header_get_account
-						(EComposerPostHeader *header);
-void		e_composer_post_header_set_account
-						(EComposerPostHeader *header,
-						 EAccount *account);
+		e_composer_post_header_new	(ESourceRegistry *registry,
+						 const gchar *label);
 GList *		e_composer_post_header_get_folders
 						(EComposerPostHeader *header);
 void		e_composer_post_header_set_folders
@@ -78,6 +72,11 @@ void		e_composer_post_header_set_folders_base
 						(EComposerPostHeader *header,
 						 const gchar *base_url,
 						 const gchar *folders);
+ESource *	e_composer_post_header_get_mail_account
+						(EComposerPostHeader *header);
+void		e_composer_post_header_set_mail_account
+						(EComposerPostHeader *header,
+						 ESource *mail_account);
 
 G_END_DECLS
 
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index bd7b46a..069e442 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -161,6 +161,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 	EFocusTracker *focus_tracker;
 	EShell *shell;
 	EShellSettings *shell_settings;
+	ESourceRegistry *registry;
 	EWebView *web_view;
 	GtkhtmlEditor *editor;
 	GtkUIManager *ui_manager;
@@ -179,6 +180,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 	ui_manager = gtkhtml_editor_get_ui_manager (editor);
 
 	shell = e_msg_composer_get_shell (composer);
+	registry = e_shell_get_registry (shell);
 	shell_settings = e_shell_get_shell_settings (shell);
 	web_view = e_msg_composer_get_web_view (composer);
 	small_screen_mode = e_shell_get_small_screen_mode (shell);
@@ -305,7 +307,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 
 	/* Construct the header table. */
 
-	widget = e_composer_header_table_new (shell);
+	widget = e_composer_header_table_new (shell, registry);
 	gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
 	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
 	if (small_screen_mode)
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 35eb266..0c1cc60 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -34,6 +34,9 @@
 #include <gconf/gconf-client.h>
 
 #include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
 
 #include "e-composer-actions.h"
 #include "e-composer-activity.h"
@@ -52,9 +55,9 @@
 #include "widgets/misc/e-attachment-icon-view.h"
 #include "widgets/misc/e-attachment-paned.h"
 #include "widgets/misc/e-attachment-store.h"
+#include "widgets/misc/e-mail-signature-combo-box.h"
 #include "widgets/misc/e-picture-gallery.h"
 #include "widgets/misc/e-preferences-window.h"
-#include "widgets/misc/e-signature-combo-box.h"
 #include "widgets/misc/e-web-view.h"
 #include "shell/e-shell.h"
 
diff --git a/composer/e-composer-text-header.c b/composer/e-composer-text-header.c
index 3927923..c8e955b 100644
--- a/composer/e-composer-text-header.c
+++ b/composer/e-composer-text-header.c
@@ -87,21 +87,27 @@ e_composer_text_header_init (EComposerTextHeader *header)
 }
 
 EComposerHeader *
-e_composer_text_header_new_label (const gchar *label)
+e_composer_text_header_new_label (ESourceRegistry *registry,
+                                  const gchar *label)
 {
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	return g_object_new (
 		E_TYPE_COMPOSER_TEXT_HEADER,
 		"label", label, "button", FALSE,
-		NULL);
+		"registry", registry, NULL);
 }
 
 EComposerHeader *
-e_composer_text_header_new_button (const gchar *label)
+e_composer_text_header_new_button (ESourceRegistry *registry,
+                                   const gchar *label)
 {
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	return g_object_new (
 		E_TYPE_COMPOSER_TEXT_HEADER,
 		"label", label, "button", TRUE,
-		NULL);
+		"registry", registry, NULL);
 }
 
 const gchar *
diff --git a/composer/e-composer-text-header.h b/composer/e-composer-text-header.h
index 860fcc3..51d3309 100644
--- a/composer/e-composer-text-header.h
+++ b/composer/e-composer-text-header.h
@@ -58,10 +58,12 @@ struct _EComposerTextHeaderClass {
 GType		e_composer_text_header_get_type	(void);
 EComposerHeader *
 		e_composer_text_header_new_label
-						(const gchar *label);
+						(ESourceRegistry *registry,
+						 const gchar *label);
 EComposerHeader *
 		e_composer_text_header_new_button
-						(const gchar *label);
+						(ESourceRegistry *registry,
+						 const gchar *label);
 const gchar *	e_composer_text_header_get_text	(EComposerTextHeader *header);
 void		e_composer_text_header_set_text (EComposerTextHeader *header,
 						 const gchar *text);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index ba7a7a4..1e361f3 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -37,10 +37,8 @@
 #include <ctype.h>
 #include <fcntl.h>
 
-#include "e-util/e-account-utils.h"
 #include "e-util/e-alert-dialog.h"
 #include "e-util/e-dialog-utils.h"
-#include "e-util/e-signature-utils.h"
 #include "e-util/e-util-private.h"
 #include "em-format/em-format.h"
 #include "em-format/em-format-quote.h"
@@ -56,7 +54,7 @@ struct _AsyncContext {
 	CamelDataWrapper *top_level_part;
 	CamelDataWrapper *text_plain_part;
 
-	EAccount *account;
+	ESource *source;
 	CamelSession *session;
 	CamelInternetAddress *from;
 
@@ -151,8 +149,8 @@ async_context_free (AsyncContext *context)
 	if (context->text_plain_part != NULL)
 		g_object_unref (context->text_plain_part);
 
-	if (context->account != NULL)
-		g_object_unref (context->account);
+	if (context->source != NULL)
+		g_object_unref (context->source);
 
 	if (context->session != NULL)
 		g_object_unref (context->session);
@@ -505,27 +503,47 @@ build_message_headers (EMsgComposer *composer,
 {
 	EComposerHeaderTable *table;
 	EComposerHeader *header;
-	EAccount *account;
+	ESourceRegistry *registry;
+	ESource *source;
 	const gchar *subject;
 	const gchar *reply_to;
+	const gchar *uid;
 
 	g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
 	table = e_msg_composer_get_header_table (composer);
 
+	registry = e_composer_header_table_get_registry (table);
+	uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+
 	/* Subject: */
 	subject = e_composer_header_table_get_subject (table);
 	camel_mime_message_set_subject (message, subject);
 
-	account = e_composer_header_table_get_account (table);
-	if (account != NULL) {
+	if (source != NULL) {
 		CamelMedium *medium;
 		CamelInternetAddress *addr;
+		ESourceMailIdentity *mi;
+		ESourceMailSubmission *ms;
+		const gchar *extension_name;
 		const gchar *header_name;
-		const gchar *name = account->id->name;
-		const gchar *address = account->id->address;
-		gchar *transport_uid;
+		const gchar *name, *address;
+		const gchar *transport_uid;
+		const gchar *sent_folder;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		mi = e_source_get_extension (source, extension_name);
+
+		name = e_source_mail_identity_get_name (mi);
+		address = e_source_mail_identity_get_address (mi);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+		ms = e_source_get_extension (source, extension_name);
+
+		sent_folder = e_source_mail_submission_get_sent_folder (ms);
+		transport_uid = e_source_mail_submission_get_transport_uid (ms);
 
 		medium = CAMEL_MEDIUM (message);
 
@@ -544,18 +562,15 @@ build_message_headers (EMsgComposer *composer,
 
 		/* X-Evolution-Account */
 		header_name = "X-Evolution-Account";
-		camel_medium_set_header (medium, header_name, account->uid);
+		camel_medium_set_header (medium, header_name, uid);
 
 		/* X-Evolution-Fcc */
 		header_name = "X-Evolution-Fcc";
-		camel_medium_set_header (medium, header_name, account->sent_folder_uri);
+		camel_medium_set_header (medium, header_name, sent_folder);
 
 		/* X-Evolution-Transport */
 		header_name = "X-Evolution-Transport";
-		transport_uid = g_strconcat (
-			account->uid, "-transport", NULL);
 		camel_medium_set_header (medium, header_name, transport_uid);
-		g_free (transport_uid);
 	}
 
 	/* Reply-To: */
@@ -662,6 +677,7 @@ composer_build_message_pgp (AsyncContext *context,
                             GCancellable *cancellable,
                             GError **error)
 {
+#if 0  /* ACCOUNT_MGMT */
 	CamelCipherContext *cipher;
 	CamelDataWrapper *content;
 	CamelMimePart *mime_part;
@@ -778,6 +794,7 @@ composer_build_message_pgp (AsyncContext *context,
 	context->top_level_part = g_object_ref (content);
 
 	g_object_unref (mime_part);
+#endif /* ACCOUNT_MGMT */
 
 	return TRUE;
 }
@@ -788,6 +805,7 @@ composer_build_message_smime (AsyncContext *context,
                               GCancellable *cancellable,
                               GError **error)
 {
+#if 0  /* ACCOUNT_MGMT */
 	CamelCipherContext *cipher;
 	CamelMimePart *mime_part;
 	gboolean have_signing_certificate;
@@ -923,6 +941,7 @@ composer_build_message_smime (AsyncContext *context,
 	}
 
 	g_object_unref (mime_part);
+#endif /* ACCOUNT_MGMT */
 
 	return TRUE;
 }
@@ -1025,7 +1044,12 @@ composer_build_message (EMsgComposer *composer,
 	EAttachmentStore *store;
 	EComposerHeaderTable *table;
 	CamelDataWrapper *html;
+	ESourceMailIdentity *mi;
+	ESourceRegistry *registry;
+	const gchar *extension_name;
 	const gchar *iconv_charset = NULL;
+	const gchar *identity_uid;
+	const gchar *organization;
 	CamelMultipart *body = NULL;
 	CamelContentType *type;
 	CamelSession *session;
@@ -1033,23 +1057,27 @@ composer_build_message (EMsgComposer *composer,
 	CamelStream *mem_stream;
 	CamelMimePart *part;
 	GByteArray *data;
-	EAccount *account;
+	ESource *source;
 	gchar *charset;
 	gint i;
 
 	priv = composer->priv;
 	editor = GTKHTML_EDITOR (composer);
 	table = e_msg_composer_get_header_table (composer);
-	account = e_composer_header_table_get_account (table);
 	view = e_msg_composer_get_attachment_view (composer);
 	store = e_attachment_view_get_store (view);
 	session = e_msg_composer_get_session (composer);
 
+	registry = e_composer_header_table_get_registry (table);
+	identity_uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, identity_uid);
+	g_return_if_fail (source != NULL);
+
 	/* Do all the non-blocking work here, and defer
 	 * any blocking operations to a separate thread. */
 
 	context = g_slice_new0 (AsyncContext);
-	context->account = g_object_ref (account);
+	context->source = g_object_ref (source);
 	context->session = g_object_ref (session);
 	context->from = e_msg_composer_get_from (composer);
 
@@ -1100,12 +1128,17 @@ composer_build_message (EMsgComposer *composer,
 			priv->extra_hdr_values->pdata[i]);
 	}
 
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	mi = e_source_get_extension (source, extension_name);
+	organization = e_source_mail_identity_get_organization (mi);
+
 	/* Disposition-Notification-To */
 	if (flags & COMPOSER_FLAG_REQUEST_READ_RECEIPT) {
-		gchar *mdn_address = account->id->reply_to;
+		const gchar *mdn_address;
 
+		mdn_address = e_source_mail_identity_get_reply_to (mi);
 		if (mdn_address == NULL || *mdn_address == '\0')
-			mdn_address = account->id->address;
+			mdn_address = e_source_mail_identity_get_address (mi);
 
 		camel_medium_add_header (
 			CAMEL_MEDIUM (context->message),
@@ -1119,15 +1152,15 @@ composer_build_message (EMsgComposer *composer,
 			"X-Priority", "1");
 
 	/* Organization */
-	if (account != NULL && account->id->organization != NULL) {
-		gchar *organization;
+	if (organization != NULL && *organization != '\0') {
+		gchar *encoded_organization;
 
-		organization = camel_header_encode_string (
-			(const guchar *) account->id->organization);
+		encoded_organization = camel_header_encode_string (
+			(const guchar *) organization);
 		camel_medium_set_header (
 			CAMEL_MEDIUM (context->message),
-			"Organization", organization);
-		g_free (organization);
+			"Organization", encoded_organization);
+		g_free (encoded_organization);
 	}
 
 	/* X-Evolution-Format */
@@ -1391,6 +1424,7 @@ composer_build_message_finish (EMsgComposer *composer,
 
 /* Signatures */
 
+#if 0  /* ACCOUNT_MGMT */
 static gchar *
 encode_signature_uid (ESignature *signature)
 {
@@ -1438,6 +1472,7 @@ encode_signature_uid (ESignature *signature)
 
 	return ename;
 }
+#endif /* ACCONT_MGMT */
 
 static gchar *
 decode_signature_name (const gchar *name)
@@ -1529,9 +1564,59 @@ add_signature_delim (EMsgComposer *composer)
 	"                     key=\"signature_name\" " \
 	"                   value=\"uid:Noname\">--><BR>"
 
+static void
+generate_signature (EMsgComposer *composer,
+                    GString *string)
+{
+#if 0  /* ACCOUNT_MGMT */
+	ESource *source;
+	EComposerHeaderTable *table;
+	ESourceMailIdentity *mail_identity;
+	const gchar *extension_name;
+	const gchar *value;
+	gchar *html_value;
+
+	table = e_msg_composer_get_header_table (composer);
+	source = e_composer_header_table_get_mail_identity (table);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	mail_identity = e_source_get_extension (source, extension_name);
+
+	value = e_source_mail_identity_get_name (mail_identity);
+	if (value != NULL)
+		html_value = camel_text_to_html (value, CONVERT_SPACES, 0);
+	else
+		html_value = NULL;
+	if (html_value != NULL && *html_value != '\0')
+		g_string_append (string, html_value);
+	g_free (html_value);
+
+	value = e_source_mail_identity_get_address (mail_identity);
+	if (value != NULL)
+		html_value = camel_text_to_html (value, CONVERT_SPACES, 0);
+	else
+		html_value = NULL;
+	if (html_value != NULL && *html_value != '\0')
+		g_string_append_printf (
+			string, " &lt;<A HREF=\"mailto:%s\";>%s</A>&gt;",
+			html_value, html_value);
+	g_free (html_value);
+
+	value = e_source_mail_identity_get_organization (mail_identity);
+	if (value != NULL)
+		html_value = camel_text_to_html (value, CONVERT_SPACES, 0);
+	else
+		html_value = NULL;
+	if (html_value != NULL && *html_value != '\0')
+		g_string_append_printf (string, "<BR>%s", html_value);
+	g_free (html_value);
+#endif /* ACCOUNT_MGMT */
+}
+
 static gchar *
 get_signature_html (EMsgComposer *composer)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EComposerHeaderTable *table;
 	gchar *text = NULL, *html = NULL;
 	ESignature *signature;
@@ -1559,40 +1644,16 @@ get_signature_html (EMsgComposer *composer)
 		else
 			text = e_read_signature_file (signature, TRUE, NULL);
 	} else {
-		EAccount *account;
-		EAccountIdentity *id;
-		gchar *organization = NULL;
-		gchar *address = NULL;
-		gchar *name = NULL;
+		GString *string;
 
-		account = e_composer_header_table_get_account (table);
-		if (!account)
-			return NULL;
+		string = g_string_sized_new (256);
 
-		id = account->id;
-		if (id->address != NULL)
-			address = camel_text_to_html (
-				id->address, CONVERT_SPACES, 0);
-		if (id->name != NULL)
-			name = camel_text_to_html (
-				id->name, CONVERT_SPACES, 0);
-		if (id->organization != NULL)
-			organization = camel_text_to_html (
-				id->organization, CONVERT_SPACES, 0);
-
-		text = g_strdup_printf ("%s%s%s%s%s%s%s%s%s",
-					add_delim ? "-- \n<BR>" : "",
-					name ? name : "",
-					(address && *address) ? " &lt;<A HREF=\"mailto:"; : "",
-					address ? address : "",
-					(address && *address) ? "\">" : "",
-					address ? address : "",
-					(address && *address) ? "</A>&gt;" : "",
-					(organization && *organization) ? "<BR>" : "",
-					organization ? organization : "");
-		g_free (address);
-		g_free (name);
-		g_free (organization);
+		if (add_delim)
+			g_string_append (string, "-- \n<BR>");
+
+		generate_signature (composer, string);
+
+		text = g_string_free (string, FALSE);
 		format_html = TRUE;
 	}
 
@@ -1634,6 +1695,9 @@ get_signature_html (EMsgComposer *composer)
 	}
 
 	return text;
+#endif /* ACCOUNT_MGMT */
+
+	return NULL;
 }
 
 static void
@@ -1705,43 +1769,50 @@ msg_composer_subject_changed_cb (EMsgComposer *composer)
 }
 
 static void
-msg_composer_account_changed_cb (EMsgComposer *composer)
+msg_composer_mail_identity_changed_cb (EMsgComposer *composer)
 {
 	EMsgComposerPrivate *p = composer->priv;
+	ESourceRegistry *registry;
+	ESourceMailComposition *mc;
+	ESourceMailIdentity *mi;
 	EComposerHeaderTable *table;
 	GtkToggleAction *action;
-	ESignature *signature;
-	EAccount *account;
+	ESource *source;
 	gboolean active, can_sign;
+	const gchar *extension_name;
 	const gchar *uid;
 
 	table = e_msg_composer_get_header_table (composer);
-	account = e_composer_header_table_get_account (table);
+	registry = e_composer_header_table_get_registry (table);
+	uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+	g_return_if_fail (source != NULL);
 
-	if (account == NULL) {
-		e_msg_composer_show_sig_file (composer);
-		return;
-	}
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	mc = e_source_get_extension (source, extension_name);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	mi = e_source_get_extension (source, extension_name);
 
-	can_sign = (!account->pgp_no_imip_sign || p->mime_type == NULL ||
-		g_ascii_strncasecmp (p->mime_type, "text/calendar", 13) != 0);
+	can_sign =
+		(p->mime_type == NULL) ||
+		e_source_mail_composition_get_sign_imip (mc) ||
+		(g_ascii_strncasecmp (p->mime_type, "text/calendar", 13) != 0);
 
 	action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
-	active = account->pgp_always_sign && can_sign;
+	active = can_sign && e_source_mail_composition_get_pgp_sign (mc);
 	gtk_toggle_action_set_active (action, active);
 
 	action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
-	active = account->smime_sign_default && can_sign;
+	active = can_sign && e_source_mail_composition_get_smime_sign (mc);
 	gtk_toggle_action_set_active (action, active);
 
 	action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
-	active = account->smime_encrypt_default;
+	active = e_source_mail_composition_get_smime_encrypt (mc);
 	gtk_toggle_action_set_active (action, active);
 
-	uid = account->id->sig_uid;
-	signature = uid ? e_get_signature_by_uid (uid) : NULL;
-	e_composer_header_table_set_signature (table, signature);
-	e_msg_composer_show_sig_file (composer);
+	uid = e_source_mail_identity_get_signature_uid (mi);
+	e_composer_header_table_set_signature_uid (table, uid);
 }
 
 static void
@@ -2150,14 +2221,6 @@ msg_composer_constructed (GObject *object)
 
 	/* Configure Headers */
 
-	e_composer_header_table_set_account_list (
-		table, e_get_account_list ());
-	e_composer_header_table_set_signature_list (
-		table, e_get_signature_list ());
-
-	g_signal_connect_swapped (
-		table, "notify::account",
-		G_CALLBACK (msg_composer_account_changed_cb), composer);
 	g_signal_connect_swapped (
 		table, "notify::destinations-bcc",
 		G_CALLBACK (msg_composer_notify_header_cb), composer);
@@ -2168,6 +2231,9 @@ msg_composer_constructed (GObject *object)
 		table, "notify::destinations-to",
 		G_CALLBACK (msg_composer_notify_header_cb), composer);
 	g_signal_connect_swapped (
+		table, "notify::mail-identity",
+		G_CALLBACK (msg_composer_mail_identity_changed_cb), composer);
+	g_signal_connect_swapped (
 		table, "notify::reply-to",
 		G_CALLBACK (msg_composer_notify_header_cb), composer);
 	g_signal_connect_swapped (
@@ -2180,7 +2246,7 @@ msg_composer_constructed (GObject *object)
 		table, "notify::subject",
 		G_CALLBACK (msg_composer_notify_header_cb), composer);
 
-	msg_composer_account_changed_cb (composer);
+	msg_composer_mail_identity_changed_cb (composer);
 
 	/* Attachments */
 
@@ -3104,6 +3170,7 @@ handle_multipart (EMsgComposer *composer,
 static void
 set_signature_gui (EMsgComposer *composer)
 {
+#if 0  /* ACCOUNT_MGMT */
 	GtkhtmlEditor *editor;
 	EComposerHeaderTable *table;
 	ESignature *signature = NULL;
@@ -3128,6 +3195,7 @@ set_signature_gui (EMsgComposer *composer)
 	}
 
 	e_composer_header_table_set_signature (table, signature);
+#endif /* ACCOUNT_MGMT */
 }
 
 /**
@@ -3146,6 +3214,7 @@ e_msg_composer_new_with_message (EShell *shell,
                                  CamelMimeMessage *message,
                                  GCancellable *cancellable)
 {
+#if 0  /* ACCOUNT_MGMT */
 	CamelInternetAddress *to, *cc, *bcc;
 	GList *To = NULL, *Cc = NULL, *Bcc = NULL, *postto = NULL;
 	const gchar *format, *subject;
@@ -3155,12 +3224,12 @@ e_msg_composer_new_with_message (EShell *shell,
 	struct _camel_header_raw *headers;
 	CamelDataWrapper *content;
 	EAccount *account = NULL;
-	gchar *account_name;
 	EMsgComposer *composer;
 	EMsgComposerPrivate *priv;
 	EComposerHeaderTable *table;
 	GtkToggleAction *action;
 	struct _camel_header_raw *xev;
+	gchar *identity_uid;
 	gint len, i;
 
 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -3188,23 +3257,11 @@ e_msg_composer_new_with_message (EShell *shell,
 		postto = NULL;
 	}
 
-	/* Restore the Account preference */
-	account_name = (gchar *) camel_medium_get_header (
-		CAMEL_MEDIUM (message), "X-Evolution-Account");
-	if (account_name) {
-		account_name = g_strdup (account_name);
-		g_strstrip (account_name);
-
-		account = e_get_account_by_uid (account_name);
-		if (account == NULL)
-			/* XXX Backwards compatibility */
-			account = e_get_account_by_name (account_name);
-
-		if (account != NULL) {
-			g_free (account_name);
-			account_name = g_strdup (account->name);
-		}
-	}
+	/* Restore the mail identity preference. */
+	identity_uid = (gchar *) camel_medium_get_header (
+		CAMEL_MEDIUM (message), "X-Evolution-Identity");
+	if (identity_uid != NULL)
+		identity_uid = g_strstrip (g_strdup (identity_uid));
 
 	if (postto == NULL) {
 		auto_cc = g_hash_table_new_full (
@@ -3323,13 +3380,13 @@ e_msg_composer_new_with_message (EShell *shell,
 
 	subject = camel_mime_message_get_subject (message);
 
-	e_composer_header_table_set_account_name (table, account_name);
+	e_composer_header_table_set_identity_uid (table, identity_uid);
 	e_composer_header_table_set_destinations_to (table, Tov);
 	e_composer_header_table_set_destinations_cc (table, Ccv);
 	e_composer_header_table_set_destinations_bcc (table, Bccv);
 	e_composer_header_table_set_subject (table, subject);
 
-	g_free (account_name);
+	g_free (identity_uid);
 
 	e_destination_freev (Tov);
 	e_destination_freev (Ccv);
@@ -3469,6 +3526,9 @@ e_msg_composer_new_with_message (EShell *shell,
 	set_signature_gui (composer);
 
 	return composer;
+#endif /* ACCOUNT_MGMT */
+
+	return NULL;
 }
 
 /**
@@ -3483,7 +3543,7 @@ e_msg_composer_new_with_message (EShell *shell,
 EMsgComposer *
 e_msg_composer_new_redirect (EShell *shell,
                              CamelMimeMessage *message,
-                             const gchar *resent_from,
+                             const gchar *identity_uid,
                              GCancellable *cancellable)
 {
 	EMsgComposer *composer;
@@ -3503,7 +3563,7 @@ e_msg_composer_new_redirect (EShell *shell,
 	composer->priv->redirect = message;
 	g_object_ref (message);
 
-	e_composer_header_table_set_account_name (table, resent_from);
+	e_composer_header_table_set_identity_uid (table, identity_uid);
 	e_composer_header_table_set_subject (table, subject);
 
 	web_view = e_msg_composer_get_web_view (composer);
@@ -4243,6 +4303,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
 	g_free (p->mime_type);
 	p->mime_type = g_strdup (mime_type);
 
+#if 0  /* ACCOUNT_MGMT */
 	if (g_ascii_strncasecmp (p->mime_type, "text/calendar", 13) == 0) {
 		EAccount *account;
 
@@ -4257,6 +4318,7 @@ e_msg_composer_set_body (EMsgComposer *composer,
 			gtk_toggle_action_set_active (action, FALSE);
 		}
 	}
+#endif /* ACCOUNT_MGMT */
 }
 
 /**
@@ -4819,23 +4881,34 @@ e_msg_composer_show_sig_file (EMsgComposer *composer)
 CamelInternetAddress *
 e_msg_composer_get_from (EMsgComposer *composer)
 {
-	CamelInternetAddress *address;
+	ESourceMailIdentity *mail_identity;
+	CamelInternetAddress *inet_address;
 	EComposerHeaderTable *table;
-	EAccount *account;
+	ESourceRegistry *registry;
+	ESource *source;
+	const gchar *extension_name;
+	const gchar *name, *address;
+	const gchar *uid;
 
 	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
 
 	table = e_msg_composer_get_header_table (composer);
 
-	account = e_composer_header_table_get_account (table);
-	if (account == NULL)
-		return NULL;
+	registry = e_composer_header_table_get_registry (table);
+	uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+	g_return_val_if_fail (source != NULL, NULL);
 
-	address = camel_internet_address_new ();
-	camel_internet_address_add (
-		address, account->id->name, account->id->address);
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	mail_identity = e_source_get_extension (source, extension_name);
 
-	return address;
+	name = e_source_mail_identity_get_name (mail_identity);
+	address = e_source_mail_identity_get_address (mail_identity);
+
+	inet_address = camel_internet_address_new ();
+	camel_internet_address_add (inet_address, name, address);
+
+	return inet_address;
 }
 
 CamelInternetAddress *
@@ -4855,8 +4928,8 @@ e_msg_composer_get_reply_to (EMsgComposer *composer)
 
 	address = camel_internet_address_new ();
 	if (camel_address_unformat (CAMEL_ADDRESS (address), reply_to) == -1) {
-		g_object_unref (CAMEL_OBJECT (address));
-		return NULL;
+		g_object_unref (address);
+		address = NULL;
 	}
 
 	return address;
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 258d260..30ad7222 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -25,7 +25,6 @@
 #define E_MSG_COMPOSER_H
 
 #include <camel/camel.h>
-#include <libedataserver/e-account.h>
 #include <libebook/e-destination.h>
 #include <gtkhtml-editor.h>
 #include <misc/e-attachment-view.h>
@@ -94,7 +93,7 @@ EMsgComposer *	e_msg_composer_new_from_url	(EShell *shell,
 						 const gchar *url);
 EMsgComposer *	e_msg_composer_new_redirect	(EShell *shell,
 						 CamelMimeMessage *message,
-						 const gchar *resent_from,
+						 const gchar *identity_uid,
 						 GCancellable *cancellable);
 EFocusTracker *	e_msg_composer_get_focus_tracker
 						(EMsgComposer *composer);



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