diff options
Diffstat (limited to 'mail/mail-callbacks.c')
-rw-r--r-- | mail/mail-callbacks.c | 130 |
1 files changed, 48 insertions, 82 deletions
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index c3223ea15e..ca0ba70d53 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -740,114 +740,69 @@ forward_get_composer (const char *subject) } static void -do_forward_inline (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data) +do_forward_non_attached (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data) { char *subject; char *text; - if (message) { - subject = mail_tool_generate_forward_subject (message); - text = mail_tool_forward_message (message); - - if (text) { - EMsgComposer *composer = forward_get_composer (subject); - if (composer) { - e_msg_composer_set_body_text (composer, text); - gtk_widget_show (GTK_WIDGET (composer)); - e_msg_composer_unset_changed (composer); - } - g_free (text); - } - - g_free (subject); - } -} + if (!message) + return; -static void -do_forward_quoted (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data) -{ - char *subject; - char *text; - - if (message) { - subject = mail_tool_generate_forward_subject (message); + subject = mail_tool_generate_forward_subject (message); + if (GPOINTER_TO_INT (data) == MAIL_CONFIG_FORWARD_INLINE) + text = mail_tool_forward_message (message); + else text = mail_tool_quote_message (message, _("Forwarded message:\n")); - - if (text) { - EMsgComposer *composer = forward_get_composer (subject); - if (composer) { - e_msg_composer_set_body_text (composer, text); - gtk_widget_show (GTK_WIDGET (composer)); - e_msg_composer_unset_changed (composer); - } - g_free (text); - } - - g_free (subject); - } -} -static void -do_forward_attach (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *data) -{ - if (part) { + if (text) { EMsgComposer *composer = forward_get_composer (subject); if (composer) { - e_msg_composer_attach (composer, part); + e_msg_composer_set_body_text (composer, text); gtk_widget_show (GTK_WIDGET (composer)); e_msg_composer_unset_changed (composer); } + g_free (text); } -} -void -forward_messages (CamelFolder *folder, GPtrArray *uids, int flags) -{ - if (flags == FORWARD_INLINE && uids->len == 1) { - mail_get_message (folder, uids->pdata[0], do_forward_inline, NULL, mail_thread_new); - } else if (flags == FORWARD_QUOTED && uids->len == 1) { - mail_get_message (folder, uids->pdata[0], do_forward_quoted, NULL, mail_thread_new); - } else { - mail_build_attachment (folder, uids, do_forward_attach, NULL); - } + g_free (subject); } -void -forward_inlined (GtkWidget *widget, gpointer user_data) +static void +forward_message (FolderBrowser *fb, MailConfigForwardStyle style) { - FolderBrowser *fb = FOLDER_BROWSER (user_data); - GPtrArray *uids; - if (!fb->message_list->cursor_uid) return; - if (!check_send_configuration (fb)) return; - - uids = g_ptr_array_new (); - g_ptr_array_add (uids, g_strdup (fb->message_list->cursor_uid)); - forward_messages (fb->message_list->folder, uids, FORWARD_INLINE); - g_free (uids->pdata[0]); - g_ptr_array_free (uids, TRUE); + + mail_get_message (fb->folder, fb->message_list->cursor_uid, + do_forward_non_attached, GINT_TO_POINTER (style), + mail_thread_new); +} + +void +forward_inline (GtkWidget *widget, gpointer user_data) +{ + forward_message (user_data, MAIL_CONFIG_FORWARD_INLINE); } void forward_quoted (GtkWidget *widget, gpointer user_data) { - FolderBrowser *fb = FOLDER_BROWSER (user_data); - GPtrArray *uids; - - if (!fb->message_list->cursor_uid) - return; - - if (!check_send_configuration (fb)) - return; - - uids = g_ptr_array_new (); - g_ptr_array_add (uids, g_strdup (fb->message_list->cursor_uid)); - forward_messages (fb->message_list->folder, uids, FORWARD_QUOTED); - g_free (uids->pdata[0]); - g_ptr_array_free (uids, TRUE); + forward_message (user_data, MAIL_CONFIG_FORWARD_QUOTED); +} + +static void +do_forward_attach (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *data) +{ + if (part) { + EMsgComposer *composer = forward_get_composer (subject); + if (composer) { + e_msg_composer_attach (composer, part); + gtk_widget_show (GTK_WIDGET (composer)); + e_msg_composer_unset_changed (composer); + } + } } void @@ -864,6 +819,17 @@ forward_attached (GtkWidget *widget, gpointer user_data) mail_build_attachment (fb->message_list->folder, uids, do_forward_attach, NULL); } +void +forward (GtkWidget *widget, gpointer user_data) +{ + MailConfigForwardStyle style = mail_config_get_default_forward_style (); + + if (style == MAIL_CONFIG_FORWARD_ATTACHED) + forward_attached (widget, user_data); + else + forward_message (user_data, style); +} + static void transfer_msg (GtkWidget *widget, gpointer user_data, gboolean delete_from_source) { |