#include <stddef.h>
#include <stdbool.h>
#include "core/lib.h"
#include "mx.h"
Go to the source code of this file.
|
void | nm_init (void) |
| Setup feature commands. More...
|
|
void | nm_db_debug_check (struct Mailbox *m) |
| Check if the database is open. More...
|
|
void | nm_db_longrun_done (struct Mailbox *m) |
| Finish a long transaction. More...
|
|
void | nm_db_longrun_init (struct Mailbox *m, bool writable) |
| Start a long transaction. More...
|
|
char * | nm_email_get_folder (struct Email *e) |
| Get the folder for a Email. More...
|
|
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. More...
|
|
int | nm_get_all_tags (struct Mailbox *m, char **tag_list, int *tag_count) |
| Fill a list with all notmuch tags. More...
|
|
bool | nm_message_is_still_queried (struct Mailbox *m, struct Email *e) |
| Is a message still visible in the query? More...
|
|
void | nm_parse_type_from_query (struct NmMboxData *mdata, char *buf) |
| Parse a query type out of a query. More...
|
|
enum MailboxType | nm_path_probe (const char *path, const struct stat *st) |
| Is this a Notmuch Mailbox? - Implements MxOps::path_probe() More...
|
|
void | nm_query_window_backward (void) |
| Function to move the current search window backward in time. More...
|
|
void | nm_query_window_forward (void) |
| Function to move the current search window forward in time. More...
|
|
int | nm_read_entire_thread (struct Mailbox *m, struct Email *e) |
| Get the entire thread of an email. More...
|
|
int | nm_record_message (struct Mailbox *m, char *path, struct Email *e) |
| Add a message to the Notmuch database. More...
|
|
int | nm_update_filename (struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e) |
| Change the filename. More...
|
|
char * | nm_url_from_query (struct Mailbox *m, char *buf, size_t buflen) |
| Turn a query into a URL. More...
|
|
Notmuch virtual mailbox type
- Authors
-
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
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 lib.h.
◆ nm_init()
Setup feature commands.
Definition at line 91 of file notmuch.c.
◆ nm_db_debug_check()
void nm_db_debug_check |
( |
struct Mailbox * |
m | ) |
|
Check if the database is open.
- Parameters
-
Definition at line 324 of file db.c.
◆ nm_db_longrun_done()
void nm_db_longrun_done |
( |
struct Mailbox * |
m | ) |
|
Finish a long transaction.
- Parameters
-
Definition at line 306 of file db.c.
312 adata->longrun =
false;
316 adata->longrun =
true;
◆ nm_db_longrun_init()
void nm_db_longrun_init |
( |
struct Mailbox * |
m, |
|
|
bool |
writable |
|
) |
| |
Start a long transaction.
- Parameters
-
Definition at line 291 of file db.c.
298 adata->longrun =
true;
◆ nm_email_get_folder()
char* nm_email_get_folder |
( |
struct Email * |
e | ) |
|
Get the folder for a Email.
- Parameters
-
- Return values
-
ptr | Folder containing email |
NULL | Error |
Definition at line 1539 of file notmuch.c.
1545 return edata->folder;
◆ nm_email_get_folder_rel_db()
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.
- Parameters
-
- Return values
-
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 1558 of file notmuch.c.
1568 return full_folder + strlen(db_path);
◆ nm_get_all_tags()
int nm_get_all_tags |
( |
struct Mailbox * |
m, |
|
|
char ** |
tag_list, |
|
|
int * |
tag_count |
|
) |
| |
Fill a list with all notmuch tags.
- Parameters
-
[in] | m | Mailbox |
[out] | tag_list | List of tags |
[out] | tag_count | Number of tags |
- Return values
-
If tag_list is NULL, just count the tags.
Definition at line 2046 of file notmuch.c.
2052 notmuch_database_t *db = NULL;
2053 notmuch_tags_t *tags = NULL;
2054 const char *tag = NULL;
2057 if (!(db =
nm_db_get(m,
false)) || !(tags = notmuch_database_get_all_tags(db)))
2063 while (notmuch_tags_valid(tags))
2065 tag = notmuch_tags_get(tags);
2073 notmuch_tags_move_to_next(tags);
2079 notmuch_tags_destroy(tags);
◆ nm_message_is_still_queried()
bool nm_message_is_still_queried |
( |
struct Mailbox * |
m, |
|
|
struct Email * |
e |
|
) |
| |
Is a message still visible in the query?
- Parameters
-
- Return values
-
Definition at line 1766 of file notmuch.c.
1769 notmuch_database_t *db =
nm_db_get(m,
false);
1772 if (!db || !orig_str)
1775 char *new_str = NULL;
1782 notmuch_query_t *q = notmuch_query_create(db, new_str);
1784 switch (
mdata->query_type)
1793 rc = notmuch_messages_valid(messages);
1794 notmuch_messages_destroy(messages);
1804 rc = notmuch_threads_valid(threads);
1805 notmuch_threads_destroy(threads);
1810 notmuch_query_destroy(q);
1813 new_str, rc ?
"true" :
"false");
◆ nm_parse_type_from_query()
void nm_parse_type_from_query |
( |
struct NmMboxData * |
mdata, |
|
|
char * |
buf |
|
) |
| |
Parse a query type out of a query.
- Parameters
-
If a user writes a query for a vfolder and includes a type= statement, that type= will be encoded, which Notmuch will treat as part of the query= statement. This method will remove the type= and set it within the Mailbox struct.
Definition at line 1646 of file notmuch.c.
1652 const char *variants[6] = {
"&type=threads",
"&type=messages",
1653 "type=threads&",
"type=messages&",
1654 "type=threads",
"type=messages" };
1657 for (
int i = 0; i < variants_size; i++)
1659 if (strcasestr(buf, variants[i]) != NULL)
◆ nm_path_probe()
enum MailboxType nm_path_probe |
( |
const char * |
path, |
|
|
const struct stat * |
st |
|
) |
| |
◆ nm_query_window_backward()
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 1754 of file notmuch.c.
◆ nm_query_window_forward()
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 1738 of file notmuch.c.
◆ nm_read_entire_thread()
int nm_read_entire_thread |
( |
struct Mailbox * |
m, |
|
|
struct Email * |
e |
|
) |
| |
Get the entire thread of an email.
- Parameters
-
- Return values
-
Definition at line 1578 of file notmuch.c.
1587 notmuch_query_t *q = NULL;
1588 notmuch_database_t *db = NULL;
1589 notmuch_message_t *msg = NULL;
1599 const char *
id = notmuch_message_get_thread_id(msg);
1607 q = notmuch_query_create(db, qstr);
1612 notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
1623 notmuch_query_destroy(q);
1630 mdata->oldmsgcount = 0;
◆ nm_record_message()
int nm_record_message |
( |
struct Mailbox * |
m, |
|
|
char * |
path, |
|
|
struct Email * |
e |
|
) |
| |
Add a message to the Notmuch database.
- Parameters
-
- Return values
-
Definition at line 1965 of file notmuch.c.
1967 notmuch_database_t *db = NULL;
1968 notmuch_status_t st;
1969 notmuch_message_t *msg = NULL;
1988 if (!path || !
mdata || (access(path, F_OK) != 0))
1999 #ifdef HAVE_NOTMUCH_DATABASE_INDEX_FILE
2000 st = notmuch_database_index_file(db, path, NULL, &msg);
2002 st = notmuch_database_add_message(db, path, &msg);
2005 if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
2011 if ((st == NOTMUCH_STATUS_SUCCESS) && msg)
2013 notmuch_message_maildir_flags_to_tags(msg);
2027 notmuch_message_destroy(msg);
◆ nm_update_filename()
int nm_update_filename |
( |
struct Mailbox * |
m, |
|
|
const char * |
old_file, |
|
|
const char * |
new_file, |
|
|
struct Email * |
e |
|
) |
| |
Change the filename.
- Parameters
-
- Return values
-
Definition at line 1827 of file notmuch.c.
1832 if (!
mdata || !new_file)
◆ nm_url_from_query()
char* nm_url_from_query |
( |
struct Mailbox * |
m, |
|
|
char * |
buf, |
|
|
size_t |
buflen |
|
) |
| |
Turn a query into a URL.
- Parameters
-
- Return values
-
ptr | Query as a URL |
NULL | Error |
Definition at line 1677 of file notmuch.c.
1683 bool using_default_data =
false;
1694 using_default_data =
true;
1701 added = snprintf(url,
sizeof(url),
"%s%s?type=%s&query=",
NmUrlProtocol,
1706 added = snprintf(url,
sizeof(url),
"%s%s?type=%s&limit=%d&query=",
NmUrlProtocol,
1711 if (added >=
sizeof(url))
1720 buf[buflen - 1] =
'\0';
1722 if (using_default_data)
◆ MxNotmuchOps
struct MxOps MxNotmuchOps |
◆ C_NmQueryWindowCurrentSearch
char* C_NmQueryWindowCurrentSearch |
Config: (notmuch) Current search parameters.
Definition at line 44 of file config.c.
◆ C_NmQueryWindowDuration
int C_NmQueryWindowDuration |
Config: (notmuch) Time duration of the current search window.
Definition at line 45 of file config.c.
◆ C_VfolderFormat
Config: (notmuch) printf-like format string for the browser's display of virtual folders.
Definition at line 50 of file config.c.
◆ C_VirtualSpoolFile
Config: (notmuch) Use the first virtual mailbox as a spool file.
Definition at line 51 of file config.c.
void mutt_str_append_item(char **str, const char *item, char sep)
Add string to another separated by sep.
static int update_tags(notmuch_message_t *msg, const char *tags)
Update the tags on a message.
int C_NmQueryWindowCurrentPosition
Config: (notmuch) Position of current search window.
int nm_db_trans_begin(struct Mailbox *m)
Start a Notmuch database transaction.
@ NT_MAILBOX_INVALID
Email list was changed.
static struct Mailbox * get_default_mailbox(void)
Get Mailbox for notmuch without any parameters.
const char * nm_db_get_filename(struct Mailbox *m)
Get the filename of the Notmuch database.
int mutt_istr_remall(char *str, const char *target)
Remove all occurrences of substring, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
@ LL_DEBUG1
Log at debug level 1.
static notmuch_threads_t * get_threads(notmuch_query_t *query)
load threads for a query
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
static const char * query_type_to_string(enum NmQueryType query_type)
Turn a query type into a string.
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
static int get_limit(struct NmMboxData *mdata)
Get the database limit.
#define mutt_array_size(x)
static char * email_get_id(struct Email *e)
Get the unique Notmuch Id.
void nm_parse_type_from_query(struct NmMboxData *mdata, char *buf)
Parse a query type out of a query.
void url_pct_encode(char *buf, size_t buflen, const char *src)
Percent-encode a string.
static int rename_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Rename the file.
static char * get_query_string(struct NmMboxData *mdata, bool window)
builds the notmuch vfolder search string
void * mdata
Driver specific data.
static notmuch_message_t * get_nm_message(notmuch_database_t *db, struct Email *e)
Find a Notmuch message.
char * nm_email_get_folder(struct Email *e)
Get the folder for a Email.
int msg_count
Total number of messages.
char * C_NmRecordTags
Config: (notmuch) Tags to apply to the 'record' mailbox (sent mail)
struct timespec mtime
Time Mailbox was last changed.
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Notmuch-specific Account data -.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
int C_NmDbLimit
Config: (notmuch) Default limit for Notmuch queries.
@ NM_QUERY_TYPE_THREADS
Whole threads.
#define mutt_debug(LEVEL,...)
static notmuch_messages_t * get_messages(notmuch_query_t *query)
load messages for a query
int nm_db_trans_end(struct Mailbox *m)
End a database transaction.
int nm_db_release(struct Mailbox *m)
Close the Notmuch database.
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
const char NmUrlProtocol[]
static const struct Command nm_commands[]
notmuch_database_t * nm_db_get(struct Mailbox *m, bool writable)
Get the Notmuch database.
void nm_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free()
struct NmEmailData * nm_edata_get(struct Email *e)
Get the Notmuch Email data.
void * edata
Driver-specific data.
struct TagList tags
For drivers that support server tagging.
static void apply_exclude_tags(notmuch_query_t *query)
Exclude the configured tags.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
@ NM_QUERY_TYPE_MESGS
Default: Messages only.
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
void * adata
Private data (for Mailbox backends)
Notmuch-specific Mailbox data -.
Notmuch-specific Email data -.
static struct NmMboxData * nm_get_default_data(void)
Create a Mailbox with default Notmuch settings.
#define mutt_message(...)
int mutt_str_asprintf(char **strp, const char *fmt,...)
static bool read_threads_query(struct Mailbox *m, notmuch_query_t *q, bool dedup, int limit)
Perform a query with threads.
#define COMMANDS_REGISTER(cmds)
static char * email_get_fullpath(struct Email *e, char *buf, size_t buflen)
Get the full path of an email.
@ LL_DEBUG2
Log at debug level 2.
static void progress_reset(struct Mailbox *m)
Reset the progress counter.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)