[geary/wip/713846-plain-inline: 1/3] Robert Schroll's proposed patch.



commit 2e2dbdd897b30d6f40b08a88d4cc2119fd9de173
Author: Robert Schroll <rschroll gmail com>
Date:   Mon Jan 6 16:34:19 2014 -0800

    Robert Schroll's proposed patch.

 src/engine/rfc822/rfc822-message.vala |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 7063d67..5542008 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -440,7 +440,8 @@ public class Geary.RFC822.Message : BaseObject {
      * Returns: a bool indicating whether a text part with the desired text_subtype was found
      */
     private bool construct_body_from_mime_parts(ref string? body, InlinePartReplacer? replacer,
-        string text_subtype, bool to_html = false, GMime.Object? node = null) throws RFC822Error {
+        string text_subtype, bool allow_only_replaced = false, bool to_html = false,
+        GMime.Object? node = null) throws RFC822Error {
         if (node == null) {
             node = message.get_mime_part();
         }
@@ -455,7 +456,7 @@ public class Geary.RFC822.Message : BaseObject {
                 GMime.Object child = multipart.get_part(i);
                 string? child_body = null;
                 found_text_subtype |= construct_body_from_mime_parts(ref child_body, replacer,
-                    text_subtype, to_html, child);
+                    text_subtype, allow_only_replaced, to_html, child);
                 if (child_body != null)
                     builder.append(child_body);
             }
@@ -508,19 +509,21 @@ public class Geary.RFC822.Message : BaseObject {
         if (replaced_part != null)
             body = replaced_part;
         
-        return (replaced_part != null);
+        return allow_only_replaced && (replaced_part != null);
     }
     
-    public string? get_html_body(InlinePartReplacer? replacer = null) throws RFC822Error {
+    public string? get_html_body(bool allow_only_replaced = false,
+        InlinePartReplacer? replacer = null) throws RFC822Error {
         string? body = null;
-        if (!construct_body_from_mime_parts(ref body, replacer, "html"))
+        if (!construct_body_from_mime_parts(ref body, replacer, "html", allow_only_replaced))
             throw new RFC822Error.NOT_FOUND("Could not find any \"text/html\" parts");
         return body;
     }
     
-    public string? get_text_body(bool convert_to_html = true, InlinePartReplacer? replacer = null) throws 
RFC822Error {
+    public string? get_text_body(bool convert_to_html = true, bool allow_only_replaced = false,
+        InlinePartReplacer? replacer = null) throws RFC822Error {
         string? body = null;
-        if (!construct_body_from_mime_parts(ref body, replacer, "plain", convert_to_html))
+        if (!construct_body_from_mime_parts(ref body, replacer, "plain", allow_only_replaced, 
convert_to_html))
             throw new RFC822Error.NOT_FOUND("Could not find any \"text/plain\" parts");
         return body;
     }
@@ -530,9 +533,9 @@ public class Geary.RFC822.Message : BaseObject {
     // the other.
     public string? get_body(bool html_format, InlinePartReplacer? replacer = null) throws RFC822Error {
         try {
-            return html_format ? get_html_body(replacer) : get_text_body(true, replacer);
+            return html_format ? get_html_body(false, replacer) : get_text_body(true, false, replacer);
         } catch (Error error) {
-            return html_format ? get_text_body(true, replacer) : get_html_body(replacer);
+            return html_format ? get_text_body(true, true, replacer) : get_html_body(true, replacer);
         }
     }
     


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]