NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
module.c
Go to the documentation of this file.
1
22
28
29#include "config.h"
30#include <stdbool.h>
31#include <stddef.h>
32#include "mutt/lib.h"
33#include "address/lib.h"
34#include "config/lib.h"
35#include "core/lib.h"
36#include "alias.h"
37#include "module_data.h"
38#include "reverse.h"
39
40extern struct ConfigDef AliasVars[];
41
42extern const struct Command AliasCommands[];
43
47static bool alias_init(struct NeoMutt *n)
48{
49 struct AliasModuleData *mod_data = MUTT_MEM_CALLOC(1, struct AliasModuleData);
51
52 mod_data->notify = notify_new();
53 notify_set_parent(mod_data->notify, n->notify);
54
55 STAILQ_INIT(&mod_data->alternates);
56 STAILQ_INIT(&mod_data->unalternates);
57
58 mod_data->alternates_notify = notify_new();
60
61 ARRAY_INIT(&mod_data->aliases);
63
64 mod_data->groups = groups_new();
65
66 mod_data->auto_subscribe_cache = NULL;
67 STAILQ_INIT(&mod_data->mail);
68 STAILQ_INIT(&mod_data->subscribed);
69 STAILQ_INIT(&mod_data->unmail);
70 STAILQ_INIT(&mod_data->unsubscribed);
71
72 return true;
73}
74
78static bool alias_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
79{
81}
82
86static bool alias_commands_register(struct NeoMutt *n, struct CommandArray *ca)
87{
89}
90
94static bool alias_cleanup(struct NeoMutt *n, void *data)
95{
96 struct AliasModuleData *mod_data = data;
97
98 notify_free(&mod_data->notify);
100
103
104 struct Alias **ap = NULL;
105 ARRAY_FOREACH(ap, &mod_data->aliases)
106 {
108 }
109 aliaslist_clear(&mod_data->aliases);
110
112
113 groups_free(&mod_data->groups);
114
116 mutt_regexlist_free(&mod_data->mail);
118 mutt_regexlist_free(&mod_data->unmail);
120
121 FREE(&mod_data);
122 return true;
123}
124
128const struct Module ModuleAlias = {
130 "alias",
132 NULL, // config_define_types
135 NULL, // gui_init
136 NULL, // gui_cleanup
138};
struct HashTable * groups_new(void)
Create a HashTable for the Address Groups.
Definition group.c:267
void groups_free(struct HashTable **pptr)
Free Address Groups HashTable.
Definition group.c:280
Email Address Handling.
const struct Command AliasCommands[]
Alias Commands.
Definition commands.c:361
struct ConfigDef AliasVars[]
Config definitions for the alias library.
Definition config.c:112
void alias_cleanup(void)
void alias_init(void)
static bool alias_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:86
static bool alias_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:78
const struct Module ModuleAlias
Module for the Alias library.
Definition module.c:128
Alias private Module data.
void aliaslist_clear(struct AliasArray *aa)
Empty a List of Aliases.
Definition alias.c:698
Representation of a single alias to an email address.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
Convenience wrapper for the config headers.
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
Convenience wrapper for the core headers.
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:459
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
Convenience wrapper for the library headers.
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition regex.c:179
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
#define STAILQ_INIT(head)
Definition queue.h:410
void alias_reverse_cleanup(struct HashTable **reverse)
Clear up the Reverse Alias Hash Table.
Definition reverse.c:53
struct HashTable * alias_reverse_init(void)
Set up the Reverse Alias Hash Table.
Definition reverse.c:43
void alias_reverse_delete(struct HashTable *reverse_aliases, struct Alias *alias)
Remove an email address lookup for an Alias.
Definition reverse.c:88
Manage alias reverse lookups.
Alias private Module data.
Definition module_data.h:33
struct AliasArray aliases
User's email aliases.
Definition module_data.h:35
struct HashTable * reverse_aliases
Hash Table of aliases (email address -> alias)
Definition module_data.h:36
struct RegexList unalternates
Regexes to exclude false matches in alternates.
Definition module_data.h:39
struct RegexList subscribed
Regexes to match subscribed mailing lists.
Definition module_data.h:49
struct RegexList mail
Regexes to match mailing lists.
Definition module_data.h:48
struct Notify * alternates_notify
Notifications: NotifyAlternates.
Definition module_data.h:40
struct HashTable * auto_subscribe_cache
Hash Table: "mailto:" (no value)
Definition module_data.h:47
struct HashTable * groups
Hash Table: "group-name" -> Group.
Definition module_data.h:45
struct RegexList unmail
Regexes to exclude false matches in mail.
Definition module_data.h:50
struct RegexList unsubscribed
Regexes to exclude false matches in subscribed.
Definition module_data.h:51
struct Notify * notify
Notifications.
Definition module_data.h:34
struct RegexList alternates
Regexes to match the user's alternate email addresses.
Definition module_data.h:38
A shortcut for an email address or addresses.
Definition alias.h:35
Container for lots of config items.
Definition set.h:251
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify
Notifications handler.
Definition neomutt.h:45