Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / e7 / 2c3fc923ce76e406e061432ec544ad4c825209
1 Return-Path: <amdragon@mit.edu>\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 18317431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:24:27 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 FNO36cWvF36A for <notmuch@notmuchmail.org>;\r
16         Sat,  8 Sep 2012 10:24:26 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id 0EF40431FBD\r
20         for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:24:25 -0700 (PDT)\r
21 X-AuditID: 1209190f-b7f706d0000008d5-d8-504b7f492385\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id E8.A7.02261.94F7B405; Sat,  8 Sep 2012 13:24:25 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q88HOOEa020240; \r
27         Sat, 8 Sep 2012 13:24:25 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q88HONeR026350\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Sat, 8 Sep 2012 13:24:24 -0400 (EDT)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1TAOlb-00061d-7p; Sat, 08 Sep 2012 13:24:23 -0400\r
37 Date: Sat, 8 Sep 2012 13:24:23 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Jameson Graef Rollins <jrollins@finestructure.net>\r
40 Subject: Re: [PATCH 02/11] lib: use new addresses structure for thread authors\r
41 Message-ID: <20120908172423.GA22117@mit.edu>\r
42 References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
43         <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
44         <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1/Ws9w4waHqmbLFnn5fF9ZszmR2Y\r
52         PO6e5vJ4tuoWcwBTFJdNSmpOZllqkb5dAlfG1ZMdzAXrlCom7TrI1MD4WKqLkZNDQsBE4u6C\r
53         l6wQtpjEhXvr2boYuTiEBPYxSuy7sZEFwlnPKPFl5h4o5wSTxKe+3awQzhJGiebG2Swg/SwC\r
54         KhKnv99lA7HZBDQktu1fzghiiwiYSfR8+QNmMwtoSWzd+AHMFhbwk/j+eRY7iM0roCMx6/Ic\r
55         ZoihZxglmvavgkoISpyc+YQFpvnGv5dMXYwcQLa0xPJ/HCBhTgFviWu3PoCViALdMOXkNrYJ\r
56         jEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0TvdzMEr3UlNJNjKCw5pTk\r
57         38H47aDSIUYBDkYlHt4Ncl4BQqyJZcWVuYcYJTmYlER5d9d4BwjxJeWnVGYkFmfEF5XmpBYf\r
58         YpTgYFYS4b2eDpTjTUmsrEotyodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgta0D\r
59         ahQsSk1PrUjLzClBSDNxcIIM5wEabgxSw1tckJhbnJkOkT/FqCglzusNcpEASCKjNA+uF5Z2\r
60         XjGKA70iDLGCB5iy4LpfAQ1mAhos8swDZHBJIkJKqoHRvJPnRPqmZepFlXeb98d/3hofWxZ2\r
61         syrvTfE19VmzxbZ0u9zJDDi8mI1z268olb+NGkZTLINXijl/O3MoRENiuYejjsZ0Mdl1R/X3\r
62         GYf0H4md+vO36Te1/vp3JhOTZb9xBZgqXj81/dvT3ZUZrQGGQbHvNjA7fA/dLebxwUg/KNYl\r
63         /eOuSyVKLMUZiYZazEXFiQBk9+zbFgMAAA==\r
64 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sat, 08 Sep 2012 17:24:27 -0000\r
78 \r
79 Quoth Jameson Graef Rollins on Aug 19 at  6:52 pm:\r
80 > Now that we have the infrastructure in place, we modify the thread\r
81 > object and associated functions to use the new addresses structure for\r
82 > storing thread authors.\r
83 > ---\r
84 >  lib/thread.cc |   41 +++++++++++------------------------------\r
85 >  1 file changed, 11 insertions(+), 30 deletions(-)\r
86\r
87 > diff --git a/lib/thread.cc b/lib/thread.cc\r
88 > index 7af9eeb..9e0e5cb 100644\r
89 > --- a/lib/thread.cc\r
90 > +++ b/lib/thread.cc\r
91 > @@ -36,11 +36,7 @@ struct visible _notmuch_thread {\r
92 >      notmuch_database_t *notmuch;\r
93 >      char *thread_id;\r
94 >      char *subject;\r
95 > -    GHashTable *authors_hash;\r
96 > -    GPtrArray *authors_array;\r
97 > -    GHashTable *matched_authors_hash;\r
98 > -    GPtrArray *matched_authors_array;\r
99 > -    char *authors;\r
100 > +    notmuch_thread_addresses_t *authors;\r
101 >      GHashTable *tags;\r
102 >  \r
103 >      notmuch_message_list_t *message_list;\r
104 > @@ -66,21 +62,9 @@ _notmuch_thread_addresses_destructor (notmuch_thread_addresses_t *addresses)\r
105 >  static int\r
106 >  _notmuch_thread_destructor (notmuch_thread_t *thread)\r
107 >  {\r
108 > -    g_hash_table_unref (thread->authors_hash);\r
109 > -    g_hash_table_unref (thread->matched_authors_hash);\r
110 > +    _notmuch_thread_addresses_destructor (thread->authors);\r
111 \r
112 This is the explicit call I mentioned in my talloc destructor comment\r
113 on patch 1.\r
114 \r
115 >      g_hash_table_unref (thread->tags);\r
116 >      g_hash_table_unref (thread->message_hash);\r
117 > -\r
118 > -    if (thread->authors_array) {\r
119 > -     g_ptr_array_free (thread->authors_array, TRUE);\r
120 > -     thread->authors_array = NULL;\r
121 > -    }\r
122 > -\r
123 > -    if (thread->matched_authors_array) {\r
124 > -     g_ptr_array_free (thread->matched_authors_array, TRUE);\r
125 > -     thread->matched_authors_array = NULL;\r
126 > -    }\r
127 > -\r
128 >      return 0;\r
129 >  }\r
130 >  \r
131 > @@ -341,7 +325,7 @@ _thread_add_message (notmuch_thread_t *thread,\r
132 >               author = internet_address_mailbox_get_addr (mailbox);\r
133 >           }\r
134 >           clean_author = _thread_cleanup_author (thread, author, from);\r
135 > -         _thread_add_author (thread, clean_author);\r
136 > +         _thread_add_address (thread->authors, clean_author, FALSE);\r
137 >           notmuch_message_set_author (message, clean_author);\r
138 >       }\r
139 >       g_object_unref (G_OBJECT (list));\r
140 > @@ -436,7 +420,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
141 >                                 NOTMUCH_MESSAGE_FLAG_MATCH, 1);\r
142 >      }\r
143 >  \r
144 > -    _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message));\r
145 > +    _thread_add_address (thread->authors, notmuch_message_get_author (hashed_message), TRUE);\r
146 >  }\r
147 >  \r
148 >  static void\r
149 > @@ -555,14 +539,11 @@ _notmuch_thread_create (void *ctx,\r
150 >      thread->notmuch = notmuch;\r
151 >      thread->thread_id = talloc_strdup (thread, thread_id);\r
152 >      thread->subject = NULL;\r
153 > -    thread->authors_hash = g_hash_table_new_full (g_str_hash, g_str_equal,\r
154 > -                                               NULL, NULL);\r
155 > -    thread->authors_array = g_ptr_array_new ();\r
156 > -    thread->matched_authors_hash = g_hash_table_new_full (g_str_hash,\r
157 > -                                                       g_str_equal,\r
158 > -                                                       NULL, NULL);\r
159 > -    thread->matched_authors_array = g_ptr_array_new ();\r
160 > -    thread->authors = NULL;\r
161 > +\r
162 > +    thread->authors = _thread_addresses_init (thread);\r
163 > +    if (unlikely (thread->authors == NULL))\r
164 > +     return NULL;\r
165 > +\r
166 >      thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,\r
167 >                                         free, NULL);\r
168 >  \r
169 > @@ -607,7 +588,7 @@ _notmuch_thread_create (void *ctx,\r
170 >  \r
171 >      notmuch_query_destroy (thread_id_query);\r
172 >  \r
173 > -    _resolve_thread_authors_string (thread);\r
174 > +    _resolve_thread_addresses_string (thread->authors);\r
175 \r
176 If you make my suggested change to the\r
177 _resolve_thread_addresses_string API, this call would simply go\r
178 away...\r
179 \r
180 >  \r
181 >      _resolve_thread_relationships (thread);\r
182 >  \r
183 > @@ -641,7 +622,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread)\r
184 >  const char *\r
185 >  notmuch_thread_get_authors (notmuch_thread_t *thread)\r
186 >  {\r
187 > -    return thread->authors;\r
188 > +    return thread->authors->string;\r
189 \r
190 ... and this would be return _thread_addresses_to_string (or\r
191 whatever).\r
192 \r
193 >  }\r
194 >  \r
195 >  const char *\r
196 \r
197 -- \r
198 Austin Clements                                      MIT/'06/PhD/CSAIL\r
199 amdragon@mit.edu                           http://web.mit.edu/amdragon\r
200        Somewhere in the dream we call reality you will find me,\r
201               searching for the reality we call dreams.\r