Re: [PATCH v4 09/16] index encrypted parts when asked.
[notmuch-archives.git] / a4 / 91911c767afb9eb2f1a2dd3d37ad42bac78142
1 Return-Path: <jrollins@finestructure.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 olra.theworths.org (Postfix) with ESMTP id 587C2431FBD\r
6         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:16 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id ecyA0FAXQmej for <notmuch@notmuchmail.org>;\r
16         Sun, 19 Aug 2012 18:53:14 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id 9850D431FC7\r
20         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:08 -0700 (PDT)\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by fire-doxen-postvirus (Postfix) with ESMTP id 4032A2E50D7E\r
23         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:06 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
25 Received: from finestructure.net (unknown [76.89.192.57])\r
26         (Authenticated sender: jrollins)\r
27         by fire-doxen-submit (Postfix) with ESMTP id 50083328015\r
28         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:04 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id CB4FA868; Sun, 19 Aug 2012 18:53:03 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH 02/11] lib: use new addresses structure for thread authors\r
34 Date: Sun, 19 Aug 2012 18:52:41 -0700\r
35 Message-Id: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
38 References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
39         <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Mon, 20 Aug 2012 01:53:16 -0000\r
53 \r
54 Now that we have the infrastructure in place, we modify the thread\r
55 object and associated functions to use the new addresses structure for\r
56 storing thread authors.\r
57 ---\r
58  lib/thread.cc |   41 +++++++++++------------------------------\r
59  1 file changed, 11 insertions(+), 30 deletions(-)\r
60 \r
61 diff --git a/lib/thread.cc b/lib/thread.cc\r
62 index 7af9eeb..9e0e5cb 100644\r
63 --- a/lib/thread.cc\r
64 +++ b/lib/thread.cc\r
65 @@ -36,11 +36,7 @@ struct visible _notmuch_thread {\r
66      notmuch_database_t *notmuch;\r
67      char *thread_id;\r
68      char *subject;\r
69 -    GHashTable *authors_hash;\r
70 -    GPtrArray *authors_array;\r
71 -    GHashTable *matched_authors_hash;\r
72 -    GPtrArray *matched_authors_array;\r
73 -    char *authors;\r
74 +    notmuch_thread_addresses_t *authors;\r
75      GHashTable *tags;\r
76  \r
77      notmuch_message_list_t *message_list;\r
78 @@ -66,21 +62,9 @@ _notmuch_thread_addresses_destructor (notmuch_thread_addresses_t *addresses)\r
79  static int\r
80  _notmuch_thread_destructor (notmuch_thread_t *thread)\r
81  {\r
82 -    g_hash_table_unref (thread->authors_hash);\r
83 -    g_hash_table_unref (thread->matched_authors_hash);\r
84 +    _notmuch_thread_addresses_destructor (thread->authors);\r
85      g_hash_table_unref (thread->tags);\r
86      g_hash_table_unref (thread->message_hash);\r
87 -\r
88 -    if (thread->authors_array) {\r
89 -       g_ptr_array_free (thread->authors_array, TRUE);\r
90 -       thread->authors_array = NULL;\r
91 -    }\r
92 -\r
93 -    if (thread->matched_authors_array) {\r
94 -       g_ptr_array_free (thread->matched_authors_array, TRUE);\r
95 -       thread->matched_authors_array = NULL;\r
96 -    }\r
97 -\r
98      return 0;\r
99  }\r
100  \r
101 @@ -341,7 +325,7 @@ _thread_add_message (notmuch_thread_t *thread,\r
102                 author = internet_address_mailbox_get_addr (mailbox);\r
103             }\r
104             clean_author = _thread_cleanup_author (thread, author, from);\r
105 -           _thread_add_author (thread, clean_author);\r
106 +           _thread_add_address (thread->authors, clean_author, FALSE);\r
107             notmuch_message_set_author (message, clean_author);\r
108         }\r
109         g_object_unref (G_OBJECT (list));\r
110 @@ -436,7 +420,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
111                                   NOTMUCH_MESSAGE_FLAG_MATCH, 1);\r
112      }\r
113  \r
114 -    _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message));\r
115 +    _thread_add_address (thread->authors, notmuch_message_get_author (hashed_message), TRUE);\r
116  }\r
117  \r
118  static void\r
119 @@ -555,14 +539,11 @@ _notmuch_thread_create (void *ctx,\r
120      thread->notmuch = notmuch;\r
121      thread->thread_id = talloc_strdup (thread, thread_id);\r
122      thread->subject = NULL;\r
123 -    thread->authors_hash = g_hash_table_new_full (g_str_hash, g_str_equal,\r
124 -                                                 NULL, NULL);\r
125 -    thread->authors_array = g_ptr_array_new ();\r
126 -    thread->matched_authors_hash = g_hash_table_new_full (g_str_hash,\r
127 -                                                         g_str_equal,\r
128 -                                                         NULL, NULL);\r
129 -    thread->matched_authors_array = g_ptr_array_new ();\r
130 -    thread->authors = NULL;\r
131 +\r
132 +    thread->authors = _thread_addresses_init (thread);\r
133 +    if (unlikely (thread->authors == NULL))\r
134 +       return NULL;\r
135 +\r
136      thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,\r
137                                           free, NULL);\r
138  \r
139 @@ -607,7 +588,7 @@ _notmuch_thread_create (void *ctx,\r
140  \r
141      notmuch_query_destroy (thread_id_query);\r
142  \r
143 -    _resolve_thread_authors_string (thread);\r
144 +    _resolve_thread_addresses_string (thread->authors);\r
145  \r
146      _resolve_thread_relationships (thread);\r
147  \r
148 @@ -641,7 +622,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread)\r
149  const char *\r
150  notmuch_thread_get_authors (notmuch_thread_t *thread)\r
151  {\r
152 -    return thread->authors;\r
153 +    return thread->authors->string;\r
154  }\r
155  \r
156  const char *\r
157 -- \r
158 1.7.10.4\r
159 \r