return NULL;
}
-static void
+static notmuch_status_t
_ensure_maildir_flags (notmuch_message_t *message, bool force)
{
const char *flags;
message->maildir_flags = NULL;
}
}
-
- for (filenames = notmuch_message_get_filenames (message);
+ filenames = notmuch_message_get_filenames (message);
+ if (! filenames)
+ return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+ for (;
notmuch_filenames_valid (filenames);
notmuch_filenames_move_to_next (filenames)) {
filename = notmuch_filenames_get (filenames);
}
if (seen_maildir_info)
message->maildir_flags = combined_flags;
+ return NOTMUCH_STATUS_SUCCESS;
}
notmuch_bool_t
notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag)
{
- _ensure_maildir_flags (message, false);
- return message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL);
+ notmuch_status_t status;
+ notmuch_bool_t ret;
+ status = notmuch_message_has_maildir_flag_st (message, flag, &ret);
+ if (status)
+ return FALSE;
+
+ return ret;
+}
+
+notmuch_status_t
+notmuch_message_has_maildir_flag_st (notmuch_message_t *message,
+ char flag,
+ notmuch_bool_t *is_set)
+{
+ notmuch_status_t status;
+
+ if (! is_set)
+ return NOTMUCH_STATUS_NULL_POINTER;
+
+ status = _ensure_maildir_flags (message, false);
+ if (status)
+ return status;
+
+ *is_set = message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL);
+ return NOTMUCH_STATUS_SUCCESS;
}
notmuch_status_t
notmuch_status_t status;
unsigned i;
- _ensure_maildir_flags (message, true);
+ status = _ensure_maildir_flags (message, true);
+ if (status)
+ return status;
/* If none of the filenames have any maildir info field (not even
* an empty info with no flags set) then there's no information to
* go on, so do nothing. */
status = _notmuch_database_ensure_writable (message->notmuch);
if (status)
return status;
+ tags = notmuch_message_get_tags (message);
+ if (! tags)
+ return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
- for (tags = notmuch_message_get_tags (message);
+ for (;
notmuch_tags_valid (tags);
notmuch_tags_move_to_next (tags)) {
tag = notmuch_tags_get (tags);
private_status = _notmuch_message_remove_term (message, "tag", tag);
if (private_status) {
- INTERNAL_ERROR ("_notmuch_message_remove_term return unexpected value: %d\n",
- private_status);
+ return COERCE_STATUS (private_status,
+ "_notmuch_message_remove_term return unexpected value: %d\n",
+ private_status);
}
}