NeoMutt  2019-11-11
Teaching an old dog new tricks
DOXYGEN
context.c File Reference

The "currently-open" mailbox. More...

#include "config.h"
#include <string.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "context.h"
#include "globals.h"
#include "mutt_header.h"
#include "mutt_thread.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "pattern.h"
#include "score.h"
#include "sort.h"
+ Include dependency graph for context.c:

Go to the source code of this file.

Functions

void ctx_free (struct Context **ptr)
 Free a Context. More...
 
struct Contextctx_new (void)
 Create a new Context. More...
 
void ctx_cleanup (struct Context *ctx)
 Release memory and initialize a Context object. More...
 
void ctx_update (struct Context *ctx)
 Update the Context's message counts. More...
 
void ctx_update_tables (struct Context *ctx, bool committing)
 Update a Context structure's internal tables. More...
 
int ctx_mailbox_observer (struct NotifyCallback *nc)
 Watch for changes affecting the Context - Implements observer_t. More...
 
bool message_is_visible (struct Context *ctx, int index)
 Is a message in the index within limit. More...
 
bool message_is_tagged (struct Context *ctx, int index)
 Is a message in the index tagged (and within limit) More...
 
int el_add_tagged (struct EmailList *el, struct Context *ctx, struct Email *e, bool use_tagged)
 Get a list of the tagged Emails. More...
 
int el_add_email (struct EmailList *el, struct Email *e)
 Get a list of the selected Emails. More...
 

Detailed Description

The "currently-open" mailbox.

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 context.c.

Function Documentation

◆ ctx_free()

void ctx_free ( struct Context **  ptr)

Free a Context.

Parameters
[out]ptrContext to free

Definition at line 49 of file context.c.

50 {
51  if (!ptr || !*ptr)
52  return;
53 
54  struct Context *ctx = *ptr;
55 
56  struct EventContext ev_ctx = { ctx };
58 
59  if (ctx->mailbox)
61 
62  notify_free(&ctx->notify);
63 
64  FREE(ptr);
65 }
The "current" mailbox.
Definition: context.h:36
int ctx_mailbox_observer(struct NotifyCallback *nc)
Watch for changes affecting the Context - Implements observer_t.
Definition: context.c:290
bool notify_observer_remove(struct Notify *notify, observer_t callback, intptr_t data)
Remove an observer from an object.
Definition: notify.c:194
struct Mailbox * mailbox
Definition: context.h:50
struct Notify * notify
Notifications handler.
Definition: context.h:51
The Context is about to be destroyed.
Definition: context.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:69
Context has changed.
Definition: notify_type.h:38
#define IP
Definition: set.h:144
#define FREE(x)
Definition: memory.h:40
struct Notify * notify
Notifications handler.
Definition: mailbox.h:150
An Event that happened to an Context.
Definition: context.h:57
bool notify_send(struct Notify *notify, int type, int subtype, intptr_t data)
Send out a notification message.
Definition: notify.c:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ctx_new()

struct Context* ctx_new ( void  )

Create a new Context.

Return values
ptrNew Context

Definition at line 71 of file context.c.

72 {
73  struct Context *ctx = mutt_mem_calloc(1, sizeof(struct Context));
74 
75  ctx->notify = notify_new(ctx, NT_CONTEXT);
77 
78  return ctx;
79 }
The "current" mailbox.
Definition: context.h:36
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
Container for Accounts, Notifications.
Definition: neomutt.h:35
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:89
struct Notify * notify_new(void *object, enum NotifyType type)
Create a new notifications handler.
Definition: notify.c:54
struct Notify * notify
Notifications handler.
Definition: context.h:51
struct Notify * notify
Notifications handler.
Definition: neomutt.h:37
Context has changed.
Definition: notify_type.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ctx_cleanup()

void ctx_cleanup ( struct Context ctx)

Release memory and initialize a Context object.

Parameters
ctxContext to cleanup

Definition at line 85 of file context.c.

86 {
87  FREE(&ctx->pattern);
89  if (ctx->mailbox)
91 
92  struct Notify *notify = ctx->notify;
93  memset(ctx, 0, sizeof(struct Context));
94  ctx->notify = notify;
95 }
The "current" mailbox.
Definition: context.h:36
int ctx_mailbox_observer(struct NotifyCallback *nc)
Watch for changes affecting the Context - Implements observer_t.
Definition: context.c:290
bool notify_observer_remove(struct Notify *notify, observer_t callback, intptr_t data)
Remove an observer from an object.
Definition: notify.c:194
struct Mailbox * mailbox
Definition: context.h:50
struct Notify * notify
Notifications handler.
Definition: context.h:51
struct PatternList * limit_pattern
Compiled limit pattern.
Definition: context.h:40
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: pattern.c:1340
Notification API.
Definition: notify.c:40
#define IP
Definition: set.h:144
#define FREE(x)
Definition: memory.h:40
struct Notify * notify
Notifications handler.
Definition: mailbox.h:150
char * pattern
Limit pattern string.
Definition: context.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ctx_update()

void ctx_update ( struct Context ctx)

Update the Context's message counts.

Parameters
ctxMailbox

this routine is called to update the counts in the context structure

Definition at line 103 of file context.c.

104 {
105  if (!ctx || !ctx->mailbox)
106  return;
107 
108  struct Mailbox *m = ctx->mailbox;
109 
111  mutt_hash_free(&m->id_hash);
112 
113  /* reset counters */
114  m->msg_unread = 0;
115  m->msg_flagged = 0;
116  m->msg_new = 0;
117  m->msg_deleted = 0;
118  m->msg_tagged = 0;
119  m->vcount = 0;
120  m->changed = false;
121 
122  mutt_clear_threads(ctx);
123 
124  struct Email *e = NULL;
125  for (int msgno = 0; msgno < m->msg_count; msgno++)
126  {
127  e = m->emails[msgno];
128  if (!e)
129  continue;
130 
131  if (WithCrypto)
132  {
133  /* NOTE: this _must_ be done before the check for mailcap! */
134  e->security = crypt_query(e->content);
135  }
136 
137  if (ctx->pattern)
138  {
139  e->vnum = -1;
140  }
141  else
142  {
143  m->v2r[m->vcount] = msgno;
144  e->vnum = m->vcount++;
145  }
146  e->msgno = msgno;
147 
148  if (e->env->supersedes)
149  {
150  struct Email *e2 = NULL;
151 
152  if (!m->id_hash)
153  m->id_hash = mutt_make_id_hash(m);
154 
155  e2 = mutt_hash_find(m->id_hash, e->env->supersedes);
156  if (e2)
157  {
158  e2->superseded = true;
159  if (C_Score)
160  mutt_score_message(ctx->mailbox, e2, true);
161  }
162  }
163 
164  /* add this message to the hash tables */
165  if (m->id_hash && e->env->message_id)
167  if (m->subj_hash && e->env->real_subj)
169  mutt_label_hash_add(m, e);
170 
171  if (C_Score)
172  mutt_score_message(ctx->mailbox, e, false);
173 
174  if (e->changed)
175  m->changed = true;
176  if (e->flagged)
177  m->msg_flagged++;
178  if (e->deleted)
179  m->msg_deleted++;
180  if (!e->read)
181  {
182  m->msg_unread++;
183  if (!e->old)
184  m->msg_new++;
185  }
186  }
187 
188  mutt_sort_headers(ctx, true); /* rethread from scratch */
189 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
int msg_count
Total number of messages.
Definition: mailbox.h:102
The envelope/body of an email.
Definition: email.h:37
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:107
int msg_unread
Number of unread messages.
Definition: mailbox.h:103
char * supersedes
Supersedes header.
Definition: envelope.h:70
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:104
struct Body * content
List of MIME parts.
Definition: email.h:90
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:378
void mutt_score_message(struct Mailbox *m, struct Email *e, bool upd_mbox)
Apply scoring to an email.
Definition: score.c:169
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
bool changed
Email has been edited.
Definition: email.h:48
void mutt_label_hash_add(struct Mailbox *m, struct Email *e)
Add a message&#39;s labels to the Hash Table.
Definition: mutt_header.c:370
int vcount
The number of virtual messages.
Definition: mailbox.h:113
bool read
Email is read.
Definition: email.h:51
char * message_id
Message ID.
Definition: envelope.h:69
struct Mailbox * mailbox
Definition: context.h:50
bool old
Email is seen, but unread.
Definition: email.h:50
struct Envelope * env
Envelope information.
Definition: email.h:89
bool superseded
Got superseded?
Definition: email.h:53
void mutt_sort_headers(struct Context *ctx, bool init)
Sort emails by their headers.
Definition: sort.c:362
A mailbox.
Definition: mailbox.h:92
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:108
int vnum
Virtual message number.
Definition: email.h:87
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:39
struct Hash * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
Definition: mutt_thread.c:1434
void mutt_clear_threads(struct Context *ctx)
Clear the threading of message in a mailbox.
Definition: mutt_thread.c:599
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
bool flagged
Marked important?
Definition: email.h:43
int msg_new
Number of new messages.
Definition: mailbox.h:106
struct Hash * subj_hash
Hash table by subject.
Definition: mailbox.h:139
bool deleted
Email is deleted.
Definition: email.h:45
WHERE bool C_Score
Config: Use message scoring.
Definition: globals.h:255
bool changed
Mailbox has been modified.
Definition: mailbox.h:125
void mutt_hash_free(struct Hash **ptr)
free_hdata a hash table
Definition: hash.c:471
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:351
char * pattern
Limit pattern string.
Definition: context.h:39
#define WithCrypto
Definition: ncrypt.h:160
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:694
struct Hash * id_hash
Hash table by msg id.
Definition: mailbox.h:138
int msgno
Number displayed to the user.
Definition: email.h:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ctx_update_tables()

void ctx_update_tables ( struct Context ctx,
bool  committing 
)

Update a Context structure's internal tables.

Parameters
ctxMailbox
committingCommit the changes?

Definition at line 196 of file context.c.

197 {
198  if (!ctx || !ctx->mailbox)
199  return;
200 
201  struct Mailbox *m = ctx->mailbox;
202 
203  int i, j, padding;
204 
205  /* update memory to reflect the new state of the mailbox */
206  m->vcount = 0;
207  ctx->vsize = 0;
208  m->msg_tagged = 0;
209  m->msg_deleted = 0;
210  m->msg_new = 0;
211  m->msg_unread = 0;
212  m->changed = false;
213  m->msg_flagged = 0;
214  padding = mx_msg_padding_size(m);
215  for (i = 0, j = 0; i < m->msg_count; i++)
216  {
217  if (!m->emails[i]->quasi_deleted &&
218  ((committing && (!m->emails[i]->deleted || ((m->magic == MUTT_MAILDIR) && C_MaildirTrash))) ||
219  (!committing && m->emails[i]->active)))
220  {
221  if (i != j)
222  {
223  m->emails[j] = m->emails[i];
224  m->emails[i] = NULL;
225  }
226  m->emails[j]->msgno = j;
227  if (m->emails[j]->vnum != -1)
228  {
229  m->v2r[m->vcount] = j;
230  m->emails[j]->vnum = m->vcount++;
231  struct Body *b = m->emails[j]->content;
232  ctx->vsize += b->length + b->offset - b->hdr_offset + padding;
233  }
234 
235  if (committing)
236  {
237  m->emails[j]->changed = false;
238  m->emails[j]->env->changed = false;
239  }
240  else if (m->emails[j]->changed)
241  m->changed = true;
242 
243  if (!committing || ((m->magic == MUTT_MAILDIR) && C_MaildirTrash))
244  {
245  if (m->emails[j]->deleted)
246  m->msg_deleted++;
247  }
248 
249  if (m->emails[j]->tagged)
250  m->msg_tagged++;
251  if (m->emails[j]->flagged)
252  m->msg_flagged++;
253  if (!m->emails[j]->read)
254  {
255  m->msg_unread++;
256  if (!m->emails[j]->old)
257  m->msg_new++;
258  }
259 
260  j++;
261  }
262  else
263  {
264  if ((m->magic == MUTT_NOTMUCH) || (m->magic == MUTT_MH) ||
265  (m->magic == MUTT_MAILDIR) || (m->magic == MUTT_IMAP))
266  {
267  mailbox_size_sub(m, m->emails[i]);
268  }
269  /* remove message from the hash tables */
270  if (m->subj_hash && m->emails[i]->env->real_subj)
271  mutt_hash_delete(m->subj_hash, m->emails[i]->env->real_subj, m->emails[i]);
272  if (m->id_hash && m->emails[i]->env->message_id)
273  mutt_hash_delete(m->id_hash, m->emails[i]->env->message_id, m->emails[i]);
274  mutt_label_hash_remove(m, m->emails[i]);
275  /* The path mx_mbox_check() -> imap_check_mailbox() ->
276  * imap_expunge_mailbox() -> ctx_update_tables()
277  * can occur before a call to mx_mbox_sync(), resulting in
278  * last_tag being stale if it's not reset here. */
279  if (ctx->last_tag == m->emails[i])
280  ctx->last_tag = NULL;
281  email_free(&m->emails[i]);
282  }
283  }
284  m->msg_count = j;
285 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:443
int msg_count
Total number of messages.
Definition: mailbox.h:102
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:107
int msg_unread
Number of unread messages.
Definition: mailbox.h:103
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:104
struct Body * content
List of MIME parts.
Definition: email.h:90
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
bool changed
Email has been edited.
Definition: email.h:48
void mutt_label_hash_remove(struct Mailbox *m, struct Email *e)
Remove a message&#39;s labels from the Hash Table.
Definition: mutt_header.c:383
int vcount
The number of virtual messages.
Definition: mailbox.h:113
The body of an email.
Definition: body.h:34
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition: envelope.h:88
bool tagged
Email is tagged.
Definition: email.h:44
bool read
Email is read.
Definition: email.h:51
char * message_id
Message ID.
Definition: envelope.h:69
struct Mailbox * mailbox
Definition: context.h:50
bool old
Email is seen, but unread.
Definition: email.h:50
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
struct Envelope * env
Envelope information.
Definition: email.h:89
&#39;Maildir&#39; Mailbox type
Definition: mailbox.h:50
bool quasi_deleted
Deleted from neomutt, but not modified on disk.
Definition: email.h:47
off_t vsize
Definition: context.h:38
bool active
Message is not to be removed.
Definition: email.h:59
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
A mailbox.
Definition: mailbox.h:92
WHERE bool C_MaildirTrash
Config: Use the maildir &#39;trashed&#39; flag, rather than deleting.
Definition: globals.h:245
&#39;MH&#39; Mailbox type
Definition: mailbox.h:49
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:108
int vnum
Virtual message number.
Definition: email.h:87
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:53
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
bool flagged
Marked important?
Definition: email.h:43
int msg_new
Number of new messages.
Definition: mailbox.h:106
struct Hash * subj_hash
Hash table by subject.
Definition: mailbox.h:139
bool deleted
Email is deleted.
Definition: email.h:45
bool changed
Mailbox has been modified.
Definition: mailbox.h:125
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size()
Definition: mx.c:1475
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
void mailbox_size_sub(struct Mailbox *m, const struct Email *e)
Subtract an email&#39;s size from the total size of a Mailbox.
Definition: mailbox.c:183
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:52
struct Hash * id_hash
Hash table by msg id.
Definition: mailbox.h:138
struct Email * last_tag
Last tagged msg (used to link threads)
Definition: context.h:41
int msgno
Number displayed to the user.
Definition: email.h:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ctx_mailbox_observer()

int ctx_mailbox_observer ( struct NotifyCallback nc)

Watch for changes affecting the Context - Implements observer_t.

Definition at line 290 of file context.c.

291 {
292  if (!nc)
293  return -1;
294  if ((nc->obj_type != NT_MAILBOX) || (nc->event_type != NT_MAILBOX))
295  return 0;
296  struct Context *ctx = (struct Context *) nc->data;
297  if (!ctx)
298  return -1;
299 
300  switch (nc->event_subtype)
301  {
302  case MBN_CLOSED:
303  mutt_clear_threads(ctx);
304  ctx_cleanup(ctx);
305  break;
306  case MBN_INVALID:
307  ctx_update(ctx);
308  break;
309  case MBN_UPDATE:
310  ctx_update_tables(ctx, true);
311  break;
312  case MBN_RESORT:
313  mutt_sort_headers(ctx, true);
314  break;
315  case MBN_UNTAG:
316  if (ctx->last_tag && ctx->last_tag->deleted)
317  ctx->last_tag = NULL;
318  break;
319  }
320 
321  return 0;
322 }
void ctx_update_tables(struct Context *ctx, bool committing)
Update a Context structure&#39;s internal tables.
Definition: context.c:196
The "current" mailbox.
Definition: context.h:36
intptr_t data
Observer: private to observer.
Definition: observer.h:48
Mailbox was closed.
Definition: mailbox.h:63
Update internal tables.
Definition: mailbox.h:66
int event_subtype
Send: event subtype.
Definition: observer.h:45
int event_type
Send: event type.
Definition: observer.h:44
void mutt_sort_headers(struct Context *ctx, bool init)
Sort emails by their headers.
Definition: sort.c:362
void ctx_update(struct Context *ctx)
Update the Context&#39;s message counts.
Definition: context.c:103
Clear the &#39;last-tagged&#39; pointer.
Definition: mailbox.h:67
Email list needs resorting.
Definition: mailbox.h:65
void ctx_cleanup(struct Context *ctx)
Release memory and initialize a Context object.
Definition: context.c:85
void mutt_clear_threads(struct Context *ctx)
Clear the threading of message in a mailbox.
Definition: mutt_thread.c:599
Email list was changed.
Definition: mailbox.h:64
bool deleted
Email is deleted.
Definition: email.h:45
int obj_type
Notify: type of object event happened on.
Definition: observer.h:43
Mailbox has changed.
Definition: notify_type.h:35
struct Email * last_tag
Last tagged msg (used to link threads)
Definition: context.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ message_is_visible()

bool message_is_visible ( struct Context ctx,
int  index 
)

Is a message in the index within limit.

Parameters
ctxOpen mailbox
indexMessage ID (index into ctx->emails[]
Return values
trueThe message is within limit

If no limit is in effect, all the messages are visible.

Definition at line 332 of file context.c.

333 {
334  if (!ctx || !ctx->mailbox->emails || (index >= ctx->mailbox->msg_count))
335  return false;
336 
337  return !ctx->pattern || ctx->mailbox->emails[index]->limited;
338 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
int msg_count
Total number of messages.
Definition: mailbox.h:102
struct Mailbox * mailbox
Definition: context.h:50
bool limited
Is this message in a limited view?
Definition: email.h:74
char * pattern
Limit pattern string.
Definition: context.h:39
+ Here is the caller graph for this function:

◆ message_is_tagged()

bool message_is_tagged ( struct Context ctx,
int  index 
)

Is a message in the index tagged (and within limit)

Parameters
ctxOpen mailbox
indexMessage ID (index into ctx->emails[]
Return values
trueThe message is both tagged and within limit

If a limit is in effect, the message must be visible within it.

Definition at line 348 of file context.c.

349 {
350  return message_is_visible(ctx, index) && ctx->mailbox->emails[index]->tagged;
351 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
bool tagged
Email is tagged.
Definition: email.h:44
struct Mailbox * mailbox
Definition: context.h:50
bool message_is_visible(struct Context *ctx, int index)
Is a message in the index within limit.
Definition: context.c:332
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ el_add_tagged()

int el_add_tagged ( struct EmailList *  el,
struct Context ctx,
struct Email e,
bool  use_tagged 
)

Get a list of the tagged Emails.

Parameters
elEmpty EmailList to populate
ctxCurrent Mailbox
eCurrent Email
use_taggedUse tagged Emails
Return values
numNumber of selected emails
-1Error

Definition at line 362 of file context.c.

363 {
364  int count = 0;
365 
366  if (use_tagged)
367  {
368  if (!ctx || !ctx->mailbox || !ctx->mailbox->emails)
369  return -1;
370 
371  for (size_t i = 0; i < ctx->mailbox->msg_count; i++)
372  {
373  if (!message_is_tagged(ctx, i))
374  continue;
375 
376  struct EmailNode *en = mutt_mem_calloc(1, sizeof(*en));
377  en->email = ctx->mailbox->emails[i];
378  STAILQ_INSERT_TAIL(el, en, entries);
379  count++;
380  }
381  }
382  else
383  {
384  if (!e)
385  return -1;
386 
387  struct EmailNode *en = mutt_mem_calloc(1, sizeof(*en));
388  en->email = e;
389  STAILQ_INSERT_TAIL(el, en, entries);
390  count = 1;
391  }
392 
393  return count;
394 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
int msg_count
Total number of messages.
Definition: mailbox.h:102
#define STAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:387
struct Mailbox * mailbox
Definition: context.h:50
struct Email * email
Email in the list.
Definition: email.h:116
List of Emails.
Definition: email.h:114
bool message_is_tagged(struct Context *ctx, int index)
Is a message in the index tagged (and within limit)
Definition: context.c:348
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ el_add_email()

int el_add_email ( struct EmailList *  el,
struct Email e 
)

Get a list of the selected Emails.

Parameters
eCurrent Email
elEmailList to add to
Return values
0Success
-1Error

Definition at line 403 of file context.c.

404 {
405  if (!el || !e)
406  return -1;
407 
408  struct EmailNode *en = mutt_mem_calloc(1, sizeof(*en));
409  en->email = e;
410  STAILQ_INSERT_TAIL(el, en, entries);
411 
412  return 0;
413 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define STAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:387
struct Email * email
Email in the list.
Definition: email.h:116
List of Emails.
Definition: email.h:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function: