[Xfce4-commits] <postler:master> Use lynx to prepare replies
Christian Dywan
noreply at xfce.org
Wed Dec 15 18:22:01 CET 2010
Updating branch refs/heads/master
to ba6687bc03d53287ff9fdcfa4633a53626dc50b2 (commit)
from afb8640f61ac77fe6157b5024f92320a3cd4195a (commit)
commit ba6687bc03d53287ff9fdcfa4633a53626dc50b2
Author: Bernd Prünster <bernd.pruenster at gmail.com>
Date: Wed Dec 15 18:08:11 2010 +0100
Use lynx to prepare replies
Fixes: https://bugs.launchpad.net/postler/+bug/671734
postler/postler-content.vala | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 9ea624e..f68a1e5 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -37,7 +37,35 @@ public class Postler.MessagePart {
}
return empty;
}
- }
+
+ public string get_plain_text () {
+ string body_plain = body.str;
+ if ((body != null) && (mime_type != null)) {
+ try {
+ string plain_text = "";
+ int std_in;
+ int std_out;
+ string[] argv = { "lynx", "-force_html", "-width=900", "-dump",
+ "-display_charset=utf-8", "-stdin" };
+ Process.spawn_async_with_pipes (null, argv, null,
+ SpawnFlags.SEARCH_PATH, null, null,
+ out std_in, out std_out, null);
+ IOChannel ioc_stdout = new IOChannel.unix_new (std_out);
+ IOChannel ioc_stdin = new IOChannel.unix_new (std_in);
+ char[] content_chars = (char[]) (body.str.data);
+ var status = ioc_stdin.write_chars (content_chars, null);
+ ioc_stdin.shutdown (true);
+ if (status != IOStatus.ERROR)
+ status = ioc_stdout.read_to_end (out plain_text, null);
+ if (status != IOStatus.ERROR)
+ body_plain = plain_text;
+ } catch (Error error) {
+ GLib.message (_("Error converting HTML to text: %s"), error.message);
+ }
+ }
+ return body_plain;
+ }
+}
struct Postler.EmoticonMapping {
public string token;
@@ -357,10 +385,11 @@ public class Postler.Content : WebKit.WebView {
bool last_line_empty = true;
StringBuilder b_temp = new StringBuilder ();
foreach (var bpart in message_parts) {
- if (bpart.plain_text) {
+ if (mime_type_is_text (bpart.mime_type)) {
if (!bpart.is_empty ()) {
b_temp.append_c ('\n');
- b_temp.append (bpart.body.str);
+ b_temp.append (bpart.get_plain_text ());
+ break;
}
}
}
More information about the Xfce4-commits
mailing list