X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=message.cc;h=28f19a88502dc79ff29210297abfbed4f5ef2562;hp=dfd55d596e21af0cac4d79416f9029644a5f4d75;hb=8ae1c3c6e11f7c8d4066ef3d8affe4d07528807b;hpb=bf78a89196b251c2465f6cefa8198f22c87ff23d diff --git a/message.cc b/message.cc index dfd55d59..28f19a88 100644 --- a/message.cc +++ b/message.cc @@ -21,6 +21,8 @@ #include "notmuch-private.h" #include "database-private.h" +#include + #include struct _notmuch_message { @@ -257,16 +259,6 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header) return notmuch_message_file_get_header (message->message_file, header); } -const char * -notmuch_message_get_all_headers (notmuch_message_t *message) -{ - _notmuch_message_ensure_message_file (message); - if (message->message_file == NULL) - return NULL; - - return notmuch_message_file_get_all_headers (message->message_file); -} - const char * notmuch_message_get_thread_id (notmuch_message_t *message) { @@ -359,6 +351,21 @@ notmuch_message_get_filename (notmuch_message_t *message) return message->filename; } +time_t +notmuch_message_get_date (notmuch_message_t *message) +{ + std::string value; + + try { + value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP); + } catch (Xapian::Error &error) { + INTERNAL_ERROR ("Failed to read timestamp value from document."); + return 0; + } + + return Xapian::sortable_unserialise (value); +} + notmuch_tags_t * notmuch_message_get_tags (notmuch_message_t *message) { @@ -402,7 +409,12 @@ _notmuch_message_set_date (notmuch_message_t *message, { time_t time_value; - time_value = notmuch_parse_date (date, NULL); + /* GMime really doesn't want to see a NULL date, so protect its + * sensibilities. */ + if (date == NULL) + time_value = 0; + else + time_value = g_mime_utils_header_decode_date (date, NULL); message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP, Xapian::sortable_serialise (time_value));