X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;fp=lib%2Fmessage.cc;h=4e1be986abc326842314b9d92c8553bb1aea016d;hp=5ea5aa22214c7900d105b9fca1ea47d5550b91e3;hb=2d04ed263121d970cd24a8c26ac924425a7ae3d2;hpb=13116c5cedf58171d04b5f518b3d6f2fe8aea99d diff --git a/lib/message.cc b/lib/message.cc index 5ea5aa22..4e1be986 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1166,15 +1166,40 @@ notmuch_message_count_files (notmuch_message_t *message) return _notmuch_string_list_length (message->filename_list); } +notmuch_status_t +notmuch_message_get_flag_st (notmuch_message_t *message, + notmuch_message_flag_t flag, + notmuch_bool_t *is_set) +{ + if (! is_set) + return NOTMUCH_STATUS_NULL_POINTER; + + try { + if (flag == NOTMUCH_MESSAGE_FLAG_GHOST && + ! NOTMUCH_TEST_BIT (message->lazy_flags, flag)) + _notmuch_message_ensure_metadata (message, NULL); + } catch (Xapian::Error &error) { + LOG_XAPIAN_EXCEPTION (message, error); + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; + } + + *is_set = NOTMUCH_TEST_BIT (message->flags, flag); + return NOTMUCH_STATUS_SUCCESS; +} + notmuch_bool_t notmuch_message_get_flag (notmuch_message_t *message, notmuch_message_flag_t flag) { - if (flag == NOTMUCH_MESSAGE_FLAG_GHOST && - ! NOTMUCH_TEST_BIT (message->lazy_flags, flag)) - _notmuch_message_ensure_metadata (message, NULL); + notmuch_bool_t is_set; + notmuch_status_t status; + + status = notmuch_message_get_flag_st (message, flag, &is_set); - return NOTMUCH_TEST_BIT (message->flags, flag); + if (status) + return FALSE; + else + return is_set; } void