NeoMutt  2020-09-25
Teaching an old dog new tricks
DOXYGEN
private.h File Reference

Notmuch private types. More...

#include <notmuch.h>
#include <stdbool.h>
#include <time.h>
#include "core/lib.h"
#include "progress.h"
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NmAccountData
 Notmuch-specific Account data -. More...
 
struct  NmMboxData
 Notmuch-specific Mailbox data -. More...
 
struct  NmEmailData
 Notmuch-specific Email data -. More...
 

Macros

#define LIBNOTMUCH_CHECK_VERSION(major, minor, micro)
 

Enumerations

enum  NmQueryType { NM_QUERY_TYPE_MESGS = 1, NM_QUERY_TYPE_THREADS }
 Notmuch Query Types. More...
 

Functions

notmuch_database_t * nm_db_do_open (const char *filename, bool writable, bool verbose)
 Open a Notmuch database. More...
 
void nm_db_free (notmuch_database_t *db)
 decoupled way to close a Notmuch database More...
 
const char * nm_db_get_filename (struct Mailbox *m)
 Get the filename of the Notmuch database. More...
 
int nm_db_get_mtime (struct Mailbox *m, time_t *mtime)
 Get the database modification time. More...
 
notmuch_database_t * nm_db_get (struct Mailbox *m, bool writable)
 Get the Notmuch database. More...
 
bool nm_db_is_longrun (struct Mailbox *m)
 Is Notmuch in the middle of a long-running transaction. More...
 
int nm_db_release (struct Mailbox *m)
 Close the Notmuch database. More...
 
int nm_db_trans_begin (struct Mailbox *m)
 Start a Notmuch database transaction. More...
 
int nm_db_trans_end (struct Mailbox *m)
 End a database transaction. More...
 
void nm_adata_free (void **ptr)
 Free the private Account data - Implements Account::adata_free() More...
 
struct NmAccountDatanm_adata_get (struct Mailbox *m)
 Get the Notmuch Account data. More...
 
struct NmAccountDatanm_adata_new (void)
 Allocate and initialise a new NmAccountData structure. More...
 
void nm_edata_free (void **ptr)
 Free data attached to an Email. More...
 
struct NmEmailDatanm_edata_get (struct Email *e)
 Get the Notmuch Email data. More...
 
struct NmEmailDatanm_edata_new (void)
 Create a new NmEmailData for an email. More...
 
void nm_mdata_free (void **ptr)
 Free the private Mailbox data - Implements Mailbox::mdata_free() More...
 
struct NmMboxDatanm_mdata_get (struct Mailbox *m)
 Get the Notmuch Mailbox data. More...
 
struct NmMboxDatanm_mdata_new (const char *url)
 Create a new NmMboxData object from a query. More...
 

Variables

const int NmUrlProtocolLen
 
int C_NmDbLimit
 Config: (notmuch) Default limit for Notmuch queries. More...
 
char * C_NmDefaultUrl
 Config: (notmuch) Path to the Notmuch database. More...
 
char * C_NmExcludeTags
 Config: (notmuch) Exclude messages with these tags. More...
 
char * C_NmFlaggedTag
 Config: (notmuch) Tag to use for flagged messages. More...
 
int C_NmOpenTimeout
 Config: (notmuch) Database timeout. More...
 
char * C_NmQueryType
 Config: (notmuch) Default query type: 'threads' or 'messages'. More...
 
int C_NmQueryWindowCurrentPosition
 Config: (notmuch) Position of current search window. More...
 
char * C_NmQueryWindowTimebase
 Config: (notmuch) Units for the time duration. More...
 
char * C_NmRecordTags
 Config: (notmuch) Tags to apply to the 'record' mailbox (sent mail) More...
 
char * C_NmRepliedTag
 Config: (notmuch) Tag to use for replied messages. More...
 
char * C_NmUnreadTag
 Config: (notmuch) Tag to use for unread messages. More...
 

Detailed Description

Notmuch private types.

Authors
  • Richard Russon

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 private.h.

Macro Definition Documentation

◆ LIBNOTMUCH_CHECK_VERSION

#define LIBNOTMUCH_CHECK_VERSION (   major,
  minor,
  micro 
)
Value:
(LIBNOTMUCH_MAJOR_VERSION > (major) || \
(LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION > (minor)) || \
(LIBNOTMUCH_MAJOR_VERSION == (major) && \
LIBNOTMUCH_MINOR_VERSION == (minor) && LIBNOTMUCH_MICRO_VERSION >= (micro)))

Definition at line 37 of file private.h.

Enumeration Type Documentation

◆ NmQueryType

Notmuch Query Types.

Read whole-thread or matching messages only?

Enumerator
NM_QUERY_TYPE_MESGS 

Default: Messages only.

NM_QUERY_TYPE_THREADS 

Whole threads.

Definition at line 60 of file private.h.

61 {
64 };
Default: Messages only.
Definition: private.h:62
Whole threads.
Definition: private.h:63

Function Documentation

◆ nm_db_do_open()

notmuch_database_t* nm_db_do_open ( const char *  filename,
bool  writable,
bool  verbose 
)

Open a Notmuch database.

Parameters
filenameDatabase filename
writableRead/write?
verboseShow errors on failure?
Return values
ptrNotmuch database

Definition at line 83 of file db.c.

84 {
85  notmuch_database_t *db = NULL;
86  int ct = 0;
87  notmuch_status_t st = NOTMUCH_STATUS_SUCCESS;
88 #if LIBNOTMUCH_CHECK_VERSION(4, 2, 0)
89  char *msg = NULL;
90 #endif
91 
92  mutt_debug(LL_DEBUG1, "nm: db open '%s' %s (timeout %d)\n", filename,
93  writable ? "[WRITE]" : "[READ]", C_NmOpenTimeout);
94 
95  const notmuch_database_mode_t mode =
96  writable ? NOTMUCH_DATABASE_MODE_READ_WRITE : NOTMUCH_DATABASE_MODE_READ_ONLY;
97 
98  do
99  {
100 #if LIBNOTMUCH_CHECK_VERSION(4, 2, 0)
101  st = notmuch_database_open_verbose(filename, mode, &db, &msg);
102 #elif defined(NOTMUCH_API_3)
103  st = notmuch_database_open(filename, mode, &db);
104 #else
105  db = notmuch_database_open(filename, mode);
106 #endif
107  if ((st == NOTMUCH_STATUS_FILE_ERROR) || db || !C_NmOpenTimeout || ((ct / 2) > C_NmOpenTimeout))
108  break;
109 
110  if (verbose && ct && ((ct % 2) == 0))
111  mutt_error(_("Waiting for notmuch DB... (%d sec)"), ct / 2);
112  mutt_date_sleep_ms(500000); /* Half a second */
113  ct++;
114  } while (true);
115 
116  if (verbose)
117  {
118  if (!db)
119  {
120 #if LIBNOTMUCH_CHECK_VERSION(4, 2, 0)
121  if (msg)
122  {
123  mutt_error(msg);
124  FREE(&msg);
125  }
126  else
127 #endif
128  {
129  mutt_error(_("Can't open notmuch database: %s: %s"), filename,
130  st ? notmuch_status_to_string(st) : _("unknown reason"));
131  }
132  }
133  else if (ct > 1)
134  {
136  }
137  }
138  return db;
139 }
int C_NmOpenTimeout
Config: (notmuch) Database timeout.
Definition: config.c:41
#define _(a)
Definition: message.h:28
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
Log at debug level 1.
Definition: logging.h:40
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
void mutt_date_sleep_ms(size_t ms)
Sleep for milliseconds.
Definition: date.c:693
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_free()

void nm_db_free ( notmuch_database_t *  db)

decoupled way to close a Notmuch database

Parameters
dbNotmuch database

Definition at line 188 of file db.c.

189 {
190 #ifdef NOTMUCH_API_3
191  notmuch_database_destroy(db);
192 #else
193  notmuch_database_close(db);
194 #endif
195 }
+ Here is the caller graph for this function:

◆ nm_db_get_filename()

const char* nm_db_get_filename ( struct Mailbox m)

Get the filename of the Notmuch database.

Parameters
mMailbox
Return values
ptrFilename
Note
The return value is a pointer into the C_NmDefaultUrl global variable. If that variable changes, the result will be invalid. It must not be freed.

Definition at line 53 of file db.c.

54 {
55  struct NmMboxData *mdata = nm_mdata_get(m);
56  char *db_filename = NULL;
57 
58  if (mdata && mdata->db_url && mdata->db_url->path)
59  db_filename = mdata->db_url->path;
60  else
61  db_filename = C_NmDefaultUrl;
62 
63  if (!db_filename && !C_Folder)
64  return NULL;
65 
66  if (!db_filename)
67  db_filename = C_Folder;
68 
69  if (nm_path_probe(db_filename, NULL) == MUTT_NOTMUCH)
70  db_filename += NmUrlProtocolLen;
71 
72  mutt_debug(LL_DEBUG2, "nm: db filename '%s'\n", db_filename);
73  return db_filename;
74 }
Log at debug level 2.
Definition: logging.h:41
Notmuch-specific Mailbox data -.
Definition: private.h:69
char * C_NmDefaultUrl
Config: (notmuch) Path to the Notmuch database.
Definition: config.c:38
void * mdata
Driver specific data.
Definition: mailbox.h:136
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: mutt_globals.h:96
enum MailboxType nm_path_probe(const char *path, const struct stat *st)
Is this a Notmuch Mailbox? - Implements MxOps::path_probe()
Definition: notmuch.c:2610
struct Url * db_url
Parsed view url of the Notmuch database.
Definition: private.h:71
char * path
Path.
Definition: url.h:73
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
Definition: notmuch.c:235
const int NmUrlProtocolLen
Definition: notmuch.c:82
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_get_mtime()

int nm_db_get_mtime ( struct Mailbox m,
time_t *  mtime 
)

Get the database modification time.

Parameters
[in]mMailbox
[out]mtimeSave the modification time
Return values
0Success (result in mtime)
-1Error

Get the "mtime" (modification time) of the database file. This is the time of the last update.

Definition at line 253 of file db.c.

254 {
255  if (!m || !mtime)
256  return -1;
257 
258  char path[PATH_MAX];
259  snprintf(path, sizeof(path), "%s/.notmuch/xapian", nm_db_get_filename(m));
260  mutt_debug(LL_DEBUG2, "nm: checking '%s' mtime\n", path);
261 
262  struct stat st;
263  if (stat(path, &st) != 0)
264  return -1;
265 
266  *mtime = st.st_mtime;
267  return 0;
268 }
struct timespec mtime
Time Mailbox was last changed.
Definition: mailbox.h:107
Log at debug level 2.
Definition: logging.h:41
#define PATH_MAX
Definition: mutt.h:44
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
const char * nm_db_get_filename(struct Mailbox *m)
Get the filename of the Notmuch database.
Definition: db.c:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_get()

notmuch_database_t* nm_db_get ( struct Mailbox m,
bool  writable 
)

Get the Notmuch database.

Parameters
mMailbox
writableRead/write?
Return values
ptrNotmuch database

Definition at line 147 of file db.c.

148 {
149  struct NmAccountData *adata = nm_adata_get(m);
150 
151  if (!adata)
152  return NULL;
153 
154  // Use an existing open db if we have one.
155  if (adata->db)
156  return adata->db;
157 
158  const char *db_filename = nm_db_get_filename(m);
159  if (db_filename)
160  adata->db = nm_db_do_open(db_filename, writable, true);
161 
162  return adata->db;
163 }
notmuch_database_t * nm_db_do_open(const char *filename, bool writable, bool verbose)
Open a Notmuch database.
Definition: db.c:83
notmuch_database_t * db
Definition: private.h:50
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: notmuch.c:168
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
Notmuch-specific Account data -.
Definition: private.h:48
const char * nm_db_get_filename(struct Mailbox *m)
Get the filename of the Notmuch database.
Definition: db.c:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_is_longrun()

bool nm_db_is_longrun ( struct Mailbox m)

Is Notmuch in the middle of a long-running transaction.

Parameters
mMailbox
Return values
trueif it is

Definition at line 275 of file db.c.

276 {
277  struct NmAccountData *adata = nm_adata_get(m);
278  if (!adata)
279  return false;
280 
281  return adata->longrun;
282 }
bool longrun
A long-lived action is in progress.
Definition: private.h:51
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: notmuch.c:168
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_release()

int nm_db_release ( struct Mailbox m)

Close the Notmuch database.

Parameters
mMailbox
Return values
0Success
-1Failure

Definition at line 171 of file db.c.

172 {
173  struct NmAccountData *adata = nm_adata_get(m);
174  if (!adata || !adata->db || nm_db_is_longrun(m))
175  return -1;
176 
177  mutt_debug(LL_DEBUG1, "nm: db close\n");
178  nm_db_free(adata->db);
179  adata->db = NULL;
180  adata->longrun = false;
181  return 0;
182 }
bool longrun
A long-lived action is in progress.
Definition: private.h:51
notmuch_database_t * db
Definition: private.h:50
bool nm_db_is_longrun(struct Mailbox *m)
Is Notmuch in the middle of a long-running transaction.
Definition: db.c:275
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: notmuch.c:168
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void nm_db_free(notmuch_database_t *db)
decoupled way to close a Notmuch database
Definition: db.c:188
Log at debug level 1.
Definition: logging.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_trans_begin()

int nm_db_trans_begin ( struct Mailbox m)

Start a Notmuch database transaction.

Parameters
mMailbox
Return values
<0error
1new transaction started
0already within transaction

Definition at line 204 of file db.c.

205 {
206  struct NmAccountData *adata = nm_adata_get(m);
207  if (!adata || !adata->db)
208  return -1;
209 
210  if (adata->trans)
211  return 0;
212 
213  mutt_debug(LL_DEBUG2, "nm: db trans start\n");
214  if (notmuch_database_begin_atomic(adata->db))
215  return -1;
216  adata->trans = true;
217  return 1;
218 }
notmuch_database_t * db
Definition: private.h:50
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: notmuch.c:168
Log at debug level 2.
Definition: logging.h:41
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool trans
Atomic transaction in progress.
Definition: private.h:52
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_trans_end()

int nm_db_trans_end ( struct Mailbox m)

End a database transaction.

Parameters
mMailbox
Return values
0Success
-1Failure

Definition at line 226 of file db.c.

227 {
228  struct NmAccountData *adata = nm_adata_get(m);
229  if (!adata || !adata->db)
230  return -1;
231 
232  if (!adata->trans)
233  return 0;
234 
235  mutt_debug(LL_DEBUG2, "nm: db trans end\n");
236  adata->trans = false;
237  if (notmuch_database_end_atomic(adata->db))
238  return -1;
239 
240  return 0;
241 }
notmuch_database_t * db
Definition: private.h:50
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: notmuch.c:168
Log at debug level 2.
Definition: logging.h:41
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
bool trans
Atomic transaction in progress.
Definition: private.h:52
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_adata_free()

void nm_adata_free ( void **  ptr)

Free the private Account data - Implements Account::adata_free()

Definition at line 136 of file notmuch.c.

137 {
138  if (!ptr || !*ptr)
139  return;
140 
141  struct NmAccountData *adata = *ptr;
142  if (adata->db)
143  {
144  nm_db_free(adata->db);
145  adata->db = NULL;
146  }
147 
148  FREE(ptr);
149 }
notmuch_database_t * db
Definition: private.h:50
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void nm_db_free(notmuch_database_t *db)
decoupled way to close a Notmuch database
Definition: db.c:188
#define FREE(x)
Definition: memory.h:40
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_adata_get()

struct NmAccountData* nm_adata_get ( struct Mailbox m)

Get the Notmuch Account data.

Parameters
mMailbox
Return values
ptrSuccess
NULLFailure, not a Notmuch mailbox

Definition at line 168 of file notmuch.c.

169 {
170  if (!m || (m->type != MUTT_NOTMUCH))
171  return NULL;
172 
173  struct Account *a = m->account;
174  if (!a)
175  return NULL;
176 
177  return a->adata;
178 }
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
A group of associated Mailboxes.
Definition: account.h:36
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
+ Here is the caller graph for this function:

◆ nm_adata_new()

struct NmAccountData* nm_adata_new ( void  )

Allocate and initialise a new NmAccountData structure.

Return values
ptrNew NmAccountData

Definition at line 155 of file notmuch.c.

156 {
157  struct NmAccountData *adata = mutt_mem_calloc(1, sizeof(struct NmAccountData));
158 
159  return adata;
160 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
Notmuch-specific Account data -.
Definition: private.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_edata_free()

void nm_edata_free ( void **  ptr)

Free data attached to an Email.

Parameters
[out]ptrEmail data

Each email has an attached NmEmailData, which contains things like the tags (labels).

Definition at line 250 of file notmuch.c.

251 {
252  if (!ptr || !*ptr)
253  return;
254 
255  struct NmEmailData *edata = *ptr;
256 
257  mutt_debug(LL_DEBUG2, "nm: freeing email %p\n", (void *) edata);
258  FREE(&edata->folder);
259  FREE(&edata->oldpath);
260  FREE(&edata->virtual_id);
261 
262  FREE(ptr);
263 }
char * oldpath
Definition: private.h:90
Log at debug level 2.
Definition: logging.h:41
char * virtual_id
Unique Notmuch Id.
Definition: private.h:91
char * folder
Location of the Email.
Definition: private.h:89
Notmuch-specific Email data -.
Definition: private.h:87
void * edata
Driver-specific data.
Definition: email.h:111
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81

◆ nm_edata_get()

struct NmEmailData* nm_edata_get ( struct Email e)

Get the Notmuch Email data.

Parameters
eEmail
Return values
ptrSuccess
NULLError

Definition at line 280 of file notmuch.c.

281 {
282  if (!e)
283  return NULL;
284 
285  return e->nm_edata;
286 }
void * nm_edata
Notmuch private data.
Definition: email.h:106
+ Here is the caller graph for this function:

◆ nm_edata_new()

struct NmEmailData* nm_edata_new ( void  )

Create a new NmEmailData for an email.

Return values
ptrNew NmEmailData struct

Definition at line 269 of file notmuch.c.

270 {
271  return mutt_mem_calloc(1, sizeof(struct NmEmailData));
272 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
Notmuch-specific Email data -.
Definition: private.h:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_mdata_free()

void nm_mdata_free ( void **  ptr)

Free the private Mailbox data - Implements Mailbox::mdata_free()

The NmMboxData struct stores global Notmuch data, such as the connection to the database. This function will close the database, free the resources and the struct itself.

Definition at line 187 of file notmuch.c.

188 {
189  if (!ptr || !*ptr)
190  return;
191 
192  struct NmMboxData *mdata = *ptr;
193 
194  mutt_debug(LL_DEBUG1, "nm: freeing context data %p\n", mdata);
195 
196  url_free(&mdata->db_url);
197  FREE(&mdata->db_query);
198  FREE(ptr);
199 }
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
Notmuch-specific Mailbox data -.
Definition: private.h:69
void * mdata
Driver specific data.
Definition: mailbox.h:136
char * db_query
Previous query.
Definition: private.h:72
struct Url * db_url
Parsed view url of the Notmuch database.
Definition: private.h:71
Log at debug level 1.
Definition: logging.h:40
#define FREE(x)
Definition: memory.h:40
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_mdata_get()

struct NmMboxData* nm_mdata_get ( struct Mailbox m)

Get the Notmuch Mailbox data.

Parameters
mMailbox
Return values
ptrSuccess
NULLFailure, not a Notmuch mailbox

Definition at line 235 of file notmuch.c.

236 {
237  if (!m || (m->type != MUTT_NOTMUCH))
238  return NULL;
239 
240  return m->mdata;
241 }
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
void * mdata
Driver specific data.
Definition: mailbox.h:136
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
+ Here is the caller graph for this function:

◆ nm_mdata_new()

struct NmMboxData* nm_mdata_new ( const char *  url)

Create a new NmMboxData object from a query.

Parameters
urlNotmuch query string
Return values
ptrNew NmMboxData struct

A new NmMboxData struct is created, then the query is parsed and saved within it. This should be freed using nm_mdata_free().

Definition at line 209 of file notmuch.c.

210 {
211  if (!url)
212  return NULL;
213 
214  struct NmMboxData *mdata = mutt_mem_calloc(1, sizeof(struct NmMboxData));
215  mutt_debug(LL_DEBUG1, "nm: initialize mailbox mdata %p\n", (void *) mdata);
216 
217  mdata->db_limit = C_NmDbLimit;
219  mdata->db_url = url_parse(url);
220  if (!mdata->db_url)
221  {
222  mutt_error(_("failed to parse notmuch url: %s"), url);
223  FREE(&mdata);
224  return NULL;
225  }
226  return mdata;
227 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
static enum NmQueryType string_to_query_type(const char *str)
Lookup a query type.
Definition: notmuch.c:122
#define _(a)
Definition: message.h:28
Notmuch-specific Mailbox data -.
Definition: private.h:69
void * mdata
Driver specific data.
Definition: mailbox.h:136
struct Url * db_url
Parsed view url of the Notmuch database.
Definition: private.h:71
int C_NmDbLimit
Config: (notmuch) Default limit for Notmuch queries.
Definition: config.c:37
Log at debug level 1.
Definition: logging.h:40
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
char * C_NmQueryType
Config: (notmuch) Default query type: &#39;threads&#39; or &#39;messages&#39;.
Definition: config.c:42
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
enum NmQueryType query_type
Messages or Threads.
Definition: private.h:74
int db_limit
Maximum number of results to return.
Definition: private.h:73
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ NmUrlProtocolLen

const int NmUrlProtocolLen

Definition at line 82 of file notmuch.c.

◆ C_NmDbLimit

int C_NmDbLimit

Config: (notmuch) Default limit for Notmuch queries.

Definition at line 37 of file config.c.

◆ C_NmDefaultUrl

char* C_NmDefaultUrl

Config: (notmuch) Path to the Notmuch database.

Definition at line 38 of file config.c.

◆ C_NmExcludeTags

char* C_NmExcludeTags

Config: (notmuch) Exclude messages with these tags.

Definition at line 39 of file config.c.

◆ C_NmFlaggedTag

char* C_NmFlaggedTag

Config: (notmuch) Tag to use for flagged messages.

Definition at line 40 of file config.c.

◆ C_NmOpenTimeout

int C_NmOpenTimeout

Config: (notmuch) Database timeout.

Definition at line 41 of file config.c.

◆ C_NmQueryType

char* C_NmQueryType

Config: (notmuch) Default query type: 'threads' or 'messages'.

Definition at line 42 of file config.c.

◆ C_NmQueryWindowCurrentPosition

int C_NmQueryWindowCurrentPosition

Config: (notmuch) Position of current search window.

Definition at line 43 of file config.c.

◆ C_NmQueryWindowTimebase

char* C_NmQueryWindowTimebase

Config: (notmuch) Units for the time duration.

Definition at line 46 of file config.c.

◆ C_NmRecordTags

char* C_NmRecordTags

Config: (notmuch) Tags to apply to the 'record' mailbox (sent mail)

Definition at line 47 of file config.c.

◆ C_NmRepliedTag

char* C_NmRepliedTag

Config: (notmuch) Tag to use for replied messages.

Definition at line 48 of file config.c.

◆ C_NmUnreadTag

char* C_NmUnreadTag

Config: (notmuch) Tag to use for unread messages.

Definition at line 49 of file config.c.