[evolution] Bug 758383 - Composer should save both HTML and text when saving drafts
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 758383 - Composer should save both HTML and text when saving drafts
- Date: Fri, 20 Nov 2015 13:41:00 +0000 (UTC)
commit 61ae3c8e90d1c17894975862242956c98ce90fc1
Author: Tomas Popela <tpopela redhat com>
Date: Fri Nov 20 14:23:26 2015 +0100
Bug 758383 - Composer should save both HTML and text when saving drafts
composer/e-msg-composer.c | 92 ++++++++++++++++++--------------------------
1 files changed, 38 insertions(+), 54 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 7fc8be3..34b88fe 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1232,55 +1232,6 @@ composer_build_message (EMsgComposer *composer,
g_free (encoded_organization);
}
- if (flags & COMPOSER_FLAG_SAVE_DRAFT) {
- gboolean selection_saved = FALSE;
- gchar *text;
- EHTMLEditor *editor;
- EHTMLEditorView *view;
- EHTMLEditorSelection *selection;
- WebKitDOMDocument *document;
-
- editor = e_msg_composer_get_editor (composer);
- view = e_html_editor_get_view (editor);
- selection = e_html_editor_view_get_selection (view);
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
- /* X-Evolution-Format */
- composer_add_evolution_format_header (
- CAMEL_MEDIUM (context->message), flags);
-
- /* X-Evolution-Composer-Mode */
- composer_add_evolution_composer_mode_header (
- CAMEL_MEDIUM (context->message), composer);
-
- data = g_byte_array_new ();
-
- e_html_editor_view_embed_styles (view);
- selection_saved = webkit_dom_document_get_element_by_id (
- document, "-x-evo-selection-start-marker") != NULL;
- if (!selection_saved)
- e_html_editor_selection_save (selection);
-
- text = e_html_editor_view_get_text_html_for_drafts (view);
-
- e_html_editor_view_remove_embed_styles (view);
- e_html_editor_selection_restore (selection);
- e_html_editor_view_force_spell_check_in_viewport (view);
-
- if (selection_saved)
- e_html_editor_selection_save (selection);
-
- g_byte_array_append (data, (guint8 *) text, strlen (text));
-
- g_free (text);
-
- type = camel_content_type_new ("text", "html");
- camel_content_type_set_param (type, "charset", "utf-8");
- iconv_charset = camel_iconv_charset_name ("utf-8");
-
- goto wrap_drafts_html;
- }
-
/* Build the text/plain part. */
if (priv->mime_body) {
@@ -1326,7 +1277,6 @@ composer_build_message (EMsgComposer *composer,
}
}
- wrap_drafts_html:
mem_stream = camel_stream_mem_new_with_byte_array (data);
stream = camel_stream_filter_new (mem_stream);
g_object_unref (mem_stream);
@@ -1373,8 +1323,8 @@ composer_build_message (EMsgComposer *composer,
* ...
*/
- if ((flags & COMPOSER_FLAG_HTML_CONTENT) != 0 &&
- !(flags & COMPOSER_FLAG_SAVE_DRAFT)) {
+ if ((flags & COMPOSER_FLAG_HTML_CONTENT) != 0 ||
+ (flags & COMPOSER_FLAG_SAVE_DRAFT) != 0) {
gchar *text;
guint count;
gsize length;
@@ -1387,8 +1337,42 @@ composer_build_message (EMsgComposer *composer,
view = e_html_editor_get_view (editor);
data = g_byte_array_new ();
- text = e_html_editor_view_get_text_html (view, from_domain, &inline_images);
- length = strlen (text);
+ if ((flags & COMPOSER_FLAG_SAVE_DRAFT) != 0) {
+ EHTMLEditorSelection *selection;
+ gboolean selection_saved = FALSE;
+ WebKitDOMDocument *document;
+
+ selection = e_html_editor_view_get_selection (view);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+
+ /* X-Evolution-Format */
+ composer_add_evolution_format_header (
+ CAMEL_MEDIUM (context->message), flags);
+
+ /* X-Evolution-Composer-Mode */
+ composer_add_evolution_composer_mode_header (
+ CAMEL_MEDIUM (context->message), composer);
+
+ e_html_editor_view_embed_styles (view);
+ selection_saved = webkit_dom_document_get_element_by_id (
+ document, "-x-evo-selection-start-marker") != NULL;
+ if (!selection_saved)
+ e_html_editor_selection_save (selection);
+
+ text = e_html_editor_view_get_text_html_for_drafts (view);
+
+ e_html_editor_view_remove_embed_styles (view);
+ e_html_editor_selection_restore (selection);
+ e_html_editor_view_force_spell_check_in_viewport (view);
+
+ if (selection_saved)
+ e_html_editor_selection_save (selection);
+
+ length = strlen (text);
+ } else {
+ text = e_html_editor_view_get_text_html (view, from_domain, &inline_images);
+ length = strlen (text);
+ }
g_byte_array_append (data, (guint8 *) text, (guint) length);
pre_encode = text_requires_quoted_printable (text, length);
g_free (text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]