[Xfce4-commits] <postler:master> Index the id's of thread references of all messages

Christian Dywan noreply at xfce.org
Sat Jun 4 14:30:01 CEST 2011


Updating branch refs/heads/master
         to 712a9b0fbcf687e343272c8a413b95431993e427 (commit)
       from aa9c0e8a86f67128f440057515e867ff66f30aee (commit)

commit 712a9b0fbcf687e343272c8a413b95431993e427
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon May 30 20:17:00 2011 +0200

    Index the id's of thread references of all messages

 postler/postler-index.vala   |    8 +++++---
 postler/postler-message.vala |   22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/postler/postler-index.vala b/postler/postler-index.vala
index 5209a58..5cc0751 100644
--- a/postler/postler-index.vala
+++ b/postler/postler-index.vala
@@ -43,7 +43,8 @@ namespace Postler {
             if (database.exec (
                 """
                 CREATE TABLE IF NOT EXISTS
-                messages (id TEXT, uri TEXT, subject TEXT, sender TEXT, recipients TEXT,
+                messages (id TEXT, uri TEXT, threads TEXT,
+                          subject TEXT, sender TEXT, recipients TEXT,
                           unread BOOLEAN, flagged BOOLEAN,
                           forwarded BOOLEAN, replied BOOLEAN, priority BOOLEAN,
                           date INTEGER, timestamp INTEGER, excerpt TEXT);
@@ -57,8 +58,8 @@ namespace Postler {
                 if (database.prepare_v2 ("""
                     INSERT INTO messages
                     (uri, subject, sender, recipients,
-                     unread, flagged, forwarded, replied, priority, date, id, timestamp)
-                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)
+                     unread, flagged, forwarded, replied, priority, date, id, timestamp, threads)
+                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)
                     """,
                     -1, out statement_insert) != Sqlite.OK)
                     throw new GLib.FileError.FAILED (_("Failed to index message: %s"), database.errmsg ());
@@ -76,6 +77,7 @@ namespace Postler {
              && statement_insert.bind_int64 (10, message.get_timestamp ()) == Sqlite.OK
              && statement_insert.bind_text (11, message.id) == Sqlite.OK
              && statement_insert.bind_int64 (12, startup_timestamp) == Sqlite.OK
+             && statement_insert.bind_text (13, message.threads, -1) == Sqlite.OK
              && statement_insert.step () == Sqlite.DONE;
             statement_insert.reset ();
             if (!success)
diff --git a/postler/postler-message.vala b/postler/postler-message.vala
index b5c7b3b..3a237f4 100644
--- a/postler/postler-message.vala
+++ b/postler/postler-message.vala
@@ -23,6 +23,7 @@ namespace Postler {
         public string? uri { public get; set; }
         public string get_path () { return GLib.File.new_for_uri (uri).get_path (); }
         public string? id { public get; set; }
+        public string? threads { public get; set; }
         string? charset = null;
         public string get_charset () { return charset ?? "ISO-8859-1"; }
         public GLib.DateTime? date { public get; set; }
@@ -158,6 +159,27 @@ namespace Postler {
                     if (message_id.has_prefix ("<") && message_id.has_suffix (">"))
                         id = message_id.slice (1, -1);
                 }
+                else if (field == "in-reply-to") {
+                    string message_id = parts[1].strip ();
+                    if (message_id.has_prefix ("<") && message_id.has_suffix (">")) {
+                        if (threads != null)
+                            threads += "," + message_id.slice (1, -1);
+                        else
+                            threads = message_id.slice (1, -1);
+                    }
+                }
+                else if (field == "references") {
+                    string[] message_ids = parts[1].split_set (", \t");
+                    string[] parsed_ids = {};
+                    foreach (string message_id in message_ids) {
+                        if (message_id.has_prefix ("<") && message_id.has_suffix (">"))
+                            parsed_ids += message_id.slice (1, -1);
+                    }
+                    if (threads != null)
+                        threads = string.joinv (",", parsed_ids) + "," + threads;
+                    else
+                        threads = string.joinv (",", parsed_ids);
+                }
                 else if (field == "subject")
                     subject = parse_encoded (parts[1], out charset);
                 else if (field == "from") {



More information about the Xfce4-commits mailing list