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
37extern struct ConfigDef NotmuchVars[];
38
39extern const struct Command NmCommands[];
40
44static bool notmuch_init(struct NeoMutt *n)
45{
46 struct NotmuchModuleData *mod_data = MUTT_MEM_CALLOC(1, struct NotmuchModuleData);
48
49 mod_data->notify = notify_new();
50 notify_set_parent(mod_data->notify, n->notify);
51
52 return true;
53}
54
58static bool notmuch_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
59{
60 bool rc = false;
61
62#if defined(USE_NOTMUCH)
64#endif
65
66 return rc;
67}
68
72static bool notmuch_commands_register(struct NeoMutt *n, struct CommandArray *ca)
73{
74 return commands_register(ca, NmCommands);
75}
76
80static bool notmuch_gui_init(struct NeoMutt *n)
81{
82 const bool c_virtual_spool_file = cs_subset_bool(n->sub, "virtual_spool_file");
83 if (c_virtual_spool_file)
84 {
85 /* Find the first virtual folder and open it */
86 struct MailboxArray ma = neomutt_mailboxes_get(n, MUTT_NOTMUCH);
87 struct Mailbox **mp = ARRAY_FIRST(&ma);
88 if (mp)
89 cs_str_string_set(n->cs, "spool_file", mailbox_path(*mp), NULL);
90 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
91 }
92 return true;
93}
94
98static void notmuch_gui_cleanup(struct NeoMutt *n)
99{
100}
101
105static bool notmuch_cleanup(struct NeoMutt *n, void *data)
106{
107 struct NotmuchModuleData *mod_data = data;
108
109 notify_free(&mod_data->notify);
110
111 FREE(&mod_data);
112 return true;
113}
114
118const struct Module ModuleNotmuch = {
120 "notmuch",
122 NULL, // config_define_types
128};
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition array.h:136
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
Convenience wrapper for the config headers.
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition set.c:693
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.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
const struct Module ModuleNotmuch
Module for the Notmuch library.
Definition module.c:118
#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_NOTMUCH
ModuleNotmuch, Notmuch
Definition module_api.h:82
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 neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:604
struct ConfigDef NotmuchVars[]
Config definitions for the Notmuch library.
Definition config.c:75
static bool notmuch_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:58
static bool notmuch_gui_init(struct NeoMutt *n)
Initialise the GUI - Implements Module::gui_init()
Definition module.c:80
const struct Command NmCommands[]
Notmuch Commands.
Definition notmuch.c:91
static void notmuch_gui_cleanup(struct NeoMutt *n)
Clean up the GUI - Implements Module::gui_cleanup()
Definition module.c:98
static bool notmuch_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:44
static bool notmuch_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:105
static bool notmuch_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:72
Notmuch private Module data.
Container for lots of config items.
Definition set.h:251
A mailbox.
Definition mailbox.h:81
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSet * cs
Config set.
Definition neomutt.h:48
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
Notmuch private Module data.
Definition module_data.h:30
struct Notify * notify
Notifications.
Definition module_data.h:31