From cec18e26aa44ff984e15fa71fd4dec1c21c4e328 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 7 Dec 2000 23:41:59 +0000 Subject: Only do a message_list_foreach if we plan on attaching messages, otherwise 2000-12-07 Jeffrey Stedfast * mail-callbacks.c (forward_message): Only do a message_list_foreach if we plan on attaching messages, otherwise just use ml->cursor_uid. * mail-ops.c (cleanup_forward_messages): If attaching multiple forwarded message, wrap them in a multipart/digest otherwise just attach the single message as a message/rfc822. svn path=/trunk/; revision=6851 --- mail/ChangeLog | 10 ++++++++++ mail/mail-callbacks.c | 9 ++++++--- mail/mail-ops.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index e27dfe30dd..c311de8750 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2000-12-07 Jeffrey Stedfast + + * mail-callbacks.c (forward_message): Only do a + message_list_foreach if we plan on attaching messages, otherwise + just use ml->cursor_uid. + + * mail-ops.c (cleanup_forward_messages): If attaching multiple + forwarded message, wrap them in a multipart/digest otherwise just + attach the single message as a message/rfc822. + 2000-12-07 Dan Winship * mail-display.c (on_object_requested): Make the iTip hack spew a diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 6eb37c48d0..ac35067caf 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -488,7 +488,7 @@ forward_message (FolderBrowser *fb, gboolean attach) cursor_msg = fb->mail_display->current_message; g_return_if_fail (cursor_msg != NULL); - + if (!check_send_configuration (fb)) return; @@ -496,8 +496,11 @@ forward_message (FolderBrowser *fb, gboolean attach) if (!composer) return; - uids = g_ptr_array_new(); - message_list_foreach (fb->message_list, enumerate_msg, uids); + uids = g_ptr_array_new (); + if (attach) + message_list_foreach (fb->message_list, enumerate_msg, uids); + else + g_ptr_array_add (uids, fb->message_list->cursor_uid); gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (composer_send_cb), NULL); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index cb6c0ee671..dd2ad8040a 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1602,6 +1602,7 @@ do_forward_messages (gpointer in_data, gpointer op_data, CamelException *ex) part = mail_tool_make_message_attachment (message); if (!part) { + camel_object_unref (CAMEL_OBJECT (message)); camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Failed to generate mime part from " "message while generating forwarded message.")); @@ -1637,13 +1638,38 @@ cleanup_forward_messages (gpointer in_data, gpointer op_data, forward_messages_data_t *data = (forward_messages_data_t *) op_data; if (input->attach) { - int i; - - for (i = 0; i < data->parts->len; i++) { - e_msg_composer_attach (input->composer, data->parts->pdata[i]); - camel_object_unref (CAMEL_OBJECT (data->parts->pdata[i])); + if (data->parts->len > 1) { + /* construct and attach a multipart/digest */ + CamelMimePart *digest; + CamelMultipart *multipart; + int i; + + multipart = camel_multipart_new (); + camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), + "multipart/digest"); + camel_multipart_set_boundary (multipart, NULL); + + for (i = 0; i < data->parts->len; i++) { + camel_multipart_add_part (multipart, CAMEL_MIME_PART (data->parts->pdata[i])); + camel_object_unref (CAMEL_OBJECT (data->parts->pdata[i])); + } + + digest = camel_mime_part_new (); + camel_medium_set_content_object (CAMEL_MEDIUM (digest), + CAMEL_DATA_WRAPPER (multipart)); + camel_object_unref (CAMEL_OBJECT (multipart)); + + camel_mime_part_set_description (digest, _("Forwarded messages")); + + e_msg_composer_attach (input->composer, CAMEL_MIME_PART (digest)); + camel_object_unref (CAMEL_OBJECT (digest)); + } else if (data->parts->len == 1) { + /* simply attach the message as message/rfc822 */ + e_msg_composer_attach (input->composer, CAMEL_MIME_PART (data->parts->pdata[0])); + camel_object_unref (CAMEL_OBJECT (data->parts->pdata[0])); } } else { + /* attach as inlined text */ CamelMimeMessage *message = data->parts->pdata[0]; char *text; -- cgit