aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-composer-utils.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-20 01:15:24 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-20 01:15:24 +0800
commita0bee77c3a2a0f3d071149566413b4273cc4c8de (patch)
treea8e9a314c6a45b28361c56724e09f9f5dfb269c6 /mail/em-composer-utils.c
parentfa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53 (diff)
downloadgsoc2013-evolution-a0bee77c3a2a0f3d071149566413b4273cc4c8de.tar.gz
gsoc2013-evolution-a0bee77c3a2a0f3d071149566413b4273cc4c8de.tar.zst
gsoc2013-evolution-a0bee77c3a2a0f3d071149566413b4273cc4c8de.zip
** Fix for bug #204891
2009-01-19 Milan Crha <mcrha@redhat.com> ** Fix for bug #204891 * filtertypes.xml: * em-composer-utils.h: (em_utils_forward_message_raw): * em-composer-utils.c: (emu_forward_raw_done), (em_utils_forward_message_raw): * mail-session.c: (ms_forward_to), (class_init): Implement "forward-to" rule for message filters. Note: Be sure you've eds of revision 9956 or higher. svn path=/trunk/; revision=37101
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 3d18fc824c..88225669c8 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1565,6 +1565,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 *