]> granicus.if.org Git - neomutt/blob - hook.h
Fix mutt_write_mime_body() application/pgp-encrypted handling
[neomutt] / hook.h
1 /**
2  * @file
3  * Parse and execute user-defined hooks
4  *
5  * @authors
6  * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
7  *
8  * @copyright
9  * This program is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License as published by the Free Software
11  * Foundation, either version 2 of the License, or (at your option) any later
12  * version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef MUTT_HOOK_H
24 #define MUTT_HOOK_H
25
26 #include "config.h"
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <stdio.h>
30 #include "mutt_commands.h"
31
32 struct Address;
33 struct Buffer;
34 struct Email;
35 struct ListHead;
36 struct Mailbox;
37
38 /* These Config Variables are only used in hook.c */
39 extern char *C_DefaultHook;
40 extern bool  C_ForceName;
41 extern bool  C_SaveName;
42
43 typedef uint32_t HookFlags;          ///< Flags for mutt_parse_hook(), e.g. #MUTT_FOLDER_HOOK
44 #define MUTT_HOOK_NO_FLAGS       0   ///< No flags are set
45 #define MUTT_FOLDER_HOOK   (1 << 0)  ///< folder-hook: when entering a mailbox
46 #define MUTT_MBOX_HOOK     (1 << 1)  ///< mbox-hook: move messages after reading them
47 #define MUTT_SEND_HOOK     (1 << 2)  ///< send-hook: when composing a new email
48 #define MUTT_FCC_HOOK      (1 << 3)  ///< fcc-hook: to save outgoing email
49 #define MUTT_SAVE_HOOK     (1 << 4)  ///< save-hook: set a default folder when saving an email
50 #define MUTT_CHARSET_HOOK  (1 << 5)  ///< charset-hook: create a charset alias for malformed emails
51 #define MUTT_ICONV_HOOK    (1 << 6)  ///< iconv-hook: create a system charset alias
52 #define MUTT_MESSAGE_HOOK  (1 << 7)  ///< message-hook: run before displaying a message
53 #define MUTT_CRYPT_HOOK    (1 << 8)  ///< crypt-hook: automatically select a PGP/SMIME key
54 #define MUTT_ACCOUNT_HOOK  (1 << 9)  ///< account-hook: when changing between accounts
55 #define MUTT_REPLY_HOOK    (1 << 10) ///< reply-hook: when replying to an email
56 #define MUTT_SEND2_HOOK    (1 << 11) ///< send2-hook: when changing fields in the compose menu
57 #ifdef USE_COMPRESSED
58 #define MUTT_OPEN_HOOK     (1 << 12) ///< open-hook: to read a compressed mailbox
59 #define MUTT_APPEND_HOOK   (1 << 13) ///< append-hook: append to a compressed mailbox
60 #define MUTT_CLOSE_HOOK    (1 << 14) ///< close-hook: write to a compressed mailbox
61 #endif
62 #define MUTT_IDXFMTHOOK    (1 << 15) ///< index-format-hook: customise the format of the index
63 #define MUTT_TIMEOUT_HOOK  (1 << 16) ///< timeout-hook: run a command periodically
64 #define MUTT_STARTUP_HOOK  (1 << 17) ///< startup-hook: run when starting NeoMutt
65 #define MUTT_SHUTDOWN_HOOK (1 << 18) ///< shutdown-hook: run when leaving NeoMutt
66 #define MUTT_GLOBAL_HOOK   (1 << 19) ///< Hooks which don't take a regex
67
68 void  mutt_account_hook(const char *url);
69 void  mutt_crypt_hook(struct ListHead *list, struct Address *addr);
70 void  mutt_default_save(char *path, size_t pathlen, struct Email *e);
71 void  mutt_delete_hooks(HookFlags type);
72 char *mutt_find_hook(HookFlags type, const char *pat);
73 void  mutt_folder_hook(const char *path, const char *desc);
74 const char *mutt_idxfmt_hook(const char *name, struct Mailbox *m, struct Email *e);
75 void  mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type);
76 enum CommandResult mutt_parse_idxfmt_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
77 enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
78 enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
79 void  mutt_select_fcc(char *path, size_t pathlen, struct Email *e);
80 void  mutt_startup_shutdown_hook(HookFlags type);
81 void  mutt_timeout_hook(void);
82
83 #endif /* MUTT_HOOK_H */