X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=a91e69e0283f7fcbf02fe19c3f7108e19d35ad2a;hp=63a8da562b473aef926c9774ca99e9f0650f76f8;hb=930920d5106e01d511dc339171ec3254e3d8771e;hpb=4dfb69169e6b685670ebdeedab898c31adc995b2 diff --git a/lib/message.cc b/lib/message.cc index 63a8da56..a91e69e0 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -20,6 +20,7 @@ #include "notmuch-private.h" #include "database-private.h" +#include "message-private.h" #include @@ -395,7 +396,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message) message->in_reply_to = talloc_strdup (message, ""); } -static void +void _notmuch_message_invalidate_metadata (notmuch_message_t *message, const char *prefix_name) { @@ -552,7 +553,7 @@ notmuch_message_get_replies (notmuch_message_t *message) return _notmuch_messages_create (message->replies); } -static void +void _notmuch_message_remove_terms (notmuch_message_t *message, const char *prefix) { Xapian::TermIterator i; @@ -848,9 +849,9 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message) * * It would be nice to do the upgrade of the document directly * here, but the database is likely open in read-only mode. */ - const char *data; - data = message->doc.get_data ().c_str (); + std::string datastr = message->doc.get_data (); + const char *data = datastr.c_str (); if (data == NULL) INTERNAL_ERROR ("message with no filename"); @@ -1799,3 +1800,50 @@ _notmuch_message_database (notmuch_message_t *message) { return message->notmuch; } + +void +_notmuch_message_ensure_property_map (notmuch_message_t *message) +{ + notmuch_string_node_t *node; + + if (message->property_map) + return; + + if (!message->property_term_list) + _notmuch_message_ensure_metadata (message); + + message->property_map = _notmuch_string_map_create (message); + + for (node = message->property_term_list->head; node; node = node->next) { + const char *key; + char *value; + + value = index(node->string, '='); + if (!value) + INTERNAL_ERROR ("malformed property term"); + + *value = '\0'; + value++; + key = node->string; + + _notmuch_string_map_append (message->property_map, key, value); + + } + + talloc_free (message->property_term_list); + message->property_term_list = NULL; +} + +notmuch_string_map_t * +_notmuch_message_property_map (notmuch_message_t *message) +{ + _notmuch_message_ensure_property_map (message); + + return message->property_map; +} + +notmuch_bool_t +_notmuch_message_frozen (notmuch_message_t *message) +{ + return message->frozen; +}