NeoMutt  2024-03-23-142-g2b2e76
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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...
 

Enumerations

enum  ExpandoDataIndex {
  ED_IND_DELETED_COUNT = 1 , ED_IND_DESCRIPTION , ED_IND_FLAGGED_COUNT , ED_IND_LIMIT_COUNT ,
  ED_IND_LIMIT_PATTERN , ED_IND_LIMIT_SIZE , ED_IND_MAILBOX_PATH , ED_IND_MAILBOX_SIZE ,
  ED_IND_MESSAGE_COUNT , ED_IND_NEW_COUNT , ED_IND_OLD_COUNT , ED_IND_POSTPONED_COUNT ,
  ED_IND_READONLY , ED_IND_READ_COUNT , ED_IND_TAGGED_COUNT , ED_IND_UNREAD_COUNT ,
  ED_IND_UNREAD_MAILBOXES
}
 Expando UIDs for the Index. More...
 

Functions

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

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.

Enumeration Type Documentation

◆ ExpandoDataIndex

Expando UIDs for the Index.

See also
ED_INDEX, ExpandoDomain
Enumerator
ED_IND_DELETED_COUNT 

Mailbox.msg_deleted.

ED_IND_DESCRIPTION 

Mailbox.name.

ED_IND_FLAGGED_COUNT 

Mailbox.msg_flagged.

ED_IND_LIMIT_COUNT 

Mailbox.vcount.

ED_IND_LIMIT_PATTERN 

MailboxView.pattern.

ED_IND_LIMIT_SIZE 

MailboxView.vsize.

ED_IND_MAILBOX_PATH 

Mailbox.pathbuf, Mailbox.name.

ED_IND_MAILBOX_SIZE 

Mailbox.size.

ED_IND_MESSAGE_COUNT 

Mailbox.msg_count.

ED_IND_NEW_COUNT 

Mailbox.msg_new.

ED_IND_OLD_COUNT 

Mailbox.msg_unread, Mailbox.msg_new.

ED_IND_POSTPONED_COUNT 

mutt_num_postponed()

ED_IND_READONLY 

Mailbox.readonly, Mailbox.dontwrite.

ED_IND_READ_COUNT 

Mailbox.msg_count, Mailbox.msg_unread.

ED_IND_TAGGED_COUNT 

Mailbox.msg_tagged.

ED_IND_UNREAD_COUNT 

Mailbox.msg_unread.

ED_IND_UNREAD_MAILBOXES 

Mailbox, mutt_mailbox_check()

Definition at line 54 of file shared_data.h.

55{
73};
@ ED_IND_LIMIT_COUNT
Mailbox.vcount.
Definition: shared_data.h:59
@ ED_IND_MAILBOX_PATH
Mailbox.pathbuf, Mailbox.name.
Definition: shared_data.h:62
@ ED_IND_DELETED_COUNT
Mailbox.msg_deleted.
Definition: shared_data.h:56
@ ED_IND_NEW_COUNT
Mailbox.msg_new.
Definition: shared_data.h:65
@ ED_IND_MAILBOX_SIZE
Mailbox.size.
Definition: shared_data.h:63
@ ED_IND_LIMIT_PATTERN
MailboxView.pattern.
Definition: shared_data.h:60
@ ED_IND_READ_COUNT
Mailbox.msg_count, Mailbox.msg_unread.
Definition: shared_data.h:69
@ ED_IND_POSTPONED_COUNT
mutt_num_postponed()
Definition: shared_data.h:67
@ ED_IND_FLAGGED_COUNT
Mailbox.msg_flagged.
Definition: shared_data.h:58
@ ED_IND_MESSAGE_COUNT
Mailbox.msg_count.
Definition: shared_data.h:64
@ ED_IND_OLD_COUNT
Mailbox.msg_unread, Mailbox.msg_new.
Definition: shared_data.h:66
@ ED_IND_READONLY
Mailbox.readonly, Mailbox.dontwrite.
Definition: shared_data.h:68
@ ED_IND_UNREAD_COUNT
Mailbox.msg_unread.
Definition: shared_data.h:71
@ ED_IND_TAGGED_COUNT
Mailbox.msg_tagged.
Definition: shared_data.h:70
@ ED_IND_LIMIT_SIZE
MailboxView.vsize.
Definition: shared_data.h:61
@ ED_IND_DESCRIPTION
Mailbox.name.
Definition: shared_data.h:57
@ ED_IND_UNREAD_MAILBOXES
Mailbox, mutt_mailbox_check()
Definition: shared_data.h:72

Function Documentation

◆ index_shared_data_new()

struct IndexSharedData * index_shared_data_new ( void  )

Create new Index Data.

Return values
ptrNew IndexSharedData

Definition at line 307 of file shared_data.c.

308{
309 struct IndexSharedData *shared = mutt_mem_calloc(1, sizeof(struct IndexSharedData));
310
311 shared->notify = notify_new();
312 shared->sub = NeoMutt->sub;
313 shared->search_state = search_state_new();
314
315 mutt_debug(LL_NOTIFY, "NT_INDEX_ADD: %p\n", (void *) shared);
316 notify_send(shared->notify, NT_INDEX, NT_INDEX_ADD, shared);
317
318 return shared;
319}
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
#define NT_INDEX_ADD
New Index Shared Data has been created.
Definition: lib.h:59
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
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:62
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:173
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition: notify_type.h:48
struct SearchState * search_state_new(void)
Create a new SearchState.
Definition: search_state.c:39
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 SearchState * search_state
State of the current search.
Definition: shared_data.h:45
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition: shared_data.h:44
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
+ 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 264 of file shared_data.c.

266{
267 if (!shared)
268 return false;
269
270 return shared->email_seq == e->sequence;
271}
size_t sequence
Sequence number assigned on creation.
Definition: email.h:67
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_mview()

void index_shared_data_set_mview ( 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 160 of file shared_data.c.

161{
162 if (!shared)
163 return;
164
166
167 if (shared->mailbox_view != mv)
168 {
169 if (shared->mailbox_view)
170 {
173 }
174
175 shared->mailbox_view = mv;
176 subtype |= NT_INDEX_MVIEW;
177
178 if (mv)
180 }
181
182 struct Mailbox *m = mview_mailbox(mv);
183 if (shared->mailbox != m)
184 {
185 if (shared->mailbox)
187
188 shared->mailbox = m;
189 shared->email = NULL;
190 shared->email_seq = 0;
191 subtype |= NT_INDEX_MAILBOX | NT_INDEX_EMAIL;
192
193 if (m)
195 }
196
197 struct Account *a = m ? m->account : NULL;
198 if (shared->account != a)
199 {
200 if (shared->account)
202
203 shared->account = a;
204 subtype |= NT_INDEX_ACCOUNT;
205
206 if (a)
208 }
209
210 struct ConfigSubset *sub = NeoMutt->sub;
211#if 0
212 if (m)
213 sub = m->sub;
214 else if (a)
215 sub = a->sub;
216#endif
217 if (shared->sub != sub)
218 {
219 shared->sub = sub;
220 subtype |= NT_INDEX_SUBSET;
221 }
222
223 if (subtype != NT_INDEX_NO_FLAGS)
224 {
225 mutt_debug(LL_NOTIFY, "NT_INDEX: %p\n", (void *) shared);
226 notify_send(shared->notify, NT_INDEX, subtype, shared);
227 }
228}
static int index_shared_mview_observer(struct NotifyCallback *nc)
Notification that the MailboxView has changed - Implements observer_t -.
Definition: shared_data.c:43
static int index_shared_account_observer(struct NotifyCallback *nc)
Notification that an Account has changed - Implements observer_t -.
Definition: shared_data.c:68
static int index_shared_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
Definition: shared_data.c:93
#define NT_INDEX_MAILBOX
Mailbox has changed.
Definition: lib.h:64
uint8_t NotifyIndex
Flags, e.g. NT_INDEX_ACCOUNT.
Definition: lib.h:57
#define NT_INDEX_SUBSET
Config Subset has changed.
Definition: lib.h:61
#define NT_INDEX_MVIEW
MailboxView has changed.
Definition: lib.h:63
#define NT_INDEX_ACCOUNT
Account has changed.
Definition: lib.h:62
#define NT_INDEX_EMAIL
Email has changed.
Definition: lib.h:65
#define NT_INDEX_NO_FLAGS
No flags are set.
Definition: lib.h:58
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
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:191
struct Mailbox * mview_mailbox(struct MailboxView *mv)
Wrapper to get the mailbox in a MailboxView, or NULL.
Definition: mview.c:450
@ 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:36
struct Notify * notify
Notifications: NotifyAccount, EventAccount.
Definition: account.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:39
A set of inherited config items.
Definition: subset.h:47
struct Account * account
Current Account.
Definition: shared_data.h:39
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
struct MailboxView * mailbox_view
Current Mailbox view.
Definition: shared_data.h:40
struct Notify * notify
Notifications: NotifyMview, EventMview.
Definition: mview.h:52
A mailbox.
Definition: mailbox.h:79
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition: mailbox.h:145
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 235 of file shared_data.c.

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