aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-composer-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-21 10:52:05 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-21 10:52:05 +0800
commitab00f5b08adb1d74a0c70d935a32ffd982e86f34 (patch)
tree45bfaa44682bc3eee5a2ad8a64112b248767af5b /mail/em-composer-utils.c
parent5a1c48696363e3f3c7ffe11bdffdcad6557f811a (diff)
downloadgsoc2013-evolution-ab00f5b08adb1d74a0c70d935a32ffd982e86f34.tar.gz
gsoc2013-evolution-ab00f5b08adb1d74a0c70d935a32ffd982e86f34.tar.zst
gsoc2013-evolution-ab00f5b08adb1d74a0c70d935a32ffd982e86f34.zip
Merge revisions 37075:37107 from trunk.
svn path=/branches/kill-bonobo/; revision=37112
Diffstat (limited to 'mail/em-composer-utils.c')
-rw-r--r--mail/em-composer-utils.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index a7b982386e..75a237c472 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1557,6 +1557,102 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message)
mail_append_mail (out_folder, receipt, info, em_utils_receipt_done, NULL);
}
+static void
+emu_forward_raw_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info,
+ int queued, const char *appended_uid, void *data)
+{
+ camel_message_info_free (info);
+ /* do not call mail send, just pile them all in the outbox */
+ /* mail_send (); */
+}
+
+/**
+ * em_utils_forward_message_raw:
+ * @param folder Where's a message located.
+ * @param message Message to forward.
+ * @param address Forward to whom.
+ * @param ex Exception.
+ * Forwards message to the address, in very similar way as redirect does.
+ **/
+void
+em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, const char *address, CamelException *ex)
+{
+ EAccount *account;
+ CamelMimeMessage *forward;
+ CamelStream *mem;
+ CamelInternetAddress *addr;
+ CamelFolder *out_folder;
+ CamelMessageInfo *info;
+ struct _camel_header_raw *xev;
+ char *subject;
+
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (message != NULL);
+ g_return_if_fail (address != NULL);
+
+ if (!*address) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("No destination address provided, forward of the message has been cancelled."));
+ return;
+ }
+
+ account = guess_account (message, folder);
+ if (!account) {
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("No account found to use, forward of the message has been cancelled."));
+ return;
+ }
+
+ forward = camel_mime_message_new ();
+
+ /* make copy of the message, because we are going to modify it */
+ mem = camel_stream_mem_new ();
+ camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem);
+ camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET);
+ camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem);
+ camel_object_unref (mem);
+
+ /* clear previous recipients */
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_TO, NULL);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_CC, NULL);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_BCC, NULL);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_TO, NULL);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_CC, NULL);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_RESENT_BCC, NULL);
+
+ /* remove all delivery and notification headers */
+ while (camel_medium_get_header (CAMEL_MEDIUM (forward), "Disposition-Notification-To"))
+ camel_medium_remove_header (CAMEL_MEDIUM (forward), "Disposition-Notification-To");
+
+ while (camel_medium_get_header (CAMEL_MEDIUM (forward), "Delivered-To"))
+ camel_medium_remove_header (CAMEL_MEDIUM (forward), "Delivered-To");
+
+ /* remove any X-Evolution-* headers that may have been set */
+ xev = mail_tool_remove_xevolution_headers (forward);
+ camel_header_raw_clear (&xev);
+
+ /* from */
+ addr = camel_internet_address_new ();
+ camel_internet_address_add (addr, account->id->name, account->id->address);
+ camel_mime_message_set_from (forward, addr);
+ camel_object_unref (addr);
+
+ /* to */
+ addr = camel_internet_address_new ();
+ camel_address_decode (CAMEL_ADDRESS (addr), address);
+ camel_mime_message_set_recipients (forward, CAMEL_RECIPIENT_TYPE_TO, addr);
+ camel_object_unref (addr);
+
+ /* subject */
+ subject = mail_tool_generate_forward_subject (message);
+ camel_mime_message_set_subject (forward, subject);
+ g_free (subject);
+
+ /* and send it */
+ out_folder = mail_component_get_folder (NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
+ info = camel_message_info_new (NULL);
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ mail_append_mail (out_folder, forward, info, emu_forward_raw_done, NULL);
+}
+
/* Replying to messages... */
static GHashTable *