Index: mail/ChangeLog
===================================================================
--- mail/ChangeLog	(revision 37227)
+++ mail/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2009-02-05  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #336337
+
+	* mail-send-recv.c: (struct _send_info), (free_send_info),
+	(operation_status_timeout), (set_send_status), (set_send_account),
+	(build_dialog), (receive_status):
+	* mail-ops.c: (mail_send_message), (send_queue_exec): Show current
+	send server used for sending a message in a Send & Receive window.
+
 2009-02-04  Gilles Dartiguelongue  <gdartigu@svn.gnome.org>
 
 	** Fix for bug #568176
Index: mail/mail-send-recv.c
===================================================================
--- mail/mail-send-recv.c	(revision 37227)
+++ mail/mail-send-recv.c	(working copy)
@@ -117,6 +117,9 @@ struct _send_info {
 	char *what;
 	int pc;
 
+	GtkWidget *send_account_label;
+	char *send_url;
+
 	/*time_t update;*/
 	struct _send_data *data;
 };
@@ -145,6 +148,7 @@ free_send_info(struct _send_info *info)
 	if (info->timeout_id != 0)
 		g_source_remove(info->timeout_id);
 	g_free(info->what);
+	g_free (info->send_url);
 	g_free(info);
 }
 
@@ -254,12 +258,17 @@ dialog_response(GtkDialog *gd, int butto
 	}
 }
 
+static GStaticMutex status_lock = G_STATIC_MUTEX_INIT;
+static char *format_url (const char *internal_url, const char *account_name);
+
 static int
 operation_status_timeout(void *data)
 {
 	struct _send_info *info = data;
 
 	if (info->progress_bar) {
+		g_static_mutex_lock (&status_lock);
+
 		gtk_progress_bar_set_fraction (
 			GTK_PROGRESS_BAR (info->progress_bar),
 			info->pc / 100.0);
@@ -267,6 +276,21 @@ operation_status_timeout(void *data)
 			gtk_label_set_text (
 				GTK_LABEL (info->status_label),
 				info->what);
+		if (info->send_url && info->send_account_label) {
+			char *tmp = format_url (info->send_url, NULL);
+
+			g_free (info->send_url);
+			info->send_url = NULL;
+
+			gtk_label_set_markup (
+				GTK_LABEL (info->send_account_label),
+				tmp);
+
+			g_free (tmp);
+		}
+
+		g_static_mutex_unlock (&status_lock);
+
 		return TRUE;
 	}
 
@@ -276,10 +300,24 @@ operation_status_timeout(void *data)
 static void
 set_send_status(struct _send_info *info, const char *desc, int pc)
 {
-	/* FIXME: LOCK */
+	g_static_mutex_lock (&status_lock);
+
 	g_free(info->what);
 	info->what = g_strdup(desc);
 	info->pc = pc;
+
+	g_static_mutex_unlock (&status_lock);
+}
+
+static void
+set_send_account (struct _send_info *info, const char *account_url)
+{
+	g_static_mutex_lock (&status_lock);
+
+	g_free (info->send_url);
+	info->send_url = g_strdup (account_url);
+
+	g_static_mutex_unlock (&status_lock);
 }
 
 /* for camel operation status */
@@ -604,6 +642,7 @@ build_dialog (EAccountList *accounts, Ca
 		info->cancel_button = cancel_button;
 		info->data = data;
 		info->status_label = status_label;
+		info->send_account_label = label;
 
 		g_signal_connect (
 			cancel_button, "clicked",
@@ -666,6 +705,9 @@ receive_status (CamelFilterDriver *drive
 	case CAMEL_FILTER_STATUS_END:
 		set_send_status(info, desc, pc);
 		break;
+	case CAMEL_FILTER_STATUS_ACTION:
+		set_send_account (info, desc);
+		break;
 	default:
 		break;
 	}
Index: mail/mail-ops.c
===================================================================
--- mail/mail-ops.c	(revision 37227)
+++ mail/mail-ops.c	(working copy)
@@ -440,9 +440,12 @@ static char *resent_recipients[] = {
 	CAMEL_RECIPIENT_TYPE_RESENT_BCC
 };
 
+struct _send_queue_msg;
+static void report_status (struct _send_queue_msg *m, enum camel_filter_status_t status, int pc, const char *desc, ...);
+
 /* send 1 message to a specific transport */
 static void
-mail_send_message(CamelFolder *queue, const char *uid, const char *destination, CamelFilterDriver *driver, CamelException *ex)
+mail_send_message(struct _send_queue_msg *m, CamelFolder *queue, const char *uid, const char *destination, CamelFilterDriver *driver, CamelException *ex)
 {
 	EAccount *account = NULL;
 	const CamelInternetAddress *iaddr;
@@ -494,6 +497,9 @@ mail_send_message(CamelFolder *queue, co
 			sent_folder_uri = g_strstrip(g_strdup(tmp));
 	}
 
+	/* let the dialog know the right account it is using; percentage is ignored */
+	report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, transport_url ? transport_url : destination);
+
 	/* Check for email sending */
 	from = (CamelAddress *) camel_internet_address_new ();
 	resent_from = camel_medium_get_header (CAMEL_MEDIUM (message), "Resent-From");
@@ -736,7 +742,7 @@ send_queue_exec (struct _send_queue_msg 
  		if (!m->cancel)
  			camel_operation_progress (NULL, (i+1) * 100 / send_uids->len);
 
-		mail_send_message (m->queue, send_uids->pdata[i], m->destination, m->driver, &ex);
+		mail_send_message (m, m->queue, send_uids->pdata[i], m->destination, m->driver, &ex);
 		if (camel_exception_is_set (&ex)) {
 			if (ex.id != CAMEL_EXCEPTION_USER_CANCEL) {
 				/* merge exceptions into one */
