Notmuch virtual mailbox type. More...
#include "config.h"#include <errno.h>#include <limits.h>#include <notmuch.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include <time.h>#include <unistd.h>#include "private.h"#include "mutt/lib.h"#include "config/lib.h"#include "email/lib.h"#include "core/lib.h"#include "mutt.h"#include "lib.h"#include "editor/lib.h"#include "hcache/lib.h"#include "history/lib.h"#include "index/lib.h"#include "progress/lib.h"#include "adata.h"#include "commands.h"#include "edata.h"#include "maildir/shared.h"#include "mdata.h"#include "mutt_thread.h"#include "mx.h"#include "protos.h"#include "query.h"#include "tag.h"#include <libintl.h>
Include dependency graph for notmuch.c:Go to the source code of this file.
Functions | |
| void | nm_init (void) |
| Setup feature commands. | |
| static struct HeaderCache * | nm_hcache_open (struct Mailbox *m) |
| Open a header cache. | |
| static void | nm_hcache_close (struct HeaderCache **ptr) |
| Close the header cache. | |
| static char * | nm_get_default_url (void) |
| Create a Mailbox with default Notmuch settings. | |
| static struct NmMboxData * | nm_get_default_data (void) |
| Create a Mailbox with default Notmuch settings. | |
| static int | init_mailbox (struct Mailbox *m) |
| Add Notmuch data to the Mailbox. | |
| static char * | email_get_id (struct Email *e) |
| Get the unique Notmuch Id. | |
| static char * | email_get_fullpath (struct Email *e, char *buf, size_t buflen) |
| Get the full path of an email. | |
| static void | query_window_reset (void) |
| Restore vfolder's search window to its original position. | |
| static bool | windowed_query_from_query (const char *query, char *buf, size_t buflen) |
| Transforms a vfolder search query into a windowed one. | |
| static char * | get_query_string (struct NmMboxData *mdata, bool window) |
| Builds the notmuch vfolder search string. | |
| static int | get_limit (struct NmMboxData *mdata) |
| Get the database limit. | |
| static void | apply_exclude_tags (notmuch_query_t *query) |
| Exclude the configured tags. | |
| static notmuch_query_t * | get_query (struct Mailbox *m, bool writable) |
| Create a new query. | |
| static int | update_email_tags (struct Email *e, notmuch_message_t *msg) |
| Update the Email's tags from Notmuch. | |
| static int | update_message_path (struct Email *e, const char *path) |
| Set the path for a message. | |
| static char * | get_folder_from_path (const char *path) |
| Find an email's folder from its path. | |
| static char * | nm2mutt_message_id (const char *id) |
| Converts notmuch message Id to neomutt message Id. | |
| static int | init_email (struct Email *e, const char *path, notmuch_message_t *msg) |
| Set up an email's Notmuch data. | |
| static const char * | get_message_last_filename (notmuch_message_t *msg) |
| Get a message's last filename. | |
| static void | progress_setup (struct Mailbox *m) |
| Set up the Progress Bar. | |
| static void | nm_progress_update (struct Mailbox *m) |
| Update the progress counter. | |
| static struct Email * | get_mutt_email (struct Mailbox *m, notmuch_message_t *msg) |
| Get the Email of a Notmuch message. | |
| static void | append_message (struct HeaderCache *hc, struct Mailbox *m, notmuch_message_t *msg, bool dedup) |
| Associate a message. | |
| static void | append_replies (struct HeaderCache *hc, struct Mailbox *m, notmuch_query_t *q, notmuch_message_t *top, bool dedup) |
| Add all the replies to a given messages into the display. | |
| static void | append_thread (struct HeaderCache *hc, struct Mailbox *m, notmuch_query_t *q, notmuch_thread_t *thread, bool dedup) |
| Add each top level reply in the thread. | |
| static notmuch_messages_t * | get_messages (notmuch_query_t *query) |
| Load messages for a query. | |
| static bool | read_mesgs_query (struct Mailbox *m, notmuch_query_t *q, bool dedup) |
| Search for matching messages. | |
| static notmuch_threads_t * | get_threads (notmuch_query_t *query) |
| Load threads for a query. | |
| static bool | read_threads_query (struct Mailbox *m, notmuch_query_t *q, bool dedup, int limit) |
| Perform a query with threads. | |
| static notmuch_message_t * | get_nm_message (notmuch_database_t *db, struct Email *e) |
| Find a Notmuch message. | |
| static bool | nm_message_has_tag (notmuch_message_t *msg, const char *tag) |
| Does a message have this tag? | |
| static void | sync_email_path_with_nm (struct Email *e, notmuch_message_t *msg) |
| Synchronize NeoMutt's Email path with notmuch. | |
| static int | update_tags (notmuch_message_t *msg, const char *tag_str) |
| Update the tags on a message. | |
| static int | update_email_flags (struct Mailbox *m, struct Email *e, const char *tag_str) |
| Update the Email's flags. | |
| static int | rename_maildir_filename (const char *old, char *buf, size_t buflen, struct Email *e) |
| Rename a Maildir file. | |
| static int | remove_filename (struct Mailbox *m, const char *path) |
| Delete a file. | |
| static int | rename_filename (struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e) |
| Rename the file. | |
| static unsigned int | count_query (notmuch_database_t *db, const char *qstr, int limit) |
| Count the results of a query. | |
| char * | nm_email_get_folder (struct Email *e) |
| Get the folder for a Email. | |
| char * | nm_email_get_folder_rel_db (struct Mailbox *m, struct Email *e) |
| Get the folder for a Email from the same level as the notmuch database. | |
| int | nm_read_entire_thread (struct Mailbox *m, struct Email *e) |
| Get the entire thread of an email. | |
| char * | nm_url_from_query (struct Mailbox *m, char *buf, size_t buflen) |
| Turn a query into a URL. | |
| bool | nm_query_window_available (void) |
| Are windowed queries enabled for use? | |
| void | nm_query_window_forward (void) |
| Function to move the current search window forward in time. | |
| void | nm_query_window_backward (void) |
| Function to move the current search window backward in time. | |
| void | nm_query_window_reset (void) |
| Resets the vfolder window position to the present. | |
| bool | nm_message_is_still_queried (struct Mailbox *m, struct Email *e) |
| Is a message still visible in the query? | |
| int | nm_update_filename (struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e) |
| Change the filename. | |
| static enum MxStatus | nm_mbox_check_stats (struct Mailbox *m, uint8_t flags) |
| Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -. | |
| static struct Mailbox * | get_default_mailbox (void) |
| Get Mailbox for notmuch without any parameters. | |
| int | nm_record_message (struct Mailbox *m, char *path, struct Email *e) |
| Add a message to the Notmuch database. | |
| int | nm_get_all_tags (struct Mailbox *m, const char **tag_list, int *tag_count) |
| Fill a list with all notmuch tags. | |
| static bool | nm_ac_owns_path (struct Account *a, const char *path) |
| Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -. | |
| static bool | nm_ac_add (struct Account *a, struct Mailbox *m) |
| Add a Mailbox to an Account - Implements MxOps::ac_add() -. | |
| static enum MxOpenReturns | nm_mbox_open (struct Mailbox *m) |
| Open a Mailbox - Implements MxOps::mbox_open() -. | |
| static enum MxStatus | nm_mbox_check (struct Mailbox *m) |
| Check for new mail - Implements MxOps::mbox_check() -. | |
| static enum MxStatus | nm_mbox_sync (struct Mailbox *m) |
| Save changes to the Mailbox - Implements MxOps::mbox_sync() -. | |
| static enum MxStatus | nm_mbox_close (struct Mailbox *m) |
| Close a Mailbox - Implements MxOps::mbox_close() -. | |
| static bool | nm_msg_open (struct Mailbox *m, struct Message *msg, struct Email *e) |
| Open an email message in a Mailbox - Implements MxOps::msg_open() -. | |
| static int | nm_msg_commit (struct Mailbox *m, struct Message *msg) |
| Save changes to an email - Implements MxOps::msg_commit() -. | |
| static int | nm_msg_close (struct Mailbox *m, struct Message *msg) |
| Close an email - Implements MxOps::msg_close() -. | |
| static int | nm_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf) |
| Prompt and validate new messages tags - Implements MxOps::tags_edit() -. | |
| static int | nm_tags_commit (struct Mailbox *m, struct Email *e, const char *buf) |
| Save the tags to a message - Implements MxOps::tags_commit() -. | |
| enum MailboxType | nm_path_probe (const char *path, const struct stat *st) |
| Is this a Notmuch Mailbox? | |
| static int | nm_path_canon (struct Buffer *path) |
| Canonicalise a Mailbox path - Implements MxOps::path_canon() -. | |
Variables | |
| static const struct Command | NmCommands [] |
| Notmuch Commands. | |
| const char | NmUrlProtocol [] = "notmuch://" |
| Protocol string for Notmuch URLs. | |
| const int | NmUrlProtocolLen = sizeof(NmUrlProtocol) - 1 |
| Length of NmUrlProtocol string. | |
| const struct MxOps | MxNotmuchOps |
| Notmuch Mailbox - Implements MxOps -. | |
Notmuch virtual mailbox type.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file notmuch.c.
| void nm_init | ( | void | ) |
Setup feature commands.
Definition at line 109 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Open a header cache.
| m | Mailbox |
| ptr | Header cache handle |
Definition at line 119 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Close the header cache.
| ptr | Header cache handle |
Definition at line 133 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create a Mailbox with default Notmuch settings.
| ptr | Mailbox with default Notmuch settings |
| NULL | Error, it's impossible to create an NmMboxData |
Definition at line 145 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create a Mailbox with default Notmuch settings.
| ptr | Mailbox with default Notmuch settings |
| NULL | Error, it's impossible to create an NmMboxData |
Definition at line 177 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Add Notmuch data to the Mailbox.
| m | Mailbox |
| 0 | Success |
| -1 | Error Bad format |
Create a new NmMboxData struct and add it Mailbox::data. Notmuch-specific data will be stored in this struct. This struct can be freed using nm_mdata_free().
Definition at line 200 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the unique Notmuch Id.
| e |
| ptr | ID string |
| NULL | Error |
Definition at line 222 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the full path of an email.
| ptr | Path string |
Definition at line 238 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Restore vfolder's search window to its original position.
After moving a vfolder search window backward and forward, calling this function will reset the search position to its original value, setting to 0 the user settable variable:
nm_query_window_current_position
Definition at line 253 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Transforms a vfolder search query into a windowed one.
| [in] | query | vfolder search string |
| [out] | buf | allocated string buffer to receive the modified search query |
| [in] | buflen | allocated maximum size of the buf string buffer |
| true | Transformed search query is available as a string in buf |
| false | Search query shall not be transformed |
Creates a date: search term window from the following user settings:
nm_query_window_enable (only required for nm_query_window_duration = 0)nm_query_window_durationnm_query_window_timebasenm_query_window_current_positionThe window won't be applied:
0 this function will be disabled unless a user explicitly enables windowed queries.If there's no search registered in nm_query_window_current_search or this is a new search, it will reset the window and do the search.
Definition at line 283 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Builds the notmuch vfolder search string.
| mdata | Notmuch Mailbox data |
| window | If true enable application of the window on the search string |
| ptr | String containing a notmuch search query |
| NULL | None can be generated |
This function parses the internal representation of a search, and returns a search query string ready to be fed to the notmuch API, given the search is valid.
Definition at line 347 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Exclude the configured tags.
| query | Notmuch query |
Definition at line 424 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create a new query.
| m | Mailbox |
| writable | Should the query be updateable? |
| ptr | Notmuch query |
| NULL | Error |
Definition at line 450 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Update the Email's tags from Notmuch.
| e | |
| msg | Notmuch message |
| 0 | Success |
| 1 | Tags unchanged |
Definition at line 482 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Set the path for a message.
| e | |
| path | Path |
| 0 | Success |
| 1 | Failure |
Definition at line 534 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Find an email's folder from its path.
| path | Path |
| ptr | Path string |
| NULL | Error |
Definition at line 596 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Converts notmuch message Id to neomutt message Id.
| id | Notmuch ID to convert |
| ptr | NeoMutt message ID |
Caller must free the NeoMutt Message ID
Definition at line 621 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Set up an email's Notmuch data.
| e | |
| path | Path to email |
| msg | Notmuch message |
| 0 | Success |
| -1 | Failure |
Definition at line 639 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get a message's last filename.
| msg | Notmuch message |
| ptr | Filename |
| NULL | Error |
Definition at line 683 of file notmuch.c.
Here is the caller graph for this function:
|
static |
Set up the Progress Bar.
| m | Mailbox |
Definition at line 700 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Update the progress counter.
| m | Mailbox |
Definition at line 719 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:Get the Email of a Notmuch message.
| m | Mailbox |
| msg | Notmuch message |
| ptr | |
| NULL | Error |
Definition at line 736 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Associate a message.
| hc | Header cache handle |
| m | Mailbox |
| msg | Notmuch message |
| dedup | De-duplicate results |
Definition at line 770 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Add all the replies to a given messages into the display.
| hc | Header cache handle |
| m | Mailbox |
| q | Notmuch query |
| top | Notmuch message |
| dedup | De-duplicate the results |
Careful, this calls itself recursively to make sure we get everything.
Definition at line 883 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Add each top level reply in the thread.
| hc | Header cache handle |
| m | Mailbox |
| q | Notmuch query |
| thread | Notmuch thread |
| dedup | De-duplicate the results |
add each top level reply in the thread, and then add each reply to the top level replies
Definition at line 910 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Load messages for a query.
| query | Notmuch query |
| ptr | Messages matching query |
| NULL | Error occurred |
This helper method is to be the single point for retrieving messages. It handles version specific calls, which will make maintenance easier.
Definition at line 934 of file notmuch.c.
Here is the caller graph for this function:
|
static |
Search for matching messages.
| m | Mailbox |
| q | Notmuch query |
| dedup | De-duplicate the results |
| true | Success |
| false | Failure |
Definition at line 962 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Load threads for a query.
| query | Notmuch query |
| ptr | Threads matching query |
| NULL | Error occurred |
This helper method is to be the single point for retrieving messages. It handles version specific calls, which will make maintenance easier.
Definition at line 1004 of file notmuch.c.
Here is the caller graph for this function:
|
static |
Perform a query with threads.
| m | Mailbox |
| q | Query type |
| dedup | Should the results be de-duped? |
| limit | Maximum number of results |
| true | Success |
| false | Failure |
Definition at line 1032 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Find a Notmuch message.
| db | Notmuch database |
| e |
| ptr | Handle to the Notmuch message |
| NULL | Error occurred |
Definition at line 1069 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Does a message have this tag?
| msg | Notmuch message |
| tag | Tag |
| true | It does |
Definition at line 1088 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Synchronize NeoMutt's Email path with notmuch.
Definition at line 1110 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Update the tags on a message.
| msg | Notmuch message |
| tag_str | String of tags (space separated) |
| 0 | Success |
| -1 | Failure |
Definition at line 1127 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:Update the Email's flags.
| 0 | Success |
| -1 | Failure |
TODO: join update_email_tags and update_email_flags, which are given an array of tags.
Definition at line 1181 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Rename a Maildir file.
| 0 | Success, renamed |
| 1 | Success, no change |
| -1 | Failure |
Definition at line 1233 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Delete a file.
| m | Mailbox |
| path | Path of file |
| 0 | Success |
| -1 | Failure |
Definition at line 1289 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Rename the file.
| 0 | Success |
| -1 | Failure |
Definition at line 1353 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Count the results of a query.
| db | Notmuch database |
| qstr | Query to execute |
| limit | Maximum number of results |
| num | Number of results |
Definition at line 1458 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char * nm_email_get_folder | ( | struct Email * | e | ) |
Get the folder for a Email from the same level as the notmuch database.
| ptr | Folder containing email from the same level as the notmuch db |
| NULL | Error |
Instead of returning a path like /var/mail/account/Inbox, this returns account/Inbox. If wanting the full path, use nm_email_get_folder().
Definition at line 1510 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:Get the entire thread of an email.
| 0 | Success |
| -1 | Failure |
Definition at line 1536 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char * nm_url_from_query | ( | struct Mailbox * | m, |
| char * | buf, | ||
| size_t | buflen ) |
Turn a query into a URL.
| ptr | Query as a URL |
| NULL | Error |
Definition at line 1601 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| bool nm_query_window_available | ( | void | ) |
Are windowed queries enabled for use?
| true | Windowed queries in use |
Definition at line 1660 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void nm_query_window_forward | ( | void | ) |
Function to move the current search window forward in time.
Updates nm_query_window_current_position by decrementing it by 1, or does nothing if the current window already is set to 0.
The lower the value of nm_query_window_current_position is, the more recent the result will be.
Definition at line 1677 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void nm_query_window_backward | ( | void | ) |
Function to move the current search window backward in time.
Updates nm_query_window_current_position by incrementing it by 1
The higher the value of nm_query_window_current_position is, the less recent the result will be.
Definition at line 1697 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void nm_query_window_reset | ( | void | ) |
Is a message still visible in the query?
| true | Message is still in query |
Definition at line 1720 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int nm_update_filename | ( | struct Mailbox * | m, |
| const char * | old_file, | ||
| const char * | new_file, | ||
| struct Email * | e ) |
Change the filename.
| 0 | Success |
| -1 | Failure |
Definition at line 1785 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get Mailbox for notmuch without any parameters.
| ptr | Mailbox pointer |
Definition at line 1895 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:Add a message to the Notmuch database.
| 0 | Success |
| -1 | Failure |
Definition at line 1918 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int nm_get_all_tags | ( | struct Mailbox * | m, |
| const char ** | tag_list, | ||
| int * | tag_count ) |
Fill a list with all notmuch tags.
| [in] | m | Mailbox |
| [out] | tag_list | List of tags |
| [out] | tag_count | Number of tags |
| 0 | Success |
| -1 | Failure |
If tag_list is NULL, just count the tags.
Definition at line 2001 of file notmuch.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Notmuch Commands.
Definition at line 93 of file notmuch.c.
| const char NmUrlProtocol[] = "notmuch://" |
| const int NmUrlProtocolLen = sizeof(NmUrlProtocol) - 1 |
Length of NmUrlProtocol string.