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 <stdint.h> 28 #include <stdio.h> 29 #include "core/lib.h" 30 31 struct Address; 32 struct Buffer; 33 struct Email; 34 struct ListHead; 35 36 typedef uint32_t HookFlags; ///< Flags for mutt_parse_hook(), e.g. #MUTT_FOLDER_HOOK 37 #define MUTT_HOOK_NO_FLAGS 0 ///< No flags are set 38 #define MUTT_FOLDER_HOOK (1 << 0) ///< folder-hook: when entering a mailbox 39 #define MUTT_MBOX_HOOK (1 << 1) ///< mbox-hook: move messages after reading them 40 #define MUTT_SEND_HOOK (1 << 2) ///< send-hook: when composing a new email 41 #define MUTT_FCC_HOOK (1 << 3) ///< fcc-hook: to save outgoing email 42 #define MUTT_SAVE_HOOK (1 << 4) ///< save-hook: set a default folder when saving an email 43 #define MUTT_CHARSET_HOOK (1 << 5) ///< charset-hook: create a charset alias for malformed emails 44 #define MUTT_ICONV_HOOK (1 << 6) ///< iconv-hook: create a system charset alias 45 #define MUTT_MESSAGE_HOOK (1 << 7) ///< message-hook: run before displaying a message 46 #define MUTT_CRYPT_HOOK (1 << 8) ///< crypt-hook: automatically select a PGP/SMIME key 47 #define MUTT_ACCOUNT_HOOK (1 << 9) ///< account-hook: when changing between accounts 48 #define MUTT_REPLY_HOOK (1 << 10) ///< reply-hook: when replying to an email 49 #define MUTT_SEND2_HOOK (1 << 11) ///< send2-hook: when changing fields in the compose menu 50 #ifdef USE_COMP_MBOX 51 #define MUTT_OPEN_HOOK (1 << 12) ///< open-hook: to read a compressed mailbox 52 #define MUTT_APPEND_HOOK (1 << 13) ///< append-hook: append to a compressed mailbox 53 #define MUTT_CLOSE_HOOK (1 << 14) ///< close-hook: write to a compressed mailbox 54 #endif 55 #define MUTT_IDXFMTHOOK (1 << 15) ///< index-format-hook: customise the format of the index 56 #define MUTT_TIMEOUT_HOOK (1 << 16) ///< timeout-hook: run a command periodically 57 #define MUTT_STARTUP_HOOK (1 << 17) ///< startup-hook: run when starting NeoMutt 58 #define MUTT_SHUTDOWN_HOOK (1 << 18) ///< shutdown-hook: run when leaving NeoMutt 59 #define MUTT_GLOBAL_HOOK (1 << 19) ///< Hooks which don't take a regex 60 61 void mutt_account_hook(const char *url); 62 void mutt_crypt_hook(struct ListHead *list, struct Address *addr); 63 void mutt_default_save(char *path, size_t pathlen, struct Email *e); 64 void mutt_delete_hooks(HookFlags type); 65 char *mutt_find_hook(HookFlags type, const char *pat); 66 void mutt_folder_hook(const char *path, const char *desc); 67 const char *mutt_idxfmt_hook(const char *name, struct Mailbox *m, struct Email *e); 68 void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type); 69 enum CommandResult mutt_parse_idxfmt_hook(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err); 70 enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err); 71 enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err); 72 void mutt_select_fcc(struct Buffer *path, struct Email *e); 73 void mutt_startup_shutdown_hook(HookFlags type); 74 void mutt_timeout_hook(void); 75 76 #endif /* MUTT_HOOK_H */ 77