NeoMutt  2025-09-05-70-gcfdde0
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
neomutt.h File Reference

Container for Accounts, Notifications. More...

#include <locale.h>
#include <stdbool.h>
#include <sys/types.h>
#include "account.h"
#include "command.h"
#include "mailbox.h"
+ Include dependency graph for neomutt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NeoMutt
 Container for Accounts, Notifications. More...
 

Macros

#define mutt_file_fopen_masked(PATH, MODE)
 

Enumerations

enum  NotifyGlobal { NT_GLOBAL_STARTUP = 1 , NT_GLOBAL_SHUTDOWN , NT_GLOBAL_COMMAND }
 Events not associated with an object. More...
 

Functions

bool neomutt_account_add (struct NeoMutt *n, struct Account *a)
 Add an Account to the global list.
 
void neomutt_account_remove (struct NeoMutt *n, const struct Account *a)
 Remove an Account from the global list.
 
void neomutt_accounts_free (struct NeoMutt *n)
 
void neomutt_free (struct NeoMutt **ptr)
 Free a NeoMutt.
 
struct NeoMuttneomutt_new (struct ConfigSet *cs)
 Create the main NeoMutt object.
 
struct MailboxArray neomutt_mailboxes_get (struct NeoMutt *n, enum MailboxType type)
 Get an Array of matching Mailboxes.
 

Variables

struct NeoMutt * NeoMutt
 Global NeoMutt object.
 

Detailed Description

Container for Accounts, Notifications.

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

Macro Definition Documentation

◆ mutt_file_fopen_masked

#define mutt_file_fopen_masked ( PATH,
MODE )
Value:
mutt_file_fopen_masked_full(PATH, MODE, __FILE__, __LINE__, __func__)
FILE * mutt_file_fopen_masked_full(const char *path, const char *mode, const char *file, int line, const char *func)
Wrapper around mutt_file_fopen_full()
Definition neomutt.c:221
#define PATH

Definition at line 80 of file neomutt.h.

Enumeration Type Documentation

◆ NotifyGlobal

Events not associated with an object.

Observers of NT_GLOBAL will not be passed any Event data.

Enumerator
NT_GLOBAL_STARTUP 

NeoMutt is initialised.

NT_GLOBAL_SHUTDOWN 

NeoMutt is about to close.

NT_GLOBAL_COMMAND 

A NeoMutt command.

Definition at line 64 of file neomutt.h.

65{
69};
@ NT_GLOBAL_STARTUP
NeoMutt is initialised.
Definition neomutt.h:66
@ NT_GLOBAL_COMMAND
A NeoMutt command.
Definition neomutt.h:68
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition neomutt.h:67

Function Documentation

◆ neomutt_account_add()

bool neomutt_account_add ( struct NeoMutt * n,
struct Account * a )

Add an Account to the global list.

Parameters
nNeoMutt
aAccount to add
Return values
trueAccount was added

Definition at line 114 of file neomutt.c.

115{
116 if (!n || !a)
117 return false;
118
119 ARRAY_ADD(&n->accounts, a);
121
122 mutt_debug(LL_NOTIFY, "NT_ACCOUNT_ADD: %s %p\n",
123 mailbox_get_type_name(a->type), (void *) a);
124 struct EventAccount ev_a = { a };
126 return true;
127}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:156
@ NT_ACCOUNT_ADD
Account has been added.
Definition account.h:67
const char * mailbox_get_type_name(enum MailboxType type)
Get the type of a Mailbox.
Definition mailbox.c:324
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:49
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
@ NT_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition notify_type.h:36
enum MailboxType type
Type of Mailboxes this Account contains.
Definition account.h:37
struct Notify * notify
Notifications: NotifyAccount, EventAccount.
Definition account.h:41
An Event that happened to an Account.
Definition account.h:77
struct AccountArray accounts
All Accounts.
Definition neomutt.h:47
struct Notify * notify
Notifications handler.
Definition neomutt.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_account_remove()

void neomutt_account_remove ( struct NeoMutt * n,
const struct Account * a )

Remove an Account from the global list.

Parameters
nNeoMutt
aAccount to remove

Definition at line 134 of file neomutt.c.

135{
136 if (!n || !a || ARRAY_EMPTY(&n->accounts))
137 return;
138
139 struct Account **ap = NULL;
140 ARRAY_FOREACH(ap, &n->accounts)
141 {
142 if ((*ap) != a)
143 continue;
144
145 ARRAY_REMOVE(&n->accounts, ap);
146 account_free(ap);
147 break;
148 }
149}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:323
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:214
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
void account_free(struct Account **ptr)
Free an Account.
Definition account.c:148
A group of associated Mailboxes.
Definition account.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_accounts_free()

void neomutt_accounts_free ( struct NeoMutt * n)
  • Free all the Accounts
    Parameters
    nNeoMutt

Definition at line 155 of file neomutt.c.

156{
157 if (!n)
158 return;
159
160 if (!ARRAY_EMPTY(&n->accounts))
161 {
162 mutt_debug(LL_NOTIFY, "NT_ACCOUNT_DELETE_ALL\n");
163 struct EventAccount ev_a = { NULL };
165
166 struct Account **ap = NULL;
167 ARRAY_FOREACH(ap, &n->accounts)
168 {
169 account_free(ap);
170 }
171 }
172
173 ARRAY_FREE(&n->accounts);
174}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:204
@ NT_ACCOUNT_DELETE_ALL
All Accounts are about to be deleted.
Definition account.h:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_free()

void neomutt_free ( struct NeoMutt ** ptr)

Free a NeoMutt.

Parameters
[out]ptrNeoMutt to free

Definition at line 85 of file neomutt.c.

86{
87 if (!ptr || !*ptr)
88 return;
89
90 struct NeoMutt *n = *ptr;
91
97 if (n->time_c_locale)
98 freelocale(n->time_c_locale);
99
100 FREE(&n->home_dir);
101 FREE(&n->username);
102
103 envlist_free(&n->env);
104
105 FREE(ptr);
106}
void envlist_free(char ***envp)
Free the private copy of the environment.
Definition envlist.c:42
#define FREE(x)
Definition memory.h:62
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
void neomutt_accounts_free(struct NeoMutt *n)
Definition neomutt.c:155
Container for Accounts, Notifications.
Definition neomutt.h:42
struct Notify * notify_timeout
Timeout notifications handler.
Definition neomutt.h:45
struct Notify * notify_resize
Window resize notifications handler.
Definition neomutt.h:44
char ** env
Private copy of the environment variables.
Definition neomutt.h:54
char * username
User's login name.
Definition neomutt.h:53
char * home_dir
User's home directory.
Definition neomutt.h:52
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:46
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition neomutt.h:48
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition subset.c:112
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_new()

struct NeoMutt * neomutt_new ( struct ConfigSet * cs)

Create the main NeoMutt object.

Parameters
csConfig Set
Return values
ptrNew NeoMutt

Definition at line 49 of file neomutt.c.

50{
51 if (!cs)
52 return NULL;
53
54 struct NeoMutt *n = MUTT_MEM_CALLOC(1, struct NeoMutt);
55
57 n->notify = notify_new();
58 n->sub = cs_subset_new(NULL, NULL, n->notify);
59 n->sub->cs = cs;
61
62 n->time_c_locale = duplocale(LC_GLOBAL_LOCALE);
63 if (n->time_c_locale)
64 n->time_c_locale = newlocale(LC_TIME_MASK, "C", n->time_c_locale);
65
66 if (!n->time_c_locale)
67 {
68 mutt_error("%s", strerror(errno)); // LCOV_EXCL_LINE
69 mutt_exit(1); // LCOV_EXCL_LINE
70 }
71
74
77
78 return n;
79}
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition exit.c:41
#define mutt_error(...)
Definition logging2.h:93
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:47
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
struct ConfigSet * cs
Parent ConfigSet.
Definition subset.h:50
enum ConfigScope scope
Scope of Subset, e.g. SET_SCOPE_ACCOUNT.
Definition subset.h:48
struct ConfigSubset * cs_subset_new(const char *name, struct ConfigSubset *sub_parent, struct Notify *not_parent)
Create a new Config Subset.
Definition subset.c:158
@ SET_SCOPE_NEOMUTT
This Config is NeoMutt-specific (global)
Definition subset.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_mailboxes_get()

struct MailboxArray neomutt_mailboxes_get ( struct NeoMutt * n,
enum MailboxType type )

Get an Array of matching Mailboxes.

Parameters
nNeoMutt
typeType of Account to match, see MailboxType
Return values
objArray of Mailboxes
Note
If type is MUTT_MAILBOX_ANY then all Mailbox types will be matched

Definition at line 184 of file neomutt.c.

185{
186 struct MailboxArray ma = ARRAY_HEAD_INITIALIZER;
187
188 if (!n)
189 return ma;
190
191 struct Account **ap = NULL;
192 struct Mailbox **mp = NULL;
193
194 ARRAY_FOREACH(ap, &n->accounts)
195 {
196 struct Account *a = *ap;
197 if ((type > MUTT_UNKNOWN) && (a->type != type))
198 continue;
199
200 ARRAY_FOREACH(mp, &a->mailboxes)
201 {
202 ARRAY_ADD(&ma, *mp);
203 }
204 }
205
206 return ma;
207}
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:44
struct MailboxArray mailboxes
All Mailboxes.
Definition account.h:40
A mailbox.
Definition mailbox.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ NeoMutt

struct NeoMutt* NeoMutt
extern

Global NeoMutt object.

Definition at line 42 of file neomutt.c.