[Xfce4-commits] <postler:master> Make plain_text a boolean property of MessagePart
Christian Dywan
noreply at xfce.org
Thu Dec 2 04:26:03 CET 2010
Updating branch refs/heads/master
to fb2dd0d17a8eb3e11bf2bc319f1e09273b22b621 (commit)
from 08ebb441bedb373d020c2837eb8cea8cd9aef069 (commit)
commit fb2dd0d17a8eb3e11bf2bc319f1e09273b22b621
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Dec 2 01:41:20 2010 +0100
Make plain_text a boolean property of MessagePart
The value always means it really is text, not a subtype.
postler/postler-content.vala | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index faa4108..bb34b58 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -12,10 +12,12 @@
public class Postler.MessagePart {
public StringBuilder? body;
public string? mime_type;
+ public bool plain_text;
public string? filename;
public MessagePart (string mime_type) {
body = new StringBuilder ();
this.mime_type = mime_type;
+ plain_text = mime_type == "text/plain";
filename = null;
}
}
@@ -646,7 +648,6 @@ public class Postler.Content : WebKit.WebView {
message_parts.append (message_part);
}
- bool plain_text = mime_type == "text/plain";
int in_quote = 0;
bool in_signature = false;
string inner_boundary = "";
@@ -657,7 +658,6 @@ public class Postler.Content : WebKit.WebView {
if (line == "--" + inner_boundary) {
message_part = new MessagePart ("text/plain");
message_parts.append (message_part);
- plain_text = true;
multipart = 2;
continue;
} else if (line == "--" + boundary) {
@@ -665,7 +665,6 @@ public class Postler.Content : WebKit.WebView {
inner_boundary = "";
message_part = new MessagePart ("text/plain");
message_parts.append (message_part);
- plain_text = true;
multipart = 2;
continue;
} else if (line == "--" + boundary + "--") {
@@ -698,7 +697,7 @@ public class Postler.Content : WebKit.WebView {
if (line.chomp ().has_suffix (";"))
mtype += ";";
if (mtype != "text/plain")
- plain_text = false;
+ message_part.plain_text = false;
message_part.filename = fname;
message_part.mime_type = mtype;
}
@@ -729,7 +728,7 @@ public class Postler.Content : WebKit.WebView {
line = GLib.convert (line, -1, "UTF-8", charset, null);
}
catch (GLib.ConvertError error) { }
- if (plain_text) {
+ if (message_part.plain_text) {
/* Looks like a signature */
if (in_signature && line[0] == '\0') {
message_part.body.append ("</span>");
@@ -774,14 +773,14 @@ public class Postler.Content : WebKit.WebView {
line = line.substring (1);
}
if (content_encoding == "base64") {
- if (plain_text)
+ if (message_part.plain_text)
line = line.replace ("\n", "<br>");
message_part.body.append (line);
} else {
message_part.body.append (line);
if (content_encoding == "quoted-printable" && line.has_suffix ("="))
message_part.body.truncate (message_part.body.len - 1);
- message_part.body.append (plain_text ? "<br>" : " ");
+ message_part.body.append (message_part.plain_text ? "<br>" : " ");
}
}
} catch (GLib.Error error) {
@@ -818,12 +817,10 @@ public class Postler.Content : WebKit.WebView {
string body_chunk;
string mime_type = message_part.mime_type;
- bool plain_text = false;
if (mime_type == "text/html")
body_chunk = message_part.body.str;
else if (mime_type_is_text (mime_type)) {
mime_type = "text/html";
- plain_text = true;
body_chunk = "<span class=\"plain_text\">" + message_part.body.str + "</span>";
}
else if (mime_type.has_prefix ("image/")) {
@@ -848,7 +845,7 @@ public class Postler.Content : WebKit.WebView {
try {
/* Linkify */
- if (plain_text) {
+ if (message_part.plain_text) {
foreach (var link_format in link_formats) {
var regex = new GLib.Regex (link_format);
body_chunk = regex.replace (body_chunk, -1, 0,
@@ -897,7 +894,7 @@ public class Postler.Content : WebKit.WebView {
format_header (_("Reply To:"), reply),
format_header (_("Organization:"), organization),
format_header (_("Application:"), x_mailer),
- plain_text ? "font-family: Monospace;" : "",
+ message_part.plain_text ? "font-family: Monospace;" : "",
body_chunk),
mime_type, "UTF-8", "about:blank");
} catch (GLib.Error contents_error) {
More information about the Xfce4-commits
mailing list