diff options
author | Milan Crha <mcrha@redhat.com> | 2013-05-07 05:54:37 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-05-07 05:54:37 +0800 |
commit | b254ea37eff47973b076fcf9345f80215ae5c978 (patch) | |
tree | 6a3c594988e168ee938f73adb4c13319c52f2616 | |
parent | 9567024148976a663585894ccef76d729f0fb095 (diff) | |
download | gsoc2013-evolution-b254ea37eff47973b076fcf9345f80215ae5c978.tar.gz gsoc2013-evolution-b254ea37eff47973b076fcf9345f80215ae5c978.tar.zst gsoc2013-evolution-b254ea37eff47973b076fcf9345f80215ae5c978.zip |
Bug #301323 - "Edit as new message" doesn't strip signature properly
-rw-r--r-- | composer/e-msg-composer.c | 63 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 1 | ||||
-rw-r--r-- | mail/e-mail-folder-pane.c | 4 | ||||
-rw-r--r-- | mail/e-mail-reader-utils.c | 4 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 2 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 12 | ||||
-rw-r--r-- | mail/em-composer-utils.h | 6 | ||||
-rw-r--r-- | modules/composer-autosave/e-autosave-utils.c | 2 | ||||
-rw-r--r-- | plugins/templates/templates.c | 2 |
9 files changed, 57 insertions, 39 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 78419b7d14..2dc6ac7c9d 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -109,18 +109,22 @@ static void add_attachments_from_multipart (EMsgComposer *composer, /* used by e_msg_composer_new_with_message () */ static void handle_multipart (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth); static void handle_multipart_alternative (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth); static void handle_multipart_encrypted (EMsgComposer *composer, CamelMimePart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth); static void handle_multipart_signed (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth); @@ -179,6 +183,7 @@ static gchar * emcu_part_to_html (EMsgComposer *composer, CamelMimePart *part, gssize *len, + gboolean keep_signature, GCancellable *cancellable) { CamelSession *session; @@ -217,7 +222,7 @@ emcu_part_to_html (EMsgComposer *composer, g_object_unref (parser); formatter = e_mail_formatter_quote_new ( - NULL, E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG); + NULL, keep_signature ? E_MAIL_FORMATTER_QUOTE_FLAG_KEEP_SIG : 0); e_mail_formatter_update_style ( formatter, gtk_widget_get_state_flags (GTK_WIDGET (window))); @@ -2649,6 +2654,7 @@ e_msg_composer_add_message_attachments (EMsgComposer *composer, static void handle_multipart_signed (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth) { @@ -2693,24 +2699,24 @@ handle_multipart_signed (EMsgComposer *composer, /* Handle the signed content and configure * the composer to sign outgoing messages. */ handle_multipart_signed ( - composer, multipart, cancellable, depth); + composer, multipart, keep_signature, cancellable, depth); } else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) { /* Decrypt the encrypted content and configure * the composer to encrypt outgoing messages. */ handle_multipart_encrypted ( - composer, mime_part, cancellable, depth); + composer, mime_part, keep_signature, cancellable, depth); } else if (camel_content_type_is (content_type, "multipart", "alternative")) { /* This contains the text/plain and text/html * versions of the message body. */ handle_multipart_alternative ( - composer, multipart, cancellable, depth); + composer, multipart, keep_signature, cancellable, depth); } else { /* There must be attachments... */ handle_multipart ( - composer, multipart, cancellable, depth); + composer, multipart, keep_signature, cancellable, depth); } } else if (camel_content_type_is (content_type, "text", "*")) { @@ -2718,7 +2724,7 @@ handle_multipart_signed (EMsgComposer *composer, gssize length; html = emcu_part_to_html ( - composer, mime_part, &length, cancellable); + composer, mime_part, &length, keep_signature, cancellable); e_msg_composer_set_pending_body (composer, html, length); } else { @@ -2729,6 +2735,7 @@ handle_multipart_signed (EMsgComposer *composer, static void handle_multipart_encrypted (EMsgComposer *composer, CamelMimePart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth) { @@ -2783,24 +2790,24 @@ handle_multipart_encrypted (EMsgComposer *composer, /* Handle the signed content and configure the * composer to sign outgoing messages. */ handle_multipart_signed ( - composer, content_multipart, cancellable, depth); + composer, content_multipart, keep_signature, cancellable, depth); } else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) { /* Decrypt the encrypted content and configure the * composer to encrypt outgoing messages. */ handle_multipart_encrypted ( - composer, mime_part, cancellable, depth); + composer, mime_part, keep_signature, cancellable, depth); } else if (camel_content_type_is (content_type, "multipart", "alternative")) { /* This contains the text/plain and text/html * versions of the message body. */ handle_multipart_alternative ( - composer, content_multipart, cancellable, depth); + composer, content_multipart, keep_signature, cancellable, depth); } else { /* There must be attachments... */ handle_multipart ( - composer, content_multipart, cancellable, depth); + composer, content_multipart, keep_signature, cancellable, depth); } } else if (camel_content_type_is (content_type, "text", "*")) { @@ -2808,7 +2815,7 @@ handle_multipart_encrypted (EMsgComposer *composer, gssize length; html = emcu_part_to_html ( - composer, mime_part, &length, cancellable); + composer, mime_part, &length, keep_signature, cancellable); e_msg_composer_set_pending_body (composer, html, length); } else { @@ -2821,6 +2828,7 @@ handle_multipart_encrypted (EMsgComposer *composer, static void handle_multipart_alternative (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth) { @@ -2852,20 +2860,20 @@ handle_multipart_alternative (EMsgComposer *composer, /* Handle the signed content and configure * the composer to sign outgoing messages. */ handle_multipart_signed ( - composer, mp, cancellable, depth + 1); + composer, mp, keep_signature, cancellable, depth + 1); } else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) { /* Decrypt the encrypted content and configure * the composer to encrypt outgoing messages. */ handle_multipart_encrypted ( - composer, mime_part, + composer, mime_part, keep_signature, cancellable, depth + 1); } else { /* Depth doesn't matter so long as we * don't pass 0. */ handle_multipart ( - composer, mp, cancellable, depth + 1); + composer, mp, keep_signature, cancellable, depth + 1); } } else if (camel_content_type_is (content_type, "text", "html")) { @@ -2887,7 +2895,7 @@ handle_multipart_alternative (EMsgComposer *composer, gssize length; html = emcu_part_to_html ( - composer, text_part, &length, cancellable); + composer, text_part, &length, keep_signature, cancellable); e_msg_composer_set_pending_body (composer, html, length); } } @@ -2895,6 +2903,7 @@ handle_multipart_alternative (EMsgComposer *composer, static void handle_multipart (EMsgComposer *composer, CamelMultipart *multipart, + gboolean keep_signature, GCancellable *cancellable, gint depth) { @@ -2924,25 +2933,25 @@ handle_multipart (EMsgComposer *composer, /* Handle the signed content and configure * the composer to sign outgoing messages. */ handle_multipart_signed ( - composer, mp, cancellable, depth + 1); + composer, mp, keep_signature, cancellable, depth + 1); } else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) { /* Decrypt the encrypted content and configure * the composer to encrypt outgoing messages. */ handle_multipart_encrypted ( - composer, mime_part, + composer, mime_part, keep_signature, cancellable, depth + 1); } else if (camel_content_type_is ( content_type, "multipart", "alternative")) { handle_multipart_alternative ( - composer, mp, cancellable, depth + 1); + composer, mp, keep_signature, cancellable, depth + 1); } else { /* Depth doesn't matter so long as we * don't pass 0. */ handle_multipart ( - composer, mp, cancellable, depth + 1); + composer, mp, keep_signature, cancellable, depth + 1); } } else if (depth == 0 && i == 0) { @@ -2952,7 +2961,7 @@ handle_multipart (EMsgComposer *composer, /* Since the first part is not multipart/alternative, * this must be the body. */ html = emcu_part_to_html ( - composer, mime_part, &length, cancellable); + composer, mime_part, &length, keep_signature, cancellable); e_msg_composer_set_pending_body (composer, html, length); } else if (camel_mime_part_get_content_id (mime_part) || @@ -3045,6 +3054,7 @@ composer_add_auto_recipients (ESource *source, * e_msg_composer_new_with_message: * @shell: an #EShell * @message: The message to use as the source + * @keep_signature: Keep message signature, if any * * Create a new message composer widget. * @@ -3055,6 +3065,7 @@ composer_add_auto_recipients (ESource *source, EMsgComposer * e_msg_composer_new_with_message (EShell *shell, CamelMimeMessage *message, + gboolean keep_signature, GCancellable *cancellable) { CamelInternetAddress *to, *cc, *bcc; @@ -3294,25 +3305,25 @@ e_msg_composer_new_with_message (EShell *shell, /* Handle the signed content and configure the * composer to sign outgoing messages. */ handle_multipart_signed ( - composer, multipart, cancellable, 0); + composer, multipart, keep_signature, cancellable, 0); } else if (CAMEL_IS_MULTIPART_ENCRYPTED (content)) { /* Decrypt the encrypted content and configure the * composer to encrypt outgoing messages. */ handle_multipart_encrypted ( - composer, mime_part, cancellable, 0); + composer, mime_part, keep_signature, cancellable, 0); } else if (camel_content_type_is ( content_type, "multipart", "alternative")) { /* This contains the text/plain and text/html * versions of the message body. */ handle_multipart_alternative ( - composer, multipart, cancellable, 0); + composer, multipart, keep_signature, cancellable, 0); } else { /* There must be attachments... */ handle_multipart ( - composer, multipart, cancellable, 0); + composer, multipart, keep_signature, cancellable, 0); } } else { CamelMimePart *mime_part; @@ -3335,7 +3346,7 @@ e_msg_composer_new_with_message (EShell *shell, html = emcu_part_to_html ( composer, CAMEL_MIME_PART (message), - &length, cancellable); + &length, keep_signature, cancellable); e_msg_composer_set_pending_body (composer, html, length); } @@ -3375,7 +3386,7 @@ e_msg_composer_new_redirect (EShell *shell, g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); composer = e_msg_composer_new_with_message ( - shell, message, cancellable); + shell, message, TRUE, cancellable); table = e_msg_composer_get_header_table (composer); subject = camel_mime_message_get_subject (message); diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 28c189a377..7c05668543 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -86,6 +86,7 @@ GType e_msg_composer_get_type (void); EMsgComposer * e_msg_composer_new (EShell *shell); EMsgComposer * e_msg_composer_new_with_message (EShell *shell, CamelMimeMessage *msg, + gboolean keep_signature, GCancellable *cancellable); EMsgComposer * e_msg_composer_new_from_url (EShell *shell, const gchar *url); diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c index 985f47b99c..a84aab1453 100644 --- a/mail/e-mail-folder-pane.c +++ b/mail/e-mail-folder-pane.c @@ -100,7 +100,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view) if (em_utils_folder_is_drafts (registry, folder) || em_utils_folder_is_outbox (registry, folder) || em_utils_folder_is_templates (registry, folder)) { - em_utils_edit_messages (reader, folder, uids, TRUE); + em_utils_edit_messages (reader, folder, uids, TRUE, TRUE); g_ptr_array_unref (uids); return 0; } @@ -135,7 +135,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view) (GDestroyNotify) g_free); g_ptr_array_add (edits, real_uid); em_utils_edit_messages ( - reader, real_folder, edits, TRUE); + reader, real_folder, edits, TRUE, TRUE); g_ptr_array_unref (edits); } else { g_free (real_uid); diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 36e745570a..c4a6ac09b9 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -789,7 +789,7 @@ e_mail_reader_open_selected (EMailReader *reader) if (em_utils_folder_is_drafts (registry, folder) || em_utils_folder_is_outbox (registry, folder) || em_utils_folder_is_templates (registry, folder)) { - em_utils_edit_messages (reader, folder, uids, TRUE); + em_utils_edit_messages (reader, folder, uids, TRUE, TRUE); return uids->len; } @@ -822,7 +822,7 @@ e_mail_reader_open_selected (EMailReader *reader) edits = g_ptr_array_new (); g_ptr_array_add (edits, real_uid); em_utils_edit_messages ( - reader, real_folder, edits, TRUE); + reader, real_folder, edits, TRUE, TRUE); } else { g_free (real_uid); g_ptr_array_add (views, g_strdup (uid)); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index e36b1f745b..97774c84d4 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -926,7 +926,7 @@ action_mail_message_edit_cb (GtkAction *action, g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free); replace = em_utils_folder_is_drafts (registry, folder); - em_utils_edit_messages (reader, folder, uids, replace); + em_utils_edit_messages (reader, folder, uids, replace, replace); g_ptr_array_unref (uids); } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 64e1e2deed..cf5039b9fd 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -81,6 +81,7 @@ struct _AsyncContext { gchar *folder_uri; gchar *message_uid; gboolean replace; + gboolean keep_signature; GtkWidget *destroy_when_done; }; @@ -1336,7 +1337,8 @@ GtkWidget * em_utils_edit_message (EShell *shell, CamelFolder *folder, CamelMimeMessage *message, - const gchar *message_uid) + const gchar *message_uid, + gboolean keep_signature) { EMsgComposer *composer; ESourceRegistry *registry; @@ -1377,7 +1379,7 @@ em_utils_edit_message (EShell *shell, g_slist_free (clue_list); } - composer = e_msg_composer_new_with_message (shell, message, NULL); + composer = e_msg_composer_new_with_message (shell, message, keep_signature, NULL); if (!folder_is_templates) { EComposerHeaderTable *table; ESource *source; @@ -1483,7 +1485,7 @@ edit_messages_cb (CamelFolder *folder, message = CAMEL_MIME_MESSAGE (value); camel_medium_remove_header (CAMEL_MEDIUM (value), "X-Mailer"); - em_utils_edit_message (shell, folder, message, key); + em_utils_edit_message (shell, folder, message, key, context->keep_signature); } g_hash_table_unref (hash_table); @@ -1506,7 +1508,8 @@ void em_utils_edit_messages (EMailReader *reader, CamelFolder *folder, GPtrArray *uids, - gboolean replace) + gboolean replace, + gboolean keep_signature) { EActivity *activity; AsyncContext *context; @@ -1524,6 +1527,7 @@ em_utils_edit_messages (EMailReader *reader, context->reader = g_object_ref (reader); context->ptr_array = g_ptr_array_ref (uids); context->replace = replace; + context->keep_signature = keep_signature; e_mail_folder_get_multiple_messages ( folder, uids, G_PRIORITY_DEFAULT, diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index cda63d1458..14d65f73ba 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -41,11 +41,13 @@ EMsgComposer * em_utils_compose_new_message_with_mailto GtkWidget * em_utils_edit_message (EShell *shell, CamelFolder *folder, CamelMimeMessage *message, - const gchar *message_uid); + const gchar *message_uid, + gboolean keep_signature); void em_utils_edit_messages (EMailReader *reader, CamelFolder *folder, GPtrArray *uids, - gboolean replace); + gboolean replace, + gboolean keep_signature); EMsgComposer * em_utils_forward_message (EShell *shell, CamelSession *session, CamelMimeMessage *msg, diff --git a/modules/composer-autosave/e-autosave-utils.c b/modules/composer-autosave/e-autosave-utils.c index 88f6dde0e8..6971ab8054 100644 --- a/modules/composer-autosave/e-autosave-utils.c +++ b/modules/composer-autosave/e-autosave-utils.c @@ -167,7 +167,7 @@ load_snapshot_loaded_cb (GFile *snapshot_file, * the same file. */ shell = E_SHELL (object); g_object_ref (snapshot_file); - composer = e_msg_composer_new_with_message (shell, message, NULL); + composer = e_msg_composer_new_with_message (shell, message, TRUE, NULL); g_object_set_data_full ( G_OBJECT (composer), SNAPSHOT_FILE_KEY, snapshot_file, diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c index 0d3fcdc41d..2ef7453dfb 100644 --- a/plugins/templates/templates.c +++ b/plugins/templates/templates.c @@ -928,7 +928,7 @@ create_new_message (CamelFolder *folder, template, CAMEL_RECIPIENT_TYPE_BCC)); /* Create the composer */ - composer = E_MSG_COMPOSER (em_utils_edit_message (shell, folder, new, message_uid)); + composer = E_MSG_COMPOSER (em_utils_edit_message (shell, folder, new, message_uid, TRUE)); if (composer && context->source_folder_uri && context->message_uid) e_msg_composer_set_source_headers ( composer, context->source_folder_uri, |