[notmuch] [PATCH 1/3] message: add flags to notmuch_message_t
[notmuch-archives.git] / 9e / 3b3bfe9edb999c2af34686bde565adc0c9d47e
diff --git a/9e/3b3bfe9edb999c2af34686bde565adc0c9d47e b/9e/3b3bfe9edb999c2af34686bde565adc0c9d47e
new file mode 100644 (file)
index 0000000..086ab05
--- /dev/null
@@ -0,0 +1,122 @@
+Return-Path: <bart@jukie.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id BD926431FC2\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:55:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id cXCnpuGYmDE3 for <notmuch@notmuchmail.org>;\r
+       Tue, 24 Nov 2009 20:55:18 -0800 (PST)\r
+Received: from tau.jukie.net (tau.jukie.net [216.239.93.128])\r
+       by olra.theworths.org (Postfix) with ESMTP id 67DE7431FBC\r
+       for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:55:18 -0800 (PST)\r
+Received: from localhost.localdomain (oxygen.jukie.net [10.10.10.8])\r
+       by tau.jukie.net (Postfix) with ESMTP id D1993C00F84;\r
+       Tue, 24 Nov 2009 23:55:17 -0500 (EST)\r
+From: Bart Trojanowski <bart@jukie.net>\r
+To: notmuch@notmuchmail.org\r
+Date: Tue, 24 Nov 2009 23:54:33 -0500\r
+Message-Id: <1259124875-28212-2-git-send-email-bart@jukie.net>\r
+X-Mailer: git-send-email 1.6.4.4.2.gc2f148\r
+In-Reply-To: <1259124875-28212-1-git-send-email-bart@jukie.net>\r
+References: <1259124875-28212-1-git-send-email-bart@jukie.net>\r
+Cc: Bart Trojanowski <bart@jukie.net>\r
+Subject: [notmuch] [PATCH 1/3] message: add flags to notmuch_message_t\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 25 Nov 2009 04:55:21 -0000\r
+\r
+This patch allows for different flags, internal to notmuch, to be set on a\r
+message object.  The patch does not define any such flags, just the\r
+facilities to manage these flags.\r
+\r
+Signed-off-by: Bart Trojanowski <bart@jukie.net>\r
+---\r
+ lib/message.cc |   19 +++++++++++++++++++\r
+ lib/notmuch.h  |   14 ++++++++++++++\r
+ 2 files changed, 33 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 1e325e2..e0834f1 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -37,6 +37,7 @@ struct _notmuch_message {\r
+     char *filename;\r
+     notmuch_message_file_t *message_file;\r
+     notmuch_message_list_t *replies;\r
++    unsigned long flags;\r
\r
+     Xapian::Document doc;\r
+ };\r
+@@ -108,6 +109,7 @@ _notmuch_message_create (const void *talloc_owner,\r
+     message->doc_id = doc_id;\r
\r
+     message->frozen = 0;\r
++    message->flags = 0;\r
\r
+     /* Each of these will be lazily created as needed. */\r
+     message->message_id = NULL;\r
+@@ -445,6 +447,23 @@ notmuch_message_get_filename (notmuch_message_t *message)\r
+     return message->filename;\r
+ }\r
\r
++notmuch_bool_t\r
++notmuch_message_get_flag (notmuch_message_t *message,\r
++                        notmuch_message_flag_t flag)\r
++{\r
++    return message->flags & (1 << flag);\r
++}\r
++\r
++void\r
++notmuch_message_set_flag (notmuch_message_t *message,\r
++                        notmuch_message_flag_t flag, notmuch_bool_t enable)\r
++{\r
++    if (enable)\r
++      message->flags |= (1 << flag);\r
++    else\r
++      message->flags &= ~(1 << flag);\r
++}\r
++\r
+ time_t\r
+ notmuch_message_get_date (notmuch_message_t *message)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 8bba442..c232c58 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -684,6 +684,20 @@ notmuch_message_get_replies (notmuch_message_t *message);\r
+ const char *\r
+ notmuch_message_get_filename (notmuch_message_t *message);\r
\r
++/* Message flags */\r
++typedef enum _notmuch_message_flag {\r
++} notmuch_message_flag_t;\r
++\r
++/* Get a value of a flag for the email corresponding to 'message'. */\r
++notmuch_bool_t\r
++notmuch_message_get_flag (notmuch_message_t *message,\r
++                        notmuch_message_flag_t flag);\r
++\r
++/* Set a value of a flag for the email corresponding to 'message'. */\r
++void\r
++notmuch_message_set_flag (notmuch_message_t *message,\r
++                        notmuch_message_flag_t flag, notmuch_bool_t value);\r
++\r
+ /* Get the date of 'message' as a time_t value.\r
+  *\r
+  * For the original textual representation of the Date header from the\r
+-- \r
+1.6.4.4.2.gc2f148\r
+\r