--- /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 DD0EF6DE02AC\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:13:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.108\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.108 tagged_above=-999 required=5 tests=[AWL=0.108]\r
+ 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 eo15abrp6g-e for <notmuch@notmuchmail.org>;\r
+ Fri, 8 Jul 2016 03:13:24 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 94C316DE02AF\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:13:09 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [88.128.80.54])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id EFA0DF99D\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 06:13:07 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id C12D4215CD; Fri, 8 Jul 2016 11:27:34 +0200 (CEST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v4 13/16] add indexopts to notmuch python bindings.\r
+Date: Fri, 8 Jul 2016 11:27:24 +0200\r
+Message-Id: <1467970047-8013-14-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467970047-8013-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: Fri, 08 Jul 2016 10:13:34 -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 | 24 ++++++---\r
+ bindings/python/notmuch/globals.py | 5 ++\r
+ bindings/python/notmuch/indexopts.py | 97 ++++++++++++++++++++++++++++++++++++\r
+ 4 files changed, 120 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 cf627ff..5c19532 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 67fb1c4..a13b9bb 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,15 @@ 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
++ io = None\r
++ if indexopts is not None:\r
++ io = indexopts._indexopts\r
++ status = self._add_message_with_indexopts(self._db, _str(filename), io, 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 b1eec2c..71426c8 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.8.1\r
+\r