[PATCH v2 4/7] Add internal functions to search for alternate doc types
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sat, 2 Apr 2016 14:15:38 +0000 (11:15 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:27 +0000 (16:21 -0700)
a6/d231a62201004bdb01e047c79011626b7cf273 [new file with mode: 0644]

diff --git a/a6/d231a62201004bdb01e047c79011626b7cf273 b/a6/d231a62201004bdb01e047c79011626b7cf273
new file mode 100644 (file)
index 0000000..e1a84fb
--- /dev/null
@@ -0,0 +1,133 @@
+Return-Path: <dkg@fifthhorseman.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 arlo.cworth.org (Postfix) with ESMTP id 2173F6DE02C2\r
+ for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 07:15:56 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.549\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.549 tagged_above=-999 required=5\r
+ tests=[AWL=-0.549] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ghxCVSZSnPRV for <notmuch@notmuchmail.org>;\r
+ Sat,  2 Apr 2016 07:15:47 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id BA7DF6DE02D1\r
+ for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 07:15:47 -0700 (PDT)\r
+Received: from fifthhorseman.net (dhcp-a244.meeting.ietf.org [31.133.162.68])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 79C7CF999\r
+ for <notmuch@notmuchmail.org>; Sat,  2 Apr 2016 10:15:45 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id AF7B62089F; Sat,  2 Apr 2016 11:15:41 -0300 (BRT)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 4/7] Add internal functions to search for alternate doc\r
+ types\r
+Date: Sat,  2 Apr 2016 11:15:38 -0300\r
+Message-Id: <1459606541-23889-4-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.0.rc3\r
+In-Reply-To: <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
+ <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 02 Apr 2016 14:15:56 -0000\r
+\r
+Publicly we are only exposing the non-ghost documents (of "type"\r
+"mail").  But internally we might want to inspect the ghost messages\r
+as well.\r
+\r
+This changeset adds two new private interfaces to queries to recover\r
+information about alternate document types.\r
+---\r
+ lib/notmuch-private.h | 10 ++++++++++\r
+ lib/query.cc          | 18 ++++++++++++++++--\r
+ 2 files changed, 26 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index 5dd4770..cbfc144 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -477,6 +477,16 @@ void\r
+ _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,\r
+                             unsigned int doc_id);\r
\r
++notmuch_status_t\r
++_notmuch_query_search_messages_type_st (notmuch_query_t *query,\r
++                                      const char *type,\r
++                                      notmuch_messages_t **out);\r
++\r
++notmuch_status_t\r
++_notmuch_query_count_messages_type_st (notmuch_query_t *query,\r
++                                     const char *type,\r
++                                     unsigned *count_out);\r
++\r
+ /* message.cc */\r
\r
+ void\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index e627bfc..ba6ee49 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -187,6 +187,14 @@ notmuch_status_t\r
+ notmuch_query_search_messages_st (notmuch_query_t *query,\r
+                                 notmuch_messages_t **out)\r
+ {\r
++    return _notmuch_query_search_messages_type_st (query, "mail", out);\r
++}\r
++\r
++notmuch_status_t\r
++_notmuch_query_search_messages_type_st (notmuch_query_t *query,\r
++                                      const char *type,\r
++                                      notmuch_messages_t **out)\r
++{\r
+     notmuch_database_t *notmuch = query->notmuch;\r
+     const char *query_string = query->query_string;\r
+     notmuch_mset_messages_t *messages;\r
+@@ -208,7 +216,7 @@ notmuch_query_search_messages_st (notmuch_query_t *query,\r
+       Xapian::Enquire enquire (*notmuch->xapian_db);\r
+       Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
+                                                  _find_prefix ("type"),\r
+-                                                 "mail"));\r
++                                                 type));\r
+       Xapian::Query string_query, final_query, exclude_query;\r
+       Xapian::MSet mset;\r
+       Xapian::MSetIterator iterator;\r
+@@ -554,6 +562,12 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
+ notmuch_status_t\r
+ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)\r
+ {\r
++    return _notmuch_query_count_messages_type_st (query, "mail", count_out);\r
++}\r
++\r
++notmuch_status_t\r
++_notmuch_query_count_messages_type_st (notmuch_query_t *query, const char *type, unsigned *count_out)\r
++{\r
+     notmuch_database_t *notmuch = query->notmuch;\r
+     const char *query_string = query->query_string;\r
+     Xapian::doccount count = 0;\r
+@@ -562,7 +576,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)\r
+       Xapian::Enquire enquire (*notmuch->xapian_db);\r
+       Xapian::Query mail_query (talloc_asprintf (query, "%s%s",\r
+                                                  _find_prefix ("type"),\r
+-                                                 "mail"));\r
++                                                 type));\r
+       Xapian::Query string_query, final_query, exclude_query;\r
+       Xapian::MSet mset;\r
+       unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |\r
+-- \r
+2.8.0.rc3\r
+\r