[evolution/account-mgmt: 24/50] Adapt modules/mail to the new ESource API.



commit 9e90e105c17bb0f73aab5e15eb25cb1942ed8566
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Apr 13 10:31:24 2011 -0400

    Adapt modules/mail to the new ESource API.

 modules/mail/e-mail-shell-backend.c      |   18 +-
 modules/mail/e-mail-shell-view-actions.c |   46 +++-
 modules/mail/e-mail-shell-view-private.c |  452 +++++++++++-------------------
 modules/mail/e-mail-shell-view-private.h |   13 +-
 modules/mail/e-mail-shell-view.c         |   42 ++-
 modules/mail/em-account-prefs.c          |   18 +-
 modules/mail/em-composer-prefs.c         |   27 +--
 7 files changed, 268 insertions(+), 348 deletions(-)
---
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 4e28d8c..bcb98b9 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -27,6 +27,9 @@
 
 #include <glib/gi18n.h>
 
+#include <libedataserver/e-source-registry.h>
+#include <libedataserver/e-source-mail-transport.h>
+
 #include <e-util/e-import.h>
 #include <e-util/e-util.h>
 
@@ -164,13 +167,26 @@ action_mail_message_new_cb (GtkAction *action,
 	EShellSidebar *shell_sidebar;
 	EShellView *shell_view;
 	EShell *shell;
+	ESourceRegistry *registry;
 	EMFolderTree *folder_tree;
 	CamelFolder *folder = NULL;
 	CamelStore *store;
+	GList *list;
+	const gchar *extension_name;
 	const gchar *view_name;
+	gboolean no_transport_defined;
 	gchar *folder_name;
 
 	shell = e_shell_window_get_shell (shell_window);
+	registry = e_shell_get_registry (shell);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+	list = e_source_registry_list_sources (registry, extension_name);
+	no_transport_defined = (list == NULL);
+	g_list_free (list);
+
+	if (no_transport_defined)
+		return;
 
 	/* Take care not to unnecessarily load the mail shell view. */
 	view_name = e_shell_window_get_active_view (shell_window);
@@ -488,8 +504,6 @@ mail_shell_backend_start (EShellBackend *shell_backend)
 		g_error_free (error);
 	}
 
-	mail_autoreceive_init (session);
-
 	if (g_getenv ("CAMEL_FLUSH_CHANGES") != NULL)
 		priv->mail_sync_source_id = g_timeout_add_seconds (
 			mail_config_get_sync_timeout (),
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 407f17e..3281e46 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -809,24 +809,58 @@ static void
 action_mail_send_receive_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
 {
-	e_mail_shell_view_send_receive (
-		mail_shell_view, E_MAIL_SEND_RECEIVE_BOTH, NULL);
+	EShellView *shell_view;
+	EShellWindow *shell_window;
+	EShellBackend *shell_backend;
+	EMailBackend *backend;
+	EMailSession *session;
+
+	shell_view = E_SHELL_VIEW (mail_shell_view);
+	shell_window = e_shell_view_get_shell_window (shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+
+	mail_send_receive (GTK_WINDOW (shell_window), session);
 }
 
 static void
 action_mail_send_receive_receive_all_cb (GtkAction *action,
                                          EMailShellView *mail_shell_view)
 {
-	e_mail_shell_view_send_receive (
-		mail_shell_view, E_MAIL_SEND_RECEIVE_RECEIVE, NULL);
+	EShellView *shell_view;
+	EShellWindow *shell_window;
+	EShellBackend *shell_backend;
+	EMailBackend *backend;
+	EMailSession *session;
+
+	shell_view = E_SHELL_VIEW (mail_shell_view);
+	shell_window = e_shell_view_get_shell_window (shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+
+	mail_receive (GTK_WINDOW (shell_window), session);
 }
 
 static void
 action_mail_send_receive_send_all_cb (GtkAction *action,
                                       EMailShellView *mail_shell_view)
 {
-	e_mail_shell_view_send_receive (
-		mail_shell_view, E_MAIL_SEND_RECEIVE_SEND, NULL);
+	EShellView *shell_view;
+	EShellBackend *shell_backend;
+	EMailBackend *backend;
+	EMailSession *session;
+
+	shell_view = E_SHELL_VIEW (mail_shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+
+	mail_send (session);
 }
 
 static void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index f43734f..e33f868 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -959,10 +959,13 @@ void
 e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
 {
 	EMailShellContent *mail_shell_content;
+	EShellBackend *shell_backend;
 	EShellSidebar *shell_sidebar;
 	EShellView *shell_view;
+	EShell *shell;
 	EMailReader *reader;
 	EMailView *mail_view;
+	ESourceRegistry *registry;
 	CamelStore *parent_store;
 	CamelFolder *folder;
 	GPtrArray *uids;
@@ -984,8 +987,12 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
 	mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
 
 	shell_view = E_SHELL_VIEW (mail_shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
 	shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
 
+	shell = e_shell_backend_get_shell (shell_backend);
+	registry = e_shell_get_registry (shell);
+
 	reader = E_MAIL_READER (mail_view);
 	folder = e_mail_reader_get_folder (reader);
 
@@ -1048,19 +1055,19 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
 				num_junked), num_junked);
 
 	/* "Drafts" folder */
-	} else if (em_utils_folder_is_drafts (folder)) {
+	} else if (em_utils_folder_is_drafts (registry, folder)) {
 		g_string_append_printf (
 			buffer, ngettext ("%d draft", "%d drafts",
 			num_visible), num_visible);
 
 	/* "Outbox" folder */
-	} else if (em_utils_folder_is_outbox (folder)) {
+	} else if (em_utils_folder_is_outbox (registry, folder)) {
 		g_string_append_printf (
 			buffer, ngettext ("%d unsent", "%d unsent",
 			num_visible), num_visible);
 
 	/* "Sent" folder */
-	} else if (em_utils_folder_is_sent (folder)) {
+	} else if (em_utils_folder_is_sent (registry, folder)) {
 		g_string_append_printf (
 			buffer, ngettext ("%d sent", "%d sent",
 			num_visible), num_visible);
@@ -1113,308 +1120,195 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
 	g_string_free (buffer, TRUE);
 }
 
-void
-e_mail_shell_view_send_receive (EMailShellView *mail_shell_view,
-                                EMailSendReceiveMode mode,
-                                const gchar *account_uid)
-{
-	EShellView *shell_view;
-	EShellWindow *shell_window;
-	EShellBackend *shell_backend;
-	EMailBackend *backend;
-	EMailSession *session;
-
-	g_return_if_fail (mail_shell_view != NULL);
+typedef struct {
+	GtkMenuShell *menu;
+	CamelSession *session;
+	ESourceRegistry *registry;
 
-	shell_view = E_SHELL_VIEW (mail_shell_view);
-	shell_window = e_shell_view_get_shell_window (shell_view);
-	shell_backend = e_shell_view_get_shell_backend (shell_view);
+	/* GtkMenuItem -> ESource */
+	GHashTable *menu_items;
 
-	backend = E_MAIL_BACKEND (shell_backend);
-	session = e_mail_backend_get_session (backend);
-
-	em_utils_clear_get_password_canceled_accounts_flag ();
-
-	if (!account_uid) {
-		switch (mode) {
-		case E_MAIL_SEND_RECEIVE_BOTH:
-			mail_send_receive (GTK_WINDOW (shell_window), session);
-			break;
-		case E_MAIL_SEND_RECEIVE_RECEIVE:
-			mail_receive (GTK_WINDOW (shell_window), session);
-			break;
-		case E_MAIL_SEND_RECEIVE_SEND:
-			mail_send (session);
-			break;
-		}
-	} else {
-		/* allow only receive on individual accounts */
-		EAccount *account;
-		CamelService *service;
-
-		account = e_get_account_by_uid (account_uid);
-		g_return_if_fail (account != NULL);
-
-		if (!account->enabled)
-			return;
-
-		service = camel_session_get_service (
-			CAMEL_SESSION (session), account->uid);
-
-		mail_receive_service (service);
-	}
-}
+	/* Signal handlers */
+	gulong source_added_id;
+	gulong source_removed_id;
+} SendReceiveData;
 
 static GtkMenuItem *
-send_receive_find_account_menu_item (GtkMenuShell *menu,
-                                     EAccount *account)
+send_receive_find_menu_item (SendReceiveData *data,
+                             gpointer source)
 {
-	GList *children, *child;
+	GHashTableIter iter;
+	gpointer menu_item;
+	gpointer candidate;
 
-	g_return_val_if_fail (menu != NULL, NULL);
-	g_return_val_if_fail (account != NULL, NULL);
-	g_return_val_if_fail (account->uid != NULL, NULL);
+	g_hash_table_iter_init (&iter, data->menu_items);
 
-	children = gtk_container_get_children (GTK_CONTAINER (menu));
-
-	for (child = children; child != NULL; child = child->next) {
-		GObject *obj = child->data;
-		const gchar *uid;
-
-		if (!obj)
-			continue;
-
-		uid = g_object_get_data (obj, "e-account-uid");
-		if (!uid)
-			continue;
-
-		if (g_strcmp0 (uid, account->uid) == 0) {
-			g_list_free (children);
-
-			return GTK_MENU_ITEM (obj);
-		}
-	}
-
-	g_list_free (children);
+	while (g_hash_table_iter_next (&iter, &menu_item, &candidate))
+		if (source == candidate)
+			return GTK_MENU_ITEM (menu_item);
 
 	return NULL;
 }
 
-static gint
-send_receive_get_account_index (EAccount *account)
-{
-	gint res;
-	EAccountList *accounts;
-	EIterator *iterator;
-
-	g_return_val_if_fail (account != NULL, -1);
-
-	accounts = e_get_account_list ();
-	g_return_val_if_fail (accounts != NULL, -1);
-
-	res = 0;
-	for (iterator = e_list_get_iterator (E_LIST (accounts));
-	     e_iterator_is_valid (iterator);
-	     e_iterator_next (iterator)) {
-		EAccount *candidate;
-		const gchar *name;
-
-		candidate = (EAccount *) e_iterator_get (iterator);
-
-		if (candidate == NULL)
-			continue;
-
-		if (!candidate->enabled)
-			continue;
-
-		if (candidate->source == NULL)
-			continue;
-
-		if (candidate->source->url == NULL)
-			continue;
-
-		if (*candidate->source->url == '\0')
-			continue;
-
-		name = e_account_get_string (candidate, E_ACCOUNT_NAME);
-		if (name == NULL || *name == '\0')
-			continue;
-
-		if (candidate->uid == NULL)
-			continue;
-
-		if (*candidate->uid == '\0')
-			continue;
-
-		if (g_strcmp0 (candidate->uid, account->uid) == 0) {
-			g_object_unref (iterator);
-			return res;
-		}
-
-		res++;
-	}
-
-	g_object_unref (iterator);
-
-	return -1;
-}
-
 static void
-send_receive_account_item_activate_cb (GtkMenuItem *item,
-                                       GtkMenuShell *menu)
+send_receive_account_item_activate_cb (GtkMenuItem *menu_item,
+                                       SendReceiveData *data)
 {
-	EMailShellView *mail_shell_view;
-	const gchar *account_uid;
+	ESource *source;
+	CamelService *service;
+	const gchar *uid;
 
-	g_return_if_fail (item != NULL);
-	g_return_if_fail (menu != NULL);
+	source = g_hash_table_lookup (data->menu_items, menu_item);
+	g_return_if_fail (E_IS_SOURCE (source));
 
-	mail_shell_view = g_object_get_data (G_OBJECT (menu), "mail-shell-view");
-	g_return_if_fail (mail_shell_view != NULL);
+	/* Shouldn't get here if the source is disabled. */
+	g_return_if_fail (e_source_get_enabled (source));
 
-	account_uid = g_object_get_data (G_OBJECT (item), "e-account-uid");
-	g_return_if_fail (account_uid != NULL);
+	uid = e_source_get_uid (source);
+	service = camel_session_get_service (data->session, uid);
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
-	e_mail_shell_view_send_receive (
-		mail_shell_view, E_MAIL_SEND_RECEIVE_RECEIVE, account_uid);
+	mail_receive_service (service);
 }
 
 static void
-send_receive_add_to_menu (GtkMenuShell *menu,
-                          EAccount *account,
-                          gint insert_index)
+send_receive_add_to_menu (SendReceiveData *data,
+                          ESource *source,
+                          gint position)
 {
-	const gchar *name;
-	GtkWidget *item;
-
-	g_return_if_fail (menu != NULL);
-	g_return_if_fail (account != NULL);
-
-	if (send_receive_find_account_menu_item (menu, account) != NULL)
-		return;
-
-	if (account->source == NULL)
-		return;
+	GtkWidget *menu_item;
 
-	if (account->source->url == NULL)
+	if (send_receive_find_menu_item (data, source) != NULL)
 		return;
 
-	if (*account->source->url == '\0')
-		return;
+	menu_item = gtk_menu_item_new ();
+	gtk_widget_show (menu_item);
 
-	name = e_account_get_string (account, E_ACCOUNT_NAME);
-	if (name == NULL || *name == '\0')
-		return;
+	g_object_bind_property (
+		source, "display-name",
+		menu_item, "label",
+		G_BINDING_SYNC_CREATE);
 
-	if (account->uid == NULL)
-		return;
+	g_object_bind_property (
+		source, "enabled",
+		menu_item, "visible",
+		G_BINDING_SYNC_CREATE);
 
-	if (*account->uid == '\0')
-		return;
+	g_hash_table_insert (
+		data->menu_items, menu_item,
+		g_object_ref (source));
 
-	item = gtk_menu_item_new_with_label (name);
-	gtk_widget_show (item);
-	g_object_set_data_full (
-		G_OBJECT (item), "e-account-uid",
-		g_strdup (account->uid), g_free);
 	g_signal_connect (
-		item, "activate",
-		G_CALLBACK (send_receive_account_item_activate_cb), menu);
+		menu_item, "activate",
+		G_CALLBACK (send_receive_account_item_activate_cb), data);
 
-	/* it's index between accounts, not in the menu */
-	if (insert_index < 0)
-		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	/* Position is with respect to the sorted list of ESources
+	 * with a mail account extension, not menu item position. */
+	if (position < 0)
+		gtk_menu_shell_append (data->menu, menu_item);
 	else
-		gtk_menu_shell_insert (
-			GTK_MENU_SHELL (menu), item, insert_index + 4);
+		gtk_menu_shell_insert (data->menu, menu_item, position + 4);
 }
 
 static void
-send_receive_remove_from_menu (GtkMenuShell *menu,
-                               EAccount *account)
+send_receive_menu_source_added_cb (ESourceRegistry *registry,
+                                   ESource *source,
+                                   SendReceiveData *data)
 {
-	GtkMenuItem *item;
-
-	g_return_if_fail (menu != NULL);
-	g_return_if_fail (account != NULL);
+	const gchar *extension_name;
+	GList *list;
+	gint position;
 
-	item = send_receive_find_account_menu_item (menu, account);
-	if (item == NULL)
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	if (!e_source_has_extension (source, extension_name))
 		return;
 
-	gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET (item));
+	/* List is already sorted by display name. */
+	list = e_source_registry_list_sources (data->registry, extension_name);
+	position = g_list_index (list, source);
+	g_list_free (list);
+
+	send_receive_add_to_menu (data, source, position);
 }
 
 static void
-send_receive_menu_account_added_cb (EAccountList *list,
-                                    EAccount *account,
-                                    GtkMenuShell *menu)
+send_receive_menu_source_removed_cb (ESourceRegistry *registry,
+                                     ESource *source,
+                                     SendReceiveData *data)
 {
-	g_return_if_fail (account != NULL);
-	g_return_if_fail (menu != NULL);
+	GtkMenuItem *menu_item;
+	const gchar *extension_name;
 
-	if (account->enabled)
-		send_receive_add_to_menu (
-			menu, account,
-			send_receive_get_account_index (account));
-}
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	if (!e_source_has_extension (source, extension_name))
+		return;
 
-static void
-send_receive_menu_account_changed_cb (EAccountList *list,
-                                      EAccount *account,
-                                      GtkMenuShell *menu)
-{
-	g_return_if_fail (account != NULL);
-	g_return_if_fail (menu != NULL);
-
-	if (account->enabled) {
-		GtkMenuItem *item;
-
-		item = send_receive_find_account_menu_item (menu, account);
-
-		if (item) {
-			if (account->source == NULL ||
-				account->source->url == NULL ||
-				*account->source->url == '\0') {
-				send_receive_remove_from_menu (menu, account);
-			} else {
-				const gchar *name;
-
-				name = e_account_get_string (
-					account, E_ACCOUNT_NAME);
-				if (name != NULL && *name != '\0')
-					gtk_menu_item_set_label (item, name);
-			}
-		} else {
-			send_receive_add_to_menu (
-				menu, account,
-				send_receive_get_account_index (account));
-		}
-	} else {
-		send_receive_remove_from_menu (menu, account);
-	}
+	menu_item = send_receive_find_menu_item (data, source);
+	if (menu_item == NULL)
+		return;
+
+	g_hash_table_remove (data->menu_items, menu_item);
+
+	gtk_container_remove (
+		GTK_CONTAINER (data->menu),
+		GTK_WIDGET (menu_item));
 }
 
 static void
-send_receive_menu_account_removed_cb (EAccountList *list,
-                                      EAccount *account,
-                                      GtkMenuShell *menu)
+send_receive_data_free (SendReceiveData *data)
 {
-	g_return_if_fail (account != NULL);
-	g_return_if_fail (menu != NULL);
+	g_signal_handler_disconnect (data->registry, data->source_added_id);
+	g_signal_handler_disconnect (data->registry, data->source_removed_id);
 
-	send_receive_remove_from_menu (menu, account);
+	g_object_unref (data->session);
+	g_object_unref (data->registry);
+
+	g_hash_table_destroy (data->menu_items);
+
+	g_slice_free (SendReceiveData, data);
 }
 
-static void
-menu_weak_ref_cb (gpointer accounts,
-                  GObject *where_the_object_was)
+static SendReceiveData *
+send_receive_data_new (EMailShellView *mail_shell_view,
+                       GtkWidget *menu)
 {
-	g_return_if_fail (accounts != NULL);
+	SendReceiveData *data;
+	EShellView *shell_view;
+	EShellBackend *shell_backend;
+	ESourceRegistry *registry;
+	EMailBackend *backend;
+	EMailSession *session;
+
+	shell_view = E_SHELL_VIEW (mail_shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
 
-	g_signal_handlers_disconnect_matched (
-		accounts, G_SIGNAL_MATCH_DATA,
-		0, 0, NULL, NULL, where_the_object_was);
+	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+	registry = e_mail_session_get_registry (session);
+
+	data = g_slice_new0 (SendReceiveData);
+	data->menu = GTK_MENU_SHELL (menu);  /* do not reference */
+	data->session = g_object_ref (session);
+	data->registry = g_object_ref (registry);
+
+	data->menu_items = g_hash_table_new_full (
+		(GHashFunc) g_direct_hash,
+		(GEqualFunc) g_direct_equal,
+		(GDestroyNotify) NULL,
+		(GDestroyNotify) g_object_unref);
+
+	data->source_added_id = g_signal_connect (
+		registry, "source-added",
+		G_CALLBACK (send_receive_menu_source_added_cb), data);
+	data->source_removed_id = g_signal_connect (
+		registry, "source-removed",
+		G_CALLBACK (send_receive_menu_source_removed_cb), data);
+
+	g_object_weak_ref (
+		G_OBJECT (menu), (GWeakNotify)
+		send_receive_data_free, data);
+
+	return data;
 }
 
 static GtkWidget *
@@ -1422,18 +1316,28 @@ create_send_receive_submenu (EMailShellView *mail_shell_view)
 {
 	EShellView *shell_view;
 	EShellWindow *shell_window;
-	EAccountList *accounts;
+	EShellBackend *shell_backend;
+	ESourceRegistry *registry;
+	EMailBackend *backend;
+	EMailSession *session;
 	GtkWidget *menu;
 	GtkAccelGroup *accel_group;
 	GtkUIManager *ui_manager;
 	GtkAction *action;
+	GList *list, *link;
+	SendReceiveData *data;
+	const gchar *extension_name;
 
 	g_return_val_if_fail (mail_shell_view != NULL, NULL);
 
 	shell_view = E_SHELL_VIEW (mail_shell_view);
 	shell_window = e_shell_view_get_shell_window (shell_view);
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
+
+	backend = E_MAIL_BACKEND (shell_backend);
+	session = e_mail_backend_get_session (backend);
+	registry = e_mail_session_get_registry (session);
 
-	accounts = e_get_account_list ();
 	menu = gtk_menu_new ();
 	ui_manager = e_shell_window_get_ui_manager (shell_window);
 	accel_group = gtk_ui_manager_get_accel_group (ui_manager);
@@ -1462,46 +1366,18 @@ create_send_receive_submenu (EMailShellView *mail_shell_view)
 		GTK_MENU_SHELL (menu),
 		gtk_separator_menu_item_new ());
 
-	if (accounts) {
-		EIterator *iterator;
-
-		for (iterator = e_list_get_iterator (E_LIST (accounts));
-		     e_iterator_is_valid (iterator);
-		     e_iterator_next (iterator)) {
-			EAccount *account;
+	data = send_receive_data_new (mail_shell_view, menu);
 
-			account = (EAccount *) e_iterator_get (iterator);
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-			if (account == NULL)
-				continue;
+	for (link = list; link != NULL; link = g_list_next (link))
+		send_receive_add_to_menu (data, E_SOURCE (link->data), -1);
 
-			if (!account->enabled)
-				continue;
-
-			send_receive_add_to_menu (
-				GTK_MENU_SHELL (menu), account, -1);
-		}
-
-		g_object_unref (iterator);
-
-		g_signal_connect (
-			accounts, "account-added",
-			G_CALLBACK (send_receive_menu_account_added_cb), menu);
-		g_signal_connect (
-			accounts, "account-changed",
-			G_CALLBACK (send_receive_menu_account_changed_cb), menu);
-		g_signal_connect (
-			accounts, "account-removed",
-			G_CALLBACK (send_receive_menu_account_removed_cb), menu);
-
-		g_object_weak_ref (
-			G_OBJECT (menu), menu_weak_ref_cb, accounts);
-	}
+	g_list_free (list);
 
 	gtk_widget_show_all (menu);
 
-	g_object_set_data (G_OBJECT (menu), "mail-shell-view", mail_shell_view);
-
 	return menu;
 }
 
diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h
index c60d5c6..e793d5f 100644
--- a/modules/mail/e-mail-shell-view-private.h
+++ b/modules/mail/e-mail-shell-view-private.h
@@ -27,14 +27,13 @@
 #include <glib/gi18n.h>
 #include <gtkhtml/gtkhtml.h>
 #include <camel/camel-search-private.h>  /* for camel_search_word */
+#include <libedataserver/e-source-mail-account.h>
 
 #include <e-util/e-util.h>
 #include <e-util/e-ui-manager.h>
 
 #include <filter/e-filter-part.h>
 
-#include <libemail-utils/e-account-utils.h>
-
 #include <libemail-engine/e-mail-folder-utils.h>
 #include <libemail-engine/e-mail-session.h>
 #include <libemail-engine/e-mail-session-utils.h>
@@ -133,12 +132,6 @@ enum {
 	MAIL_SCOPE_ALL_ACCOUNTS
 };
 
-typedef enum  {
-	E_MAIL_SEND_RECEIVE_BOTH,
-	E_MAIL_SEND_RECEIVE_RECEIVE,
-	E_MAIL_SEND_RECEIVE_SEND
-} EMailSendReceiveMode;
-
 struct _EMailShellViewPrivate {
 
 	/*** Other Stuff ***/
@@ -194,10 +187,6 @@ void		e_mail_shell_view_update_search_filter
 					(EMailShellView *mail_shell_view);
 void		e_mail_shell_view_update_sidebar
 					(EMailShellView *mail_shell_view);
-void		e_mail_shell_view_send_receive
-					(EMailShellView *mail_shell_view,
-					 EMailSendReceiveMode mode,
-					 const gchar *account_uid);
 void		e_mail_shell_view_update_send_receive_menus
 					(EMailShellView *mail_shell_view);
 
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index afd7501..23699a4 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -223,6 +223,7 @@ mail_shell_view_execute_search (EShellView *shell_view)
 	EMailBackend *backend;
 	EMailSession *session;
 	MailFolderCache *cache;
+	ESourceRegistry *registry;
 	EMFolderTree *folder_tree;
 	GtkWidget *message_list;
 	EFilterRule *rule;
@@ -269,6 +270,7 @@ mail_shell_view_execute_search (EShellView *shell_view)
 	folder = e_mail_reader_get_folder (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
+	registry = e_mail_session_get_registry (session);
 	label_store = e_mail_ui_session_get_label_store (E_MAIL_UI_SESSION (session));
 
 	action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN);
@@ -388,7 +390,7 @@ filter:
 			break;
 
 		case MAIL_FILTER_RECENT_MESSAGES:
-			if (em_utils_folder_is_sent (folder))
+			if (em_utils_folder_is_sent (registry, folder))
 				temp = g_strdup_printf (
 					"(and %s (match-all "
 					"(> (get-sent-date) "
@@ -405,7 +407,7 @@ filter:
 			break;
 
 		case MAIL_FILTER_LAST_5_DAYS_MESSAGES:
-			if (em_utils_folder_is_sent (folder))
+			if (em_utils_folder_is_sent (registry, folder))
 				temp = g_strdup_printf (
 					"(and %s (match-all "
 					"(> (get-sent-date) "
@@ -808,12 +810,14 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	EMailShellSidebar *mail_shell_sidebar;
 	EShellSidebar *shell_sidebar;
 	EShellWindow *shell_window;
+	EShell *shell;
 	EMFolderTree *folder_tree;
 	EMFolderTreeModel *model;
 	EMailReader *reader;
 	EMailView *mail_view;
 	CamelStore *store;
-	EAccount *account;
+	ESourceRegistry *registry;
+	ESource *source = NULL;
 	GtkAction *action;
 	GList *list, *link;
 	const gchar *label;
@@ -837,6 +841,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	E_SHELL_VIEW_CLASS (parent_class)->update_actions (shell_view);
 
 	shell_window = e_shell_view_get_shell_window (shell_view);
+	shell = e_shell_window_get_shell (shell_window);
+	registry = e_shell_get_registry (shell);
 
 	mail_shell_view = E_MAIL_SHELL_VIEW (shell_view);
 	mail_shell_content = mail_shell_view->priv->mail_shell_content;
@@ -876,9 +882,26 @@ mail_shell_view_update_actions (EShellView *shell_view)
 
 		service = CAMEL_SERVICE (store);
 		uid = camel_service_get_uid (service);
-		account = e_get_account_by_uid (uid);
-	} else
-		account = NULL;
+		source = e_source_registry_lookup_by_uid (registry, uid);
+	}
+
+	if (source != NULL) {
+		ESourceExtension *extension;
+		const gchar *backend_name;
+		const gchar *extension_name;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+
+		backend_name =
+			e_source_backend_get_backend_name (
+			E_SOURCE_BACKEND (extension));
+
+		/* FIXME This belongs in a GroupWise plugin. */
+		account_is_groupwise =
+			(g_strcmp0 (backend_name, "groupwise") == 0) &&
+			(e_source_get_parent (source) != NULL);
+	}
 
 	if (uri != NULL) {
 		GtkTreeRowReference *reference;
@@ -902,11 +925,6 @@ mail_shell_view_update_actions (EShellView *shell_view)
 			g_free (folder_uri);
 		}
 
-		/* FIXME This belongs in a GroupWise plugin. */
-		account_is_groupwise =
-			(g_strrstr (uri, "groupwise://") != NULL) &&
-			account != NULL && account->parent_uid != NULL;
-
 		reference = em_folder_tree_model_lookup_uri (model, uri);
 		if (reference != NULL) {
 			GtkTreePath *path;
@@ -937,7 +955,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
 	g_list_free (list);
 
 	action = ACTION (MAIL_ACCOUNT_DISABLE);
-	sensitive = (account != NULL) && folder_is_store;
+	sensitive = (source != NULL) && folder_is_store;
 	if (account_is_groupwise)
 		label = _("Proxy _Logout");
 	else
diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c
index c6b132e..6b7c087 100644
--- a/modules/mail/em-account-prefs.c
+++ b/modules/mail/em-account-prefs.c
@@ -37,8 +37,6 @@
 
 #include <shell/e-shell.h>
 
-#include <libemail-utils/e-account-utils.h>
-
 #include <capplet/settings/mail-capplet-shell.h>
 
 #include <mail/e-mail-backend.h>
@@ -180,6 +178,8 @@ account_prefs_add_account (EMailAccountManager *manager)
 {
 	EMAccountPrefsPrivate *priv;
 	EMAccountEditor *emae;
+	EMailAccountStore *store;
+	EMailSession *session;
 	gpointer parent;
 
 	priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
@@ -189,6 +189,9 @@ account_prefs_add_account (EMailAccountManager *manager)
 		return;
 	}
 
+	store = e_mail_account_manager_get_store (manager);
+	session = e_mail_account_store_get_session (store);
+
 	parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
 	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
 
@@ -202,7 +205,7 @@ account_prefs_add_account (EMailAccountManager *manager)
 		 * The new mail account assistant.
 		 */
 		emae = em_account_editor_new (
-			NULL, EMAE_ASSISTANT, priv->backend,
+			NULL, EMAE_ASSISTANT, session,
 			"org.gnome.evolution.mail.config.accountAssistant");
 		e_config_create_window (
 			E_CONFIG (emae->config), NULL,
@@ -222,10 +225,12 @@ account_prefs_add_account (EMailAccountManager *manager)
 
 static void
 account_prefs_edit_account (EMailAccountManager *manager,
-                            EAccount *account)
+                            ESource *source)
 {
 	EMAccountPrefsPrivate *priv;
 	EMAccountEditor *emae;
+	EMailAccountStore *store;
+	EMailSession *session;
 	gpointer parent;
 
 	priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
@@ -235,6 +240,9 @@ account_prefs_edit_account (EMailAccountManager *manager,
 		return;
 	}
 
+	store = e_mail_account_manager_get_store (manager);
+	session = e_mail_account_store_get_session (store);
+
 	parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
 	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
 
@@ -247,7 +255,7 @@ account_prefs_edit_account (EMailAccountManager *manager,
 	 * The account editor window.
 	 */
 	emae = em_account_editor_new (
-		account, EMAE_NOTEBOOK, priv->backend,
+		source, EMAE_NOTEBOOK, session,
 		"org.gnome.evolution.mail.config.accountEditor");
 	e_config_create_window (
 		E_CONFIG (emae->config), parent, _("Account Editor"));
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index e678152..e36a0a5 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -41,16 +41,12 @@
 #include <e-util/e-util.h>
 #include <e-util/e-util-private.h>
 
-#include <libemail-utils/e-signature-utils.h>
-
 #include <composer/e-msg-composer.h>
 
 #include <shell/e-shell-utils.h>
 
 #include <misc/e-charset-combo-box.h>
-#include <misc/e-signature-editor.h>
-#include <misc/e-signature-manager.h>
-#include <misc/e-signature-preview.h>
+#include <misc/e-mail-signature-manager.h>
 
 #include <mail/em-config.h>
 #include <mail/em-folder-selection-button.h>
@@ -323,8 +319,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
 	GtkWidget *toplevel, *widget, *info_pixmap;
 	GtkWidget *container;
 	EShellSettings *shell_settings;
-	ESignatureList *signature_list;
-	ESignatureTreeView *signature_tree_view;
+	ESourceRegistry *registry;
 	GtkTreeView *view;
 	GtkListStore *store;
 	GtkTreeSelection *selection;
@@ -334,6 +329,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
 	GSList *l;
 	gint i;
 
+	registry = e_shell_get_registry (shell);
 	shell_settings = e_shell_get_shell_settings (shell);
 
 	/* Make sure our custom widget classes are registered with
@@ -548,10 +544,9 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
 		NULL, (GDestroyNotify) NULL);
 
 	/* Signatures */
-	signature_list = e_get_signature_list ();
 	container = e_builder_get_widget (
 		prefs->builder, "signature-alignment");
-	widget = e_signature_manager_new (signature_list);
+	widget = e_mail_signature_manager_new (registry);
 	gtk_container_add (GTK_CONTAINER (container), widget);
 	gtk_widget_show (widget);
 
@@ -568,20 +563,6 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
 			widget, "prefer-html",
 			G_BINDING_SYNC_CREATE);
 
-	signature_tree_view = e_signature_manager_get_tree_view (
-		E_SIGNATURE_MANAGER (widget));
-
-	container = e_builder_get_widget (
-		prefs->builder, "signature-preview-scrolled-window");
-	widget = e_signature_preview_new ();
-	gtk_container_add (GTK_CONTAINER (container), widget);
-	gtk_widget_show (widget);
-
-	g_object_bind_property (
-		signature_tree_view, "selected",
-		widget, "signature",
-		G_BINDING_SYNC_CREATE);
-
 	/* Sanitize the dialog for Express mode */
 	e_shell_hide_widgets_for_express_mode (
 		shell, prefs->builder,



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