/* ASCII ordered table of Maildir flags and associated tags */
static struct maildir_flag_tag flag2tag[] = {
/* ASCII ordered table of Maildir flags and associated tags */
static struct maildir_flag_tag flag2tag[] = {
- { 'D', "draft", false},
- { 'F', "flagged", false},
- { 'P', "passed", false},
- { 'R', "replied", false},
+ { 'D', "draft", false },
+ { 'F', "flagged", false },
+ { 'P', "passed", false },
+ { 'R', "replied", false },
- _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n",
- error.get_msg().c_str());
+ _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n",
+ error.get_msg ().c_str ());
- *tag_prefix = _find_prefix ("tag"),
- *id_prefix = _find_prefix ("id"),
- *type_prefix = _find_prefix ("type"),
- *filename_prefix = _find_prefix ("file-direntry"),
- *property_prefix = _find_prefix ("property"),
- *reference_prefix = _find_prefix ("reference"),
- *replyto_prefix = _find_prefix ("replyto");
+ *tag_prefix = _find_prefix ("tag"),
+ *id_prefix = _find_prefix ("id"),
+ *type_prefix = _find_prefix ("type"),
+ *filename_prefix = _find_prefix ("file-direntry"),
+ *property_prefix = _find_prefix ("property"),
+ *reference_prefix = _find_prefix ("reference"),
+ *replyto_prefix = _find_prefix ("replyto");
/* We do this all in a single pass because Xapian decompresses the
* term list every time you iterate over it. Thus, while this is
* slightly more costly than looking up individual fields if only
* one field of the message object is actually used, it's a huge
* win as more fields are used. */
/* We do this all in a single pass because Xapian decompresses the
* term list every time you iterate over it. Thus, while this is
* slightly more costly than looking up individual fields if only
* one field of the message object is actually used, it's a huge
* win as more fields are used. */
message->thread_id =
_notmuch_message_get_term (message, i, end, thread_prefix);
/* Get tags */
assert (strcmp (thread_prefix, tag_prefix) < 0);
message->thread_id =
_notmuch_message_get_term (message, i, end, thread_prefix);
/* Get tags */
assert (strcmp (thread_prefix, tag_prefix) < 0);
message->tag_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
tag_prefix);
message->tag_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
tag_prefix);
message->message_id =
_notmuch_message_get_term (message, i, end, id_prefix);
message->message_id =
_notmuch_message_get_term (message, i, end, id_prefix);
* expand them to full file names when needed in
* _notmuch_message_ensure_filename_list. */
assert (strcmp (type_prefix, filename_prefix) < 0);
* expand them to full file names when needed in
* _notmuch_message_ensure_filename_list. */
assert (strcmp (type_prefix, filename_prefix) < 0);
message->filename_term_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
filename_prefix);
message->filename_term_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
filename_prefix);
/* Get property terms. Mimic the setup with filenames above */
assert (strcmp (filename_prefix, property_prefix) < 0);
/* Get property terms. Mimic the setup with filenames above */
assert (strcmp (filename_prefix, property_prefix) < 0);
message->property_term_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
message->property_term_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
message->reference_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
reference_prefix);
message->reference_list =
_notmuch_database_get_terms_with_prefix (message, i, end,
reference_prefix);
message->in_reply_to =
_notmuch_message_get_term (message, i, end, replyto_prefix);
/* It's perfectly valid for a message to have no In-Reply-To
* header. For these cases, we return an empty string. */
message->in_reply_to =
_notmuch_message_get_term (message, i, end, replyto_prefix);
/* It's perfectly valid for a message to have no In-Reply-To
* header. For these cases, we return an empty string. */
message->in_reply_to = talloc_strdup (message, "");
/* all the way without an exception */
message->in_reply_to = talloc_strdup (message, "");
/* all the way without an exception */
notmuch_status_to_string (status));
} catch (const Xapian::Error &error) {
INTERNAL_ERROR ("A Xapian exception occurred fetching message metadata: %s\n",
notmuch_status_to_string (status));
} catch (const Xapian::Error &error) {
INTERNAL_ERROR ("A Xapian exception occurred fetching message metadata: %s\n",
notmuch_message_get_message_id (notmuch_message_t *message)
{
_notmuch_message_ensure_metadata (message, message->message_id);
notmuch_message_get_message_id (notmuch_message_t *message)
{
_notmuch_message_ensure_metadata (message, message->message_id);
INTERNAL_ERROR ("Message with document ID of %u has no message ID.\n",
message->doc_id);
return message->message_id;
INTERNAL_ERROR ("Message with document ID of %u has no message ID.\n",
message->doc_id);
return message->message_id;
* it could just mean we didn't record the header. */
if ((message->notmuch->features &
NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES) ||
* it could just mean we didn't record the header. */
if ((message->notmuch->features &
NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES) ||
return talloc_strdup (message, value.c_str ());
} catch (Xapian::Error &error) {
return talloc_strdup (message, value.c_str ());
} catch (Xapian::Error &error) {
- _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred when reading header: %s\n",
- error.get_msg().c_str());
+ _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred when reading header: %s\n",
+ error.get_msg ().c_str ());
notmuch_message_get_thread_id (notmuch_message_t *message)
{
_notmuch_message_ensure_metadata (message, message->thread_id);
notmuch_message_get_thread_id (notmuch_message_t *message)
{
_notmuch_message_ensure_metadata (message, message->thread_id);
INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n",
message->doc_id);
return message->thread_id;
INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n",
message->doc_id);
return message->thread_id;
notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) {
notmuch_message_t *child = notmuch_messages_get (messages);
notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) {
notmuch_message_t *child = notmuch_messages_get (messages);
/* Empirically, it turns out to be faster to remove all the terms,
* and add back the ones we want. */
/* Empirically, it turns out to be faster to remove all the terms,
* and add back the ones we want. */
STRNCMP_LITERAL (tag, "signed") != 0 &&
STRNCMP_LITERAL (tag, "attachment") != 0) {
std::string term = tag_prefix + tag;
STRNCMP_LITERAL (tag, "signed") != 0 &&
STRNCMP_LITERAL (tag, "attachment") != 0) {
std::string term = tag_prefix + tag;
for (list = notmuch_message_get_properties (message, "", false);
notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
std::string term = property_prefix +
for (list = notmuch_message_get_properties (message, "", false);
notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {
std::string term = property_prefix +
status = _notmuch_database_filename_to_direntry (
local, message->notmuch, filename, NOTMUCH_FIND_LOOKUP, &direntry);
status = _notmuch_database_filename_to_direntry (
local, message->notmuch, filename, NOTMUCH_FIND_LOOKUP, &direntry);
message->filename_list = _notmuch_string_list_create (message);
node = message->filename_term_list->head;
message->filename_list = _notmuch_string_list_create (message);
node = message->filename_term_list->head;
/* A message document created by an old version of notmuch
* (prior to rename support) will have the filename in the
* data of the document rather than as a file-direntry term.
/* A message document created by an old version of notmuch
* (prior to rename support) will have the filename in the
* data of the document rather than as a file-direntry term.
- _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred when reading date: %s\n",
- error.get_msg().c_str());
+ _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred when reading date: %s\n",
+ error.get_msg ().c_str ());
* possible to modify the message tags (which talloc_unlink's the
* current list from the message) while still iterating because
* the iterator will keep the current list alive. */
* possible to modify the message tags (which talloc_unlink's the
* current list from the message) while still iterating because
* the iterator will keep the current list alive. */
- talloc_free(message->author);
- message->author = talloc_strdup(message, author);
+ talloc_free (message->author);
+ message->author = talloc_strdup (message, author);
_notmuch_message_sync (ghost);
} else if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) {
/* this is deeply weird, and we should not have gotten
_notmuch_message_sync (ghost);
} else if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) {
/* this is deeply weird, and we should not have gotten
message = notmuch_messages_get (messages);
status = _notmuch_message_delete (message);
if (status) /* we'll report the last failure we see;
message = notmuch_messages_get (messages);
status = _notmuch_message_delete (message);
if (status) /* we'll report the last failure we see;
- * if there is more than one failure, we
- * forget about previous ones */
+ * if there is more than one failure, we
+ * forget about previous ones */
status = notmuch_message_add_tag (message, flag2tag[i].tag);
} else {
status = notmuch_message_remove_tag (message, flag2tag[i].tag);
status = notmuch_message_add_tag (message, flag2tag[i].tag);
} else {
status = notmuch_message_remove_tag (message, flag2tag[i].tag);
/* First, find flags for all set tags. */
for (tags = notmuch_message_get_tags (message);
notmuch_tags_valid (tags);
/* First, find flags for all set tags. */
for (tags = notmuch_message_get_tags (message);
notmuch_tags_valid (tags);
* non-ASCII ordering of flags), this function will return NULL
* (meaning that renaming would not be safe and should not occur).
*/
* non-ASCII ordering of flags), this function will return NULL
* (meaning that renaming would not be safe and should not occur).
*/
_new_maildir_filename (void *ctx,
const char *filename,
const char *flags_to_set,
_new_maildir_filename (void *ctx,
const char *filename,
const char *flags_to_set,
} else {
/* Loop through existing flags in filename. */
for (flags = info + 3, last_flag = 0;
*flags;
} else {
/* Loop through existing flags in filename. */
for (flags = info + 3, last_flag = 0;
*flags;
/* Messages in new/ without maildir info can be kept in new/ if no
* flags have changed. */
dir = (char *) _filename_is_in_maildir (filename);
/* Messages in new/ without maildir info can be kept in new/ if no
* flags have changed. */
dir = (char *) _filename_is_in_maildir (filename);
return talloc_strdup (ctx, filename);
filename_new = (char *) talloc_size (ctx,
return talloc_strdup (ctx, filename);
filename_new = (char *) talloc_size (ctx,
strcat (filename_new, ":2,");
s = filename_new + strlen (filename_new);
strcat (filename_new, ":2,");
s = filename_new + strlen (filename_new);
tag = notmuch_tags_get (tags);
private_status = _notmuch_message_remove_term (message, "tag", tag);
tag = notmuch_tags_get (tags);
private_status = _notmuch_message_remove_term (message, "tag", tag);
/* Save in case we need to delete message */
orig_thread_id = notmuch_message_get_thread_id (message);
/* Save in case we need to delete message */
orig_thread_id = notmuch_message_get_thread_id (message);