Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 587C2431FBD for ; Sun, 19 Aug 2012 18:53:16 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ecyA0FAXQmej for ; Sun, 19 Aug 2012 18:53:14 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 9850D431FC7 for ; Sun, 19 Aug 2012 18:53:08 -0700 (PDT) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id 4032A2E50D7E for ; Sun, 19 Aug 2012 18:53:06 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new Received: from finestructure.net (unknown [76.89.192.57]) (Authenticated sender: jrollins) by fire-doxen-submit (Postfix) with ESMTP id 50083328015 for ; Sun, 19 Aug 2012 18:53:04 -0700 (PDT) Received: by finestructure.net (Postfix, from userid 1000) id CB4FA868; Sun, 19 Aug 2012 18:53:03 -0700 (PDT) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 02/11] lib: use new addresses structure for thread authors Date: Sun, 19 Aug 2012 18:52:41 -0700 Message-Id: <1345427570-26518-3-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1345427570-26518-2-git-send-email-jrollins@finestructure.net> References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net> <1345427570-26518-2-git-send-email-jrollins@finestructure.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2012 01:53:16 -0000 Now that we have the infrastructure in place, we modify the thread object and associated functions to use the new addresses structure for storing thread authors. --- lib/thread.cc | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 7af9eeb..9e0e5cb 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -36,11 +36,7 @@ struct visible _notmuch_thread { notmuch_database_t *notmuch; char *thread_id; char *subject; - GHashTable *authors_hash; - GPtrArray *authors_array; - GHashTable *matched_authors_hash; - GPtrArray *matched_authors_array; - char *authors; + notmuch_thread_addresses_t *authors; GHashTable *tags; notmuch_message_list_t *message_list; @@ -66,21 +62,9 @@ _notmuch_thread_addresses_destructor (notmuch_thread_addresses_t *addresses) static int _notmuch_thread_destructor (notmuch_thread_t *thread) { - g_hash_table_unref (thread->authors_hash); - g_hash_table_unref (thread->matched_authors_hash); + _notmuch_thread_addresses_destructor (thread->authors); g_hash_table_unref (thread->tags); g_hash_table_unref (thread->message_hash); - - if (thread->authors_array) { - g_ptr_array_free (thread->authors_array, TRUE); - thread->authors_array = NULL; - } - - if (thread->matched_authors_array) { - g_ptr_array_free (thread->matched_authors_array, TRUE); - thread->matched_authors_array = NULL; - } - return 0; } @@ -341,7 +325,7 @@ _thread_add_message (notmuch_thread_t *thread, author = internet_address_mailbox_get_addr (mailbox); } clean_author = _thread_cleanup_author (thread, author, from); - _thread_add_author (thread, clean_author); + _thread_add_address (thread->authors, clean_author, FALSE); notmuch_message_set_author (message, clean_author); } g_object_unref (G_OBJECT (list)); @@ -436,7 +420,7 @@ _thread_add_matched_message (notmuch_thread_t *thread, NOTMUCH_MESSAGE_FLAG_MATCH, 1); } - _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message)); + _thread_add_address (thread->authors, notmuch_message_get_author (hashed_message), TRUE); } static void @@ -555,14 +539,11 @@ _notmuch_thread_create (void *ctx, thread->notmuch = notmuch; thread->thread_id = talloc_strdup (thread, thread_id); thread->subject = NULL; - thread->authors_hash = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, NULL); - thread->authors_array = g_ptr_array_new (); - thread->matched_authors_hash = g_hash_table_new_full (g_str_hash, - g_str_equal, - NULL, NULL); - thread->matched_authors_array = g_ptr_array_new (); - thread->authors = NULL; + + thread->authors = _thread_addresses_init (thread); + if (unlikely (thread->authors == NULL)) + return NULL; + thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal, free, NULL); @@ -607,7 +588,7 @@ _notmuch_thread_create (void *ctx, notmuch_query_destroy (thread_id_query); - _resolve_thread_authors_string (thread); + _resolve_thread_addresses_string (thread->authors); _resolve_thread_relationships (thread); @@ -641,7 +622,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread) const char * notmuch_thread_get_authors (notmuch_thread_t *thread) { - return thread->authors; + return thread->authors->string; } const char * -- 1.7.10.4