[Xfce4-commits] <postler:master> Strip attachment before replying

Christian Dywan noreply at xfce.org
Tue Dec 7 23:02:01 CET 2010


Updating branch refs/heads/master
         to acfca458aeeb2ceef87b6618ccda736a3e7bb9c0 (commit)
       from c4f83e0c73b95f61c71fd024ac4acc17829da034 (commit)

commit acfca458aeeb2ceef87b6618ccda736a3e7bb9c0
Author: Bernd Prünster <bernd.pruenster at gmail.com>
Date:   Tue Dec 7 22:19:19 2010 +0100

    Strip attachment before replying

 postler/postler-content.vala |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 0a30ce2..9ea624e 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -20,7 +20,24 @@ public class Postler.MessagePart {
         plain_text = mime_type == "text/plain";
         filename = null;
     }
-}
+
+    public bool is_empty () {
+        bool empty = true;
+        if (!(body == null)) {
+            var b_str = body.str.strip ();
+            string[] b_str_parts = b_str.split ("<br>");
+            long str_length = 0;
+            foreach (var current_line in b_str_parts) {
+                string[] split_split = current_line.strip().split("\n");
+                foreach (var between_linebreaks in split_split)
+                str_length = between_linebreaks.strip().length;
+            }
+            if (str_length != 0)
+                empty = false;
+        }
+        return empty;
+    }
+ }
 
 struct Postler.EmoticonMapping {
     public string token;
@@ -331,20 +348,24 @@ public class Postler.Content : WebKit.WebView {
         if (location != null) {
             ulong now = new Soup.Date.from_now (0).to_time_t ();
             string date = GLib.Time.local ((time_t)now).format ("%x %X");
+
             body.append_printf (_("On %s, %s wrote:"), date, recipient);
             body.append_c ('\n');
             var contents = File.new_for_path (location);
             try {
-                var stream = new DataInputStream (contents.read (null));
-                /* Skip the header */
-                string line;
-                while ((line = stream.read_line (null, null)) != null) {
-                    if (line == "")
-                        break;
-                }
-
+                parse_message(location);
                 bool last_line_empty = true;
-                while ((line = stream.read_line (null, null)) != null) {
+                StringBuilder b_temp = new StringBuilder ();
+                foreach (var bpart in message_parts) {
+                    if (bpart.plain_text) {
+                        if (!bpart.is_empty ()) {
+                            b_temp.append_c ('\n');
+                            b_temp.append (bpart.body.str);
+                        }
+                    }
+                }
+                string [] lines = b_temp.str.split ("\n");
+                foreach (var line in lines) {
                     /* Skip effectively empty lines */
                     int position = 0;
                     do {



More information about the Xfce4-commits mailing list