1 module derelict.notmuch.statfun; 2 3 version (Derelict_Static) version = DerelictNotMuch_Static; 4 version (DerelictNotMuch_Static) : // 5 6 extern (C) @nogc nothrow: 7 8 import core.stdc.time; 9 import derelict.notmuch.types; 10 11 /** 12 * Get a string representation of a notmuch_status_t value. 13 * 14 * The result is read-only. 15 */ 16 const(char)* notmuch_status_to_string(notmuch_status_t status); 17 18 /** 19 * Create a new, empty notmuch database located at 'path'. 20 * 21 * The path should be a top-level directory to a collection of 22 * plain-text email messages (one message per file). This call will 23 * create a new ".notmuch" directory within 'path' where notmuch will 24 * store its data. 25 * 26 * After a successful call to notmuch_database_create, the returned 27 * database will be open so the caller should call 28 * notmuch_database_destroy when finished with it. 29 * 30 * The database will not yet have any data in it 31 * (notmuch_database_create itself is a very cheap function). Messages 32 * contained within 'path' can be added to the database by calling 33 * notmuch_database_add_message. 34 * 35 * In case of any failure, this function returns an error status and 36 * sets *database to NULL (after printing an error message on stderr). 37 * 38 * Return value: 39 * 40 * NOTMUCH_STATUS_SUCCESS: Successfully created the database. 41 * 42 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL. 43 * 44 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory. 45 * 46 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to create the 47 * database file (such as permission denied, or file not found, 48 * etc.), or the database already exists. 49 * 50 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred. 51 */ 52 notmuch_status_t notmuch_database_create(const(char)* path, notmuch_database_t** database); 53 54 /** 55 * Like notmuch_database_create, except optionally return an error 56 * message. This message is allocated by malloc and should be freed by 57 * the caller. 58 */ 59 notmuch_status_t notmuch_database_create_verbose(const(char)* path, notmuch_database_t** database, char** error_message); 60 /** 61 * Open an existing notmuch database located at 'path'. 62 * 63 * The database should have been created at some time in the past, 64 * (not necessarily by this process), by calling 65 * notmuch_database_create with 'path'. By default the database should be 66 * opened for reading only. In order to write to the database you need to 67 * pass the NOTMUCH_DATABASE_MODE_READ_WRITE mode. 68 * 69 * An existing notmuch database can be identified by the presence of a 70 * directory named ".notmuch" below 'path'. 71 * 72 * The caller should call notmuch_database_destroy when finished with 73 * this database. 74 * 75 * In case of any failure, this function returns an error status and 76 * sets *database to NULL (after printing an error message on stderr). 77 * 78 * Return value: 79 * 80 * NOTMUCH_STATUS_SUCCESS: Successfully opened the database. 81 * 82 * NOTMUCH_STATUS_NULL_POINTER: The given 'path' argument is NULL. 83 * 84 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory. 85 * 86 * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to open the 87 * database file (such as permission denied, or file not found, 88 * etc.), or the database version is unknown. 89 * 90 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred. 91 */ 92 notmuch_status_t notmuch_database_open(const(char)* path, notmuch_database_mode_t mode, notmuch_database_t** database); 93 94 /** 95 * Like notmuch_database_open, except optionally return an error 96 * message. This message is allocated by malloc and should be freed by 97 * the caller. 98 */ 99 100 notmuch_status_t notmuch_database_open_verbose(const(char)* path, notmuch_database_mode_t mode, 101 notmuch_database_t** database, char** error_message); 102 103 /** 104 * Retrieve last status string for given database. 105 * 106 */ 107 const(char)* notmuch_database_status_string(const notmuch_database_t* notmuch); 108 109 /** 110 * Commit changes and close the given notmuch database. 111 * 112 * After notmuch_database_close has been called, calls to other 113 * functions on objects derived from this database may either behave 114 * as if the database had not been closed (e.g., if the required data 115 * has been cached) or may fail with a 116 * NOTMUCH_STATUS_XAPIAN_EXCEPTION. The only further operation 117 * permitted on the database itself is to call 118 * notmuch_database_destroy. 119 * 120 * notmuch_database_close can be called multiple times. Later calls 121 * have no effect. 122 * 123 * For writable databases, notmuch_database_close commits all changes 124 * to disk before closing the database. If the caller is currently in 125 * an atomic section (there was a notmuch_database_begin_atomic 126 * without a matching notmuch_database_end_atomic), this will discard 127 * changes made in that atomic section (but still commit changes made 128 * prior to entering the atomic section). 129 * 130 * Return value: 131 * 132 * NOTMUCH_STATUS_SUCCESS: Successfully closed the database. 133 * 134 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; the 135 * database has been closed but there are no guarantees the 136 * changes to the database, if any, have been flushed to disk. 137 */ 138 notmuch_status_t notmuch_database_close(notmuch_database_t* database); 139 140 /** 141 * Compact a notmuch database, backing up the original database to the 142 * given path. 143 * 144 * The database will be opened with NOTMUCH_DATABASE_MODE_READ_WRITE 145 * during the compaction process to ensure no writes are made. 146 * 147 * If the optional callback function 'status_cb' is non-NULL, it will 148 * be called with diagnostic and informational messages. The argument 149 * 'closure' is passed verbatim to any callback invoked. 150 */ 151 notmuch_status_t notmuch_database_compact(const(char)* path, const(char)* backup_path, 152 notmuch_compact_status_cb_t status_cb, void* closure); 153 154 /** 155 * Destroy the notmuch database, closing it if necessary and freeing 156 * all associated resources. 157 * 158 * Return value as in notmuch_database_close if the database was open; 159 * notmuch_database_destroy itself has no failure modes. 160 */ 161 notmuch_status_t notmuch_database_destroy(notmuch_database_t* database); 162 163 /** 164 * Return the database path of the given database. 165 * 166 * The return value is a string owned by notmuch so should not be 167 * modified nor freed by the caller. 168 */ 169 const(char)* notmuch_database_get_path(notmuch_database_t* database); 170 171 /** 172 * Return the database format version of the given database. 173 */ 174 uint notmuch_database_get_version(notmuch_database_t* database); 175 176 /** 177 * Can the database be upgraded to a newer database version? 178 * 179 * If this function returns TRUE, then the caller may call 180 * notmuch_database_upgrade to upgrade the database. If the caller 181 * does not upgrade an out-of-date database, then some functions may 182 * fail with NOTMUCH_STATUS_UPGRADE_REQUIRED. This always returns 183 * FALSE for a read-only database because there's no way to upgrade a 184 * read-only database. 185 */ 186 notmuch_bool_t notmuch_database_needs_upgrade(notmuch_database_t* database); 187 188 /** 189 * Upgrade the current database to the latest supported version. 190 * 191 * This ensures that all current notmuch functionality will be 192 * available on the database. After opening a database in read-write 193 * mode, it is recommended that clients check if an upgrade is needed 194 * (notmuch_database_needs_upgrade) and if so, upgrade with this 195 * function before making any modifications. If 196 * notmuch_database_needs_upgrade returns FALSE, this will be a no-op. 197 * 198 * The optional progress_notify callback can be used by the caller to 199 * provide progress indication to the user. If non-NULL it will be 200 * called periodically with 'progress' as a floating-point value in 201 * the range of [0.0 .. 1.0] indicating the progress made so far in 202 * the upgrade process. The argument 'closure' is passed verbatim to 203 * any callback invoked. 204 */ 205 notmuch_status_t notmuch_database_upgrade(notmuch_database_t* database, void function(void* closure, 206 double progress) progress_notify, void* closure); 207 208 /** 209 * Begin an atomic database operation. 210 * 211 * Any modifications performed between a successful begin and a 212 * notmuch_database_end_atomic will be applied to the database 213 * atomically. Note that, unlike a typical database transaction, this 214 * only ensures atomicity, not durability; neither begin nor end 215 * necessarily flush modifications to disk. 216 * 217 * Atomic sections may be nested. begin_atomic and end_atomic must 218 * always be called in pairs. 219 * 220 * Return value: 221 * 222 * NOTMUCH_STATUS_SUCCESS: Successfully entered atomic section. 223 * 224 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; 225 * atomic section not entered. 226 */ 227 notmuch_status_t notmuch_database_begin_atomic(notmuch_database_t* notmuch); 228 229 /** 230 * Indicate the end of an atomic database operation. 231 * 232 * Return value: 233 * 234 * NOTMUCH_STATUS_SUCCESS: Successfully completed atomic section. 235 * 236 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; 237 * atomic section not ended. 238 * 239 * NOTMUCH_STATUS_UNBALANCED_ATOMIC: The database is not currently in 240 * an atomic section. 241 */ 242 notmuch_status_t notmuch_database_end_atomic(notmuch_database_t* notmuch); 243 244 /** 245 * Return the committed database revision and UUID. 246 * 247 * The database revision number increases monotonically with each 248 * commit to the database. Hence, all messages and message changes 249 * committed to the database (that is, visible to readers) have a last 250 * modification revision <= the committed database revision. Any 251 * messages committed in the future will be assigned a modification 252 * revision > the committed database revision. 253 * 254 * The UUID is a NUL-terminated opaque string that uniquely identifies 255 * this database. Two revision numbers are only comparable if they 256 * have the same database UUID. 257 */ 258 ulong notmuch_database_get_revision(notmuch_database_t* notmuch, const(char)** uuid); 259 260 /** 261 * Retrieve a directory object from the database for 'path'. 262 * 263 * Here, 'path' should be a path relative to the path of 'database' 264 * (see notmuch_database_get_path), or else should be an absolute path 265 * with initial components that match the path of 'database'. 266 * 267 * If this directory object does not exist in the database, this 268 * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL. 269 * 270 * Otherwise the returned directory object is owned by the database 271 * and as such, will only be valid until notmuch_database_destroy is 272 * called. 273 * 274 * Return value: 275 * 276 * NOTMUCH_STATUS_SUCCESS: Successfully retrieved directory. 277 * 278 * NOTMUCH_STATUS_NULL_POINTER: The given 'directory' argument is NULL. 279 * 280 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred; 281 * directory not retrieved. 282 * 283 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the 284 * database to use this function. 285 */ 286 notmuch_status_t notmuch_database_get_directory(notmuch_database_t* database, const(char)* path, notmuch_directory_t** directory); 287 288 /** 289 * Add a new message to the given notmuch database or associate an 290 * additional filename with an existing message. 291 * 292 * Here, 'filename' should be a path relative to the path of 293 * 'database' (see notmuch_database_get_path), or else should be an 294 * absolute filename with initial components that match the path of 295 * 'database'. 296 * 297 * The file should be a single mail message (not a multi-message mbox) 298 * that is expected to remain at its current location, (since the 299 * notmuch database will reference the filename, and will not copy the 300 * entire contents of the file. 301 * 302 * If another message with the same message ID already exists in the 303 * database, rather than creating a new message, this adds 'filename' 304 * to the list of the filenames for the existing message. 305 * 306 * If 'message' is not NULL, then, on successful return 307 * (NOTMUCH_STATUS_SUCCESS or NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) '*message' 308 * will be initialized to a message object that can be used for things 309 * such as adding tags to the just-added message. The user should call 310 * notmuch_message_destroy when done with the message. On any failure 311 * '*message' will be set to NULL. 312 * 313 * Return value: 314 * 315 * NOTMUCH_STATUS_SUCCESS: Message successfully added to database. 316 * 317 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred, 318 * message not added. 319 * 320 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: Message has the same message 321 * ID as another message already in the database. The new 322 * filename was successfully added to the message in the database 323 * (if not already present) and the existing message is returned. 324 * 325 * NOTMUCH_STATUS_FILE_ERROR: an error occurred trying to open the 326 * file, (such as permission denied, or file not found, 327 * etc.). Nothing added to the database. 328 * 329 * NOTMUCH_STATUS_FILE_NOT_EMAIL: the contents of filename don't look 330 * like an email message. Nothing added to the database. 331 * 332 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 333 * mode so no message can be added. 334 * 335 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the 336 * database to use this function. 337 */ 338 notmuch_status_t notmuch_database_add_message(notmuch_database_t* database, const(char)* filename, notmuch_message_t** message); 339 340 /** 341 * Remove a message filename from the given notmuch database. If the 342 * message has no more filenames, remove the message. 343 * 344 * If the same message (as determined by the message ID) is still 345 * available via other filenames, then the message will persist in the 346 * database for those filenames. When the last filename is removed for 347 * a particular message, the database content for that message will be 348 * entirely removed. 349 * 350 * Return value: 351 * 352 * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the 353 * message was removed from the database. 354 * 355 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred, 356 * message not removed. 357 * 358 * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but 359 * the message persists in the database with at least one other 360 * filename. 361 * 362 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 363 * mode so no message can be removed. 364 * 365 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the 366 * database to use this function. 367 */ 368 notmuch_status_t notmuch_database_remove_message(notmuch_database_t* database, const(char)* filename); 369 370 /** 371 * Find a message with the given message_id. 372 * 373 * If a message with the given message_id is found then, on successful return 374 * (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to a message 375 * object. The caller should call notmuch_message_destroy when done with the 376 * message. 377 * 378 * On any failure or when the message is not found, this function initializes 379 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the 380 * caller is supposed to check '*message' for NULL to find out whether the 381 * message with the given message_id was found. 382 * 383 * Return value: 384 * 385 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message'. 386 * 387 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL 388 * 389 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating message object 390 * 391 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred 392 */ 393 notmuch_status_t notmuch_database_find_message(notmuch_database_t* database, const(char)* message_id, notmuch_message_t** message); 394 395 /** 396 * Find a message with the given filename. 397 * 398 * If the database contains a message with the given filename then, on 399 * successful return (NOTMUCH_STATUS_SUCCESS) '*message' will be initialized to 400 * a message object. The caller should call notmuch_message_destroy when done 401 * with the message. 402 * 403 * On any failure or when the message is not found, this function initializes 404 * '*message' to NULL. This means, when NOTMUCH_STATUS_SUCCESS is returned, the 405 * caller is supposed to check '*message' for NULL to find out whether the 406 * message with the given filename is found. 407 * 408 * Return value: 409 * 410 * NOTMUCH_STATUS_SUCCESS: Successful return, check '*message' 411 * 412 * NOTMUCH_STATUS_NULL_POINTER: The given 'message' argument is NULL 413 * 414 * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory, creating the message object 415 * 416 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred 417 * 418 * NOTMUCH_STATUS_UPGRADE_REQUIRED: The caller must upgrade the 419 * database to use this function. 420 */ 421 notmuch_status_t notmuch_database_find_message_by_filename(notmuch_database_t* notmuch, const(char)* filename, 422 notmuch_message_t** message); 423 424 /** 425 * Return a list of all tags found in the database. 426 * 427 * This function creates a list of all tags found in the database. The 428 * resulting list contains all tags from all messages found in the database. 429 * 430 * On error this function returns NULL. 431 */ 432 notmuch_tags_t* notmuch_database_get_all_tags(notmuch_database_t* db); 433 434 /** 435 * Create a new query for 'database'. 436 * 437 * Here, 'database' should be an open database, (see 438 * notmuch_database_open and notmuch_database_create). 439 * 440 * For the query string, we'll document the syntax here more 441 * completely in the future, but it's likely to be a specialized 442 * version of the general Xapian query syntax: 443 * 444 * https://xapian.org/docs/queryparser.html 445 * 446 * As a special case, passing either a length-zero string, (that is ""), 447 * or a string consisting of a single asterisk (that is "*"), will 448 * result in a query that returns all messages in the database. 449 * 450 * See notmuch_query_set_sort for controlling the order of results. 451 * See notmuch_query_search_messages and notmuch_query_search_threads 452 * to actually execute the query. 453 * 454 * User should call notmuch_query_destroy when finished with this 455 * query. 456 * 457 * Will return NULL if insufficient memory is available. 458 */ 459 notmuch_query_t* notmuch_query_create(notmuch_database_t* database, const(char)* query_string); 460 461 /** 462 * Return the query_string of this query. See notmuch_query_create. 463 */ 464 const(char)* notmuch_query_get_query_string(const notmuch_query_t* query); 465 466 /** 467 * Return the notmuch database of this query. See notmuch_query_create. 468 */ 469 notmuch_database_t* notmuch_query_get_database(const notmuch_query_t* query); 470 471 /** 472 * Specify whether to omit excluded results or simply flag them. By 473 * default, this is set to TRUE. 474 * 475 * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded 476 * messages from the results, and notmuch_query_search_threads will omit 477 * threads that match only in excluded messages. If set to TRUE, 478 * notmuch_query_search_threads will include all messages in threads that 479 * match in at least one non-excluded message. Otherwise, if set to ALL, 480 * notmuch_query_search_threads will omit excluded messages from all threads. 481 * 482 * If set to FALSE or FLAG then both notmuch_query_search_messages and 483 * notmuch_query_search_threads will return all matching 484 * messages/threads regardless of exclude status. If set to FLAG then 485 * the exclude flag will be set for any excluded message that is 486 * returned by notmuch_query_search_messages, and the thread counts 487 * for threads returned by notmuch_query_search_threads will be the 488 * number of non-excluded messages/matches. Otherwise, if set to 489 * FALSE, then the exclude status is completely ignored. 490 * 491 * The performance difference when calling 492 * notmuch_query_search_messages should be relatively small (and both 493 * should be very fast). However, in some cases, 494 * notmuch_query_search_threads is very much faster when omitting 495 * excluded messages as it does not need to construct the threads that 496 * only match in excluded messages. 497 */ 498 void notmuch_query_set_omit_excluded(notmuch_query_t* query, notmuch_exclude_t omit_excluded); 499 500 /** 501 * Specify the sorting desired for this query. 502 */ 503 void notmuch_query_set_sort(notmuch_query_t* query, notmuch_sort_t sort); 504 505 /** 506 * Return the sort specified for this query. See 507 * notmuch_query_set_sort. 508 */ 509 notmuch_sort_t notmuch_query_get_sort(const notmuch_query_t* query); 510 511 /** 512 * Add a tag that will be excluded from the query results by default. 513 * This exclusion will be overridden if this tag appears explicitly in 514 * the query. 515 */ 516 void notmuch_query_add_tag_exclude(notmuch_query_t* query, const(char)* tag); 517 518 /** 519 * Execute a query for threads, returning a notmuch_threads_t object 520 * which can be used to iterate over the results. The returned threads 521 * object is owned by the query and as such, will only be valid until 522 * notmuch_query_destroy. 523 * 524 * Typical usage might be: 525 * 526 * notmuch_query_t *query; 527 * notmuch_threads_t *threads; 528 * notmuch_thread_t *thread; 529 * 530 * query = notmuch_query_create (database, query_string); 531 * 532 * for (threads = notmuch_query_search_threads (query); 533 * notmuch_threads_valid (threads); 534 * notmuch_threads_move_to_next (threads)) 535 * { 536 * thread = notmuch_threads_get (threads); 537 * .... 538 * notmuch_thread_destroy (thread); 539 * } 540 * 541 * notmuch_query_destroy (query); 542 * 543 * Note: If you are finished with a thread before its containing 544 * query, you can call notmuch_thread_destroy to clean up some memory 545 * sooner (as in the above example). Otherwise, if your thread objects 546 * are long-lived, then you don't need to call notmuch_thread_destroy 547 * and all the memory will still be reclaimed when the query is 548 * destroyed. 549 * 550 * Note that there's no explicit destructor needed for the 551 * notmuch_threads_t object. (For consistency, we do provide a 552 * notmuch_threads_destroy function, but there's no good reason 553 * to call it if the query is about to be destroyed). 554 * 555 * @since libnotmuch 4.2 (notmuch 0.20) 556 */ 557 notmuch_status_t notmuch_query_search_threads_st(notmuch_query_t* query, notmuch_threads_t** out_); 558 559 /** 560 * Like notmuch_query_search_threads_st, but without a status return. 561 * 562 * If a Xapian exception occurs this function will return NULL. 563 * 564 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please 565 * use notmuch_query_search_threads_st instead. 566 * 567 */ 568 deprecated("function deprecated as of libnotmuch 4.3") notmuch_threads_t* notmuch_query_search_threads(notmuch_query_t* query); 569 570 /** 571 * Execute a query for messages, returning a notmuch_messages_t object 572 * which can be used to iterate over the results. The returned 573 * messages object is owned by the query and as such, will only be 574 * valid until notmuch_query_destroy. 575 * 576 * Typical usage might be: 577 * 578 * notmuch_query_t *query; 579 * notmuch_messages_t *messages; 580 * notmuch_message_t *message; 581 * 582 * query = notmuch_query_create (database, query_string); 583 * 584 * for (messages = notmuch_query_search_messages (query); 585 * notmuch_messages_valid (messages); 586 * notmuch_messages_move_to_next (messages)) 587 * { 588 * message = notmuch_messages_get (messages); 589 * .... 590 * notmuch_message_destroy (message); 591 * } 592 * 593 * notmuch_query_destroy (query); 594 * 595 * Note: If you are finished with a message before its containing 596 * query, you can call notmuch_message_destroy to clean up some memory 597 * sooner (as in the above example). Otherwise, if your message 598 * objects are long-lived, then you don't need to call 599 * notmuch_message_destroy and all the memory will still be reclaimed 600 * when the query is destroyed. 601 * 602 * Note that there's no explicit destructor needed for the 603 * notmuch_messages_t object. (For consistency, we do provide a 604 * notmuch_messages_destroy function, but there's no good 605 * reason to call it if the query is about to be destroyed). 606 * 607 * If a Xapian exception occurs this function will return NULL. 608 * 609 * @since libnotmuch 4.2 (notmuch 0.20) 610 */ 611 notmuch_status_t notmuch_query_search_messages_st(notmuch_query_t* query, notmuch_messages_t** out_); 612 /** 613 * Like notmuch_query_search_messages, but without a status return. 614 * 615 * If a Xapian exception occurs this function will return NULL. 616 * 617 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please use 618 * notmuch_query_search_messages_st instead. 619 * 620 */ 621 deprecated("function deprecated as of libnotmuch 4.3") notmuch_messages_t* notmuch_query_search_messages(notmuch_query_t* query); 622 623 /** 624 * Destroy a notmuch_query_t along with any associated resources. 625 * 626 * This will in turn destroy any notmuch_threads_t and 627 * notmuch_messages_t objects generated by this query, (and in 628 * turn any notmuch_thread_t and notmuch_message_t objects generated 629 * from those results, etc.), if such objects haven't already been 630 * destroyed. 631 */ 632 void notmuch_query_destroy(notmuch_query_t* query); 633 634 /** 635 * Is the given 'threads' iterator pointing at a valid thread. 636 * 637 * When this function returns TRUE, notmuch_threads_get will return a 638 * valid object. Whereas when this function returns FALSE, 639 * notmuch_threads_get will return NULL. 640 * 641 * If passed a NULL pointer, this function returns FALSE 642 * 643 * See the documentation of notmuch_query_search_threads for example 644 * code showing how to iterate over a notmuch_threads_t object. 645 */ 646 notmuch_bool_t notmuch_threads_valid(notmuch_threads_t* threads); 647 648 /** 649 * Get the current thread from 'threads' as a notmuch_thread_t. 650 * 651 * Note: The returned thread belongs to 'threads' and has a lifetime 652 * identical to it (and the query to which it belongs). 653 * 654 * See the documentation of notmuch_query_search_threads for example 655 * code showing how to iterate over a notmuch_threads_t object. 656 * 657 * If an out-of-memory situation occurs, this function will return 658 * NULL. 659 */ 660 notmuch_thread_t* notmuch_threads_get(notmuch_threads_t* threads); 661 662 /** 663 * Move the 'threads' iterator to the next thread. 664 * 665 * If 'threads' is already pointing at the last thread then the 666 * iterator will be moved to a point just beyond that last thread, 667 * (where notmuch_threads_valid will return FALSE and 668 * notmuch_threads_get will return NULL). 669 * 670 * See the documentation of notmuch_query_search_threads for example 671 * code showing how to iterate over a notmuch_threads_t object. 672 */ 673 void notmuch_threads_move_to_next(notmuch_threads_t* threads); 674 675 /** 676 * Destroy a notmuch_threads_t object. 677 * 678 * It's not strictly necessary to call this function. All memory from 679 * the notmuch_threads_t object will be reclaimed when the 680 * containing query object is destroyed. 681 */ 682 void notmuch_threads_destroy(notmuch_threads_t* threads); 683 684 /** 685 * Return the number of messages matching a search. 686 * 687 * This function performs a search and returns the number of matching 688 * messages. 689 * 690 * @returns 691 * 692 * NOTMUCH_STATUS_SUCCESS: query completed successfully. 693 * 694 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The 695 * value of *count is not defined. 696 * 697 * @since libnotmuch 4.3 (notmuch 0.21) 698 */ 699 notmuch_status_t notmuch_query_count_messages_st(notmuch_query_t* query, uint* count); 700 701 /** 702 * like notmuch_query_count_messages_st, but without a status return. 703 * 704 * May return 0 in the case of errors. 705 * 706 * @deprecated Deprecated since libnotmuch 4.3 (notmuch 0.21). Please 707 * use notmuch_query_count_messages_st instead. 708 */ 709 deprecated("function deprecated as of libnotmuch 4.3") uint notmuch_query_count_messages(notmuch_query_t* query); 710 711 /** 712 * Return the number of threads matching a search. 713 * 714 * This function performs a search and returns the number of unique thread IDs 715 * in the matching messages. This is the same as number of threads matching a 716 * search. 717 * 718 * Note that this is a significantly heavier operation than 719 * notmuch_query_count_messages{_st}(). 720 * 721 * @returns 722 * 723 * NOTMUCH_STATUS_OUT_OF_MEMORY: Memory allocation failed. The value 724 * of *count is not defined 725 726 * NOTMUCH_STATUS_SUCCESS: query completed successfully. 727 * 728 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. The 729 * value of *count is not defined. 730 * 731 * @since libnotmuch 4.3 (notmuch 0.21) 732 */ 733 notmuch_status_t notmuch_query_count_threads_st(notmuch_query_t* query, uint* count); 734 735 /** 736 * like notmuch_query_count_threads, but without a status return. 737 * 738 * May return 0 in case of errors. 739 * 740 * @deprecated Deprecated as of libnotmuch 4.3 (notmuch 0.21). Please 741 * use notmuch_query_count_threads_st instead. 742 */ 743 deprecated("function deprecated as of libnotmuch 4.3") uint notmuch_query_count_threads(notmuch_query_t* query); 744 745 /** 746 * Get the thread ID of 'thread'. 747 * 748 * The returned string belongs to 'thread' and as such, should not be 749 * modified by the caller and will only be valid for as long as the 750 * thread is valid, (which is until notmuch_thread_destroy or until 751 * the query from which it derived is destroyed). 752 */ 753 const(char)* notmuch_thread_get_thread_id(notmuch_thread_t* thread); 754 755 /** 756 * Get the total number of messages in 'thread'. 757 * 758 * This count consists of all messages in the database belonging to 759 * this thread. Contrast with notmuch_thread_get_matched_messages() . 760 */ 761 int notmuch_thread_get_total_messages(notmuch_thread_t* thread); 762 763 /** 764 * Get a notmuch_messages_t iterator for the top-level messages in 765 * 'thread' in oldest-first order. 766 * 767 * This iterator will not necessarily iterate over all of the messages 768 * in the thread. It will only iterate over the messages in the thread 769 * which are not replies to other messages in the thread. 770 * 771 * The returned list will be destroyed when the thread is destroyed. 772 */ 773 notmuch_messages_t* notmuch_thread_get_toplevel_messages(notmuch_thread_t* thread); 774 775 /** 776 * Get a notmuch_thread_t iterator for all messages in 'thread' in 777 * oldest-first order. 778 * 779 * The returned list will be destroyed when the thread is destroyed. 780 */ 781 notmuch_messages_t* notmuch_thread_get_messages(notmuch_thread_t* thread); 782 783 /** 784 * Get the number of messages in 'thread' that matched the search. 785 * 786 * This count includes only the messages in this thread that were 787 * matched by the search from which the thread was created and were 788 * not excluded by any exclude tags passed in with the query (see 789 * notmuch_query_add_tag_exclude). Contrast with 790 * notmuch_thread_get_total_messages() . 791 */ 792 int notmuch_thread_get_matched_messages(notmuch_thread_t* thread); 793 794 /** 795 * Get the authors of 'thread' as a UTF-8 string. 796 * 797 * The returned string is a comma-separated list of the names of the 798 * authors of mail messages in the query results that belong to this 799 * thread. 800 * 801 * The string contains authors of messages matching the query first, then 802 * non-matched authors (with the two groups separated by '|'). Within 803 * each group, authors are ordered by date. 804 * 805 * The returned string belongs to 'thread' and as such, should not be 806 * modified by the caller and will only be valid for as long as the 807 * thread is valid, (which is until notmuch_thread_destroy or until 808 * the query from which it derived is destroyed). 809 */ 810 const(char)* notmuch_thread_get_authors(notmuch_thread_t* thread); 811 812 /** 813 * Get the subject of 'thread' as a UTF-8 string. 814 * 815 * The subject is taken from the first message (according to the query 816 * order---see notmuch_query_set_sort) in the query results that 817 * belongs to this thread. 818 * 819 * The returned string belongs to 'thread' and as such, should not be 820 * modified by the caller and will only be valid for as long as the 821 * thread is valid, (which is until notmuch_thread_destroy or until 822 * the query from which it derived is destroyed). 823 */ 824 const(char)* notmuch_thread_get_subject(notmuch_thread_t* thread); 825 826 /** 827 * Get the date of the oldest message in 'thread' as a time_t value. 828 */ 829 time_t notmuch_thread_get_oldest_date(notmuch_thread_t* thread); 830 831 /** 832 * Get the date of the newest message in 'thread' as a time_t value. 833 */ 834 time_t notmuch_thread_get_newest_date(notmuch_thread_t* thread); 835 836 /** 837 * Get the tags for 'thread', returning a notmuch_tags_t object which 838 * can be used to iterate over all tags. 839 * 840 * Note: In the Notmuch database, tags are stored on individual 841 * messages, not on threads. So the tags returned here will be all 842 * tags of the messages which matched the search and which belong to 843 * this thread. 844 * 845 * The tags object is owned by the thread and as such, will only be 846 * valid for as long as the thread is valid, (for example, until 847 * notmuch_thread_destroy or until the query from which it derived is 848 * destroyed). 849 * 850 * Typical usage might be: 851 * 852 * notmuch_thread_t *thread; 853 * notmuch_tags_t *tags; 854 * const char *tag; 855 * 856 * thread = notmuch_threads_get (threads); 857 * 858 * for (tags = notmuch_thread_get_tags (thread); 859 * notmuch_tags_valid (tags); 860 * notmuch_tags_move_to_next (tags)) 861 * { 862 * tag = notmuch_tags_get (tags); 863 * .... 864 * } 865 * 866 * notmuch_thread_destroy (thread); 867 * 868 * Note that there's no explicit destructor needed for the 869 * notmuch_tags_t object. (For consistency, we do provide a 870 * notmuch_tags_destroy function, but there's no good reason to call 871 * it if the message is about to be destroyed). 872 */ 873 notmuch_tags_t* notmuch_thread_get_tags(notmuch_thread_t* thread); 874 875 /** 876 * Destroy a notmuch_thread_t object. 877 */ 878 void notmuch_thread_destroy(notmuch_thread_t* thread); 879 880 /** 881 * Is the given 'messages' iterator pointing at a valid message. 882 * 883 * When this function returns TRUE, notmuch_messages_get will return a 884 * valid object. Whereas when this function returns FALSE, 885 * notmuch_messages_get will return NULL. 886 * 887 * See the documentation of notmuch_query_search_messages for example 888 * code showing how to iterate over a notmuch_messages_t object. 889 */ 890 notmuch_bool_t notmuch_messages_valid(notmuch_messages_t* messages); 891 892 /** 893 * Get the current message from 'messages' as a notmuch_message_t. 894 * 895 * Note: The returned message belongs to 'messages' and has a lifetime 896 * identical to it (and the query to which it belongs). 897 * 898 * See the documentation of notmuch_query_search_messages for example 899 * code showing how to iterate over a notmuch_messages_t object. 900 * 901 * If an out-of-memory situation occurs, this function will return 902 * NULL. 903 */ 904 notmuch_message_t* notmuch_messages_get(notmuch_messages_t* messages); 905 906 /** 907 * Move the 'messages' iterator to the next message. 908 * 909 * If 'messages' is already pointing at the last message then the 910 * iterator will be moved to a point just beyond that last message, 911 * (where notmuch_messages_valid will return FALSE and 912 * notmuch_messages_get will return NULL). 913 * 914 * See the documentation of notmuch_query_search_messages for example 915 * code showing how to iterate over a notmuch_messages_t object. 916 */ 917 void notmuch_messages_move_to_next(notmuch_messages_t* messages); 918 919 /** 920 * Destroy a notmuch_messages_t object. 921 * 922 * It's not strictly necessary to call this function. All memory from 923 * the notmuch_messages_t object will be reclaimed when the containing 924 * query object is destroyed. 925 */ 926 void notmuch_messages_destroy(notmuch_messages_t* messages); 927 928 /** 929 * Return a list of tags from all messages. 930 * 931 * The resulting list is guaranteed not to contain duplicated tags. 932 * 933 * WARNING: You can no longer iterate over messages after calling this 934 * function, because the iterator will point at the end of the list. 935 * We do not have a function to reset the iterator yet and the only 936 * way how you can iterate over the list again is to recreate the 937 * message list. 938 * 939 * The function returns NULL on error. 940 */ 941 notmuch_tags_t* notmuch_messages_collect_tags(notmuch_messages_t* messages); 942 943 /** 944 * Get the message ID of 'message'. 945 * 946 * The returned string belongs to 'message' and as such, should not be 947 * modified by the caller and will only be valid for as long as the 948 * message is valid, (which is until the query from which it derived 949 * is destroyed). 950 * 951 * This function will not return NULL since Notmuch ensures that every 952 * message has a unique message ID, (Notmuch will generate an ID for a 953 * message if the original file does not contain one). 954 */ 955 const(char)* notmuch_message_get_message_id(notmuch_message_t* message); 956 957 /** 958 * Get the thread ID of 'message'. 959 * 960 * The returned string belongs to 'message' and as such, should not be 961 * modified by the caller and will only be valid for as long as the 962 * message is valid, (for example, until the user calls 963 * notmuch_message_destroy on 'message' or until a query from which it 964 * derived is destroyed). 965 * 966 * This function will not return NULL since Notmuch ensures that every 967 * message belongs to a single thread. 968 */ 969 const(char)* notmuch_message_get_thread_id(notmuch_message_t* message); 970 971 /** 972 * Get a notmuch_messages_t iterator for all of the replies to 973 * 'message'. 974 * 975 * Note: This call only makes sense if 'message' was ultimately 976 * obtained from a notmuch_thread_t object, (such as by coming 977 * directly from the result of calling notmuch_thread_get_ 978 * toplevel_messages or by any number of subsequent 979 * calls to notmuch_message_get_replies). 980 * 981 * If 'message' was obtained through some non-thread means, (such as 982 * by a call to notmuch_query_search_messages), then this function 983 * will return NULL. 984 * 985 * If there are no replies to 'message', this function will return 986 * NULL. (Note that notmuch_messages_valid will accept that NULL 987 * value as legitimate, and simply return FALSE for it.) 988 */ 989 notmuch_messages_t* notmuch_message_get_replies(notmuch_message_t* message); 990 991 /** 992 * Get a filename for the email corresponding to 'message'. 993 * 994 * The returned filename is an absolute filename, (the initial 995 * component will match notmuch_database_get_path() ). 996 * 997 * The returned string belongs to the message so should not be 998 * modified or freed by the caller (nor should it be referenced after 999 * the message is destroyed). 1000 * 1001 * Note: If this message corresponds to multiple files in the mail 1002 * store, (that is, multiple files contain identical message IDs), 1003 * this function will arbitrarily return a single one of those 1004 * filenames. See notmuch_message_get_filenames for returning the 1005 * complete list of filenames. 1006 */ 1007 const(char)* notmuch_message_get_filename(notmuch_message_t* message); 1008 1009 /** 1010 * Get all filenames for the email corresponding to 'message'. 1011 * 1012 * Returns a notmuch_filenames_t iterator listing all the filenames 1013 * associated with 'message'. These files may not have identical 1014 * content, but each will have the identical Message-ID. 1015 * 1016 * Each filename in the iterator is an absolute filename, (the initial 1017 * component will match notmuch_database_get_path() ). 1018 */ 1019 notmuch_filenames_t* notmuch_message_get_filenames(notmuch_message_t* message); 1020 1021 /** 1022 * Get a value of a flag for the email corresponding to 'message'. 1023 */ 1024 notmuch_bool_t notmuch_message_get_flag(notmuch_message_t* message, notmuch_message_flag_t flag); 1025 1026 /** 1027 * Set a value of a flag for the email corresponding to 'message'. 1028 */ 1029 void notmuch_message_set_flag(notmuch_message_t* message, notmuch_message_flag_t flag, notmuch_bool_t value); 1030 1031 /** 1032 * Get the date of 'message' as a time_t value. 1033 * 1034 * For the original textual representation of the Date header from the 1035 * message call notmuch_message_get_header() with a header value of 1036 * "date". 1037 */ 1038 time_t notmuch_message_get_date(notmuch_message_t* message); 1039 1040 /** 1041 * Get the value of the specified header from 'message' as a UTF-8 string. 1042 * 1043 * Common headers are stored in the database when the message is 1044 * indexed and will be returned from the database. Other headers will 1045 * be read from the actual message file. 1046 * 1047 * The header name is case insensitive. 1048 * 1049 * The returned string belongs to the message so should not be 1050 * modified or freed by the caller (nor should it be referenced after 1051 * the message is destroyed). 1052 * 1053 * Returns an empty string ("") if the message does not contain a 1054 * header line matching 'header'. Returns NULL if any error occurs. 1055 */ 1056 const(char)* notmuch_message_get_header(notmuch_message_t* message, const(char)* header); 1057 1058 /** 1059 * Get the tags for 'message', returning a notmuch_tags_t object which 1060 * can be used to iterate over all tags. 1061 * 1062 * The tags object is owned by the message and as such, will only be 1063 * valid for as long as the message is valid, (which is until the 1064 * query from which it derived is destroyed). 1065 * 1066 * Typical usage might be: 1067 * 1068 * notmuch_message_t *message; 1069 * notmuch_tags_t *tags; 1070 * const char *tag; 1071 * 1072 * message = notmuch_database_find_message (database, message_id); 1073 * 1074 * for (tags = notmuch_message_get_tags (message); 1075 * notmuch_tags_valid (tags); 1076 * notmuch_tags_move_to_next (tags)) 1077 * { 1078 * tag = notmuch_tags_get (tags); 1079 * .... 1080 * } 1081 * 1082 * notmuch_message_destroy (message); 1083 * 1084 * Note that there's no explicit destructor needed for the 1085 * notmuch_tags_t object. (For consistency, we do provide a 1086 * notmuch_tags_destroy function, but there's no good reason to call 1087 * it if the message is about to be destroyed). 1088 */ 1089 notmuch_tags_t* notmuch_message_get_tags(notmuch_message_t* message); 1090 1091 /** 1092 * Add a tag to the given message. 1093 * 1094 * Return value: 1095 * 1096 * NOTMUCH_STATUS_SUCCESS: Tag successfully added to message 1097 * 1098 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL 1099 * 1100 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long 1101 * (exceeds NOTMUCH_TAG_MAX) 1102 * 1103 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 1104 * mode so message cannot be modified. 1105 */ 1106 notmuch_status_t notmuch_message_add_tag(notmuch_message_t* message, const(char)* tag); 1107 1108 /** 1109 * Remove a tag from the given message. 1110 * 1111 * Return value: 1112 * 1113 * NOTMUCH_STATUS_SUCCESS: Tag successfully removed from message 1114 * 1115 * NOTMUCH_STATUS_NULL_POINTER: The 'tag' argument is NULL 1116 * 1117 * NOTMUCH_STATUS_TAG_TOO_LONG: The length of 'tag' is too long 1118 * (exceeds NOTMUCH_TAG_MAX) 1119 * 1120 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 1121 * mode so message cannot be modified. 1122 */ 1123 notmuch_status_t notmuch_message_remove_tag(notmuch_message_t* message, const(char)* tag); 1124 1125 /** 1126 * Remove all tags from the given message. 1127 * 1128 * See notmuch_message_freeze for an example showing how to safely 1129 * replace tag values. 1130 * 1131 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 1132 * mode so message cannot be modified. 1133 */ 1134 notmuch_status_t notmuch_message_remove_all_tags(notmuch_message_t* message); 1135 1136 /** 1137 * Add/remove tags according to maildir flags in the message filename(s). 1138 * 1139 * This function examines the filenames of 'message' for maildir 1140 * flags, and adds or removes tags on 'message' as follows when these 1141 * flags are present: 1142 * 1143 * Flag Action if present 1144 * ---- ----------------- 1145 * 'D' Adds the "draft" tag to the message 1146 * 'F' Adds the "flagged" tag to the message 1147 * 'P' Adds the "passed" tag to the message 1148 * 'R' Adds the "replied" tag to the message 1149 * 'S' Removes the "unread" tag from the message 1150 * 1151 * For each flag that is not present, the opposite action (add/remove) 1152 * is performed for the corresponding tags. 1153 * 1154 * Flags are identified as trailing components of the filename after a 1155 * sequence of ":2,". 1156 * 1157 * If there are multiple filenames associated with this message, the 1158 * flag is considered present if it appears in one or more 1159 * filenames. (That is, the flags from the multiple filenames are 1160 * combined with the logical OR operator.) 1161 * 1162 * A client can ensure that notmuch database tags remain synchronized 1163 * with maildir flags by calling this function after each call to 1164 * notmuch_database_add_message. See also 1165 * notmuch_message_tags_to_maildir_flags for synchronizing tag changes 1166 * back to maildir flags. 1167 */ 1168 notmuch_status_t notmuch_message_maildir_flags_to_tags(notmuch_message_t* message); 1169 1170 /** 1171 * Rename message filename(s) to encode tags as maildir flags. 1172 * 1173 * Specifically, for each filename corresponding to this message: 1174 * 1175 * If the filename is not in a maildir directory, do nothing. (A 1176 * maildir directory is determined as a directory named "new" or 1177 * "cur".) Similarly, if the filename has invalid maildir info, 1178 * (repeated or outof-ASCII-order flag characters after ":2,"), then 1179 * do nothing. 1180 * 1181 * If the filename is in a maildir directory, rename the file so that 1182 * its filename ends with the sequence ":2," followed by zero or more 1183 * of the following single-character flags (in ASCII order): 1184 * 1185 * 'D' iff the message has the "draft" tag 1186 * 'F' iff the message has the "flagged" tag 1187 * 'P' iff the message has the "passed" tag 1188 * 'R' iff the message has the "replied" tag 1189 * 'S' iff the message does not have the "unread" tag 1190 * 1191 * Any existing flags unmentioned in the list above will be preserved 1192 * in the renaming. 1193 * 1194 * Also, if this filename is in a directory named "new", rename it to 1195 * be within the neighboring directory named "cur". 1196 * 1197 * A client can ensure that maildir filename flags remain synchronized 1198 * with notmuch database tags by calling this function after changing 1199 * tags, (after calls to notmuch_message_add_tag, 1200 * notmuch_message_remove_tag, or notmuch_message_freeze/ 1201 * notmuch_message_thaw). See also notmuch_message_maildir_flags_to_tags 1202 * for synchronizing maildir flag changes back to tags. 1203 */ 1204 notmuch_status_t notmuch_message_tags_to_maildir_flags(notmuch_message_t* message); 1205 1206 /** 1207 * Freeze the current state of 'message' within the database. 1208 * 1209 * This means that changes to the message state, (via 1210 * notmuch_message_add_tag, notmuch_message_remove_tag, and 1211 * notmuch_message_remove_all_tags), will not be committed to the 1212 * database until the message is thawed with notmuch_message_thaw. 1213 * 1214 * Multiple calls to freeze/thaw are valid and these calls will 1215 * "stack". That is there must be as many calls to thaw as to freeze 1216 * before a message is actually thawed. 1217 * 1218 * The ability to do freeze/thaw allows for safe transactions to 1219 * change tag values. For example, explicitly setting a message to 1220 * have a given set of tags might look like this: 1221 * 1222 * notmuch_message_freeze (message); 1223 * 1224 * notmuch_message_remove_all_tags (message); 1225 * 1226 * for (i = 0; i < NUM_TAGS; i++) 1227 * notmuch_message_add_tag (message, tags[i]); 1228 * 1229 * notmuch_message_thaw (message); 1230 * 1231 * With freeze/thaw used like this, the message in the database is 1232 * guaranteed to have either the full set of original tag values, or 1233 * the full set of new tag values, but nothing in between. 1234 * 1235 * Imagine the example above without freeze/thaw and the operation 1236 * somehow getting interrupted. This could result in the message being 1237 * left with no tags if the interruption happened after 1238 * notmuch_message_remove_all_tags but before notmuch_message_add_tag. 1239 * 1240 * Return value: 1241 * 1242 * NOTMUCH_STATUS_SUCCESS: Message successfully frozen. 1243 * 1244 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 1245 * mode so message cannot be modified. 1246 */ 1247 notmuch_status_t notmuch_message_freeze(notmuch_message_t* message); 1248 1249 /** 1250 * Thaw the current 'message', synchronizing any changes that may have 1251 * occurred while 'message' was frozen into the notmuch database. 1252 * 1253 * See notmuch_message_freeze for an example of how to use this 1254 * function to safely provide tag changes. 1255 * 1256 * Multiple calls to freeze/thaw are valid and these calls with 1257 * "stack". That is there must be as many calls to thaw as to freeze 1258 * before a message is actually thawed. 1259 * 1260 * Return value: 1261 * 1262 * NOTMUCH_STATUS_SUCCESS: Message successfully thawed, (or at least 1263 * its frozen count has successfully been reduced by 1). 1264 * 1265 * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: An attempt was made to thaw 1266 * an unfrozen message. That is, there have been an unbalanced 1267 * number of calls to notmuch_message_freeze and 1268 * notmuch_message_thaw. 1269 */ 1270 notmuch_status_t notmuch_message_thaw(notmuch_message_t* message); 1271 1272 /** 1273 * Destroy a notmuch_message_t object. 1274 * 1275 * It can be useful to call this function in the case of a single 1276 * query object with many messages in the result, (such as iterating 1277 * over the entire database). Otherwise, it's fine to never call this 1278 * function and there will still be no memory leaks. (The memory from 1279 * the messages get reclaimed when the containing query is destroyed.) 1280 */ 1281 void notmuch_message_destroy(notmuch_message_t* message); 1282 1283 /** 1284 * @name Message Properties 1285 * 1286 * This interface provides the ability to attach arbitrary (key,value) 1287 * string pairs to a message, to remove such pairs, and to iterate 1288 * over them. The caller should take some care as to what keys they 1289 * add or delete values for, as other subsystems or extensions may 1290 * depend on these properties. 1291 * 1292 */ 1293 /**@{*/ 1294 /** 1295 * Retrieve the value for a single property key 1296 * 1297 * *value* is set to a string owned by the message or NULL if there is 1298 * no such key. In the case of multiple values for the given key, the 1299 * first one is retrieved. 1300 * 1301 * @returns 1302 * - NOTMUCH_STATUS_NULL_POINTER: *value* may not be NULL. 1303 * - NOTMUCH_STATUS_SUCCESS: No error occured. 1304 * @since libnotmuch 4.4 (notmuch 0.23) 1305 */ 1306 notmuch_status_t notmuch_message_get_property(notmuch_message_t* message, const(char)* key, const(char)** value); 1307 1308 /** 1309 * Add a (key,value) pair to a message 1310 * 1311 * @returns 1312 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character. 1313 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL. 1314 * - NOTMUCH_STATUS_SUCCESS: No error occured. 1315 * @since libnotmuch 4.4 (notmuch 0.23) 1316 */ 1317 notmuch_status_t notmuch_message_add_property(notmuch_message_t* message, const(char)* key, const(char)* value); 1318 1319 /** 1320 * Remove a (key,value) pair from a message. 1321 * 1322 * It is not an error to remove a non-existant (key,value) pair 1323 * 1324 * @returns 1325 * - NOTMUCH_STATUS_ILLEGAL_ARGUMENT: *key* may not contain an '=' character. 1326 * - NOTMUCH_STATUS_NULL_POINTER: Neither *key* nor *value* may be NULL. 1327 * - NOTMUCH_STATUS_SUCCESS: No error occured. 1328 * @since libnotmuch 4.4 (notmuch 0.23) 1329 */ 1330 notmuch_status_t notmuch_message_remove_property(notmuch_message_t* message, const(char)* key, const(char)* value); 1331 1332 /** 1333 * Remove all (key,value) pairs from the given message. 1334 * 1335 * @param[in,out] message message to operate on. 1336 * @param[in] key key to delete properties for. If NULL, delete 1337 * properties for all keys 1338 * @returns 1339 * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in 1340 * read-only mode so message cannot be modified. 1341 * - NOTMUCH_STATUS_SUCCESS: No error occured. 1342 * 1343 * @since libnotmuch 4.4 (notmuch 0.23) 1344 */ 1345 notmuch_status_t notmuch_message_remove_all_properties(notmuch_message_t* message, const(char)* key); 1346 1347 /** 1348 * Get the properties for *message*, returning a 1349 * notmuch_message_properties_t object which can be used to iterate 1350 * over all properties. 1351 * 1352 * The notmuch_message_properties_t object is owned by the message and 1353 * as such, will only be valid for as long as the message is valid, 1354 * (which is until the query from which it derived is destroyed). 1355 * 1356 * @param[in] message The message to examine 1357 * @param[in] key key or key prefix 1358 * @param[in] exact if TRUE, require exact match with key. Otherwise 1359 * treat as prefix. 1360 * 1361 * Typical usage might be: 1362 * 1363 * notmuch_message_properties_t *list; 1364 * 1365 * for (list = notmuch_message_get_properties (message, "testkey1", TRUE); 1366 * notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) { 1367 * printf("%s\n", notmuch_message_properties_value(list)); 1368 * } 1369 * 1370 * notmuch_message_properties_destroy (list); 1371 * 1372 * Note that there's no explicit destructor needed for the 1373 * notmuch_message_properties_t object. (For consistency, we do 1374 * provide a notmuch_message_properities_destroy function, but there's 1375 * no good reason to call it if the message is about to be destroyed). 1376 * 1377 * @since libnotmuch 4.4 (notmuch 0.23) 1378 */ 1379 notmuch_message_properties_t* notmuch_message_get_properties(notmuch_message_t* message, const(char)* key, notmuch_bool_t exact); 1380 1381 /** 1382 * Is the given *properties* iterator pointing at a valid (key,value) 1383 * pair. 1384 * 1385 * When this function returns TRUE, 1386 * notmuch_message_properties_{key,value} will return a valid string, 1387 * and notmuch_message_properties_move_to_next will do what it 1388 * says. Whereas when this function returns FALSE, calling any of 1389 * these functions results in undefined behaviour. 1390 * 1391 * See the documentation of notmuch_message_properties_get for example 1392 * code showing how to iterate over a notmuch_message_properties_t 1393 * object. 1394 * 1395 * @since libnotmuch 4.4 (notmuch 0.23) 1396 */ 1397 notmuch_bool_t notmuch_message_properties_valid(notmuch_message_properties_t* properties); 1398 1399 /** 1400 * Move the *properties* iterator to the next (key,value) pair 1401 * 1402 * If *properties* is already pointing at the last pair then the iterator 1403 * will be moved to a point just beyond that last pair, (where 1404 * notmuch_message_properties_valid will return FALSE). 1405 * 1406 * See the documentation of notmuch_message_get_properties for example 1407 * code showing how to iterate over a notmuch_message_properties_t object. 1408 * 1409 * @since libnotmuch 4.4 (notmuch 0.23) 1410 */ 1411 void notmuch_message_properties_move_to_next(notmuch_message_properties_t* properties); 1412 1413 /** 1414 * Return the key from the current (key,value) pair. 1415 * 1416 * this could be useful if iterating for a prefix 1417 * 1418 * @since libnotmuch 4.4 (notmuch 0.23) 1419 */ 1420 const(char)* notmuch_message_properties_key(notmuch_message_properties_t* properties); 1421 1422 /** 1423 * Return the value from the current (key,value) pair. 1424 * 1425 * This could be useful if iterating for a prefix. 1426 * 1427 * @since libnotmuch 4.4 (notmuch 0.23) 1428 */ 1429 const(char)* notmuch_message_properties_value(notmuch_message_properties_t* properties); 1430 1431 /** 1432 * Destroy a notmuch_message_properties_t object. 1433 * 1434 * It's not strictly necessary to call this function. All memory from 1435 * the notmuch_message_properties_t object will be reclaimed when the 1436 * containing message object is destroyed. 1437 * 1438 * @since libnotmuch 4.4 (notmuch 0.23) 1439 */ 1440 void notmuch_message_properties_destroy(notmuch_message_properties_t* properties); 1441 1442 /**@}*/ 1443 1444 /** 1445 * Is the given 'tags' iterator pointing at a valid tag. 1446 * 1447 * When this function returns TRUE, notmuch_tags_get will return a 1448 * valid string. Whereas when this function returns FALSE, 1449 * notmuch_tags_get will return NULL. 1450 * 1451 * See the documentation of notmuch_message_get_tags for example code 1452 * showing how to iterate over a notmuch_tags_t object. 1453 */ 1454 notmuch_bool_t notmuch_tags_valid(notmuch_tags_t* tags); 1455 1456 /** 1457 * Get the current tag from 'tags' as a string. 1458 * 1459 * Note: The returned string belongs to 'tags' and has a lifetime 1460 * identical to it (and the query to which it ultimately belongs). 1461 * 1462 * See the documentation of notmuch_message_get_tags for example code 1463 * showing how to iterate over a notmuch_tags_t object. 1464 */ 1465 const(char)* notmuch_tags_get(notmuch_tags_t* tags); 1466 1467 /** 1468 * Move the 'tags' iterator to the next tag. 1469 * 1470 * If 'tags' is already pointing at the last tag then the iterator 1471 * will be moved to a point just beyond that last tag, (where 1472 * notmuch_tags_valid will return FALSE and notmuch_tags_get will 1473 * return NULL). 1474 * 1475 * See the documentation of notmuch_message_get_tags for example code 1476 * showing how to iterate over a notmuch_tags_t object. 1477 */ 1478 void notmuch_tags_move_to_next(notmuch_tags_t* tags); 1479 1480 /** 1481 * Destroy a notmuch_tags_t object. 1482 * 1483 * It's not strictly necessary to call this function. All memory from 1484 * the notmuch_tags_t object will be reclaimed when the containing 1485 * message or query objects are destroyed. 1486 */ 1487 void notmuch_tags_destroy(notmuch_tags_t* tags); 1488 1489 /** 1490 * Store an mtime within the database for 'directory'. 1491 * 1492 * The 'directory' should be an object retrieved from the database 1493 * with notmuch_database_get_directory for a particular path. 1494 * 1495 * The intention is for the caller to use the mtime to allow efficient 1496 * identification of new messages to be added to the database. The 1497 * recommended usage is as follows: 1498 * 1499 * o Read the mtime of a directory from the filesystem 1500 * 1501 * o Call add_message for all mail files in the directory 1502 * 1503 * o Call notmuch_directory_set_mtime with the mtime read from the 1504 * filesystem. 1505 * 1506 * Then, when wanting to check for updates to the directory in the 1507 * future, the client can call notmuch_directory_get_mtime and know 1508 * that it only needs to add files if the mtime of the directory and 1509 * files are newer than the stored timestamp. 1510 * 1511 * Note: The notmuch_directory_get_mtime function does not allow the 1512 * caller to distinguish a timestamp of 0 from a non-existent 1513 * timestamp. So don't store a timestamp of 0 unless you are 1514 * comfortable with that. 1515 * 1516 * Return value: 1517 * 1518 * NOTMUCH_STATUS_SUCCESS: mtime successfully stored in database. 1519 * 1520 * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception 1521 * occurred, mtime not stored. 1522 * 1523 * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only 1524 * mode so directory mtime cannot be modified. 1525 */ 1526 notmuch_status_t notmuch_directory_set_mtime(notmuch_directory_t* directory, time_t mtime); 1527 1528 /** 1529 * Get the mtime of a directory, (as previously stored with 1530 * notmuch_directory_set_mtime). 1531 * 1532 * Returns 0 if no mtime has previously been stored for this 1533 * directory. 1534 */ 1535 time_t notmuch_directory_get_mtime(notmuch_directory_t* directory); 1536 1537 /** 1538 * Get a notmuch_filenames_t iterator listing all the filenames of 1539 * messages in the database within the given directory. 1540 * 1541 * The returned filenames will be the basename-entries only (not 1542 * complete paths). 1543 */ 1544 notmuch_filenames_t* notmuch_directory_get_child_files(notmuch_directory_t* directory); 1545 1546 /** 1547 * Get a notmuch_filenames_t iterator listing all the filenames of 1548 * sub-directories in the database within the given directory. 1549 * 1550 * The returned filenames will be the basename-entries only (not 1551 * complete paths). 1552 */ 1553 notmuch_filenames_t* notmuch_directory_get_child_directories(notmuch_directory_t* directory); 1554 1555 /** 1556 * Delete directory document from the database, and destroy the 1557 * notmuch_directory_t object. Assumes any child directories and files 1558 * have been deleted by the caller. 1559 * 1560 * @since libnotmuch 4.3 (notmuch 0.21) 1561 */ 1562 notmuch_status_t notmuch_directory_delete(notmuch_directory_t* directory); 1563 1564 /** 1565 * Destroy a notmuch_directory_t object. 1566 */ 1567 void notmuch_directory_destroy(notmuch_directory_t* directory); 1568 1569 /** 1570 * Is the given 'filenames' iterator pointing at a valid filename. 1571 * 1572 * When this function returns TRUE, notmuch_filenames_get will return 1573 * a valid string. Whereas when this function returns FALSE, 1574 * notmuch_filenames_get will return NULL. 1575 * 1576 * It is acceptable to pass NULL for 'filenames', in which case this 1577 * function will always return FALSE. 1578 */ 1579 notmuch_bool_t notmuch_filenames_valid(notmuch_filenames_t* filenames); 1580 1581 /** 1582 * Get the current filename from 'filenames' as a string. 1583 * 1584 * Note: The returned string belongs to 'filenames' and has a lifetime 1585 * identical to it (and the directory to which it ultimately belongs). 1586 * 1587 * It is acceptable to pass NULL for 'filenames', in which case this 1588 * function will always return NULL. 1589 */ 1590 const(char)* notmuch_filenames_get(notmuch_filenames_t* filenames); 1591 1592 /** 1593 * Move the 'filenames' iterator to the next filename. 1594 * 1595 * If 'filenames' is already pointing at the last filename then the 1596 * iterator will be moved to a point just beyond that last filename, 1597 * (where notmuch_filenames_valid will return FALSE and 1598 * notmuch_filenames_get will return NULL). 1599 * 1600 * It is acceptable to pass NULL for 'filenames', in which case this 1601 * function will do nothing. 1602 */ 1603 void notmuch_filenames_move_to_next(notmuch_filenames_t* filenames); 1604 1605 /** 1606 * Destroy a notmuch_filenames_t object. 1607 * 1608 * It's not strictly necessary to call this function. All memory from 1609 * the notmuch_filenames_t object will be reclaimed when the 1610 * containing directory object is destroyed. 1611 * 1612 * It is acceptable to pass NULL for 'filenames', in which case this 1613 * function will do nothing. 1614 */ 1615 void notmuch_filenames_destroy(notmuch_filenames_t* filenames); 1616 1617 /** 1618 * set config 'key' to 'value' 1619 * 1620 * @since libnotmuch 4.4 (notmuch 0.23) 1621 */ 1622 notmuch_status_t notmuch_database_set_config(notmuch_database_t* db, const(char)* key, const(char)* value); 1623 1624 /** 1625 * retrieve config item 'key', assign to 'value' 1626 * 1627 * keys which have not been previously set with n_d_set_config will 1628 * return an empty string. 1629 * 1630 * return value is allocated by malloc and should be freed by the 1631 * caller. 1632 * 1633 * @since libnotmuch 4.4 (notmuch 0.23) 1634 */ 1635 notmuch_status_t notmuch_database_get_config(notmuch_database_t* db, const(char)* key, char** value); 1636 1637 /** 1638 * Create an iterator for all config items with keys matching a given prefix 1639 * 1640 * @since libnotmuch 4.4 (notmuch 0.23) 1641 */ 1642 notmuch_status_t notmuch_database_get_config_list(notmuch_database_t* db, const(char)* prefix, notmuch_config_list_t** out_); 1643 1644 /** 1645 * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called). 1646 * 1647 * @since libnotmuch 4.4 (notmuch 0.23) 1648 */ 1649 notmuch_bool_t notmuch_config_list_valid(notmuch_config_list_t* config_list); 1650 1651 /** 1652 * return key for current config pair 1653 * 1654 * return value is owned by the iterator, and will be destroyed by the 1655 * next call to notmuch_config_list_key or notmuch_config_list_destroy. 1656 * 1657 * @since libnotmuch 4.4 (notmuch 0.23) 1658 */ 1659 const(char)* notmuch_config_list_key(notmuch_config_list_t* config_list); 1660 1661 /** 1662 * return 'value' for current config pair 1663 * 1664 * return value is owned by the iterator, and will be destroyed by the 1665 * next call to notmuch_config_list_value or notmuch config_list_destroy 1666 * 1667 * @since libnotmuch 4.4 (notmuch 0.23) 1668 */ 1669 const(char)* notmuch_config_list_value(notmuch_config_list_t* config_list); 1670 1671 /** 1672 * move 'config_list' iterator to the next pair 1673 * 1674 * @since libnotmuch 4.4 (notmuch 0.23) 1675 */ 1676 void notmuch_config_list_move_to_next(notmuch_config_list_t* config_list); 1677 1678 /** 1679 * free any resources held by 'config_list' 1680 * 1681 * @since libnotmuch 4.4 (notmuch 0.23) 1682 */ 1683 void notmuch_config_list_destroy(notmuch_config_list_t* config_list); 1684 1685 /** 1686 * interrogate the library for compile time features 1687 * 1688 * @since libnotmuch 4.4 (notmuch 0.23) 1689 */ 1690 notmuch_bool_t notmuch_built_with(const(char)* name);