X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=9cf8062cbe7caa2c5f7ecd714ca934c7f96b1e76;hp=8f0e22a834eeb3e851577c2a97b3de4ddebf7202;hb=e49398dcada520c03ccd95d6b26900f5aa2d857e;hpb=65b17dab461ef847b418aff69bc53e697ec2d20b diff --git a/lib/database.cc b/lib/database.cc index 8f0e22a8..9cf8062c 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -21,6 +21,7 @@ #include "database-private.h" #include "parse-time-vrp.h" #include "query-fp.h" +#include "thread-fp.h" #include "regexp-fields.h" #include "string-util.h" @@ -258,7 +259,8 @@ prefix_t prefix_table[] = { { "directory", "XDIRECTORY", NOTMUCH_FIELD_NO_FLAGS }, { "file-direntry", "XFDIRENTRY", NOTMUCH_FIELD_NO_FLAGS }, { "directory-direntry", "XDDIRENTRY", NOTMUCH_FIELD_NO_FLAGS }, - { "thread", "G", NOTMUCH_FIELD_EXTERNAL }, + { "thread", "G", NOTMUCH_FIELD_EXTERNAL | + NOTMUCH_FIELD_PROCESSOR }, { "tag", "K", NOTMUCH_FIELD_EXTERNAL | NOTMUCH_FIELD_PROCESSOR }, { "is", "K", NOTMUCH_FIELD_EXTERNAL | @@ -317,6 +319,8 @@ _setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch) fp = (new DateFieldProcessor())->release (); else if (STRNCMP_LITERAL(prefix->name, "query") == 0) fp = (new QueryFieldProcessor (*notmuch->query_parser, notmuch))->release (); + else if (STRNCMP_LITERAL(prefix->name, "thread") == 0) + fp = (new ThreadFieldProcessor (*notmuch->query_parser, notmuch))->release (); else fp = (new RegexpFieldProcessor (prefix->name, prefix->flags, *notmuch->query_parser, notmuch))->release (); @@ -413,6 +417,12 @@ notmuch_status_to_string (notmuch_status_t status) return "Operation requires a database upgrade"; case NOTMUCH_STATUS_PATH_ERROR: return "Path supplied is illegal for this function"; + case NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL: + return "Crypto protocol missing, malformed, or unintelligible"; + case NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION: + return "Crypto engine initialization failure"; + case NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL: + return "Unknown crypto protocol"; default: case NOTMUCH_STATUS_LAST_STATUS: return "Unknown error status value"; @@ -562,7 +572,7 @@ notmuch_database_find_message (notmuch_database_t *notmuch, } catch (const Xapian::Error &error) { _notmuch_database_log (notmuch, "A Xapian exception occurred finding message: %s.\n", error.get_msg().c_str()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; *message_ret = NULL; return NOTMUCH_STATUS_XAPIAN_EXCEPTION; } @@ -691,7 +701,7 @@ _notmuch_database_new_revision (notmuch_database_t *notmuch) * committed revision number until we commit the atomic section. */ if (notmuch->atomic_nesting) - notmuch->atomic_dirty = TRUE; + notmuch->atomic_dirty = true; else notmuch->revision = new_revision; @@ -854,12 +864,11 @@ notmuch_database_open_verbose (const char *path, } notmuch = talloc_zero (NULL, notmuch_database_t); - notmuch->exception_reported = FALSE; + notmuch->exception_reported = false; notmuch->status_string = NULL; notmuch->path = talloc_strdup (notmuch, path); - if (notmuch->path[strlen (notmuch->path) - 1] == '/') - notmuch->path[strlen (notmuch->path) - 1] = '\0'; + strip_trailing(notmuch->path, '/'); notmuch->mode = mode; notmuch->atomic_nesting = 0; @@ -1041,7 +1050,7 @@ _notmuch_database_reopen (notmuch_database_t *notmuch) if (! notmuch->exception_reported) { _notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n", error.get_msg ().c_str ()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; } return NOTMUCH_STATUS_XAPIAN_EXCEPTION; } @@ -1119,7 +1128,7 @@ notmuch_database_compact (const char *path, notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; notmuch_database_t *notmuch = NULL; struct stat statbuf; - notmuch_bool_t keep_backup; + bool keep_backup; char *message = NULL; local = talloc_new (NULL); @@ -1155,10 +1164,10 @@ notmuch_database_compact (const char *path, ret = NOTMUCH_STATUS_OUT_OF_MEMORY; goto DONE; } - keep_backup = FALSE; + keep_backup = false; } else { - keep_backup = TRUE; + keep_backup = true; } if (stat (backup_path, &statbuf) != -1) { @@ -1314,7 +1323,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, Xapian::WritableDatabase *db; struct sigaction action; struct itimerval timerval; - notmuch_bool_t timer_is_active = FALSE; + bool timer_is_active = false; enum _notmuch_features target_features, new_features; notmuch_status_t status; notmuch_private_status_t private_status; @@ -1348,7 +1357,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch, timerval.it_value.tv_usec = 0; setitimer (ITIMER_REAL, &timerval, NULL); - timer_is_active = TRUE; + timer_is_active = true; } /* Figure out how much total work we need to do. */ @@ -1589,7 +1598,7 @@ notmuch_database_begin_atomic (notmuch_database_t *notmuch) } catch (const Xapian::Error &error) { _notmuch_database_log (notmuch, "A Xapian exception occurred beginning transaction: %s.\n", error.get_msg().c_str()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; return NOTMUCH_STATUS_XAPIAN_EXCEPTION; } @@ -1623,13 +1632,13 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch) } catch (const Xapian::Error &error) { _notmuch_database_log (notmuch, "A Xapian exception occurred committing transaction: %s.\n", error.get_msg().c_str()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; return NOTMUCH_STATUS_XAPIAN_EXCEPTION; } if (notmuch->atomic_dirty) { ++notmuch->revision; - notmuch->atomic_dirty = FALSE; + notmuch->atomic_dirty = false; } DONE: @@ -1872,7 +1881,7 @@ notmuch_database_get_directory (notmuch_database_t *notmuch, } catch (const Xapian::Error &error) { _notmuch_database_log (notmuch, "A Xapian exception occurred getting directory: %s.\n", error.get_msg().c_str()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } return status; @@ -1969,7 +1978,7 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch, } catch (const Xapian::Error &error) { _notmuch_database_log (notmuch, "Error: A Xapian exception occurred finding message by filename: %s\n", error.get_msg().c_str()); - notmuch->exception_reported = TRUE; + notmuch->exception_reported = true; status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } @@ -2022,7 +2031,7 @@ notmuch_database_get_all_tags (notmuch_database_t *db) } catch (const Xapian::Error &error) { _notmuch_database_log (db, "A Xapian exception occurred getting tags: %s.\n", error.get_msg().c_str()); - db->exception_reported = TRUE; + db->exception_reported = true; return NULL; } }