1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 4E4A16DE092A
\r
6 for <notmuch@notmuchmail.org>; Sun, 12 Jun 2016 18:06:32 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.000, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id InKerBzpu0n3 for <notmuch@notmuchmail.org>;
\r
17 Sun, 12 Jun 2016 18:06:24 -0700 (PDT)
\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id 6FBEE6DE02A6
\r
20 for <notmuch@notmuchmail.org>; Sun, 12 Jun 2016 18:06:10 -0700 (PDT)
\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)
\r
22 (envelope-from <bremner@tethera.net>)
\r
23 id 1bCGKC-0003x8-Bn; Sun, 12 Jun 2016 21:05:56 -0400
\r
24 Received: (nullmailer pid 5666 invoked by uid 1000);
\r
25 Mon, 13 Jun 2016 01:06:04 -0000
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH 1/8] lib: read "property" terms from messages.
\r
29 Date: Sun, 12 Jun 2016 22:05:48 -0300
\r
30 Message-Id: <1465779955-5539-2-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.8.1
\r
32 In-Reply-To: <1465779955-5539-1-git-send-email-david@tethera.net>
\r
33 References: <1465779955-5539-1-git-send-email-david@tethera.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.20
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Mon, 13 Jun 2016 01:06:32 -0000
\r
48 This is a first step towards providing an API to attach
\r
49 arbitrary (key,value) pairs to messages and retrieve all of the values
\r
52 lib/database.cc | 1 +
\r
53 lib/message.cc | 29 ++++++++++++++++++++++++++++-
\r
54 lib/notmuch-private.h | 3 +++
\r
55 3 files changed, 32 insertions(+), 1 deletion(-)
\r
57 diff --git a/lib/database.cc b/lib/database.cc
\r
58 index afafe88..74f31f5 100644
\r
59 --- a/lib/database.cc
\r
60 +++ b/lib/database.cc
\r
61 @@ -245,6 +245,7 @@ static prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
\r
62 { "directory", "XDIRECTORY" },
\r
63 { "file-direntry", "XFDIRENTRY" },
\r
64 { "directory-direntry", "XDDIRENTRY" },
\r
65 + { "property", "XPROPERTY" },
\r
68 static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
\r
69 diff --git a/lib/message.cc b/lib/message.cc
\r
70 index 24e698a..63a8da5 100644
\r
71 --- a/lib/message.cc
\r
72 +++ b/lib/message.cc
\r
73 @@ -37,6 +37,8 @@ struct visible _notmuch_message {
\r
74 notmuch_string_list_t *filename_list;
\r
76 notmuch_message_file_t *message_file;
\r
77 + notmuch_string_list_t *property_term_list;
\r
78 + notmuch_string_map_t *property_map;
\r
79 notmuch_message_list_t *replies;
\r
80 unsigned long flags;
\r
81 /* For flags that are initialized on-demand, lazy_flags indicates
\r
82 @@ -116,6 +118,8 @@ _notmuch_message_create_for_document (const void *talloc_owner,
\r
83 message->filename_list = NULL;
\r
84 message->message_file = NULL;
\r
85 message->author = NULL;
\r
86 + message->property_term_list = NULL;
\r
87 + message->property_map = NULL;
\r
89 message->replies = _notmuch_message_list_create (message);
\r
90 if (unlikely (message->replies == NULL)) {
\r
91 @@ -314,6 +318,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)
\r
92 *id_prefix = _find_prefix ("id"),
\r
93 *type_prefix = _find_prefix ("type"),
\r
94 *filename_prefix = _find_prefix ("file-direntry"),
\r
95 + *property_prefix = _find_prefix ("property"),
\r
96 *replyto_prefix = _find_prefix ("replyto");
\r
98 /* We do this all in a single pass because Xapian decompresses the
\r
99 @@ -369,11 +374,21 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)
\r
100 _notmuch_database_get_terms_with_prefix (message, i, end,
\r
104 + /* Get property terms. Mimic the setup with filenames above */
\r
105 + assert (strcmp (filename_prefix, property_prefix) < 0);
\r
106 + if (!message->property_map && !message->property_term_list)
\r
107 + message->property_term_list =
\r
108 + _notmuch_database_get_terms_with_prefix (message, i, end,
\r
109 + property_prefix);
\r
112 - assert (strcmp (filename_prefix, replyto_prefix) < 0);
\r
113 + assert (strcmp (property_prefix, replyto_prefix) < 0);
\r
114 if (!message->in_reply_to)
\r
115 message->in_reply_to =
\r
116 _notmuch_message_get_term (message, i, end, replyto_prefix);
\r
119 /* It's perfectly valid for a message to have no In-Reply-To
\r
120 * header. For these cases, we return an empty string. */
\r
121 if (!message->in_reply_to)
\r
122 @@ -405,6 +420,18 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message,
\r
123 message->filename_term_list = message->filename_list = NULL;
\r
126 + if (strcmp ("property", prefix_name) == 0) {
\r
128 + if (message->property_term_list)
\r
129 + talloc_free (message->property_term_list);
\r
130 + message->property_term_list = NULL;
\r
132 + if (message->property_map)
\r
133 + talloc_unlink (message, message->property_map);
\r
135 + message->property_map = NULL;
\r
138 if (strcmp ("replyto", prefix_name) == 0) {
\r
139 talloc_free (message->in_reply_to);
\r
140 message->in_reply_to = NULL;
\r
141 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
142 index 3721431..df63905 100644
\r
143 --- a/lib/notmuch-private.h
\r
144 +++ b/lib/notmuch-private.h
\r
145 @@ -537,6 +537,9 @@ _notmuch_string_list_append (notmuch_string_list_t *list,
\r
147 _notmuch_string_list_sort (notmuch_string_list_t *list);
\r
149 +/* string-map.c */
\r
150 +typedef struct _notmuch_string_map notmuch_string_map_t;
\r