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 "config/lib.h"
34#include "core/lib.h"
35#include "module_data.h"
36#include "score.h"
37#include "tags.h"
38
39extern struct ConfigDef EmailVars[];
40
41extern const struct Command EmailCommands[];
42
46static bool email_init(struct NeoMutt *n)
47{
48 struct EmailModuleData *mod_data = MUTT_MEM_CALLOC(1, struct EmailModuleData);
50
51 mod_data->notify = notify_new();
52 notify_set_parent(mod_data->notify, n->notify);
53
55 STAILQ_INIT(&mod_data->auto_view);
56 STAILQ_INIT(&mod_data->header_order);
57 STAILQ_INIT(&mod_data->ignore);
58 STAILQ_INIT(&mod_data->mail_to_allow);
59 STAILQ_INIT(&mod_data->no_spam);
60 STAILQ_INIT(&mod_data->spam);
61 STAILQ_INIT(&mod_data->unignore);
62
63 /* RFC2368, "4. Unsafe headers"
64 * The creator of a mailto URL can't expect the resolver of a URL to
65 * understand more than the "subject" and "body" headers. Clients that
66 * resolve mailto URLs into mail messages should be able to correctly create
67 * RFC822-compliant mail messages using the "subject" and "body" headers. */
68 add_to_stailq(&mod_data->mail_to_allow, "body");
69 add_to_stailq(&mod_data->mail_to_allow, "subject");
70 // Cc, In-Reply-To, and References help with not breaking threading on mailing lists
71 add_to_stailq(&mod_data->mail_to_allow, "cc");
72 add_to_stailq(&mod_data->mail_to_allow, "in-reply-to");
73 add_to_stailq(&mod_data->mail_to_allow, "references");
74
75 driver_tags_init(mod_data);
76
77 return true;
78}
79
83static bool email_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
84{
86}
87
91static bool email_commands_register(struct NeoMutt *n, struct CommandArray *ca)
92{
94}
95
99static bool email_cleanup(struct NeoMutt *n, void *data)
100{
101 struct EmailModuleData *mod_data = data;
102
103 notify_free(&mod_data->notify);
104
106 mutt_list_free(&mod_data->auto_view);
107 mutt_list_free(&mod_data->header_order);
108 mutt_list_free(&mod_data->ignore);
109 mutt_list_free(&mod_data->mail_to_allow);
110 mutt_list_free(&mod_data->unignore);
111
112 mutt_regexlist_free(&mod_data->no_spam);
113
114 mutt_replacelist_free(&mod_data->spam);
115
116 score_list_free(&mod_data->score_list);
117
118 driver_tags_cleanup(mod_data);
119
120 FREE(&mod_data);
121 return true;
122}
123
127const struct Module ModuleEmail = {
129 "email",
131 NULL, // config_define_types
134 NULL, // gui_init
135 NULL, // gui_cleanup
137};
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.
const struct Command EmailCommands[]
Email Commands.
Definition commands.c:221
struct ConfigDef EmailVars[]
Config definitions for the Email library.
Definition config.c:56
static bool email_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:99
static bool email_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:91
static bool email_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:46
static bool email_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:83
const struct Module ModuleEmail
Module for the Email library.
Definition module.c:127
Email private Module data.
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition list.c:316
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
#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_EMAIL
ModuleEmail, Email code
Definition module_api.h:64
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 mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition regex.c:450
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 score_list_free(struct Score **sp)
Free a list of scoring rules.
Definition score.c:53
Routines for adding user scores to emails.
Container for lots of config items.
Definition set.h:251
Email private Module data.
Definition module_data.h:32
struct Notify * notify
Notifications.
Definition module_data.h:33
struct Score * score_list
Linked list of email scoring rules.
Definition module_data.h:44
struct ListHead unignore
Header patterns to unignore.
Definition module_data.h:43
struct ListHead ignore
Header patterns to ignore.
Definition module_data.h:37
struct ReplaceList spam
Regexes and patterns to match spam emails.
Definition module_data.h:40
struct ListHead auto_view
List of mime types to auto view.
Definition module_data.h:35
struct ListHead mail_to_allow
Permitted fields in a mailto: url.
Definition module_data.h:38
struct RegexList no_spam
Regexes to identify non-spam emails.
Definition module_data.h:39
struct ListHead alternative_order
List of preferred mime types to display.
Definition module_data.h:34
struct ListHead header_order
List of header fields in the order they should be displayed.
Definition module_data.h:36
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
void driver_tags_init(struct EmailModuleData *mod_data)
Initialize structures used for tags.
Definition tags.c:235
void driver_tags_cleanup(struct EmailModuleData *mod_data)
Deinitialize structures used for tags.
Definition tags.c:248
Driver based email tags.