1 /** 2 * @file 3 * The "currently-open" mailbox 4 * 5 * @authors 6 * Copyright (C) 2017 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_CONTEXT_H 24 #define MUTT_CONTEXT_H 25 26 #include <stdbool.h> 27 #include <sys/types.h> 28 29 struct Email; 30 struct EmailList; 31 struct Mailbox; 32 struct NotifyCallback; 33 34 /** 35 * struct Context - The "current" mailbox 36 */ 37 struct Context 38 { 39 off_t vsize; ///< Size (in bytes) of the messages shown 40 char *pattern; ///< Limit pattern string 41 struct PatternList *limit_pattern; ///< Compiled limit pattern 42 struct ThreadsContext *threads; ///< Threads context 43 int msg_in_pager; ///< Message currently shown in the pager 44 45 struct Menu *menu; ///< Needed for pattern compilation 46 47 bool collapsed : 1; ///< Are all threads collapsed? 48 49 struct Mailbox *mailbox; ///< Current Mailbox 50 struct Notify *notify; ///< Notifications: #NotifyContext, #EventContext 51 }; 52 53 /** 54 * enum NotifyContext - Types of Context Event 55 * 56 * Observers of #NT_CONTEXT will be passed an #EventContext. 57 */ 58 enum NotifyContext 59 { 60 NT_CONTEXT_ADD = 1, ///< The Context has been opened 61 NT_CONTEXT_DELETE, ///< The Context is about to be destroyed 62 NT_CONTEXT_CHANGE, ///< The Context has changed 63 }; 64 65 /** 66 * struct EventContext - An Event that happened to an Context 67 */ 68 struct EventContext 69 { 70 struct Context *ctx; ///< The Context this Event relates to 71 }; 72 73 void ctx_free (struct Context **ptr); 74 int ctx_mailbox_observer(struct NotifyCallback *nc); 75 struct Context *ctx_new (struct Mailbox *m); 76 void ctx_update (struct Context *ctx); 77 bool ctx_has_limit (const struct Context *ctx); 78 struct Mailbox* ctx_mailbox (struct Context *ctx); 79 80 bool message_is_tagged(struct Email *e); 81 struct Email *mutt_get_virt_email(struct Mailbox *m, int vnum); 82 83 int el_add_tagged (struct EmailList *el, struct Context *ctx, struct Email *e, bool use_tagged); 84 85 #endif /* MUTT_CONTEXT_H */ 86