[Xfce4-commits] <postler:master> Index bugzilla and launchpad project names

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


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

commit 0632d13cb32fdd26acc48180bba68bdf1e995803
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon May 30 20:29:00 2011 +0200

    Index bugzilla and launchpad project names
    
    Also consider bugzilla commenters as senders.

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

diff --git a/postler/postler-index.vala b/postler/postler-index.vala
index 5cc0751..ce987ae 100644
--- a/postler/postler-index.vala
+++ b/postler/postler-index.vala
@@ -43,7 +43,7 @@ namespace Postler {
             if (database.exec (
                 """
                 CREATE TABLE IF NOT EXISTS
-                messages (id TEXT, uri TEXT, threads TEXT,
+                messages (id TEXT, uri TEXT, threads TEXT, project TEXT,
                           subject TEXT, sender TEXT, recipients TEXT,
                           unread BOOLEAN, flagged BOOLEAN,
                           forwarded BOOLEAN, replied BOOLEAN, priority BOOLEAN,
@@ -58,8 +58,9 @@ namespace Postler {
                 if (database.prepare_v2 ("""
                     INSERT INTO messages
                     (uri, subject, sender, recipients,
-                     unread, flagged, forwarded, replied, priority, date, id, timestamp, threads)
-                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)
+                     unread, flagged, forwarded, replied, priority,
+                     date, id, timestamp, threads, project)
+                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14)
                     """,
                     -1, out statement_insert) != Sqlite.OK)
                     throw new GLib.FileError.FAILED (_("Failed to index message: %s"), database.errmsg ());
@@ -78,6 +79,7 @@ namespace Postler {
              && 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.bind_text (14, message.project, -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 3a237f4..db6ac11 100644
--- a/postler/postler-message.vala
+++ b/postler/postler-message.vala
@@ -39,6 +39,7 @@ namespace Postler {
         public bool priority { public get; set; }
         public string organization { public get; set; }
         public string application { public get; set; }
+        public string project { public get; set; }
         GLib.HashTable<string,string> fields = new GLib.HashTable<string,string> (str_hash, str_equal);
         public string get_field (string field) { return fields.lookup (field); }
         GLib.DataInputStream? stream = null;
@@ -184,6 +185,11 @@ namespace Postler {
                     subject = parse_encoded (parts[1], out charset);
                 else if (field == "from") {
                     string sender_charset = null;
+                    if (sender == null)
+                        sender = parse_encoded (parts[1], out sender_charset);
+                }
+                else if (field == "x-bugzilla-who") {
+                    string sender_charset = null;
                     sender = parse_encoded (parts[1], out sender_charset);
                 }
                 else if (field == "date") {
@@ -200,6 +206,18 @@ namespace Postler {
                     organization = parts[1];
                 else if (field == "x-mailer" || field == "user-agent")
                     application = Postler.Content.format_x_mailer (parts[1]);
+                else if (field == "x-bugzilla-product" || field == "x-launchpad-bug") {
+                    /* Format:
+                       X-Bugzilla-Product: gtk+
+                       X-Launchpad-Bug: product=postler; status=Confirmed;
+                       There can be multiple occurences of the Launchpad header. */
+                    string stripped = parts[1].strip ();
+                    bool semicolon = stripped.str ("; ") != null;
+                    if (stripped.has_prefix ("product=") && semicolon)
+                        project = stripped.split (";")[0].substring (8);
+                    else if (!semicolon)
+                        project = stripped;
+                }
                 else if (field == "reply-to") {
                     string field_charset = null;
                     reply_to = parse_encoded (parts[1], out field_charset);



More information about the Xfce4-commits mailing list