--- /dev/null
+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 DC6656DE1BC8\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:34 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.022\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.022 tagged_above=-999 required=5\r
+ tests=[AWL=-0.022] 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 M8w8ci7xGJyE for <notmuch@notmuchmail.org>;\r
+ Tue, 19 Jan 2016 18:53:31 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 1C1976DE178E\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 18:53:17 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 57D02F99C\r
+ for <notmuch@notmuchmail.org>; Tue, 19 Jan 2016 21:53:14 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 0906B2092E; Tue, 19 Jan 2016 18:53:11 -0800 (PST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v2 13/16] add indexopts to notmuch python bindings.\r
+Date: Tue, 19 Jan 2016 21:52:46 -0500\r
+Message-Id: <1453258369-7366-14-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.7.0.rc3\r
+In-Reply-To: <1453258369-7366-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1453258369-7366-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: Wed, 20 Jan 2016 02:53:35 -0000\r
+\r
+Make notmuch indexing options are not available in python as\r
+the notmuch.Indexopts class. Users can do something like:\r
+\r
+ import notmuch\r
+ d = notmuch.Database()\r
+ indexopts = notmuch.Indexopts(try_decrypt=true)\r
+ d.add_message(fname, indexopts=indexopts)\r
+---\r
+ bindings/python/notmuch/__init__.py | 1 +\r
+ bindings/python/notmuch/database.py | 21 +++++---\r
+ bindings/python/notmuch/globals.py | 5 ++\r
+ bindings/python/notmuch/indexopts.py | 97 ++++++++++++++++++++++++++++++++++++\r
+ 4 files changed, 117 insertions(+), 7 deletions(-)\r
+ create mode 100644 bindings/python/notmuch/indexopts.py\r
+\r
+diff --git a/bindings/python/notmuch/__init__.py b/bindings/python/notmuch/__init__.py\r
+index 29416a5..fe2d886 100644\r
+--- a/bindings/python/notmuch/__init__.py\r
++++ b/bindings/python/notmuch/__init__.py\r
+@@ -54,6 +54,7 @@ Copyright 2010-2011 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+ from .database import Database\r
+ from .directory import Directory\r
+ from .filenames import Filenames\r
++from .indexopts import Indexopts\r
+ from .message import Message\r
+ from .messages import Messages\r
+ from .query import Query\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 93e7b7a..1b0ee1a 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\r
+@@ -29,6 +29,7 @@ from .globals import (\r
+ NotmuchDirectoryP,\r
+ NotmuchMessageP,\r
+ NotmuchTagsP,\r
++ NotmuchIndexoptsP,\r
+ )\r
+ from .errors import (\r
+ STATUS,\r
+@@ -383,12 +384,13 @@ class Database(object):\r
+ # return the Directory, init it with the absolute path\r
+ return Directory(abs_dirpath, dir_p, self)\r
+ \r
+- _add_message = nmlib.notmuch_database_add_message\r
+- _add_message.argtypes = [NotmuchDatabaseP, c_char_p,\r
+- POINTER(NotmuchMessageP)]\r
+- _add_message.restype = c_uint\r
+-\r
+- def add_message(self, filename, sync_maildir_flags=False):\r
++ _add_message_with_indexopts = nmlib.notmuch_database_add_message_with_indexopts\r
++ _add_message_with_indexopts.argtypes = [NotmuchDatabaseP, c_char_p,\r
++ NotmuchIndexoptsP,\r
++ POINTER(NotmuchMessageP)]\r
++ _add_message_with_indexopts.restype = c_uint\r
++ \r
++ def add_message(self, filename, sync_maildir_flags=False, indexopts=None):\r
+ """Adds a new message to the database\r
+ \r
+ :param filename: should be a path relative to the path of the\r
+@@ -409,6 +411,9 @@ class Database(object):\r
+ API. You might want to look into the underlying method\r
+ :meth:`Message.maildir_flags_to_tags`.\r
+ \r
++ :param indexopts: a nomtuch.Indexopts object indicating custom\r
++ options desired for indexing.\r
++\r
+ :returns: On success, we return\r
+ \r
+ 1) a :class:`Message` object that can be used for things\r
+@@ -436,10 +441,12 @@ class Database(object):\r
+ :attr:`STATUS`.READ_ONLY_DATABASE\r
+ Database was opened in read-only mode so no message can\r
+ be added.\r
++\r
+ """\r
+ self._assert_db_is_initialized()\r
+ msg_p = NotmuchMessageP()\r
+- status = self._add_message(self._db, _str(filename), byref(msg_p))\r
++\r
++ status = self._add_message_with_indexopts(self._db, _str(filename), indexopts._indexopts, byref(msg_p))\r
+ \r
+ if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:\r
+ raise NotmuchError(status)\r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index 6872a29..c4b9832 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -88,3 +88,8 @@ NotmuchDirectoryP = POINTER(NotmuchDirectoryS)\r
+ class NotmuchFilenamesS(Structure):\r
+ pass\r
+ NotmuchFilenamesP = POINTER(NotmuchFilenamesS)\r
++\r
++\r
++class NotmuchIndexoptsS(Structure):\r
++ pass\r
++NotmuchIndexoptsP = POINTER(NotmuchIndexoptsS)\r
+diff --git a/bindings/python/notmuch/indexopts.py b/bindings/python/notmuch/indexopts.py\r
+new file mode 100644\r
+index 0000000..b0d4603\r
+--- /dev/null\r
++++ b/bindings/python/notmuch/indexopts.py\r
+@@ -0,0 +1,97 @@\r
++"""\r
++This file is part of notmuch.\r
++\r
++Notmuch is free software: you can redistribute it and/or modify it\r
++under the terms of the GNU General Public License as published by the\r
++Free Software Foundation, either version 3 of the License, or (at your\r
++option) any later version.\r
++\r
++Notmuch is distributed in the hope that it will be useful, but WITHOUT\r
++ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\r
++for more details.\r
++\r
++You should have received a copy of the GNU General Public License\r
++along with notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++\r
++Copyright 2015 Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
++"""\r
++from ctypes import c_char_p, c_bool, c_int\r
++from .globals import (\r
++ nmlib,\r
++ NotmuchIndexoptsP,\r
++)\r
++from .errors import (\r
++ STATUS,\r
++ NullPointerError,\r
++ NotInitializedError,\r
++)\r
++\r
++\r
++class Indexopts(object):\r
++ """Represents available options for notmuch indexing.\r
++ """\r
++\r
++ # create\r
++ _create = nmlib.notmuch_indexopts_create\r
++ _create.argtypes = []\r
++ _create.restype = NotmuchIndexoptsP\r
++\r
++ def __init__(self, try_decrypt=False, gpg_path=None):\r
++ """\r
++ :param try_decrypt: True if notmuch should try to decrypt messages\r
++ while indexing, and index the cleartext.\r
++\r
++ :param gpg_path: the name or path to the preferred GnuPG binary.\r
++ """\r
++ self._indexopts = Indexopts._create()\r
++ self.gpg_path = gpg_path\r
++ self.try_decrypt = try_decrypt\r
++\r
++ # try_decrypt\r
++ _get_try_decrypt = nmlib.notmuch_indexopts_get_try_decrypt\r
++ _get_try_decrypt.argtypes = [NotmuchIndexoptsP]\r
++ _get_try_decrypt.restype = bool\r
++\r
++ _set_try_decrypt = nmlib.notmuch_indexopts_set_try_decrypt\r
++ _set_try_decrypt.argtypes = [NotmuchIndexoptsP, c_bool]\r
++ _set_try_decrypt.restype = c_int\r
++\r
++ @property\r
++ def try_decrypt(self):\r
++ return Indexopts._get_try_decrypt(self._indexopts)\r
++\r
++ @try_decrypt.setter\r
++ def try_decrypt(self, try_decrypt):\r
++ status = Indexopts._set_try_decrypt(self._indexopts, try_decrypt)\r
++ if status != STATUS.SUCCESS:\r
++ raise NotmuchError(status)\r
++\r
++ # gpg_path\r
++ _get_gpg_path = nmlib.notmuch_indexopts_get_gpg_path\r
++ _get_gpg_path.argtypes = [NotmuchIndexoptsP]\r
++ _get_gpg_path.restype = c_char_p\r
++\r
++ _set_gpg_path = nmlib.notmuch_indexopts_set_gpg_path\r
++ _set_gpg_path.argtypes = [NotmuchIndexoptsP, c_char_p]\r
++ _set_gpg_path.restype = c_int\r
++\r
++ @property\r
++ def gpg_path(self):\r
++ return Indexopts._get_gpg_path(self._indexopts)\r
++\r
++ @gpg_path.setter\r
++ def gpg_path(self, gpg_path):\r
++ status = Indexopts._set_gpg_path(self._indexopts, gpg_path)\r
++ if status != STATUS.SUCCESS:\r
++ raise NotmuchError(status)\r
++ \r
++\r
++ _destroy = nmlib.notmuch_indexopts_destroy\r
++ _destroy.argtypes = [NotmuchIndexoptsP]\r
++ _destroy.restype = None\r
++\r
++ def __del__(self):\r
++ """Close and free the indexopts"""\r
++ if self._indexopts:\r
++ self._destroy(self._indexopts)\r
+-- \r
+2.7.0.rc3\r
+\r