[evolution] Bug #268618 - Add: Save replies in the folder of the message being replied to



commit bf8eaa185a845fc1118b3ebd9ad474a0de58abf6
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 18 19:44:35 2012 +0200

    Bug #268618 - Add: Save replies in the folder of the message being replied to

 libemail-engine/e-mail-session-utils.c |   11 +++++++++++
 libemail-engine/mail-ops.c             |   19 +++++++++++++++++--
 mail/e-mail-config-defaults-page.c     |   26 +++++++++++++++++++++++---
 3 files changed, 51 insertions(+), 5 deletions(-)
---
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index f26981d..33e7eff 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -813,6 +813,7 @@ e_mail_session_send_to (EMailSession *session,
 	const gchar *resent_from;
 	gchar *transport_uid = NULL;
 	gchar *sent_folder_uri = NULL;
+	gboolean replies_to_origin_folder = FALSE;
 	GError *error = NULL;
 
 	g_return_if_fail (E_IS_MAIL_SESSION (session));
@@ -848,6 +849,8 @@ e_mail_session_send_to (EMailSession *session,
 		string = e_source_mail_submission_get_transport_uid (extension);
 		transport_uid = g_strdup (string);
 
+		replies_to_origin_folder = e_source_mail_submission_get_replies_to_origin_folder (extension);
+
 		g_object_unref (source);
 	}
 
@@ -859,6 +862,14 @@ e_mail_session_send_to (EMailSession *session,
 	if (transport_uid == NULL && string != NULL)
 		transport_uid = g_strstrip (g_strdup (string));
 
+	if (replies_to_origin_folder) {
+		string = camel_header_raw_find (&xev, "X-Evolution-Source-Folder", NULL);
+		if (string != NULL && camel_header_raw_find (&xev, "X-Evolution-Source-Message", NULL) != NULL) {
+			g_free (sent_folder_uri);
+			sent_folder_uri = g_strstrip (g_strdup (string));
+		}
+	}
+
 	post_to_uris = g_ptr_array_new ();
 	for (header = xev; header != NULL; header = header->next) {
 		gchar *folder_uri;
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 115c2c7..e24e8c9 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -527,7 +527,8 @@ static gboolean
 get_submission_details_from_identity (EMailSession *session,
                                       const gchar *identity_uid,
                                       gchar **out_transport_uid,
-                                      gchar **out_sent_folder_uri)
+                                      gchar **out_sent_folder_uri,
+				      gboolean *out_replies_to_origin_folder)
 {
 	ESource *source;
 	ESourceRegistry *registry;
@@ -556,6 +557,10 @@ get_submission_details_from_identity (EMailSession *session,
 		e_source_mail_submission_dup_transport_uid (
 		E_SOURCE_MAIL_SUBMISSION (extension));
 
+	*out_replies_to_origin_folder =
+		e_source_mail_submission_get_replies_to_origin_folder (
+		E_SOURCE_MAIL_SUBMISSION (extension));
+
 	g_object_unref (source);
 
 	return TRUE;
@@ -579,6 +584,7 @@ mail_send_message (struct _send_queue_msg *m,
 	gchar *transport_uid = NULL;
 	gchar *sent_folder_uri = NULL;
 	const gchar *resent_from, *tmp;
+	gboolean replies_to_origin_folder = FALSE;
 	CamelFolder *folder = NULL;
 	GString *err = NULL;
 	struct _camel_header_raw *xev, *header;
@@ -603,7 +609,8 @@ mail_send_message (struct _send_queue_msg *m,
 		identity_uid = g_strstrip (g_strdup (tmp));
 		get_submission_details_from_identity (
 			m->session, identity_uid,
-			&transport_uid, &sent_folder_uri);
+			&transport_uid, &sent_folder_uri,
+			&replies_to_origin_folder);
 		g_free (identity_uid);
 	}
 
@@ -615,6 +622,14 @@ mail_send_message (struct _send_queue_msg *m,
 	if (sent_folder_uri == NULL && tmp != NULL)
 		sent_folder_uri = g_strstrip (g_strdup (tmp));
 
+	if (replies_to_origin_folder) {
+		tmp = camel_header_raw_find (&xev, "X-Evolution-Source-Folder", NULL);
+		if (tmp != NULL && camel_header_raw_find (&xev, "X-Evolution-Source-Message", NULL) != NULL) {
+			g_free (sent_folder_uri);
+			sent_folder_uri = g_strstrip (g_strdup (tmp));
+		}
+	}
+
 	service = camel_session_ref_service (
 		CAMEL_SESSION (m->session), transport_uid);
 	if (service != NULL)
diff --git a/mail/e-mail-config-defaults-page.c b/mail/e-mail-config-defaults-page.c
index 1420dda..64e29cb 100644
--- a/mail/e-mail-config-defaults-page.c
+++ b/mail/e-mail-config-defaults-page.c
@@ -39,6 +39,7 @@ struct _EMailConfigDefaultsPagePrivate {
 
 	GtkWidget *drafts_button;  /* not referenced */
 	GtkWidget *sent_button;    /* not referenced */
+	GtkWidget *replies_toggle; /* not referenced */
 	GtkWidget *trash_toggle;   /* not referenced */
 	GtkWidget *junk_toggle;    /* not referenced */
 };
@@ -272,6 +273,8 @@ mail_config_defaults_page_restore_folders (EMailConfigDefaultsPage *page)
 		button = EM_FOLDER_SELECTION_BUTTON (page->priv->sent_button);
 		folder_uri = e_mail_session_get_local_folder_uri (session, type);
 		em_folder_selection_button_set_folder_uri (button, folder_uri);
+
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->priv->replies_toggle), FALSE);
 	}
 }
 
@@ -608,9 +611,26 @@ mail_config_defaults_page_constructed (GObject *object)
 		G_BINDING_BIDIRECTIONAL |
 		G_BINDING_SYNC_CREATE);
 
+	widget = gtk_check_button_new_with_mnemonic (_("S_ave replies in the folder of the message being replied to"));
+	g_object_set (widget, "xalign", 0.0, NULL);
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
+	page->priv->replies_toggle = widget; /* not referenced */
+	gtk_widget_show (widget);
+
+	if (provider && (provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER) != 0) {
+		gtk_widget_set_sensitive (widget, FALSE);
+	}
+
+	g_object_bind_property (
+		submission_ext, "replies-to-origin-folder",
+		widget, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
 	widget = gtk_button_new_with_mnemonic (_("_Restore Defaults"));
 	gtk_widget_set_halign (widget, GTK_ALIGN_START);
-	gtk_grid_attach (GTK_GRID (container), widget, 1, 5, 1, 1);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 6, 1, 1);
 	gtk_widget_show (widget);
 
 	g_signal_connect_swapped (
@@ -626,7 +646,7 @@ mail_config_defaults_page_constructed (GObject *object)
 		_("Choose a folder for deleted messages."),
 		"real-trash-path", "use-real-trash-path");
 	if (widget != NULL) {
-		gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
+		gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
 		gtk_widget_show (widget);
 	}
 
@@ -636,7 +656,7 @@ mail_config_defaults_page_constructed (GObject *object)
 		_("Choose a folder for junk messages."),
 		"real-junk-path", "use-real-junk-path");
 	if (widget != NULL) {
-		gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
+		gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1);
 		gtk_widget_show (widget);
 	}
 



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