NeoMutt  2024-12-12-19-ge4b57e
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mdata.h File Reference

Notmuch-specific Mailbox data. More...

#include <time.h>
#include "query.h"
+ Include dependency graph for mdata.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NmMboxData
 Notmuch-specific Mailbox data -. More...
 

Functions

void nm_mdata_free (void **ptr)
 Free the private Mailbox data - Implements Mailbox::mdata_free() -.
 
struct NmMboxDatanm_mdata_get (struct Mailbox *m)
 Get the Notmuch Mailbox data.
 
struct NmMboxDatanm_mdata_new (const char *url)
 Create a new NmMboxData object from a query.
 

Detailed Description

Notmuch-specific Mailbox data.

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

Function Documentation

◆ 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 96 of file mdata.c.

97{
98 if (!m || (m->type != MUTT_NOTMUCH))
99 return NULL;
100
101 return m->mdata;
102}
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
void * mdata
Driver specific data.
Definition: mailbox.h:132
+ 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 68 of file mdata.c.

69{
70 if (!url)
71 return NULL;
72
73 struct NmMboxData *mdata = MUTT_MEM_CALLOC(1, struct NmMboxData);
74 mutt_debug(LL_DEBUG1, "nm: initialize mailbox mdata %p\n", (void *) mdata);
75
76 const short c_nm_db_limit = cs_subset_number(NeoMutt->sub, "nm_db_limit");
77 const char *const c_nm_query_type = cs_subset_string(NeoMutt->sub, "nm_query_type");
78 mdata->db_limit = c_nm_db_limit;
79 mdata->query_type = nm_string_to_query_type(c_nm_query_type);
80 mdata->db_url = url_parse(url);
81 if (!mdata->db_url)
82 {
83 mutt_error(_("failed to parse notmuch url: %s"), url);
84 FREE(&mdata);
85 return NULL;
86 }
87 return mdata;
88}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:143
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
#define FREE(x)
Definition: memory.h:55
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
#define _(a)
Definition: message.h:28
enum NmQueryType nm_string_to_query_type(const char *str)
Lookup a query type.
Definition: query.c:110
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
Notmuch-specific Mailbox data -.
Definition: mdata.h:35
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:239
+ Here is the call graph for this function:
+ Here is the caller graph for this function: