NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
shared_data.h File Reference

Data shared between Index, Pager and Sidebar. More...

#include <stdbool.h>
#include <stdio.h>
+ Include dependency graph for shared_data.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IndexSharedData
 Data shared between Index, Pager and Sidebar. More...
 

Functions

void index_shared_data_free (struct MuttWindow *win, void **ptr)
 Free Shared Index Data - Implements MuttWindow::wdata_free() -. More...
 
struct IndexSharedDataindex_shared_data_new (void)
 Create new Index Data. More...
 
bool index_shared_data_is_cur_email (const struct IndexSharedData *shared, const struct Email *e)
 Check whether an email is the currently selected Email. More...
 
void index_shared_data_set_context (struct IndexSharedData *shared, struct MailboxView *mv)
 Set the MailboxView for the Index and friends. More...
 
void index_shared_data_set_email (struct IndexSharedData *shared, struct Email *e)
 Set the current Email for the Index and friends. More...
 

Detailed Description

Data shared between Index, Pager and Sidebar.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file shared_data.h.

Function Documentation

◆ index_shared_data_new()

struct IndexSharedData * index_shared_data_new ( void  )

Create new Index Data.

Return values
ptrNew IndexSharedData

Definition at line 300 of file shared_data.c.

301{
302 struct IndexSharedData *shared = mutt_mem_calloc(1, sizeof(struct IndexSharedData));
303
304 shared->notify = notify_new();
305 shared->sub = NeoMutt->sub;
306
307 mutt_debug(LL_NOTIFY, "NT_INDEX_ADD: %p\n", shared);
308 notify_send(shared->notify, NT_INDEX, NT_INDEX_ADD, shared);
309
310 return shared;
311}
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
#define NT_INDEX_ADD
New Index Shared Data has been created.
Definition: lib.h:60
@ LL_NOTIFY
Log of notifications.
Definition: logging.h:45
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition: notify_type.h:48
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition: shared_data.h:44
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_shared_data_is_cur_email()

bool index_shared_data_is_cur_email ( const struct IndexSharedData shared,
const struct Email e 
)

Check whether an email is the currently selected Email.

Parameters
sharedShared Index data
eEmail to check
Return values
truee is current
falsee is not current

Definition at line 259 of file shared_data.c.

261{
262 if (!shared)
263 return false;
264
265 return shared->email_seq == e->sequence;
266}
size_t sequence
Sequence number assigned on creation.
Definition: email.h:65
size_t email_seq
Sequence number of the current email.
Definition: shared_data.h:43
+ Here is the caller graph for this function:

◆ index_shared_data_set_context()

void index_shared_data_set_context ( struct IndexSharedData shared,
struct MailboxView mv 
)

Set the MailboxView for the Index and friends.

Parameters
sharedShared Index data
mvMailbox View, may be NULL

Definition at line 157 of file shared_data.c.

158{
159 if (!shared)
160 return;
161
163
164 if (shared->mailboxview != mv)
165 {
166 if (shared->mailboxview)
169
170 shared->mailboxview = mv;
171 subtype |= NT_INDEX_MVIEW;
172
173 if (mv)
175 }
176
177 struct Mailbox *m = mview_mailbox(mv);
178 if (shared->mailbox != m)
179 {
180 if (shared->mailbox)
182
183 shared->mailbox = m;
184 shared->email = NULL;
185 shared->email_seq = 0;
186 subtype |= NT_INDEX_MAILBOX | NT_INDEX_EMAIL;
187
188 if (m)
190 }
191
192 struct Account *a = m ? m->account : NULL;
193 if (shared->account != a)
194 {
195 if (shared->account)
197
198 shared->account = a;
199 subtype |= NT_INDEX_ACCOUNT;
200
201 if (a)
203 }
204
205 struct ConfigSubset *sub = NeoMutt->sub;
206#if 0
207 if (m)
208 sub = m->sub;
209 else if (a)
210 sub = a->sub;
211#endif
212 if (shared->sub != sub)
213 {
214 shared->sub = sub;
215 subtype |= NT_INDEX_SUBSET;
216 }
217
218 if (subtype != NT_INDEX_NO_FLAGS)
219 {
220 mutt_debug(LL_NOTIFY, "NT_INDEX: %p\n", shared);
221 notify_send(shared->notify, NT_INDEX, subtype, shared);
222 }
223}
static int index_shared_account_observer(struct NotifyCallback *nc)
Notification that an Account has changed - Implements observer_t -.
Definition: shared_data.c:66
static int index_shared_context_observer(struct NotifyCallback *nc)
Notification that the MailboxView has changed - Implements observer_t -.
Definition: shared_data.c:41
static int index_shared_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
Definition: shared_data.c:91
#define NT_INDEX_MAILBOX
Mailbox has changed.
Definition: lib.h:65
uint8_t NotifyIndex
Flags, e.g. NT_INDEX_ACCOUNT.
Definition: lib.h:58
#define NT_INDEX_SUBSET
Config Subset has changed.
Definition: lib.h:62
#define NT_INDEX_MVIEW
MailboxView has changed.
Definition: lib.h:64
#define NT_INDEX_ACCOUNT
Account has changed.
Definition: lib.h:63
#define NT_INDEX_EMAIL
Email has changed.
Definition: lib.h:66
#define NT_INDEX_NO_FLAGS
No flags are set.
Definition: lib.h:59
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:228
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:189
struct Mailbox * mview_mailbox(struct MailboxView *mv)
Wrapper to get the mailbox in a MailboxView, or NULL.
Definition: mview.c:446
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition: notify_type.h:49
@ NT_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition: notify_type.h:36
@ NT_MVIEW
MailboxView has changed, NotifyMview, EventMview.
Definition: notify_type.h:50
A group of associated Mailboxes.
Definition: account.h:37
struct Notify * notify
Notifications: NotifyAccount, EventAccount.
Definition: account.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:40
A set of inherited config items.
Definition: subset.h:47
struct MailboxView * mailboxview
Current Mailbox view.
Definition: shared_data.h:39
struct Account * account
Current Account.
Definition: shared_data.h:40
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
struct Notify * notify
Notifications: NotifyMview, EventMview.
Definition: mview.h:50
A mailbox.
Definition: mailbox.h:79
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition: mailbox.h:144
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:127
struct ConfigSubset * sub
Inherited config items.
Definition: mailbox.h:83
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_shared_data_set_email()

void index_shared_data_set_email ( struct IndexSharedData shared,
struct Email e 
)

Set the current Email for the Index and friends.

Parameters
sharedShared Index data
eCurrent Email, may be NULL

Definition at line 230 of file shared_data.c.

231{
232 if (!shared)
233 return;
234
235 size_t seq = e ? e->sequence : 0;
236 if ((shared->email != e) || (shared->email_seq != seq))
237 {
238 if (shared->email)
240
241 shared->email = e;
242 shared->email_seq = seq;
243
244 if (e)
246
247 mutt_debug(LL_NOTIFY, "NT_INDEX_EMAIL: %p\n", shared->email);
248 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, shared);
249 }
250}
static int index_shared_email_observer(struct NotifyCallback *nc)
Notification that an Email has changed - Implements observer_t -.
Definition: shared_data.c:116
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition: notify_type.h:44
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition: email.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function: