X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Findex.cc;h=f166aefd2fc1f6f6c5ea1e306e4fc033ead09c59;hp=e1e2a3828f024988d59b8d28d9524a4a0ba99f28;hb=e038b95ffe18b13fb47f4982ddc969669172cb32;hpb=473930bb6fb167078a9428ad85f53accf7d4559f diff --git a/lib/index.cc b/lib/index.cc index e1e2a382..f166aefd 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -231,26 +231,22 @@ _index_address_mailbox (notmuch_message_t *message, InternetAddress *address) { InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address); - const char *name, *addr; + const char *name, *addr, *combined; void *local = talloc_new (message); name = internet_address_get_name (address); addr = internet_address_mailbox_get_addr (mailbox); - /* In the absence of a name, we'll strip the part before the @ - * from the address. */ - if (! name) { - const char *at; + /* Combine the name and address and index them as a phrase. */ + if (name && addr) + combined = talloc_asprintf (local, "%s %s", name, addr); + else if (name) + combined = name; + else + combined = addr; - at = strchr (addr, '@'); - if (at) - name = talloc_strndup (local, addr, at - addr); - } - - if (name) - _notmuch_message_gen_terms (message, prefix_name, name); - if (addr) - _notmuch_message_gen_terms (message, prefix_name, addr); + if (combined) + _notmuch_message_gen_terms (message, prefix_name, combined); talloc_free (local); } @@ -318,10 +314,21 @@ _index_mime_part (notmuch_message_t *message, const char *charset; if (! part) { - fprintf (stderr, "Warning: Not indexing empty mime part.\n"); + _notmuch_database_log (_notmuch_message_database (message), + "Warning: Not indexing empty mime part.\n"); return; } + GMimeContentType *content_type = g_mime_object_get_content_type(part); + if (content_type) { + char *mime_string = g_mime_content_type_to_string(content_type); + if (mime_string) + { + _notmuch_message_gen_terms (message, "mimetype", mime_string); + g_free(mime_string); + } + } + if (GMIME_IS_MULTIPART (part)) { GMimeMultipart *multipart = GMIME_MULTIPART (part); int i; @@ -338,7 +345,8 @@ _index_mime_part (notmuch_message_t *message, if (i == 1) continue; if (i > 1) - fprintf (stderr, "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); + _notmuch_database_log (_notmuch_message_database (message), + "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); } if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) { /* Don't index encrypted parts. */ @@ -361,14 +369,16 @@ _index_mime_part (notmuch_message_t *message, } if (! (GMIME_IS_PART (part))) { - fprintf (stderr, "Warning: Not indexing unknown mime part: %s.\n", - g_type_name (G_OBJECT_TYPE (part))); + _notmuch_database_log (_notmuch_message_database (message), + "Warning: Not indexing unknown mime part: %s.\n", + g_type_name (G_OBJECT_TYPE (part))); return; } disposition = g_mime_object_get_content_disposition (part); if (disposition && - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0) + strcasecmp (g_mime_content_disposition_get_disposition (disposition), + GMIME_DISPOSITION_ATTACHMENT) == 0) { const char *filename = g_mime_part_get_filename (GMIME_PART (part));