NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
mdata.c
Go to the documentation of this file.
1
22
28
29
#include "config.h"
30
#include "
mutt/lib.h
"
31
#include "
config/lib.h
"
32
#include "
email/lib.h
"
33
#include "
core/lib.h
"
34
#include "
mdata.h
"
35
#include "
progress/lib.h
"
36
#include "
query.h
"
37
45
void
nm_mdata_free
(
void
**ptr)
46
{
47
if
(!ptr || !*ptr)
48
return
;
49
50
struct
NmMboxData
*
mdata
= *ptr;
51
52
mutt_debug
(
LL_DEBUG1
,
"nm: freeing context data %p\n"
, (
void
*)
mdata
);
53
54
url_free
(&
mdata
->db_url);
55
FREE
(&
mdata
->db_query);
56
progress_free
(&
mdata
->progress);
57
FREE
(ptr);
58
}
59
68
struct
NmMboxData
*
nm_mdata_new
(
const
char
*url)
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
enum
NmQueryType
c_nm_query_type =
cs_subset_enum
(
NeoMutt
->
sub
,
"nm_query_type"
);
78
mdata
->db_limit = c_nm_db_limit;
79
mdata
->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
}
89
96
struct
NmMboxData
*
nm_mdata_get
(
struct
Mailbox
*m)
97
{
98
if
(!m || (m->
type
!=
MUTT_NOTMUCH
))
99
return
NULL;
100
101
return
m->
mdata
;
102
}
cs_subset_enum
unsigned char cs_subset_enum(const struct ConfigSubset *sub, const char *name)
Get a enumeration config item by name.
Definition
helpers.c:71
cs_subset_number
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition
helpers.c:143
lib.h
Convenience wrapper for the config headers.
lib.h
Convenience wrapper for the core headers.
MUTT_NOTMUCH
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition
mailbox.h:50
lib.h
Structs that make up an email.
mutt_error
#define mutt_error(...)
Definition
logging2.h:94
mutt_debug
#define mutt_debug(LEVEL,...)
Definition
logging2.h:91
nm_mdata_free
void nm_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free() -.
Definition
mdata.c:45
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition
logging2.h:45
FREE
#define FREE(x)
Free memory and set the pointer to NULL.
Definition
memory.h:68
MUTT_MEM_CALLOC
#define MUTT_MEM_CALLOC(n, type)
Definition
memory.h:52
lib.h
Convenience wrapper for the library headers.
_
#define _(a)
Definition
message.h:28
nm_mdata_new
struct NmMboxData * nm_mdata_new(const char *url)
Create a new NmMboxData object from a query.
Definition
mdata.c:68
nm_mdata_get
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
Definition
mdata.c:96
mdata.h
Notmuch-specific Mailbox data.
lib.h
Progress Bar.
progress_free
void progress_free(struct Progress **ptr)
Free a Progress Bar.
Definition
progress.c:110
query.h
Notmuch query functions.
NmQueryType
NmQueryType
Notmuch Query Types.
Definition
query.h:35
Mailbox
A mailbox.
Definition
mailbox.h:81
Mailbox::type
enum MailboxType type
Mailbox type.
Definition
mailbox.h:104
Mailbox::mdata
void * mdata
Driver specific data.
Definition
mailbox.h:134
NeoMutt
Container for Accounts, Notifications.
Definition
neomutt.h:41
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition
neomutt.h:49
NmMboxData
Notmuch-specific Mailbox data -.
Definition
mdata.h:35
url_parse
struct Url * url_parse(const char *src)
Fill in Url.
Definition
url.c:242
url_free
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition
url.c:124