Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / f3 / b5b1aaa54bc3ded8824e4e94b978ecfd3d3216
1 Return-Path: <dkg@fifthhorseman.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 CD5E46DE1601\r
6  for <notmuch@notmuchmail.org>; Wed,  9 Dec 2015 19:40:10 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.035\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.035 tagged_above=-999 required=5\r
12  tests=[AWL=-0.035] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id zkScRCzV1gyZ for <notmuch@notmuchmail.org>;\r
16  Wed,  9 Dec 2015 19:40:09 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 49A856DE1603\r
19  for <notmuch@notmuchmail.org>; Wed,  9 Dec 2015 19:40:05 -0800 (PST)\r
20 Received: from fifthhorseman.net (unknown [38.109.115.130])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id 2D023F986\r
22  for <notmuch@notmuchmail.org>; Wed,  9 Dec 2015 22:40:04 -0500 (EST)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id B564220DD2; Wed,  9 Dec 2015 22:40:03 -0500 (EST)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH 5/9] Enable cleartext indexing in python bindings\r
28 Date: Wed,  9 Dec 2015 22:39:42 -0500\r
29 Message-Id: <1449718786-28000-6-git-send-email-dkg@fifthhorseman.net>\r
30 X-Mailer: git-send-email 2.6.2\r
31 In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
32 References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.20\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37  <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
39  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Thu, 10 Dec 2015 03:40:11 -0000\r
46 \r
47 The python add_message function now includes a try_decrypt flag to\r
48 permit indexing the cleartext of the mail where possible.\r
49 ---\r
50  bindings/python/notmuch/database.py | 22 +++++++++++++++++++---\r
51  1 file changed, 19 insertions(+), 3 deletions(-)\r
52 \r
53 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
54 index 5b58e09..8e25a05 100644\r
55 --- a/bindings/python/notmuch/database.py\r
56 +++ b/bindings/python/notmuch/database.py\r
57 @@ -388,8 +388,13 @@ class Database(object):\r
58      _add_message.argtypes = [NotmuchDatabaseP, c_char_p,\r
59                               POINTER(NotmuchMessageP)]\r
60      _add_message.restype = c_uint\r
61 -\r
62 -    def add_message(self, filename, sync_maildir_flags=False):\r
63 +    \r
64 +    _add_message_try_decrypt = nmlib.notmuch_database_add_message_try_decrypt\r
65 +    _add_message_try_decrypt.argtypes = [NotmuchDatabaseP, c_char_p,\r
66 +                                         POINTER(NotmuchMessageP)]\r
67 +    _add_message_try_decrypt.restype = c_uint\r
68 +    \r
69 +    def add_message(self, filename, sync_maildir_flags=False, try_decrypt=False):\r
70          """Adds a new message to the database\r
71  \r
72          :param filename: should be a path relative to the path of the\r
73 @@ -410,6 +415,13 @@ class Database(object):\r
74              API. You might want to look into the underlying method\r
75              :meth:`Message.maildir_flags_to_tags`.\r
76  \r
77 +        :param try_decrypt: If the message hasn't been seen by the\r
78 +            index before, and it includes any encrypted parts, try to\r
79 +            index the cleartext if set to `True`.  Note that this\r
80 +            means that the cleartext of the message is effectively\r
81 +            stored in the database index, so DO NOT SET THIS FLAG\r
82 +            without considering the security of your index.\r
83 +\r
84          :returns: On success, we return\r
85  \r
86             1) a :class:`Message` object that can be used for things\r
87 @@ -437,10 +449,14 @@ class Database(object):\r
88                :attr:`STATUS`.READ_ONLY_DATABASE\r
89                        Database was opened in read-only mode so no message can\r
90                        be added.\r
91 +\r
92          """\r
93          self._assert_db_is_initialized()\r
94          msg_p = NotmuchMessageP()\r
95 -        status = self._add_message(self._db, _str(filename), byref(msg_p))\r
96 +        if (try_decrypt):\r
97 +            status = self._add_message_try_decrypt(self._db, _str(filename), byref(msg_p))\r
98 +        else:\r
99 +            status = self._add_message(self._db, _str(filename), byref(msg_p))\r
100  \r
101          if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:\r
102              raise NotmuchError(status)\r
103 -- \r
104 2.6.2\r
105 \r