aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/thread.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-11-12 09:59:47 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-12 09:59:47 -0800
commit2f4c5874747c58be04764a7c9a62f3b352e4f9fb (patch)
tree81bcc44b9ef64ae2c696e9cf39e547f3b1f15683 /lib/thread.cc
parent4d35c3544d7bb0143cb1a17cc197cfe271670bf8 (diff)
notmuch search: Print the names of author of matched emails.
It's important to have the names present for determining whether a thread is worth reading or not. We may want to think about abbreviating the list somehow if it is excessively long (or redundant as in bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, etc.).
Diffstat (limited to 'lib/thread.cc')
-rw-r--r--lib/thread.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/thread.cc b/lib/thread.cc
index b67dfade..e85e2afd 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -23,12 +23,14 @@
#include <xapian.h>
+#include <gmime/gmime.h>
#include <glib.h> /* GHashTable */
struct _notmuch_thread {
notmuch_database_t *notmuch;
char *thread_id;
char *subject;
+ char *authors;
GHashTable *tags;
notmuch_bool_t has_message;
@@ -75,6 +77,7 @@ _notmuch_thread_create (const void *talloc_owner,
thread->notmuch = notmuch;
thread->thread_id = talloc_strdup (thread, thread_id);
thread->subject = NULL;
+ thread->authors = NULL;
thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,
free, NULL);
@@ -98,6 +101,32 @@ _notmuch_thread_add_message (notmuch_thread_t *thread,
notmuch_tags_t *tags;
const char *tag;
time_t date;
+ InternetAddressList *list;
+ InternetAddress *address;
+ const char *from, *author;
+
+ from = notmuch_message_get_header (message, "from");
+ list = internet_address_list_parse_string (from);
+ if (list) {
+ address = internet_address_list_get_address (list, 0);
+ if (address) {
+ author = internet_address_get_name (address);
+ if (author == NULL) {
+ InternetAddressMailbox *mailbox;
+ mailbox = INTERNET_ADDRESS_MAILBOX (address);
+ author = internet_address_mailbox_get_addr (mailbox);
+ }
+ if (author) {
+ if (thread->authors)
+ thread->authors = talloc_asprintf (thread, "%s, %s",
+ thread->authors,
+ author);
+ else
+ thread->authors = talloc_strdup (thread, author);
+ }
+ }
+ g_object_unref (G_OBJECT (list));
+ }
if (! thread->subject) {
const char *subject;
@@ -125,6 +154,12 @@ _notmuch_thread_add_message (notmuch_thread_t *thread,
}
const char *
+notmuch_thread_get_authors (notmuch_thread_t *thread)
+{
+ return thread->authors;
+}
+
+const char *
notmuch_thread_get_subject (notmuch_thread_t *thread)
{
return thread->subject;