[Xfce4-commits] <postler:master> If the original message was top-post, we also top-post

Christian Dywan noreply at xfce.org
Sun Jul 18 15:40:04 CEST 2010


Updating branch refs/heads/master
         to 92097f431791f156aad9f6795e0a34e191918cd6 (commit)
       from 6ebf8cff7e66bdeeaa80c02c1088f68f306f62b1 (commit)

commit 92097f431791f156aad9f6795e0a34e191918cd6
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Jul 8 21:43:13 2010 +0200

    If the original message was top-post, we also top-post

 postler/postler-content.vala |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 9db20c2..4b5f79a 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -331,12 +331,37 @@ public class Postler.Content : WebKit.WebView {
             }
         }
 
+        /* If the original message was top-post, we also top-post.
+           Presumably more quotes than none at the bottom indicates that. */
+        bool top_post = false;
+        ssize_t position = body.len;
+        uint line_breaks = 0;
+        uint quote_lines = 0;
+        do {
+            if (body.str[position] == ' ' && body.str[position - 1] == '>') {
+                quote_lines++;
+                if (quote_lines > 5) {
+                    top_post = true;
+                    break;
+                }
+                position--;
+            } else if (body.str[position] == '\n') {
+                line_breaks++;
+                if (line_breaks > 5)
+                    break;
+            }
+            position--;
+        } while (position > 0 && position < body.len);
+
+        string signature = "";
         try {
-            string signature = "";
             GLib.FileUtils.get_contents (Environment.get_home_dir () + "/.signature",
                                          out signature);
-            body.append ("\n\n--\n" + signature);
         } catch (GLib.FileError error) { }
+        if (top_post)
+            body.prepend ("\n\n--\n" + signature + "\n");
+        else
+            body.append ("\n\n--\n" + signature);
         load_string (body.str, "text/plain", "UTF-8", "about:blank");
         return true;
     }



More information about the Xfce4-commits mailing list