[Xfce4-commits] <postler:master> Implement forwarded and replied message properties

Christian Dywan noreply at xfce.org
Fri May 27 20:32:09 CEST 2011


Updating branch refs/heads/master
         to cf13c0c80e7d55136edfee3485b216ff23a1700d (commit)
       from 81001743bcef4a5781fc1d2d115fe64b068efd63 (commit)

commit cf13c0c80e7d55136edfee3485b216ff23a1700d
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri May 27 20:24:55 2011 +0200

    Implement forwarded and replied message properties

 postler/postler-index.vala    |   16 ++++++++++------
 postler/postler-message.vala  |   14 ++++++++++++--
 postler/postler-messages.vala |    8 ++++++--
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/postler/postler-index.vala b/postler/postler-index.vala
index a611ed3..34fb5ff 100644
--- a/postler/postler-index.vala
+++ b/postler/postler-index.vala
@@ -38,7 +38,8 @@ namespace Postler {
                 """
                 CREATE TABLE IF NOT EXISTS
                 messages (uri TEXT UNIQUE, subject TEXT, sender TEXT, recipients TEXT,
-                          unread BOOLEAN, flagged BOOLEAN, priority BOOLEAN,
+                          unread BOOLEAN, flagged BOOLEAN,
+                          forwarded BOOLEAN, replied BOOLEAN, priority BOOLEAN,
                           date INTEGER, excerpt TEXT, zeitgeist BOOLEAN);
                 """
                 ) != Sqlite.OK)
@@ -49,8 +50,9 @@ namespace Postler {
             if (statement_insert == null) {
                 if (database.prepare_v2 ("""
                     INSERT OR IGNORE INTO messages
-                    (uri, subject, sender, recipients, unread, flagged, priority, date)
-                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)
+                    (uri, subject, sender, recipients,
+                     unread, flagged, forwarded, replied, priority, date)
+                    VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)
                     """,
                     -1, out statement_insert) != Sqlite.OK)
                     throw new GLib.FileError.FAILED (_("Failed to open database: %s"), database.errmsg ());
@@ -62,8 +64,10 @@ namespace Postler {
              && statement_insert.bind_text (4, message.recipients, -1) == Sqlite.OK
              && statement_insert.bind_int64 (5, message.unread ? 1 : 0) == Sqlite.OK
              && statement_insert.bind_int64 (6, message.flagged ? 1 : 0) == Sqlite.OK
-             && statement_insert.bind_int64 (7, message.flagged ? 1 : 0) == Sqlite.OK
-             && statement_insert.bind_int64 (8, message.get_timestamp ()) == Sqlite.OK
+             && statement_insert.bind_int64 (7, message.forwarded ? 1 : 0) == Sqlite.OK
+             && statement_insert.bind_int64 (8, message.replied ? 1 : 0) == Sqlite.OK
+             && statement_insert.bind_int64 (9, message.priority ? 1 : 0) == Sqlite.OK
+             && statement_insert.bind_int64 (10, message.get_timestamp ()) == Sqlite.OK
              && statement_insert.step () == Sqlite.DONE;
             statement_insert.reset ();
             if (!success)
@@ -126,7 +130,7 @@ namespace Postler {
             if (statement_get == null) {
                 if (database.prepare_v2 ("""
                     SELECT subject, sender, recipients,
-                    unread, flagged, priority, date FROM messages WHERE uri LIKE ?1
+                    unread, flagged, forwarded, replied, priority, date FROM messages WHERE uri LIKE ?1
                     """,
                     -1, out statement_get) != Sqlite.OK)
                     throw new GLib.FileError.FAILED (_("Failed to list messages: %s"), database.errmsg ());
diff --git a/postler/postler-message.vala b/postler/postler-message.vala
index cb709d6..22f29c0 100644
--- a/postler/postler-message.vala
+++ b/postler/postler-message.vala
@@ -24,6 +24,8 @@ namespace Postler {
         public string? reply_to { public get; set; }
         public bool unread { public get; set; }
         public bool flagged { public get; set; }
+        public bool forwarded { public get; set; }
+        public bool replied { public get; set; }
         public bool priority { public get; set; }
         public string organization { public get; set; }
         public string application { public get; set; }
@@ -48,6 +50,8 @@ namespace Postler {
             message_data.insert ("recipients", this.recipients ?? "");
             message_data.insert ("unread", this.unread);
             message_data.insert ("flagged", this.flagged);
+            message_data.insert ("forwarded", this.forwarded);
+            message_data.insert ("replied", this.replied);
             message_data.insert ("priority", this.priority);
             message_data.insert ("date", this.get_timestamp ());
             return message_data;
@@ -63,6 +67,8 @@ namespace Postler {
             this.recipients = message_data.lookup ("recipients").get_string ();
             this.unread = message_data.lookup ("unread").get_boolean ();
             this.flagged = message_data.lookup ("flagged").get_boolean ();
+            this.forwarded = message_data.lookup ("forwarded").get_boolean ();
+            this.replied = message_data.lookup ("replied").get_boolean ();
             this.priority = message_data.lookup ("priority").get_boolean ();
             this.date = new GLib.DateTime.from_unix_utc (message_data.lookup ("date").get_int64 ());
         }
@@ -74,8 +80,10 @@ namespace Postler {
             this.recipients = statement.column_text (2);
             this.unread = statement.column_int64 (3) != 0;
             this.flagged = statement.column_int64 (4) != 0;
-            this.priority = statement.column_int64 (5) != 0;
-            this.date = new GLib.DateTime.from_unix_utc (statement.column_int64 (6));
+            this.forwarded = statement.column_int64 (5) != 0;
+            this.replied = statement.column_int64 (6) != 0;
+            this.priority = statement.column_int64 (7) != 0;
+            this.date = new GLib.DateTime.from_unix_utc (statement.column_int64 (8));
         }
 
         void read_flags (string path) {
@@ -84,6 +92,8 @@ namespace Postler {
             if (last_colon != null) {
                 this.unread = last_colon.chr (-1, 'S') == null;
                 this.flagged = last_colon.chr (-1, 'F') != null;
+                this.forwarded = last_colon.chr (-1, 'P') != null;
+                this.replied = last_colon.chr (-1, 'R') != null;
             }
             else {
                 this.unread = true;
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 6dfe791..db2c459 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -90,8 +90,12 @@ public class Postler.Messages : Gtk.TreeView {
 
         model.get (iter, Columns.MESSAGE, out message);
 
-        cell.set ("stock-id", message.unread ? STOCK_MAIL_UNREAD : null);
-        /* TODO: missing status values */
+        if (message.forwarded)
+            cell.set ("stock-id", STOCK_MAIL_FORWARDED);
+        else if (message.replied)
+            cell.set ("stock-id", STOCK_MAIL_REPLIED);
+        else
+            cell.set ("stock-id", message.unread ? STOCK_MAIL_UNREAD : null);
     }
 
     void render_flag (Gtk.CellLayout layout, Gtk.CellRenderer cell,



More information about the Xfce4-commits mailing list