[notmuch] [PATCH 1/2] lib/message: Add function to get maildir flags.
authorStefan Schmidt <stefan@datenfreihafen.org>
Sun, 22 Nov 2009 00:11:00 +0000 (01:11 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:38 +0000 (09:35 -0800)
8b/9e355197ffd2efbe3b6d7d33044375fb1fd4c4 [new file with mode: 0644]

diff --git a/8b/9e355197ffd2efbe3b6d7d33044375fb1fd4c4 b/8b/9e355197ffd2efbe3b6d7d33044375fb1fd4c4
new file mode 100644 (file)
index 0000000..bbfe993
--- /dev/null
@@ -0,0 +1,130 @@
+Return-Path: <stefan@datenfreihafen.org>\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 E4203431FBF\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:11:31 -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 k6PahtnYXl0O for <notmuch@notmuchmail.org>;\r
+       Sat, 21 Nov 2009 16:11:30 -0800 (PST)\r
+Received: from sirius.lasnet.de (sirius.lasnet.de [78.47.116.19])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1BAB6431FBC\r
+       for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:11:30 -0800 (PST)\r
+Received: from p5b034af6.dip.t-dialin.net ([91.3.74.246] helo=excalibur)\r
+       by sirius.lasnet.de with esmtpsa \r
+       (Cipher TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63 #1)\r
+       id 1NC02v-0000t5-LF by authid <stefan@sostec.de> with cram_md5;\r
+       Sun, 22 Nov 2009 01:11:29 +0100\r
+Received: from stefan by excalibur with local (Exim 4.69)\r
+       (envelope-from <stefan@excalibur.local>)\r
+       id 1NC02u-0001Dj-V9; Sun, 22 Nov 2009 01:11:16 +0100\r
+From: Stefan Schmidt <stefan@datenfreihafen.org>\r
+To: notmuch@notmuchmail.org\r
+Date: Sun, 22 Nov 2009 01:11:00 +0100\r
+Message-Id: <1258848661-4660-1-git-send-email-stefan@datenfreihafen.org>\r
+X-Mailer: git-send-email 1.6.5.3\r
+In-Reply-To: <yes>\r
+References: <yes>\r
+Subject: [notmuch] [PATCH 1/2] lib/message: Add function to get maildir\r
+       flags.\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: Sun, 22 Nov 2009 00:11:32 -0000\r
+\r
+With notmuch_message_get_flags() we gain the information if the message was\r
+flagged as read, draft, trashed, etc. Handy for big mail spooles that were used\r
+with another mailer.\r
+\r
+Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>\r
+---\r
+ lib/message.cc |   26 ++++++++++++++++++++++++++\r
+ lib/notmuch.h  |   10 ++++++++++\r
+ 2 files changed, 36 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 069cedb..9bec61e 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -35,6 +35,7 @@ struct _notmuch_message {\r
+     char *thread_id;\r
+     char *in_reply_to;\r
+     char *filename;\r
++    char *flags;\r
+     notmuch_message_file_t *message_file;\r
+     notmuch_message_list_t *replies;\r
\r
+@@ -114,6 +115,7 @@ _notmuch_message_create (const void *talloc_owner,\r
+     message->thread_id = NULL;\r
+     message->in_reply_to = NULL;\r
+     message->filename = NULL;\r
++    message->flags = NULL;\r
+     message->message_file = NULL;\r
\r
+     message->replies = _notmuch_message_list_create (message);\r
+@@ -438,6 +440,30 @@ notmuch_message_get_filename (notmuch_message_t *message)\r
+     return message->filename;\r
+ }\r
\r
++const char *\r
++notmuch_message_get_flags (notmuch_message_t *message)\r
++{\r
++    std::string filename_str, flags;\r
++    size_t position;\r
++    const char *db_path;\r
++\r
++    if (message->flags)\r
++      return message->flags;\r
++\r
++    filename_str = message->doc.get_data ();\r
++    db_path = notmuch_database_get_path (message->notmuch);\r
++\r
++    if (filename_str[0] != '/')\r
++      filename_str.insert (0, db_path);\r
++\r
++    /* Flags are everything behind ":" */\r
++    position = filename_str.find (":");\r
++    flags = filename_str.substr (position + 3); /* We don't want :2, */\r
++    message->flags = talloc_strdup (message, flags.c_str ());\r
++\r
++    return message->flags;\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 a61cd02..1da5dfd 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -694,6 +694,16 @@ notmuch_message_get_replies (notmuch_message_t *message);\r
+ const char *\r
+ notmuch_message_get_filename (notmuch_message_t *message);\r
\r
++/* Get the maildir flags for the email corresponding to 'message'.\r
++ *\r
++ * The returned flags will be a string of ascii format flags.\r
++ *\r
++ * The returned string belongs to the message so should not be\r
++ * modified or freed by the caller (nor should it be referenced after\r
++ * the message is destroyed). */\r
++const char *\r
++notmuch_message_get_flags (notmuch_message_t *message);\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.5.3\r
+\r