[Xfce4-commits] <postler:master> Merge inline message parts into primary part
Christian Dywan
noreply at xfce.org
Thu Feb 3 00:34:06 CET 2011
Updating branch refs/heads/master
to 5c7df0b9ac7626ea80f3467f47c098689755493e (commit)
from c3a14c07fa5ea65f86b880a9feb4ac069cce2b2c (commit)
commit 5c7df0b9ac7626ea80f3467f47c098689755493e
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Jan 31 23:19:08 2011 +0100
Merge inline message parts into primary part
Signatures can be separate parts.
postler/postler-content.vala | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 75e4bab..c3275c4 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -14,6 +14,7 @@ public class Postler.MessagePart : Object {
public string? mime_type;
public string? charset;
public bool plain_text;
+ public string? content_disposition;
public string? filename;
public int partnum { get; set; default = 0; }
public MessagePart (string mime_type) {
@@ -817,7 +818,6 @@ public class Postler.Content : WebKit.WebView {
multipart = 2;
continue;
} else if (line == "--" + boundary) {
- /* TODO: Merge inner text parts */
inner_boundary = "";
message_part = new MessagePart ("text/plain");
message_parts.append (message_part);
@@ -855,12 +855,17 @@ public class Postler.Content : WebKit.WebView {
content_encoding = parts[1].strip ();
}
else if (field == "content-disposition" ) {
+ string content_disposition = parts[1].strip ();
string cset = charset;
string mtype = "text/plain";
fname = null;
- parse_content_type (parts[1].strip (), ref cset,
+ parse_content_type (content_disposition, ref cset,
ref inner_boundary, ref mtype, ref fname);
message_part.filename = fname;
+ if (content_disposition.has_prefix ("attachment"))
+ message_part.content_disposition = content_disposition;
+ else if (content_disposition.has_prefix ("inline"))
+ message_part.content_disposition = content_disposition;
}
continue;
}
@@ -960,13 +965,29 @@ public class Postler.Content : WebKit.WebView {
/* Ignore empty parts inserted by faulty clients */
if (part.body.str.strip () == "")
continue;
+ /* Select part, merge "inline" parts, commonly signatures */
if (part.mime_type == "text/html") {
- html_part = part;
- break;
+ if (html_part == null)
+ html_part = part;
+ else if (part.content_disposition == "inline") {
+ html_part.body.append (part.body.str);
+ message_parts.remove (part);
+ }
+ }
+ if (part.mime_type == "text/plain") {
+ if (html_part != null && part.content_disposition == "inline") {
+ html_part.body.append (part.body.str);
+ message_parts.remove (part);
+ }
+ else if (text_part == null)
+ text_part = part;
+ else {
+ text_part.body.append (part.body.str);
+ message_parts.remove (part);
+ }
}
- if (part.mime_type == "text/plain" && text_part == null)
- text_part = part;
}
+ notify_property ("message-parts");
if (html_part != null)
display_part (html_part);
else if (text_part != null)
More information about the Xfce4-commits
mailing list