From ee4ef2fb57e93b1cd9a8a9deb5c486c4b6c23c4a Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 1 Feb 2016 15:39:55 +1900 Subject: [PATCH] [PATCH v3 10/16] Add n_d_add_message_with_indexopts (extension of n_d_add_message) --- 87/7c2c7136dd4df3224850642cd744b55d589ebe | 156 ++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 87/7c2c7136dd4df3224850642cd744b55d589ebe diff --git a/87/7c2c7136dd4df3224850642cd744b55d589ebe b/87/7c2c7136dd4df3224850642cd744b55d589ebe new file mode 100644 index 000000000..d3e7c3d34 --- /dev/null +++ b/87/7c2c7136dd4df3224850642cd744b55d589ebe @@ -0,0 +1,156 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id A57F76DE1B50 + for ; Sun, 31 Jan 2016 12:40:18 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 2D317BLYe21J for ; + Sun, 31 Jan 2016 12:40:16 -0800 (PST) +Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) + by arlo.cworth.org (Postfix) with ESMTP id 7A83D6DE1A1C + for ; Sun, 31 Jan 2016 12:40:09 -0800 (PST) +Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net + [64.134.185.108]) + by che.mayfirst.org (Postfix) with ESMTPSA id 9621BF9A0 + for ; Sun, 31 Jan 2016 15:40:06 -0500 (EST) +Received: by fifthhorseman.net (Postfix, from userid 1000) + id 5132421067; Sun, 31 Jan 2016 15:40:06 -0500 (EST) +From: Daniel Kahn Gillmor +To: Notmuch Mail +Subject: [PATCH v3 10/16] Add n_d_add_message_with_indexopts (extension of + n_d_add_message) +Date: Sun, 31 Jan 2016 15:39:55 -0500 +Message-Id: <1454272801-23623-11-git-send-email-dkg@fifthhorseman.net> +X-Mailer: git-send-email 2.7.0.rc3 +In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net> +References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 31 Jan 2016 20:40:18 -0000 + +Expose the ability to ask for index options via the library interface. +This _add_message_with_indexopts function is now a generalized form of +the older _add_message. It lets you specify parameters and +configurations that can affect the indexing, like indexing encrypted +messages in the clear should the user choose to do so. + +We also adjust the tests so that we test the extended function +returning bad values (since the non-extended function just calls the +extended one). +--- + lib/database.cc | 20 ++++++++++++++++---- + lib/notmuch.h | 14 ++++++++++++++ + test/T070-insert.sh | 4 ++-- + 3 files changed, 32 insertions(+), 6 deletions(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 7d88f69..990b0b1 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -2393,16 +2393,16 @@ _notmuch_database_link_message (notmuch_database_t *notmuch, + } + + notmuch_status_t +-notmuch_database_add_message (notmuch_database_t *notmuch, +- const char *filename, +- notmuch_message_t **message_ret) ++notmuch_database_add_message_with_indexopts (notmuch_database_t *notmuch, ++ const char *filename, ++ notmuch_indexopts_t *indexopts, ++ notmuch_message_t **message_ret) + { + notmuch_message_file_t *message_file; + notmuch_message_t *message = NULL; + notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS, ret2; + notmuch_private_status_t private_status; + notmuch_bool_t is_ghost = false; +- notmuch_indexopts_t *indexopts = NULL; + + const char *date, *header; + const char *from, *to, *subject; +@@ -2552,6 +2552,18 @@ notmuch_database_add_message (notmuch_database_t *notmuch, + return ret; + } + ++ ++notmuch_status_t ++notmuch_database_add_message (notmuch_database_t *notmuch, ++ const char *filename, ++ notmuch_message_t **message_ret) ++{ ++ return notmuch_database_add_message_with_indexopts (notmuch, filename, ++ NULL, ++ message_ret); ++ ++} ++ + notmuch_status_t + notmuch_database_remove_message (notmuch_database_t *notmuch, + const char *filename) +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 3679c54..854a451 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -588,6 +588,20 @@ notmuch_status_t + notmuch_database_add_message (notmuch_database_t *database, + const char *filename, + notmuch_message_t **message); ++/** ++ * Add a new message to the given notmuch database or associate an ++ * additional filename with an existing message using specified ++ * options. ++ * ++ * This does the same thing as notmuch_database_add_message except ++ * that it passes a pre-configured set of indexing options to indicate ++ * how the specific message should be indexed. ++ */ ++notmuch_status_t ++notmuch_database_add_message_with_indexopts (notmuch_database_t *database, ++ const char *filename, ++ notmuch_indexopts_t *indexopts, ++ notmuch_message_t **message); + + /** + * Remove a message filename from the given notmuch database. If the +diff --git a/test/T070-insert.sh b/test/T070-insert.sh +index e7ec6a6..557f9d5 100755 +--- a/test/T070-insert.sh ++++ b/test/T070-insert.sh +@@ -192,14 +192,14 @@ for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \ + gen_insert_msg + cat < index-file-$code.gdb + set breakpoint pending on +-break notmuch_database_add_message ++break notmuch_database_add_message_with_indexopts + commands + return NOTMUCH_STATUS_$code + continue + end + run + EOF +-test_begin_subtest "error exit when add_message returns $code" ++test_begin_subtest "error exit when add_message_with_indexopts returns $code" + gdb --batch-silent --return-child-result -x index-file-$code.gdb \ + --args notmuch insert < $gen_msg_filename + test_expect_equal $? 1 +-- +2.7.0.rc3 + -- 2.26.2