NeoMutt  2023-11-03-107-g582dc1
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Index Function API

Prototype for an Index Function. More...

+ Collaboration diagram for Index Function API:

Functions

static int op_alias_dialog (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open the aliases dialog - Implements index_function_t -.
 
static int op_attachment_edit_type (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Edit attachment content type - Implements index_function_t -.
 
static int op_bounce_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Remail a message to another user - Implements index_function_t -.
 
static int op_check_traditional (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Check for classic PGP - Implements index_function_t -.
 
static int op_compose_to_sender (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Compose new message to the current message sender - Implements index_function_t -.
 
static int op_create_alias (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Create an alias from a message sender - Implements index_function_t -.
 
static int op_delete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete the current entry - Implements index_function_t -.
 
static int op_delete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete all messages in thread - Implements index_function_t -.
 
static int op_display_address (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display full address of sender - Implements index_function_t -.
 
static int op_display_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display a message - Implements index_function_t -.
 
static int op_edit_label (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Add, change, or delete a message's label - Implements index_function_t -.
 
static int op_edit_raw_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Edit the raw message (edit and edit-raw-message are synonyms) - Implements index_function_t -.
 
static int op_end_cond (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 End of conditional execution (noop) - Implements index_function_t -.
 
static int op_exit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Exit this menu - Implements index_function_t -.
 
static int op_extract_keys (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Extract supported public keys - Implements index_function_t -.
 
static int op_flag_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'important' flag - Implements index_function_t -.
 
static int op_forget_passphrase (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Wipe passphrases from memory - Implements index_function_t -.
 
static int op_forward_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Forward a message with comments - Implements index_function_t -.
 
static int op_group_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to all recipients - Implements index_function_t -.
 
static int op_jump (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to an index number - Implements index_function_t -.
 
static int op_list_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to specified mailing list - Implements index_function_t -.
 
static int op_list_subscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Subscribe to a mailing list - Implements index_function_t -.
 
static int op_list_unsubscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Unsubscribe from mailing list - Implements index_function_t -.
 
static int op_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Compose a new mail message - Implements index_function_t -.
 
static int op_mailbox_list (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 List mailboxes with new mail - Implements index_function_t -.
 
static int op_mail_key (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mail a PGP public key - Implements index_function_t -.
 
static int op_main_break_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Break the thread in two - Implements index_function_t -.
 
static int op_main_change_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different folder - Implements index_function_t -.
 
static int op_main_collapse_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse all threads - Implements index_function_t -.
 
static int op_main_collapse_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse current thread - Implements index_function_t -.
 
static int op_main_delete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete messages matching a pattern - Implements index_function_t -.
 
static int op_main_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Limit view to a pattern/thread - Implements index_function_t -.
 
static int op_main_link_threads (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Link tagged message to the current one - Implements index_function_t -.
 
static int op_main_modify_tags (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Modify (notmuch/imap) tags - Implements index_function_t -.
 
static int op_main_next_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next new message - Implements index_function_t -.
 
static int op_main_next_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next thread - Implements index_function_t -.
 
static int op_main_next_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next undeleted message - Implements index_function_t -.
 
static int op_main_next_unread_mailbox (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open next mailbox with unread mail - Implements index_function_t -.
 
static int op_main_prev_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous undeleted message - Implements index_function_t -.
 
static int op_main_quasi_delete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete from NeoMutt, don't touch on disk - Implements index_function_t -.
 
static int op_main_read_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark the current thread as read - Implements index_function_t -.
 
static int op_main_root_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to root message in thread - Implements index_function_t -.
 
static int op_main_set_flag (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Set a status flag on a message - Implements index_function_t -.
 
static int op_main_show_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show currently active limit pattern - Implements index_function_t -.
 
static int op_main_sync_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox - Implements index_function_t -.
 
static int op_main_tag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag messages matching a pattern - Implements index_function_t -.
 
static int op_main_undelete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete messages matching a pattern - Implements index_function_t -.
 
static int op_main_untag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Untag messages matching a pattern - Implements index_function_t -.
 
static int op_mark_msg (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Create a hotkey macro for the current message - Implements index_function_t -.
 
static int op_next_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next entry - Implements index_function_t -.
 
static int op_pipe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Pipe message/attachment to a shell command - Implements index_function_t -.
 
static int op_prev_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous entry - Implements index_function_t -.
 
static int op_print (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Print the current entry - Implements index_function_t -.
 
static int op_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Query external program for addresses - Implements index_function_t -.
 
static int op_quit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox and quit - Implements index_function_t -.
 
static int op_recall_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Recall a postponed message - Implements index_function_t -.
 
static int op_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to a message - Implements index_function_t -.
 
static int op_resend (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Use the current message as a template for a new one - Implements index_function_t -.
 
static int op_save (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Make decrypted copy - Implements index_function_t -.
 
static int op_search (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Search for a regular expression - Implements index_function_t -.
 
static int op_sort (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Sort messages - Implements index_function_t -.
 
static int op_tag (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current entry - Implements index_function_t -.
 
static int op_tag_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current thread - Implements index_function_t -.
 
static int op_toggle_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'new' flag - Implements index_function_t -.
 
static int op_toggle_write (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle whether the mailbox will be rewritten - Implements index_function_t -.
 
static int op_undelete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete the current entry - Implements index_function_t -.
 
static int op_undelete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete all messages in thread - Implements index_function_t -.
 
static int op_view_attachments (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show MIME attachments - Implements index_function_t -.
 
static int op_autocrypt_acct_menu (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Manage autocrypt accounts - Implements index_function_t -.
 
static int op_main_imap_fetch (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Force retrieval of mail from IMAP server - Implements index_function_t -.
 
static int op_main_imap_logout_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Logout from all IMAP servers - Implements index_function_t -.
 
static int op_catchup (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark all articles in newsgroup as read - Implements index_function_t -.
 
static int op_get_children (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get all children of the current message - Implements index_function_t -.
 
static int op_get_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get parent of the current message - Implements index_function_t -.
 
static int op_main_change_group (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different newsgroup - Implements index_function_t -.
 
static int op_post (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Followup to newsgroup - Implements index_function_t -.
 
static int op_main_entire_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Read entire thread of the current message - Implements index_function_t -.
 
static int op_main_vfolder_from_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Generate virtual folder from query - Implements index_function_t -.
 
static int op_main_windowed_vfolder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Shifts virtual folder time window - Implements index_function_t -.
 
static int op_main_fetch_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Retrieve mail from POP server - Implements index_function_t -.
 

Detailed Description

Prototype for an Index Function.

Parameters
sharedShared Index data
privPrivate Index data
opOperation to perform, e.g. OP_MAIN_LIMIT
Return values
numFunctionRetval or opcode, e.g. OP_JUMP

Function Documentation

◆ op_alias_dialog()

static int op_alias_dialog ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Open the aliases dialog - Implements index_function_t -.

Definition at line 424 of file functions.c.

426{
427 alias_dialog(shared->mailbox, shared->sub);
428 return FR_SUCCESS;
429}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
void alias_dialog(struct Mailbox *m, struct ConfigSubset *sub)
Open the aliases dialog.
Definition: dlg_alias.c:509
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
+ Here is the call graph for this function:

◆ op_attachment_edit_type()

static int op_attachment_edit_type ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Edit attachment content type - Implements index_function_t -.

Definition at line 434 of file functions.c.

436{
437 if (!shared->email)
438 return FR_NO_ACTION;
439 mutt_edit_content_type(shared->email, shared->email->body, NULL);
440
442 return FR_SUCCESS;
443}
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition: external.c:1072
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:180
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition: lib.h:59
struct Body * body
List of MIME parts.
Definition: email.h:67
struct Menu * menu
Menu controlling the index.
Definition: private_data.h:41
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
+ Here is the call graph for this function:

◆ op_bounce_message()

static int op_bounce_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Remail a message to another user - Implements index_function_t -.

Definition at line 448 of file functions.c.

450{
451 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
452 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
453 index_bounce_message(shared->mailbox, &ea);
454 ARRAY_FREE(&ea);
455
456 return FR_SUCCESS;
457}
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:203
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:57
void index_bounce_message(struct Mailbox *m, struct EmailArray *ea)
Bounce an email.
Definition: external.c:90
int ea_add_tagged(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged)
Get an array of the tagged Emails.
Definition: mview.c:377
bool tag_prefix
tag-prefix has been pressed
Definition: private_data.h:36
struct MailboxView * mailbox_view
Current Mailbox view.
Definition: shared_data.h:40
+ Here is the call graph for this function:

◆ op_check_traditional()

static int op_check_traditional ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Check for classic PGP - Implements index_function_t -.

Definition at line 462 of file functions.c.

464{
466 return FR_NOT_IMPL;
467 if (!shared->email)
468 return FR_NO_ACTION;
469
470 if (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED))
471 {
472 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
473 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
474 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
476 ARRAY_FREE(&ea);
477 }
478
479 return FR_SUCCESS;
480}
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition: dispatcher.h:36
bool mutt_check_traditional_pgp(struct Mailbox *m, struct EmailArray *ea)
Check if a message has inline PGP content.
Definition: external.c:1213
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:60
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: lib.h:93
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:91
#define WithCrypto
Definition: lib.h:117
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:41
+ Here is the call graph for this function:

◆ op_compose_to_sender()

static int op_compose_to_sender ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Compose new message to the current message sender - Implements index_function_t -.

Definition at line 485 of file functions.c.

487{
488 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
489 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
490 int rc = mutt_send_message(SEND_TO_SENDER, NULL, NULL, shared->mailbox, &ea,
491 shared->sub);
492 ARRAY_FREE(&ea);
494
495 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
496}
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailArray *ea, struct ConfigSubset *sub)
Send an email.
Definition: send.c:2099
#define SEND_TO_SENDER
Compose new email to sender.
Definition: send.h:51
+ Here is the call graph for this function:

◆ op_create_alias()

static int op_create_alias ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Create an alias from a message sender - Implements index_function_t -.

Definition at line 501 of file functions.c.

503{
504 struct AddressList *al = NULL;
505 if (shared->email && shared->email->env)
506 al = mutt_get_address(shared->email->env, NULL);
507 alias_create(al, shared->sub);
509
510 return FR_SUCCESS;
511}
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition: alias.c:370
struct AddressList * mutt_get_address(struct Envelope *env, const char **prefix)
Get an Address from an Envelope.
Definition: alias.c:330
struct Envelope * env
Envelope information.
Definition: email.h:66
+ Here is the call graph for this function:

◆ op_delete()

static int op_delete ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Delete the current entry - Implements index_function_t -.

This function handles:

  • OP_DELETE
  • OP_PURGE_MESSAGE

Definition at line 520 of file functions.c.

521{
522 /* L10N: CHECK_ACL */
523 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete message")))
524 return FR_ERROR;
525
526 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
527 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
528
529 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, true);
530 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, (op == OP_PURGE_MESSAGE));
531 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
532 if (c_delete_untag)
533 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_TAG, false);
534 ARRAY_FREE(&ea);
535
536 if (priv->tag_prefix)
537 {
539 }
540 else
541 {
543 }
544
545 return FR_SUCCESS;
546}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
bool check_acl(struct Mailbox *m, AclFlags acl, const char *msg)
Check the ACLs for a function.
Definition: dlg_index.c:134
void mutt_emails_set_flag(struct Mailbox *m, struct EmailArray *ea, enum MessageType flag, bool bf)
Set flag on messages.
Definition: flags.c:357
static bool resolve_email(struct IndexPrivateData *priv, struct IndexSharedData *shared, enum ResolveMethod rm)
Pick the next Email to advance the cursor to.
Definition: functions.c:344
@ RESOLVE_NEXT_UNDELETED
Next undeleted email.
Definition: functions.c:332
#define MUTT_ACL_DELETE
Delete a message.
Definition: mailbox.h:63
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:57
#define _(a)
Definition: message.h:28
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition: mutt.h:76
@ MUTT_TAG
Tagged messages.
Definition: mutt.h:79
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:74
+ Here is the call graph for this function:

◆ op_delete_thread()

static int op_delete_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Delete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_DELETE_SUBTHREAD
  • OP_DELETE_THREAD
  • OP_PURGE_THREAD

Definition at line 556 of file functions.c.

558{
559 /* L10N: CHECK_ACL */
560 /* L10N: Due to the implementation details we do not know whether we
561 delete zero, 1, 12, ... messages. So in English we use
562 "messages". Your language might have other means to express this. */
563 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
564 return FR_ERROR;
565 if (!shared->email)
566 return FR_NO_ACTION;
567
568 int subthread = (op == OP_DELETE_SUBTHREAD);
569 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_DELETE, true, subthread);
570 if (rc == -1)
571 return FR_ERROR;
572 if (op == OP_PURGE_THREAD)
573 {
574 rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_PURGE, true, subthread);
575 if (rc == -1)
576 return FR_ERROR;
577 }
578
579 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
580 if (c_delete_untag)
581 mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_TAG, false, subthread);
582
585 return FR_SUCCESS;
586}
int mutt_thread_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool subthread)
Set a flag on an entire thread.
Definition: flags.c:381
+ Here is the call graph for this function:

◆ op_display_address()

static int op_display_address ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Display full address of sender - Implements index_function_t -.

Definition at line 591 of file functions.c.

593{
594 if (!shared->email)
595 return FR_NO_ACTION;
597
598 return FR_SUCCESS;
599}
void mutt_display_address(struct Envelope *env)
Display the address of a message.
Definition: external.c:661
+ Here is the call graph for this function:

◆ op_display_message()

static int op_display_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Display a message - Implements index_function_t -.

This function handles:

  • OP_DISPLAY_HEADERS
  • OP_DISPLAY_MESSAGE

Definition at line 608 of file functions.c.

610{
611 if (!shared->email)
612 return FR_NO_ACTION;
613 /* toggle the weeding of headers so that a user can press the key
614 * again while reading the message. */
615 if (op == OP_DISPLAY_HEADERS)
616 {
617 bool_str_toggle(shared->sub, "weed", NULL);
618 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, shared);
619 if (!window_is_focused(priv->win_index))
620 return FR_SUCCESS;
621 }
622
623 OptNeedResort = false;
624
625 if (mutt_using_threads() && shared->email->collapsed)
626 {
628 mutt_set_vnum(shared->mailbox);
629 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
630 if (c_uncollapse_jump)
632 }
633
634 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
635 if (c_pgp_auto_decode &&
636 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
637 {
638 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
639 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
640 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
642 ARRAY_FREE(&ea);
643 }
644 const int index = menu_get_index(priv->menu);
646
647 const char *const c_pager = pager_get_pager(NeoMutt->sub);
648 if (c_pager)
649 {
650 op = external_pager(shared->mailbox_view, shared->email, c_pager);
651 }
652 else
653 {
654 op = mutt_display_message(priv->win_index, shared);
655 }
656
658 if (op < OP_NULL)
659 {
660 OptNeedResort = false;
661 return FR_ERROR;
662 }
663
664 if (shared->mailbox)
665 {
667 shared->mailbox->msg_count, shared);
668 }
669
670 return op;
671}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:223
void update_index(struct Menu *menu, struct MailboxView *mv, enum MxStatus check, int oldcount, const struct IndexSharedData *shared)
Update the index.
Definition: dlg_index.c:538
bool OptNeedResort
(pseudo) used to force a re-sort
Definition: globals.c:74
#define NT_INDEX_EMAIL
Email has changed.
Definition: lib.h:65
void index_shared_data_set_email(struct IndexSharedData *shared, struct Email *e)
Set the current Email for the Index and friends.
Definition: shared_data.c:234
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:156
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:170
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
off_t mutt_set_vnum(struct Mailbox *m)
Set the virtual index number of all the messages in a mailbox.
Definition: mutt_thread.c:1401
#define mutt_thread_next_unread(e)
Definition: mutt_thread.h:109
#define mutt_using_threads()
Definition: mutt_thread.h:112
#define mutt_uncollapse_thread(e)
Definition: mutt_thread.h:106
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:654
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:684
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition: mview.c:417
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition: mxapi.h:66
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition: notify_type.h:48
const char * pager_get_pager(struct ConfigSubset *sub)
Get the value of $pager.
Definition: config.c:103
int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *shared)
Display a message in the pager.
Definition: message.c:457
int external_pager(struct MailboxView *mv, struct Email *e, const char *command)
Display a message in an external program.
Definition: message.c:311
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:121
struct MuttWindow * win_index
Window for the Index.
Definition: private_data.h:42
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition: shared_data.h:44
int msg_count
Total number of messages.
Definition: mailbox.h:88
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:

◆ op_edit_label()

static int op_edit_label ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Add, change, or delete a message's label - Implements index_function_t -.

Definition at line 676 of file functions.c.

677{
678 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
679 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
680 int num_changed = mutt_label_message(shared->mailbox_view, &ea);
681 ARRAY_FREE(&ea);
682
683 if (num_changed > 0)
684 {
685 shared->mailbox->changed = true;
687 /* L10N: This is displayed when the x-label on one or more
688 messages is edited. */
689 mutt_message(ngettext("%d label changed", "%d labels changed", num_changed), num_changed);
690
691 if (!priv->tag_prefix)
693 return FR_SUCCESS;
694 }
695
696 /* L10N: This is displayed when editing an x-label, but no messages
697 were updated. Possibly due to canceling at the prompt or if the new
698 label is the same as the old label. */
699 mutt_message(_("No labels changed"));
700 return FR_NO_ACTION;
701}
#define mutt_message(...)
Definition: logging2.h:91
int mutt_label_message(struct MailboxView *mv, struct EmailArray *ea)
Let the user label a message.
Definition: mutt_header.c:128
bool changed
Mailbox has been modified.
Definition: mailbox.h:109
+ Here is the call graph for this function:

◆ op_edit_raw_message()

static int op_edit_raw_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Edit the raw message (edit and edit-raw-message are synonyms) - Implements index_function_t -.

This function handles:

  • OP_EDIT_OR_VIEW_RAW_MESSAGE
  • OP_EDIT_RAW_MESSAGE
  • OP_VIEW_RAW_MESSAGE

Definition at line 711 of file functions.c.

713{
714 /* TODO split this into 3 cases? */
715 bool edit;
716 if (op == OP_EDIT_RAW_MESSAGE)
717 {
718 /* L10N: CHECK_ACL */
719 if (!check_acl(shared->mailbox, MUTT_ACL_INSERT, _("Can't edit message")))
720 return FR_ERROR;
721 edit = true;
722 }
723 else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
724 {
725 edit = !shared->mailbox->readonly && (shared->mailbox->rights & MUTT_ACL_INSERT);
726 }
727 else
728 {
729 edit = false;
730 }
731
732 if (!shared->email)
733 return FR_NO_ACTION;
734 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
735 if (c_pgp_auto_decode &&
736 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
737 {
738 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
739 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
740 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
742 ARRAY_FREE(&ea);
743 }
744 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
745 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
746 mutt_ev_message(shared->mailbox, &ea, edit ? EVM_EDIT : EVM_VIEW);
747 ARRAY_FREE(&ea);
749
750 return FR_SUCCESS;
751}
int mutt_ev_message(struct Mailbox *m, struct EmailArray *ea, enum EvMessage action)
Edit or view a message.
Definition: editmsg.c:280
#define MUTT_ACL_INSERT
Add/copy into the mailbox (used when editing a message)
Definition: mailbox.h:66
@ EVM_VIEW
View the message.
Definition: protos.h:52
@ EVM_EDIT
Edit the message.
Definition: protos.h:53
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:118
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:115
+ Here is the call graph for this function:

◆ op_end_cond()

static int op_end_cond ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

End of conditional execution (noop) - Implements index_function_t -.

Definition at line 756 of file functions.c.

757{
758 return FR_SUCCESS;
759}

◆ op_exit()

static int op_exit ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Exit this menu - Implements index_function_t -.

Definition at line 764 of file functions.c.

765{
766 if (shared->attach_msg)
767 return FR_DONE;
768
769 if (query_quadoption(_("Exit NeoMutt without saving?"), shared->sub, "quit") == MUTT_YES)
770 {
771 if (shared->mailbox_view)
772 {
773 mx_fastclose_mailbox(shared->mailbox, false);
774 mview_free(&shared->mailbox_view);
775 }
776 return FR_DONE;
777 }
778
779 return FR_NO_ACTION;
780}
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition: mview.c:49
void mx_fastclose_mailbox(struct Mailbox *m, bool keep_account)
Free up memory associated with the Mailbox.
Definition: mx.c:410
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
Definition: question.c:369
bool attach_msg
Are we in "attach message" mode?
Definition: shared_data.h:46
+ Here is the call graph for this function:

◆ op_extract_keys()

static int op_extract_keys ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Extract supported public keys - Implements index_function_t -.

Definition at line 785 of file functions.c.

787{
788 if (!WithCrypto)
789 return FR_NOT_IMPL;
790 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
791 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
793 ARRAY_FREE(&ea);
795
796 return FR_SUCCESS;
797}
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailArray *ea)
Extract keys from a message.
Definition: crypt.c:847
+ Here is the call graph for this function:

◆ op_flag_message()

static int op_flag_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Toggle a message's 'important' flag - Implements index_function_t -.

Definition at line 802 of file functions.c.

804{
805 /* L10N: CHECK_ACL */
806 if (!check_acl(shared->mailbox, MUTT_ACL_WRITE, _("Can't flag message")))
807 return FR_ERROR;
808
809 struct Mailbox *m = shared->mailbox;
810 if (priv->tag_prefix)
811 {
812 for (size_t i = 0; i < m->msg_count; i++)
813 {
814 struct Email *e = m->emails[i];
815 if (!e)
816 break;
817 if (message_is_tagged(e))
818 mutt_set_flag(m, e, MUTT_FLAG, !e->flagged, true);
819 }
820
822 }
823 else
824 {
825 if (!shared->email)
826 return FR_NO_ACTION;
827 mutt_set_flag(m, shared->email, MUTT_FLAG, !shared->email->flagged, true);
828
830 }
831
832 return FR_SUCCESS;
833}
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
Definition: flags.c:53
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition: mailbox.h:71
@ MUTT_FLAG
Flagged messages.
Definition: mutt.h:78
bool message_is_tagged(struct Email *e)
Is a message in the index tagged (and within limit)
Definition: mview.c:363
The envelope/body of an email.
Definition: email.h:37
bool flagged
Marked important?
Definition: email.h:45
A mailbox.
Definition: mailbox.h:79
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
+ Here is the call graph for this function:

◆ op_forget_passphrase()

static int op_forget_passphrase ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Wipe passphrases from memory - Implements index_function_t -.

Definition at line 838 of file functions.c.

840{
842 return FR_SUCCESS;
843}
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition: crypt.c:93
+ Here is the call graph for this function:

◆ op_forward_message()

static int op_forward_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Forward a message with comments - Implements index_function_t -.

Definition at line 848 of file functions.c.

850{
851 if (!shared->email)
852 return FR_NO_ACTION;
853 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
854 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
855 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
856 if (c_pgp_auto_decode &&
857 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
858 {
859 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
861 }
862 int rc = mutt_send_message(SEND_FORWARD, NULL, NULL, shared->mailbox, &ea,
863 shared->sub);
864 ARRAY_FREE(&ea);
866
867 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
868}
#define SEND_FORWARD
Forward email.
Definition: send.h:43
+ Here is the call graph for this function:

◆ op_group_reply()

static int op_group_reply ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Reply to all recipients - Implements index_function_t -.

This function handles:

  • OP_GROUP_CHAT_REPLY
  • OP_GROUP_REPLY

Definition at line 877 of file functions.c.

879{
880 SendFlags replyflags = SEND_REPLY;
881 if (op == OP_GROUP_REPLY)
882 replyflags |= SEND_GROUP_REPLY;
883 else
884 replyflags |= SEND_GROUP_CHAT_REPLY;
885 if (!shared->email)
886 return FR_NO_ACTION;
887 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
888 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
889 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
890 if (c_pgp_auto_decode &&
891 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
892 {
893 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
895 }
896 int rc = mutt_send_message(replyflags, NULL, NULL, shared->mailbox, &ea,
897 shared->sub);
898 ARRAY_FREE(&ea);
900
901 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
902}
#define SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition: send.h:52
#define SEND_GROUP_REPLY
Reply to all.
Definition: send.h:41
#define SEND_REPLY
Reply to sender.
Definition: send.h:40
uint16_t SendFlags
Flags for mutt_send_message(), e.g. SEND_REPLY.
Definition: send.h:38
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Jump to an index number - Implements index_function_t -.

Definition at line 907 of file functions.c.

908{
909 int rc = FR_ERROR;
910 struct Buffer *buf = buf_pool_get();
911
912 const int digit = op - OP_JUMP;
913 if ((digit > 0) && (digit < 10))
914 {
915 mutt_unget_ch('0' + digit);
916 }
917
918 int msg_num = 0;
919 if ((mw_get_field(_("Jump to message: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
920 buf_is_empty(buf))
921 {
922 mutt_message(_("Nothing to do"));
923 rc = FR_NO_ACTION;
924 }
925 else if (!mutt_str_atoi_full(buf_string(buf), &msg_num))
926 {
927 mutt_warning(_("Argument must be a message number"));
928 }
929 else if ((msg_num < 1) || (msg_num > shared->mailbox->msg_count))
930 {
931 mutt_warning(_("Invalid message number"));
932 }
933 else if (!shared->mailbox->emails[msg_num - 1]->visible)
934 {
935 mutt_warning(_("That message is not visible"));
936 }
937 else
938 {
939 struct Email *e = shared->mailbox->emails[msg_num - 1];
940
941 if (mutt_messages_in_thread(shared->mailbox, e, MIT_POSITION) > 1)
942 {
944 mutt_set_vnum(shared->mailbox);
945 }
946 menu_set_index(priv->menu, e->vnum);
947 rc = FR_SUCCESS;
948 }
949
950 buf_pool_release(&buf);
951 return rc;
952}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:303
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
int digit(const char *s)
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition: get.c:114
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition: window.c:275
#define mutt_warning(...)
Definition: logging2.h:90
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:56
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:55
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, enum MessageInThread mit)
Count the messages in a thread.
Definition: mutt_thread.c:1654
@ MIT_POSITION
Our position in the thread.
Definition: mutt_thread.h:88
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
String manipulation buffer.
Definition: buffer.h:34
bool visible
Is this message part of the view?
Definition: email.h:122
int vnum
Virtual message number.
Definition: email.h:115
+ Here is the call graph for this function:

◆ op_list_reply()

static int op_list_reply ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Reply to specified mailing list - Implements index_function_t -.

Definition at line 957 of file functions.c.

958{
959 if (!shared->email)
960 return FR_NO_ACTION;
961 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
962 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
963 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
964 if (c_pgp_auto_decode &&
965 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
966 {
967 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
969 }
970 int rc = mutt_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL,
971 shared->mailbox, &ea, shared->sub);
972 ARRAY_FREE(&ea);
974
975 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
976}
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:42
+ Here is the call graph for this function:

◆ op_list_subscribe()

static int op_list_subscribe ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Subscribe to a mailing list - Implements index_function_t -.

Definition at line 981 of file functions.c.

983{
984 return mutt_send_list_subscribe(shared->mailbox, shared->email) ? FR_SUCCESS : FR_NO_ACTION;
985}
bool mutt_send_list_subscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list subscription email.
Definition: send.c:3003
+ Here is the call graph for this function:

◆ op_list_unsubscribe()

static int op_list_unsubscribe ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Unsubscribe from mailing list - Implements index_function_t -.

Definition at line 990 of file functions.c.

992{
994}
bool mutt_send_list_unsubscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list unsubscription email.
Definition: send.c:3032
+ Here is the call graph for this function:

◆ op_mail()

static int op_mail ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Compose a new mail message - Implements index_function_t -.

Definition at line 999 of file functions.c.

1000{
1001 int rc = mutt_send_message(SEND_NO_FLAGS, NULL, NULL, shared->mailbox, NULL,
1002 shared->sub);
1004 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1005}
#define SEND_NO_FLAGS
No flags are set.
Definition: send.h:39
+ Here is the call graph for this function:

◆ op_mailbox_list()

static int op_mailbox_list ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

List mailboxes with new mail - Implements index_function_t -.

Definition at line 1010 of file functions.c.

1012{
1014 return FR_SUCCESS;
1015}
bool mutt_mailbox_list(void)
Show a message with the list of mailboxes with new mail.
Definition: mutt_mailbox.c:245
+ Here is the call graph for this function:

◆ op_mail_key()

static int op_mail_key ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Mail a PGP public key - Implements index_function_t -.

Definition at line 1020 of file functions.c.

1021{
1022 if (!(WithCrypto & APPLICATION_PGP))
1023 return FR_NOT_IMPL;
1024 int rc = mutt_send_message(SEND_KEY, NULL, NULL, NULL, NULL, shared->sub);
1026
1027 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1028}
#define SEND_KEY
Mail a PGP public key.
Definition: send.h:46
+ Here is the call graph for this function:

◆ op_main_break_thread()

static int op_main_break_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Break the thread in two - Implements index_function_t -.

Definition at line 1033 of file functions.c.

1035{
1036 struct Mailbox *m = shared->mailbox;
1037 /* L10N: CHECK_ACL */
1038 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't break thread")))
1039 return FR_ERROR;
1040
1041 struct Email *e = shared->email;
1042 if (!e)
1043 return FR_NO_ACTION;
1044
1045 if (!mutt_using_threads())
1046 {
1047 mutt_warning(_("Threading is not enabled"));
1048 return FR_NO_ACTION;
1049 }
1050
1051 struct MailboxView *mv = shared->mailbox_view;
1053 {
1054 {
1056 mutt_sort_headers(mv, true);
1057 menu_set_index(priv->menu, e->vnum);
1058 }
1059
1060 m->changed = true;
1061 mutt_message(_("Thread broken"));
1062
1064 }
1065 else
1066 {
1067 mutt_error(_("Thread can't be broken, message is not part of a thread"));
1068 }
1069
1070 return FR_SUCCESS;
1071}
#define mutt_error(...)
Definition: logging2.h:92
#define STAILQ_EMPTY(head)
Definition: queue.h:348
void mutt_sort_headers(struct MailboxView *mv, bool init)
Sort emails by their headers.
Definition: sort.c:348
struct ListHead references
message references (in reverse order)
Definition: envelope.h:83
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:84
View of a Mailbox.
Definition: mview.h:39
void mutt_break_thread(struct Email *e)
Break the email Thread.
Definition: thread.c:226
+ Here is the call graph for this function:

◆ op_main_change_folder()

static int op_main_change_folder ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Open a different folder - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_FOLDER
  • OP_MAIN_CHANGE_FOLDER_READONLY
  • OP_MAIN_CHANGE_VFOLDER

Definition at line 1081 of file functions.c.

1083{
1084 struct Buffer *folderbuf = buf_pool_get();
1085 buf_alloc(folderbuf, PATH_MAX);
1086
1087 char *cp = NULL;
1088 bool read_only;
1089 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
1090 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_FOLDER_READONLY))
1091 {
1092 cp = _("Open mailbox in read-only mode");
1093 read_only = true;
1094 }
1095 else
1096 {
1097 cp = _("Open mailbox");
1098 read_only = false;
1099 }
1100
1101 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
1102 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
1103 {
1104 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
1105 buf_pretty_mailbox(folderbuf);
1106 }
1107 /* By default, fill buf with the next mailbox that contains unread mail */
1108 mutt_mailbox_next(shared->mailbox_view ? shared->mailbox : NULL, folderbuf);
1109
1110 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
1111 MUTT_SEL_NO_FLAGS) == -1)
1112 {
1113 goto changefoldercleanup;
1114 }
1115
1116 /* Selected directory is okay, let's save it. */
1118
1119 if (buf_is_empty(folderbuf))
1120 {
1121 msgwin_clear_text(NULL);
1122 goto changefoldercleanup;
1123 }
1124
1125 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
1126 if (m)
1127 {
1128 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
1129 }
1130 else
1131 {
1132 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
1133 }
1134
1135changefoldercleanup:
1136 buf_pool_release(&folderbuf);
1138
1139 return FR_SUCCESS;
1140}
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition: lib.h:57
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:407
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:349
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
Definition: dlg_browser.c:1203
void change_folder_mailbox(struct Menu *menu, struct Mailbox *m, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Mailbox by pointer.
Definition: dlg_index.c:607
void change_folder_string(struct Menu *menu, struct Buffer *buf, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Mailbox by string.
Definition: dlg_index.c:751
int mw_enter_fname(const char *prompt, struct Buffer *fname, bool mailbox, struct Mailbox *m, bool multiple, char ***files, int *numfiles, SelectFileFlags flags)
Ask the user to select a file -.
Definition: curs_lib.c:247
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:210
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
Definition: msgwin.c:516
#define PATH_MAX
Definition: mutt.h:41
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
Definition: mutt_mailbox.c:366
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:556
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1610
int oldcount
Old count of mails in the mailbox.
Definition: private_data.h:37
struct Buffer pathbuf
Path of the Mailbox.
Definition: mailbox.h:80
+ Here is the call graph for this function:

◆ op_main_collapse_all()

static int op_main_collapse_all ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Collapse/uncollapse all threads - Implements index_function_t -.

Definition at line 1145 of file functions.c.

1147{
1148 if (!mutt_using_threads())
1149 {
1150 mutt_error(_("Threading is not enabled"));
1151 return FR_ERROR;
1152 }
1153 collapse_all(shared->mailbox_view, priv->menu, 1);
1154
1155 return FR_SUCCESS;
1156}
void collapse_all(struct MailboxView *mv, struct Menu *menu, int toggle)
Collapse/uncollapse all threads.
Definition: dlg_index.c:161
+ Here is the call graph for this function:

◆ op_main_collapse_thread()

static int op_main_collapse_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Collapse/uncollapse current thread - Implements index_function_t -.

Definition at line 1161 of file functions.c.

1163{
1164 if (!mutt_using_threads())
1165 {
1166 mutt_error(_("Threading is not enabled"));
1167 return FR_ERROR;
1168 }
1169
1170 if (!shared->email)
1171 return FR_NO_ACTION;
1172
1173 if (shared->email->collapsed)
1174 {
1175 int index = mutt_uncollapse_thread(shared->email);
1176 mutt_set_vnum(shared->mailbox);
1177 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
1178 if (c_uncollapse_jump)
1179 index = mutt_thread_next_unread(shared->email);
1180 menu_set_index(priv->menu, index);
1181 }
1182 else if (mutt_thread_can_collapse(shared->email))
1183 {
1185 mutt_set_vnum(shared->mailbox);
1186 }
1187 else
1188 {
1189 mutt_error(_("Thread contains unread or flagged messages"));
1190 return FR_ERROR;
1191 }
1192
1194
1195 return FR_SUCCESS;
1196}
bool mutt_thread_can_collapse(struct Email *e)
Check whether a thread can be collapsed.
Definition: mutt_thread.c:1814
#define mutt_collapse_thread(e)
Definition: mutt_thread.h:105
+ Here is the call graph for this function:

◆ op_main_delete_pattern()

static int op_main_delete_pattern ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Delete messages matching a pattern - Implements index_function_t -.

Definition at line 1201 of file functions.c.

1203{
1204 /* L10N: CHECK_ACL */
1205 /* L10N: Due to the implementation details we do not know whether we
1206 delete zero, 1, 12, ... messages. So in English we use
1207 "messages". Your language might have other means to express this. */
1208 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
1209 return FR_ERROR;
1210
1211 mutt_pattern_func(shared->mailbox_view, MUTT_DELETE, _("Delete messages matching: "));
1213
1214 return FR_SUCCESS;
1215}
int mutt_pattern_func(struct MailboxView *mv, int op, char *prompt)
Perform some Pattern matching.
Definition: pattern.c:288
+ Here is the call graph for this function:

◆ op_main_limit()

static int op_main_limit ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Limit view to a pattern/thread - Implements index_function_t -.

This function handles:

  • OP_LIMIT_CURRENT_THREAD
  • OP_MAIN_LIMIT
  • OP_TOGGLE_READ

Definition at line 1225 of file functions.c.

1226{
1227 const bool lmt = mview_has_limit(shared->mailbox_view);
1228 int old_index = shared->email ? shared->email->index : -1;
1229 if (op == OP_TOGGLE_READ)
1230 {
1231 char buf2[1024];
1232
1233 if (!lmt || !mutt_strn_equal(shared->mailbox_view->pattern, "!~R!~D~s", 8))
1234 {
1235 snprintf(buf2, sizeof(buf2), "!~R!~D~s%s", lmt ? shared->mailbox_view->pattern : ".*");
1236 }
1237 else
1238 {
1239 mutt_str_copy(buf2, shared->mailbox_view->pattern + 8, sizeof(buf2));
1240 if ((*buf2 == '\0') || mutt_strn_equal(buf2, ".*", 2))
1241 snprintf(buf2, sizeof(buf2), "~A");
1242 }
1243 mutt_str_replace(&shared->mailbox_view->pattern, buf2);
1245 }
1246
1247 if (((op == OP_LIMIT_CURRENT_THREAD) &&
1248 mutt_limit_current_thread(shared->mailbox_view, shared->email)) ||
1249 (op == OP_TOGGLE_READ) ||
1250 ((op == OP_MAIN_LIMIT) && (mutt_pattern_func(shared->mailbox_view, MUTT_LIMIT,
1251 _("Limit to messages matching: ")) == 0)))
1252 {
1253 priv->menu->max = shared->mailbox->vcount;
1254 menu_set_index(priv->menu, 0);
1255 if (old_index >= 0)
1256 {
1257 /* try to find what used to be the current message */
1258 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1259 {
1260 struct Email *e = mutt_get_virt_email(shared->mailbox, i);
1261 if (!e)
1262 continue;
1263 if (e->index == old_index)
1264 {
1265 menu_set_index(priv->menu, i);
1266 break;
1267 }
1268 }
1269 }
1270
1271 if ((shared->mailbox->msg_count != 0) && mutt_using_threads())
1272 {
1273 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
1274 if (c_collapse_all)
1275 collapse_all(shared->mailbox_view, priv->menu, 0);
1277 }
1279 }
1280 if (lmt)
1281 mutt_message(_("To view all messages, limit to \"all\""));
1282
1283 return FR_SUCCESS;
1284}
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition: string.c:497
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:653
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:327
@ MUTT_LIMIT
Messages in limited view.
Definition: mutt.h:81
void mutt_draw_tree(struct ThreadsContext *tctx)
Draw a tree of threaded emails.
Definition: mutt_thread.c:391
bool mutt_limit_current_thread(struct MailboxView *mv, struct Email *e)
Limit the email view to the current thread.
Definition: mview.c:480
bool mview_has_limit(const struct MailboxView *mv)
Is a limit active?
Definition: mview.c:438
int index
The absolute (unsorted) message number.
Definition: email.h:111
struct ThreadsContext * threads
Threads context.
Definition: mview.h:43
char * pattern
Limit pattern string.
Definition: mview.h:41
int vcount
The number of virtual messages.
Definition: mailbox.h:99
int max
Number of entries in the menu.
Definition: lib.h:72
+ Here is the call graph for this function:

◆ op_main_link_threads()

static int op_main_link_threads ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Link tagged message to the current one - Implements index_function_t -.

Definition at line 1289 of file functions.c.

1291{
1292 struct Mailbox *m = shared->mailbox;
1293 /* L10N: CHECK_ACL */
1294 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't link threads")))
1295 return FR_ERROR;
1296
1297 struct Email *e = shared->email;
1298 if (!e)
1299 return FR_NO_ACTION;
1300
1301 enum FunctionRetval rc = FR_ERROR;
1302
1303 if (!mutt_using_threads())
1304 {
1305 mutt_error(_("Threading is not enabled"));
1306 }
1307 else if (!e->env->message_id)
1308 {
1309 mutt_error(_("No Message-ID: header available to link thread"));
1310 }
1311 else
1312 {
1313 struct MailboxView *mv = shared->mailbox_view;
1314 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1315 ea_add_tagged(&ea, mv, NULL, true);
1316
1317 if (mutt_link_threads(e, &ea, m))
1318 {
1319 mutt_sort_headers(mv, true);
1320 menu_set_index(priv->menu, e->vnum);
1321
1322 m->changed = true;
1323 mutt_message(_("Threads linked"));
1324 rc = FR_SUCCESS;
1325 }
1326 else
1327 {
1328 mutt_error(_("No thread linked"));
1329 rc = FR_NO_ACTION;
1330 }
1331
1332 ARRAY_FREE(&ea);
1333 }
1334
1336 return rc;
1337}
FunctionRetval
Possible return values for NeoMutt functions.
Definition: dispatcher.h:32
bool mutt_link_threads(struct Email *parent, struct EmailArray *children, struct Mailbox *m)
Forcibly link threads together.
Definition: mutt_thread.c:1744
char * message_id
Message ID.
Definition: envelope.h:73
+ Here is the call graph for this function:

◆ op_main_modify_tags()

static int op_main_modify_tags ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Modify (notmuch/imap) tags - Implements index_function_t -.

This function handles:

  • OP_MAIN_MODIFY_TAGS
  • OP_MAIN_MODIFY_TAGS_THEN_HIDE

Definition at line 1346 of file functions.c.

1348{
1349 int rc = FR_ERROR;
1350 struct Buffer *buf = NULL;
1351
1352 if (!shared->mailbox)
1353 goto done;
1354 struct Mailbox *m = shared->mailbox;
1355 if (!mx_tags_is_supported(m))
1356 {
1357 mutt_message(_("Folder doesn't support tagging, aborting"));
1358 goto done;
1359 }
1360 if (!shared->email)
1361 {
1362 rc = FR_NO_ACTION;
1363 goto done;
1364 }
1365
1366 char *tags = NULL;
1367 if (!priv->tag_prefix)
1368 tags = driver_tags_get_with_hidden(&shared->email->tags);
1369 buf = buf_pool_get();
1370 int rc2 = mx_tags_edit(m, tags, buf);
1371 FREE(&tags);
1372 if (rc2 < 0)
1373 {
1374 goto done;
1375 }
1376 else if (rc2 == 0)
1377 {
1378 mutt_message(_("No tag specified, aborting"));
1379 goto done;
1380 }
1381
1382 if (priv->tag_prefix)
1383 {
1384 struct Progress *progress = NULL;
1385
1386 if (m->verbose)
1387 {
1389 progress_set_message(progress, _("Update tags..."));
1390 }
1391
1392#ifdef USE_NOTMUCH
1393 if (m->type == MUTT_NOTMUCH)
1394 nm_db_longrun_init(m, true);
1395#endif
1396 for (int px = 0, i = 0; i < m->msg_count; i++)
1397 {
1398 struct Email *e = m->emails[i];
1399 if (!e)
1400 break;
1401 if (!message_is_tagged(e))
1402 continue;
1403
1404 progress_update(progress, ++px, -1);
1405 mx_tags_commit(m, e, buf_string(buf));
1406 e->attr_color = NULL;
1407 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1408 {
1409 bool still_queried = false;
1410#ifdef USE_NOTMUCH
1411 if (m->type == MUTT_NOTMUCH)
1412 still_queried = nm_message_is_still_queried(m, e);
1413#endif
1414 e->quasi_deleted = !still_queried;
1415 m->changed = true;
1416 }
1417 }
1418 progress_free(&progress);
1419#ifdef USE_NOTMUCH
1420 if (m->type == MUTT_NOTMUCH)
1422#endif
1424 }
1425 else
1426 {
1427 if (mx_tags_commit(m, shared->email, buf_string(buf)))
1428 {
1429 mutt_message(_("Failed to modify tags, aborting"));
1430 goto done;
1431 }
1432 shared->email->attr_color = NULL;
1433 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1434 {
1435 bool still_queried = false;
1436#ifdef USE_NOTMUCH
1437 if (m->type == MUTT_NOTMUCH)
1438 still_queried = nm_message_is_still_queried(m, shared->email);
1439#endif
1440 shared->email->quasi_deleted = !still_queried;
1441 m->changed = true;
1442 }
1443
1445 }
1446 rc = FR_SUCCESS;
1447
1448done:
1449 buf_pool_release(&buf);
1450 return rc;
1451}
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
#define FREE(x)
Definition: memory.h:45
int mx_tags_edit(struct Mailbox *m, const char *tags, struct Buffer *buf)
Start the tag editor of the mailbox.
Definition: mx.c:1279
bool mx_tags_is_supported(struct Mailbox *m)
Return true if mailbox support tagging.
Definition: mx.c:1316
int mx_tags_commit(struct Mailbox *m, struct Email *e, const char *tags)
Save tags to the Mailbox - Wrapper for MxOps::tags_commit()
Definition: mx.c:1299
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: db.c:370
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: db.c:355
bool nm_message_is_still_queried(struct Mailbox *m, struct Email *e)
Is a message still visible in the query?
Definition: notmuch.c:1684
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
Definition: lib.h:83
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
Definition: progress.c:140
void progress_free(struct Progress **ptr)
Free a Progress Bar.
Definition: progress.c:111
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition: progress.c:81
const struct AttrColor * attr_color
Color-pair to use when displaying in the index.
Definition: email.h:113
struct TagList tags
For drivers that support server tagging.
Definition: email.h:70
bool quasi_deleted
Deleted from neomutt, but not modified on disk.
Definition: email.h:104
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:94
bool verbose
Display status messages?
Definition: mailbox.h:116
char * driver_tags_get_with_hidden(struct TagList *list)
Get tags with hiddens.
Definition: tags.c:158
+ Here is the call graph for this function:

◆ op_main_next_new()

static int op_main_next_new ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Jump to the next new message - Implements index_function_t -.

This function handles:

  • OP_MAIN_NEXT_NEW
  • OP_MAIN_NEXT_NEW_THEN_UNREAD
  • OP_MAIN_NEXT_UNREAD
  • OP_MAIN_PREV_NEW
  • OP_MAIN_PREV_NEW_THEN_UNREAD
  • OP_MAIN_PREV_UNREAD

Definition at line 1464 of file functions.c.

1466{
1467 int first_unread = -1;
1468 int first_new = -1;
1469
1470 const int saved_current = menu_get_index(priv->menu);
1471 int mcur = saved_current;
1472 int index = -1;
1473 const bool threaded = mutt_using_threads();
1474 for (size_t i = 0; i != shared->mailbox->vcount; i++)
1475 {
1476 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_NEXT_UNREAD) ||
1477 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD))
1478 {
1479 mcur++;
1480 if (mcur > (shared->mailbox->vcount - 1))
1481 {
1482 mcur = 0;
1483 }
1484 }
1485 else
1486 {
1487 mcur--;
1488 if (mcur < 0)
1489 {
1490 mcur = shared->mailbox->vcount - 1;
1491 }
1492 }
1493
1494 struct Email *e = mutt_get_virt_email(shared->mailbox, mcur);
1495 if (!e)
1496 break;
1497 if (e->collapsed && threaded)
1498 {
1499 int unread = mutt_thread_contains_unread(e);
1500 if ((unread != 0) && (first_unread == -1))
1501 first_unread = mcur;
1502 if ((unread == 1) && (first_new == -1))
1503 first_new = mcur;
1504 }
1505 else if (!e->deleted && !e->read)
1506 {
1507 if (first_unread == -1)
1508 first_unread = mcur;
1509 if (!e->old && (first_new == -1))
1510 first_new = mcur;
1511 }
1512
1513 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD)) && (first_unread != -1))
1514 {
1515 break;
1516 }
1517 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
1518 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1519 (first_new != -1))
1520 {
1521 break;
1522 }
1523 }
1524 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
1525 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1526 (first_new != -1))
1527 {
1528 index = first_new;
1529 }
1530 else if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD) ||
1531 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1532 (first_unread != -1))
1533 {
1534 index = first_unread;
1535 }
1536
1537 if (index == -1)
1538 {
1539 menu_set_index(priv->menu, saved_current);
1540 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW))
1541 {
1542 if (mview_has_limit(shared->mailbox_view))
1543 mutt_error(_("No new messages in this limited view"));
1544 else
1545 mutt_error(_("No new messages"));
1546 }
1547 else
1548 {
1549 if (mview_has_limit(shared->mailbox_view))
1550 mutt_error(_("No unread messages in this limited view"));
1551 else
1552 mutt_error(_("No unread messages"));
1553 }
1554 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1555 return FR_ERROR;
1556 }
1557 else
1558 {
1559 menu_set_index(priv->menu, index);
1560 }
1561
1562 index = menu_get_index(priv->menu);
1563 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_NEXT_UNREAD) ||
1564 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD))
1565 {
1566 if (saved_current > index)
1567 {
1568 mutt_message(_("Search wrapped to top"));
1569 }
1570 }
1571 else if (saved_current < index)
1572 {
1573 mutt_message(_("Search wrapped to bottom"));
1574 }
1575
1576 return FR_SUCCESS;
1577}
#define mutt_thread_contains_unread(e)
Definition: mutt_thread.h:107
bool read
Email is read.
Definition: email.h:48
bool old
Email is seen, but unread.
Definition: email.h:47
bool threaded
Used for threading.
Definition: email.h:109
bool deleted
Email is deleted.
Definition: email.h:76
+ Here is the call graph for this function:

◆ op_main_next_thread()

static int op_main_next_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Jump to the next thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_NEXT_SUBTHREAD
  • OP_MAIN_NEXT_THREAD
  • OP_MAIN_PREV_SUBTHREAD
  • OP_MAIN_PREV_THREAD

Definition at line 1588 of file functions.c.

1590{
1591 int index = -1;
1592 switch (op)
1593 {
1594 case OP_MAIN_NEXT_THREAD:
1595 index = mutt_next_thread(shared->email);
1596 break;
1597
1598 case OP_MAIN_NEXT_SUBTHREAD:
1599 index = mutt_next_subthread(shared->email);
1600 break;
1601
1602 case OP_MAIN_PREV_THREAD:
1603 index = mutt_previous_thread(shared->email);
1604 break;
1605
1606 case OP_MAIN_PREV_SUBTHREAD:
1607 index = mutt_previous_subthread(shared->email);
1608 break;
1609 }
1610
1611 if (index != -1)
1612 menu_set_index(priv->menu, index);
1613
1614 if (index < 0)
1615 {
1616 if ((op == OP_MAIN_NEXT_THREAD) || (op == OP_MAIN_NEXT_SUBTHREAD))
1617 mutt_error(_("No more threads"));
1618 else
1619 mutt_error(_("You are on the first thread"));
1620
1621 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1622 }
1623
1624 return FR_SUCCESS;
1625}
#define mutt_previous_thread(e)
Definition: mutt_thread.h:119
#define mutt_next_subthread(e)
Definition: mutt_thread.h:120
#define mutt_previous_subthread(e)
Definition: mutt_thread.h:121
#define mutt_next_thread(e)
Definition: mutt_thread.h:118
+ Here is the call graph for this function:

◆ op_main_next_undeleted()

static int op_main_next_undeleted ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Move to the next undeleted message - Implements index_function_t -.

Definition at line 1630 of file functions.c.

1632{
1633 int index = menu_get_index(priv->menu);
1634 if (index >= (shared->mailbox->vcount - 1))
1635 {
1636 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1637 mutt_message(_("You are on the last message"));
1638 return FR_ERROR;
1639 }
1640
1641 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
1642
1643 index = find_next_undeleted(shared->mailbox_view, index, uncollapse);
1644 if (index != -1)
1645 {
1646 menu_set_index(priv->menu, index);
1647 if (uncollapse)
1649 }
1650
1651 if (index == -1)
1652 {
1653 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1654 mutt_error(_("No undeleted messages"));
1655 }
1656
1657 return FR_SUCCESS;
1658}
int find_next_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the next undeleted email.
Definition: dlg_index.c:237
+ Here is the call graph for this function:

◆ op_main_next_unread_mailbox()

static int op_main_next_unread_mailbox ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Open next mailbox with unread mail - Implements index_function_t -.

Definition at line 1663 of file functions.c.

1665{
1666 struct Mailbox *m = shared->mailbox;
1667
1668 struct Buffer *folderbuf = buf_pool_get();
1669 buf_strcpy(folderbuf, mailbox_path(m));
1670 m = mutt_mailbox_next_unread(m, folderbuf);
1671 buf_pool_release(&folderbuf);
1672
1673 if (!m)
1674 {
1675 mutt_error(_("No mailboxes have new mail"));
1676 return FR_ERROR;
1677 }
1678
1679 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
1680 return FR_SUCCESS;
1681}
struct Mailbox * mutt_mailbox_next_unread(struct Mailbox *m_cur, struct Buffer *s)
Find next mailbox with unread mail.
Definition: mutt_mailbox.c:392
+ Here is the call graph for this function:

◆ op_main_prev_undeleted()

static int op_main_prev_undeleted ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Move to the previous undeleted message - Implements index_function_t -.

Definition at line 1686 of file functions.c.

1688{
1689 int index = menu_get_index(priv->menu);
1690 if (index < 1)
1691 {
1692 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1693 mutt_message(_("You are on the first message"));
1694 return FR_ERROR;
1695 }
1696
1697 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
1698
1699 index = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
1700 if (index != -1)
1701 {
1702 menu_set_index(priv->menu, index);
1703 if (uncollapse)
1705 }
1706
1707 if (index == -1)
1708 {
1709 mutt_error(_("No undeleted messages"));
1710 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1711 }
1712
1713 return FR_SUCCESS;
1714}
int find_previous_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the previous undeleted email.
Definition: dlg_index.c:271
+ Here is the call graph for this function:

◆ op_main_quasi_delete()

static int op_main_quasi_delete ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Delete from NeoMutt, don't touch on disk - Implements index_function_t -.

Definition at line 1719 of file functions.c.

1721{
1722 if (priv->tag_prefix)
1723 {
1724 struct Mailbox *m = shared->mailbox;
1725 for (size_t i = 0; i < m->msg_count; i++)
1726 {
1727 struct Email *e = m->emails[i];
1728 if (!e)
1729 break;
1730 if (message_is_tagged(e))
1731 {
1732 e->quasi_deleted = true;
1733 m->changed = true;
1734 }
1735 }
1736 }
1737 else
1738 {
1739 if (!shared->email)
1740 return FR_NO_ACTION;
1741 shared->email->quasi_deleted = true;
1742 shared->mailbox->changed = true;
1743 }
1744
1745 return FR_SUCCESS;
1746}
+ Here is the call graph for this function:

◆ op_main_read_thread()

static int op_main_read_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Mark the current thread as read - Implements index_function_t -.

This function handles:

  • OP_MAIN_READ_SUBTHREAD
  • OP_MAIN_READ_THREAD

Definition at line 1755 of file functions.c.

1757{
1758 /* L10N: CHECK_ACL */
1759 /* L10N: Due to the implementation details we do not know whether we
1760 mark zero, 1, 12, ... messages as read. So in English we use
1761 "messages". Your language might have other means to express this. */
1762 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't mark messages as read")))
1763 return FR_ERROR;
1764
1765 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_READ, true,
1766 (op != OP_MAIN_READ_THREAD));
1767 if (rc != -1)
1768 {
1769 const enum ResolveMethod rm = (op == OP_MAIN_READ_THREAD) ? RESOLVE_NEXT_THREAD :
1771 resolve_email(priv, shared, rm);
1773 }
1774
1775 return FR_SUCCESS;
1776}
ResolveMethod
How to advance the cursor.
Definition: functions.c:330
@ RESOLVE_NEXT_SUBTHREAD
Next sibling sub-thread.
Definition: functions.c:334
@ RESOLVE_NEXT_THREAD
Next top-level thread.
Definition: functions.c:333
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition: mailbox.h:70
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:72
+ Here is the call graph for this function:

◆ op_main_root_message()

static int op_main_root_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Jump to root message in thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_PARENT_MESSAGE
  • OP_MAIN_ROOT_MESSAGE

Definition at line 1785 of file functions.c.

1787{
1788 int index = mutt_parent_message(shared->email, op == OP_MAIN_ROOT_MESSAGE);
1789 if (index != -1)
1790 menu_set_index(priv->menu, index);
1791
1792 return FR_SUCCESS;
1793}
int mutt_parent_message(struct Email *e, bool find_root)
Find the parent of a message.
Definition: mutt_thread.c:1351
+ Here is the call graph for this function:

◆ op_main_set_flag()

static int op_main_set_flag ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Set a status flag on a message - Implements index_function_t -.

This function handles:

  • OP_MAIN_CLEAR_FLAG
  • OP_MAIN_SET_FLAG

Definition at line 1802 of file functions.c.

1804{
1805 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1806 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1807
1808 if (mw_change_flag(shared->mailbox, &ea, (op == OP_MAIN_SET_FLAG)) == 0)
1809 {
1810 if (priv->tag_prefix)
1811 {
1813 }
1814 else
1815 {
1817 }
1818 }
1819 ARRAY_FREE(&ea);
1820
1821 return FR_SUCCESS;
1822}
int mw_change_flag(struct Mailbox *m, struct EmailArray *ea, bool bf)
Change the flag on a Message -.
Definition: flags.c:450
+ Here is the call graph for this function:

◆ op_main_show_limit()

static int op_main_show_limit ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Show currently active limit pattern - Implements index_function_t -.

Definition at line 1827 of file functions.c.

1829{
1830 if (mview_has_limit(shared->mailbox_view))
1831 {
1832 char buf2[256];
1833 /* L10N: ask for a limit to apply */
1834 snprintf(buf2, sizeof(buf2), _("Limit: %s"), shared->mailbox_view->pattern);
1835 mutt_message("%s", buf2);
1836 }
1837 else
1838 {
1839 mutt_message(_("No limit pattern is in effect"));
1840 }
1841
1842 return FR_SUCCESS;
1843}
+ Here is the call graph for this function:

◆ op_main_sync_folder()

static int op_main_sync_folder ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Save changes to mailbox - Implements index_function_t -.

Definition at line 1848 of file functions.c.

1850{
1851 if (!shared->mailbox || (shared->mailbox->msg_count == 0) || shared->mailbox->readonly)
1852 return FR_NO_ACTION;
1853
1854 int ovc = shared->mailbox->vcount;
1855 int oc = shared->mailbox->msg_count;
1856 struct Email *e = NULL;
1857
1858 /* don't attempt to move the cursor if there are no visible messages in the current limit */
1859 int index = menu_get_index(priv->menu);
1860 if (index < shared->mailbox->vcount)
1861 {
1862 /* threads may be reordered, so figure out what header the cursor
1863 * should be on. */
1864 int newidx = index;
1865 if (!shared->email)
1866 return FR_NO_ACTION;
1867 if (shared->email->deleted)
1868 newidx = find_next_undeleted(shared->mailbox_view, index, false);
1869 if (newidx < 0)
1870 newidx = find_previous_undeleted(shared->mailbox_view, index, false);
1871 if (newidx >= 0)
1872 e = mutt_get_virt_email(shared->mailbox, newidx);
1873 }
1874
1875 enum MxStatus check = mx_mbox_sync(shared->mailbox);
1876 if (check == MX_STATUS_OK)
1877 {
1878 if (e && (shared->mailbox->vcount != ovc))
1879 {
1880 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1881 {
1882 struct Email *e2 = mutt_get_virt_email(shared->mailbox, i);
1883 if (e2 == e)
1884 {
1885 menu_set_index(priv->menu, i);
1886 break;
1887 }
1888 }
1889 }
1891 }
1892 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
1893 {
1894 update_index(priv->menu, shared->mailbox_view, check, oc, shared);
1895 }
1896
1897 /* do a sanity check even if mx_mbox_sync failed. */
1898
1899 index = menu_get_index(priv->menu);
1900 if ((index < 0) || (shared->mailbox && (index >= shared->mailbox->vcount)))
1901 {
1903 }
1904
1905 /* check for a fatal error, or all messages deleted */
1906 if (shared->mailbox && buf_is_empty(&shared->mailbox->pathbuf))
1907 {
1908 mview_free(&shared->mailbox_view);
1909 }
1910
1911 priv->menu->max = shared->mailbox->vcount;
1913
1914 return FR_SUCCESS;
1915}
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition: compile.c:777
int find_first_message(struct MailboxView *mv)
Get index of first new message.
Definition: dlg_index.c:305
enum MxStatus mx_mbox_sync(struct Mailbox *m)
Save changes to mailbox.
Definition: mx.c:901
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_snc(), and mbox_close()
Definition: mxapi.h:63
@ MX_STATUS_OK
No changes.
Definition: mxapi.h:65
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition: mxapi.h:68
struct SearchState * search_state
State of the current search.
Definition: shared_data.h:45
struct PatternList * pattern
compiled search pattern
Definition: search_state.h:36
+ Here is the call graph for this function:

◆ op_main_tag_pattern()

static int op_main_tag_pattern ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Tag messages matching a pattern - Implements index_function_t -.

Definition at line 1920 of file functions.c.

1922{
1923 mutt_pattern_func(shared->mailbox_view, MUTT_TAG, _("Tag messages matching: "));
1925
1926 return FR_SUCCESS;
1927}
+ Here is the call graph for this function:

◆ op_main_undelete_pattern()

static int op_main_undelete_pattern ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Undelete messages matching a pattern - Implements index_function_t -.

Definition at line 1932 of file functions.c.

1934{
1935 /* L10N: CHECK_ACL */
1936 /* L10N: Due to the implementation details we do not know whether we
1937 undelete zero, 1, 12, ... messages. So in English we use
1938 "messages". Your language might have other means to express this. */
1939 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
1940 return FR_ERROR;
1941
1943 _("Undelete messages matching: ")) == 0)
1944 {
1946 }
1947
1948 return FR_SUCCESS;
1949}
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition: mutt.h:75
+ Here is the call graph for this function:

◆ op_main_untag_pattern()

static int op_main_untag_pattern ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Untag messages matching a pattern - Implements index_function_t -.

Definition at line 1954 of file functions.c.

1956{
1957 if (mutt_pattern_func(shared->mailbox_view, MUTT_UNTAG, _("Untag messages matching: ")) == 0)
1959
1960 return FR_SUCCESS;
1961}
@ MUTT_UNTAG
Messages to be un-tagged.
Definition: mutt.h:80
+ Here is the call graph for this function:

◆ op_mark_msg()

static int op_mark_msg ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Create a hotkey macro for the current message - Implements index_function_t -.

Definition at line 1966 of file functions.c.

1967{
1968 if (!shared->email)
1969 return FR_NO_ACTION;
1970
1971 int rc = FR_SUCCESS;
1972
1973 if (shared->email->env->message_id)
1974 {
1975 struct Buffer *buf = buf_pool_get();
1976
1977 /* L10N: This is the prompt for <mark-message>. Whatever they
1978 enter will be prefixed by $mark_macro_prefix and will become
1979 a macro hotkey to jump to the currently selected message. */
1980 if ((mw_get_field(_("Enter macro stroke: "), buf, MUTT_COMP_NO_FLAGS,
1981 HC_OTHER, NULL, NULL) == 0) &&
1982 !buf_is_empty(buf))
1983 {
1984 const char *const c_mark_macro_prefix = cs_subset_string(shared->sub, "mark_macro_prefix");
1985 char str[256] = { 0 };
1986 snprintf(str, sizeof(str), "%s%s", c_mark_macro_prefix, buf_string(buf));
1987
1988 struct Buffer *msg_id = buf_pool_get();
1989 mutt_file_sanitize_regex(msg_id, shared->email->env->message_id);
1990 char macro[256] = { 0 };
1991 snprintf(macro, sizeof(macro), "<search>~i '%s'\n", buf_string(msg_id));
1992 buf_pool_release(&msg_id);
1993
1994 /* L10N: "message hotkey" is the key bindings menu description of a
1995 macro created by <mark-message>. */
1996 km_bind(str, MENU_INDEX, OP_MACRO, macro, _("message hotkey"));
1997
1998 /* L10N: This is echoed after <mark-message> creates a new hotkey
1999 macro. %s is the hotkey string ($mark_macro_prefix followed
2000 by whatever they typed at the prompt.) */
2001 buf_printf(buf, _("Message bound to %s"), str);
2002 mutt_message("%s", buf_string(buf));
2003 mutt_debug(LL_DEBUG1, "Mark: %s => %s\n", str, macro);
2004 buf_pool_release(&buf);
2005 }
2006 }
2007 else
2008 {
2009 /* L10N: This error is printed if <mark-message> can't find a
2010 Message-ID for the currently selected message in the index. */
2011 mutt_error(_("No message ID to macro"));
2012 rc = FR_ERROR;
2013 }
2014
2015 return rc;
2016}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:173
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
int mutt_file_sanitize_regex(struct Buffer *dest, const char *src)
Escape any regex-magic characters in a string.
Definition: file.c:709
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
Definition: parse.c:160
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
@ MENU_INDEX
Index panel (list of emails)
Definition: type.h:51
+ Here is the call graph for this function:

◆ op_next_entry()

static int op_next_entry ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Move to the next entry - Implements index_function_t -.

Definition at line 2021 of file functions.c.

2022{
2023 const int index = menu_get_index(priv->menu) + 1;
2024 if (index >= shared->mailbox->vcount)
2025 {
2026 mutt_message(_("You are on the last message"));
2027 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2028 return FR_ERROR;
2029 }
2030 menu_set_index(priv->menu, index);
2031 return FR_SUCCESS;
2032}
+ Here is the call graph for this function:

◆ op_pipe()

static int op_pipe ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Pipe message/attachment to a shell command - Implements index_function_t -.

Definition at line 2037 of file functions.c.

2038{
2039 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2040 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2041 mutt_pipe_message(shared->mailbox, &ea);
2042 ARRAY_FREE(&ea);
2043
2044 /* in an IMAP folder index with imap_peek=no, piping could change
2045 * new or old messages status to read. Redraw what's needed. */
2046 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2047 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2048 {
2050 }
2051
2052 return FR_SUCCESS;
2053}
void mutt_pipe_message(struct Mailbox *m, struct EmailArray *ea)
Pipe a message.
Definition: external.c:407
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
+ Here is the call graph for this function:

◆ op_prev_entry()

static int op_prev_entry ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Move to the previous entry - Implements index_function_t -.

Definition at line 2058 of file functions.c.

2059{
2060 int index = menu_get_index(priv->menu);
2061 if (index < 1)
2062 {
2063 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2064 mutt_message(_("You are on the first message"));
2065 return FR_ERROR;
2066 }
2067 menu_set_index(priv->menu, index - 1);
2068 return FR_SUCCESS;
2069}
+ Here is the call graph for this function:

◆ op_print()

static int op_print ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Print the current entry - Implements index_function_t -.

Definition at line 2074 of file functions.c.

2075{
2076 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2077 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2078 mutt_print_message(shared->mailbox, &ea);
2079 ARRAY_FREE(&ea);
2080
2081 /* in an IMAP folder index with imap_peek=no, printing could change
2082 * new or old messages status to read. Redraw what's needed. */
2083 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2084 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2085 {
2087 }
2088
2089 return FR_SUCCESS;
2090}
void mutt_print_message(struct Mailbox *m, struct EmailArray *ea)
Print a message.
Definition: external.c:438
+ Here is the call graph for this function:

◆ op_query()

static int op_query ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Query external program for addresses - Implements index_function_t -.

Definition at line 2095 of file functions.c.

2096{
2097 query_index(shared->mailbox, shared->sub);
2098 return FR_SUCCESS;
2099}
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition: dlg_query.c:538
+ Here is the call graph for this function:

◆ op_quit()

static int op_quit ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Save changes to mailbox and quit - Implements index_function_t -.

Definition at line 2104 of file functions.c.

2105{
2106 if (shared->attach_msg)
2107 return FR_DONE;
2108
2109 if (query_quadoption(_("Quit NeoMutt?"), shared->sub, "quit") == MUTT_YES)
2110 {
2111 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
2112
2114 mutt_debug(LL_NOTIFY, "NT_GLOBAL_SHUTDOWN\n");
2116
2117 enum MxStatus check = MX_STATUS_OK;
2118 if (!shared->mailbox_view || ((check = mx_mbox_close(shared->mailbox)) == MX_STATUS_OK))
2119 {
2120 mview_free(&shared->mailbox_view);
2121 mailbox_free(&shared->mailbox);
2122 return FR_DONE;
2123 }
2124
2125 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2126 {
2127 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2128 }
2129
2130 menu_queue_redraw(priv->menu, MENU_REDRAW_FULL); /* new mail arrived? */
2132 }
2133
2134 return FR_NO_ACTION;
2135}
void mutt_startup_shutdown_hook(HookFlags type)
Execute any startup/shutdown hooks.
Definition: hook.c:930
#define MUTT_SHUTDOWN_HOOK
shutdown-hook: run when leaving NeoMutt
Definition: hook.h:55
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:90
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition: mx.c:593
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition: neomutt.h:60
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition: notify_type.h:46
struct Notify * notify
Notifications handler.
Definition: neomutt.h:42
+ Here is the call graph for this function:

◆ op_recall_message()

static int op_recall_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Recall a postponed message - Implements index_function_t -.

Definition at line 2140 of file functions.c.

2142{
2143 int rc = mutt_send_message(SEND_POSTPONED, NULL, NULL, shared->mailbox, NULL,
2144 shared->sub);
2146 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2147}
#define SEND_POSTPONED
Recall a postponed email.
Definition: send.h:44
+ Here is the call graph for this function:

◆ op_reply()

static int op_reply ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Reply to a message - Implements index_function_t -.

Definition at line 2152 of file functions.c.

2153{
2154 if (!shared->email)
2155 return FR_NO_ACTION;
2156 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2157 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2158 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
2159 if (c_pgp_auto_decode &&
2160 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
2161 {
2162 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
2164 }
2165 int rc = mutt_send_message(SEND_REPLY, NULL, NULL, shared->mailbox, &ea,
2166 shared->sub);
2167 ARRAY_FREE(&ea);
2169
2170 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2171}
+ Here is the call graph for this function:

◆ op_resend()

static int op_resend ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Use the current message as a template for a new one - Implements index_function_t -.

Definition at line 2176 of file functions.c.

2177{
2178 int rc = -1;
2179 if (priv->tag_prefix)
2180 {
2181 struct Mailbox *m = shared->mailbox;
2182 for (size_t i = 0; i < m->msg_count; i++)
2183 {
2184 struct Email *e = m->emails[i];
2185 if (!e)
2186 break;
2187 if (message_is_tagged(e))
2188 rc = mutt_resend_message(NULL, shared->mailbox, e, shared->sub);
2189 }
2190 }
2191 else
2192 {
2193 rc = mutt_resend_message(NULL, shared->mailbox, shared->email, shared->sub);
2194 }
2195
2197 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2198}
int mutt_resend_message(FILE *fp, struct Mailbox *m, struct Email *e_cur, struct ConfigSubset *sub)
Resend an email.
Definition: send.c:1614
+ Here is the call graph for this function:

◆ op_save()

static int op_save ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Make decrypted copy - Implements index_function_t -.

This function handles:

  • OP_COPY_MESSAGE
  • OP_DECODE_COPY
  • OP_DECODE_SAVE
  • OP_DECRYPT_COPY
  • OP_DECRYPT_SAVE
  • OP_SAVE

Definition at line 2211 of file functions.c.

2212{
2213 if (((op == OP_DECRYPT_COPY) || (op == OP_DECRYPT_SAVE)) && !WithCrypto)
2214 return FR_NOT_IMPL;
2215
2216 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2217 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2218
2219 const enum MessageSaveOpt save_opt = ((op == OP_SAVE) || (op == OP_DECODE_SAVE) ||
2220 (op == OP_DECRYPT_SAVE)) ?
2221 SAVE_MOVE :
2222 SAVE_COPY;
2223
2224 enum MessageTransformOpt transform_opt =
2225 ((op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY)) ? TRANSFORM_DECODE :
2226 ((op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY)) ? TRANSFORM_DECRYPT :
2228
2229 const int rc = mutt_save_message(shared->mailbox, &ea, save_opt, transform_opt);
2230 if ((rc == 0) && (save_opt == SAVE_MOVE))
2231 {
2232 if (priv->tag_prefix)
2233 {
2235 }
2236 else
2237 {
2239 }
2240 }
2241 ARRAY_FREE(&ea);
2242
2243 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2244}
int mutt_save_message(struct Mailbox *m, struct EmailArray *ea, enum MessageSaveOpt save_opt, enum MessageTransformOpt transform_opt)
Save an email.
Definition: external.c:778
MessageTransformOpt
Message transformation option.
Definition: external.h:39
@ TRANSFORM_NONE
No transformation.
Definition: external.h:40
@ TRANSFORM_DECODE
Decode message.
Definition: external.h:42
@ TRANSFORM_DECRYPT
Decrypt message.
Definition: external.h:41
MessageSaveOpt
Message save option.
Definition: external.h:49
@ SAVE_MOVE
Move message to another mailbox, removing the original.
Definition: external.h:51
@ SAVE_COPY
Copy message, making a duplicate in another mailbox.
Definition: external.h:50
+ Here is the call graph for this function:

◆ op_search()

static int op_search ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Search for a regular expression - Implements index_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE
  • OP_SEARCH_REVERSE

Definition at line 2255 of file functions.c.

2256{
2258 switch (op)
2259 {
2260 case OP_SEARCH:
2261 flags |= SEARCH_PROMPT;
2262 shared->search_state->reverse = false;
2263 break;
2264 case OP_SEARCH_REVERSE:
2265 flags |= SEARCH_PROMPT;
2266 shared->search_state->reverse = true;
2267 break;
2268 case OP_SEARCH_NEXT:
2269 break;
2270 case OP_SEARCH_OPPOSITE:
2271 flags |= SEARCH_OPPOSITE;
2272 break;
2273 }
2274
2275 // Initiating a search can happen on an empty mailbox, but
2276 // searching for next/previous/... needs to be on a message and
2277 // thus a non-empty mailbox
2278 int index = menu_get_index(priv->menu);
2279 index = mutt_search_command(shared->mailbox_view, priv->menu, index,
2280 shared->search_state, flags);
2281 if (index != -1)
2282 menu_set_index(priv->menu, index);
2283
2284 return FR_SUCCESS;
2285}
int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition: pattern.c:438
#define SEARCH_OPPOSITE
Search in the opposite direction.
Definition: search_state.h:45
uint8_t SearchFlags
Flags for a specific search, e.g. SEARCH_PROMPT.
Definition: search_state.h:42
#define SEARCH_NO_FLAGS
No flags are set.
Definition: search_state.h:43
#define SEARCH_PROMPT
Ask for search input.
Definition: search_state.h:44
bool reverse
search backwards
Definition: search_state.h:39
+ Here is the call graph for this function:

◆ op_sort()

static int op_sort ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Sort messages - Implements index_function_t -.

This function handles:

  • OP_SORT
  • OP_SORT_REVERSE

Definition at line 2294 of file functions.c.

2295{
2296 if (!mutt_select_sort(op == OP_SORT_REVERSE))
2297 return FR_ERROR;
2298
2299 if (shared->mailbox && (shared->mailbox->msg_count != 0))
2300 {
2301 resort_index(shared->mailbox_view, priv->menu);
2303 }
2304
2305 return FR_SUCCESS;
2306}
void resort_index(struct MailboxView *mv, struct Menu *menu)
Resort the index.
Definition: dlg_index.c:365
bool mutt_select_sort(bool reverse)
Ask the user for a sort method.
Definition: external.c:476
+ Here is the call graph for this function:

◆ op_tag()

static int op_tag ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Tag the current entry - Implements index_function_t -.

Definition at line 2311 of file functions.c.

2312{
2313 const bool c_auto_tag = cs_subset_bool(shared->sub, "auto_tag");
2314 if (priv->tag_prefix && !c_auto_tag)
2315 {
2316 struct Mailbox *m = shared->mailbox;
2317 for (size_t i = 0; i < m->msg_count; i++)
2318 {
2319 struct Email *e = m->emails[i];
2320 if (!e)
2321 break;
2322 if (e->visible)
2323 mutt_set_flag(m, e, MUTT_TAG, false, true);
2324 }
2326 return FR_SUCCESS;
2327 }
2328
2329 if (!shared->email)
2330 return FR_NO_ACTION;
2331
2332 mutt_set_flag(shared->mailbox, shared->email, MUTT_TAG, !shared->email->tagged, true);
2333
2334 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL);
2335 return FR_SUCCESS;
2336}
@ RESOLVE_NEXT_EMAIL
Next email, whatever its state.
Definition: functions.c:331
bool tagged
Email is tagged.
Definition: email.h:108
+ Here is the call graph for this function:

◆ op_tag_thread()

static int op_tag_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Tag the current thread - Implements index_function_t -.

This function handles:

  • OP_TAG_SUBTHREAD
  • OP_TAG_THREAD

Definition at line 2345 of file functions.c.

2346{
2347 if (!shared->email)
2348 return FR_NO_ACTION;
2349
2350 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_TAG,
2351 !shared->email->tagged, (op != OP_TAG_THREAD));
2352 if (rc != -1)
2353 {
2354 const enum ResolveMethod rm = (op == OP_TAG_THREAD) ? RESOLVE_NEXT_THREAD :
2356 resolve_email(priv, shared, rm);
2358 }
2359
2360 return FR_SUCCESS;
2361}
+ Here is the call graph for this function:

◆ op_toggle_new()

static int op_toggle_new ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Toggle a message's 'new' flag - Implements index_function_t -.

Definition at line 2366 of file functions.c.

2367{
2368 /* L10N: CHECK_ACL */
2369 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't toggle new")))
2370 return FR_ERROR;
2371
2372 struct Mailbox *m = shared->mailbox;
2373 if (priv->tag_prefix)
2374 {
2375 for (size_t i = 0; i < m->msg_count; i++)
2376 {
2377 struct Email *e = m->emails[i];
2378 if (!e)
2379 break;
2380 if (!message_is_tagged(e))
2381 continue;
2382
2383 if (e->read || e->old)
2384 mutt_set_flag(m, e, MUTT_NEW, true, true);
2385 else
2386 mutt_set_flag(m, e, MUTT_READ, true, true);
2387 }
2389 }
2390 else
2391 {
2392 if (!shared->email)
2393 return FR_NO_ACTION;
2394 if (shared->email->read || shared->email->old)
2395 mutt_set_flag(m, shared->email, MUTT_NEW, true, true);
2396 else
2397 mutt_set_flag(m, shared->email, MUTT_READ, true, true);
2398
2400 }
2401
2402 return FR_SUCCESS;
2403}
@ MUTT_NEW
New messages.
Definition: mutt.h:69
+ Here is the call graph for this function:

◆ op_toggle_write()

static int op_toggle_write ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Toggle whether the mailbox will be rewritten - Implements index_function_t -.

Definition at line 2408 of file functions.c.

2410{
2411 mx_toggle_write(shared->mailbox);
2412 return FR_SUCCESS;
2413}
int mx_toggle_write(struct Mailbox *m)
Toggle the mailbox's readonly flag.
Definition: mx.c:1812
+ Here is the call graph for this function:

◆ op_undelete()

static int op_undelete ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Undelete the current entry - Implements index_function_t -.

Definition at line 2418 of file functions.c.

2419{
2420 /* L10N: CHECK_ACL */
2421 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete message")))
2422 return FR_ERROR;
2423
2424 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2425 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2426
2427 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, false);
2428 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, false);
2429 ARRAY_FREE(&ea);
2430
2431 if (priv->tag_prefix)
2432 {
2434 }
2435 else
2436 {
2437 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL);
2438 }
2439
2440 return FR_SUCCESS;
2441}
+ Here is the call graph for this function:

◆ op_undelete_thread()

static int op_undelete_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Undelete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_UNDELETE_SUBTHREAD
  • OP_UNDELETE_THREAD

Definition at line 2450 of file functions.c.

2452{
2453 /* L10N: CHECK_ACL */
2454 /* L10N: Due to the implementation details we do not know whether we
2455 undelete zero, 1, 12, ... messages. So in English we use
2456 "messages". Your language might have other means to express this. */
2457 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
2458 return FR_ERROR;
2459
2460 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_DELETE,
2461 false, (op != OP_UNDELETE_THREAD));
2462 if (rc != -1)
2463 {
2464 rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_PURGE, false,
2465 (op != OP_UNDELETE_THREAD));
2466 }
2467 if (rc != -1)
2468 {
2469 const enum ResolveMethod rm = (op == OP_UNDELETE_THREAD) ? RESOLVE_NEXT_THREAD :
2471 resolve_email(priv, shared, rm);
2473 }
2474
2475 return FR_SUCCESS;
2476}
+ Here is the call graph for this function:

◆ op_view_attachments()

static int op_view_attachments ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Show MIME attachments - Implements index_function_t -.

Definition at line 2481 of file functions.c.

2483{
2484 if (!shared->email)
2485 return FR_NO_ACTION;
2486
2487 enum FunctionRetval rc = FR_ERROR;
2488 struct Message *msg = mx_msg_open(shared->mailbox, shared->email);
2489 if (msg)
2490 {
2491 dlg_attachment(NeoMutt->sub, shared->mailbox_view, shared->email, msg->fp,
2492 shared->attach_msg);
2493 if (shared->email->attach_del)
2494 {
2495 shared->mailbox->changed = true;
2496 }
2497 mx_msg_close(shared->mailbox, &msg);
2498 rc = FR_SUCCESS;
2499 }
2501 return rc;
2502}
void dlg_attachment(struct ConfigSubset *sub, struct MailboxView *mv, struct Email *e, FILE *fp, bool attach_msg)
Show the attachments in a Menu -.
Definition: dlg_attach.c:473
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition: mx.c:1185
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition: mx.c:1139
bool attach_del
Has an attachment marked for deletion.
Definition: email.h:100
A local copy of an email.
Definition: message.h:34
FILE * fp
pointer to the message data
Definition: message.h:35
+ Here is the call graph for this function:

◆ op_autocrypt_acct_menu()

static int op_autocrypt_acct_menu ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Manage autocrypt accounts - Implements index_function_t -.

Definition at line 2510 of file functions.c.

2512{
2513 dlg_autocrypt();
2514 return FR_SUCCESS;
2515}
void dlg_autocrypt(void)
Display the Autocrypt account Menu -.
+ Here is the call graph for this function:

◆ op_main_imap_fetch()

static int op_main_imap_fetch ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Force retrieval of mail from IMAP server - Implements index_function_t -.

Definition at line 2521 of file functions.c.

2523{
2524 if (!shared->mailbox || (shared->mailbox->type != MUTT_IMAP))
2525 return FR_NO_ACTION;
2526
2527 imap_check_mailbox(shared->mailbox, true);
2528 return FR_SUCCESS;
2529}
enum MxStatus imap_check_mailbox(struct Mailbox *m, bool force)
Use the NOOP or IDLE command to poll for new mail.
Definition: imap.c:1019
+ Here is the call graph for this function:

◆ op_main_imap_logout_all()

static int op_main_imap_logout_all ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Logout from all IMAP servers - Implements index_function_t -.

Definition at line 2534 of file functions.c.

2536{
2537 if (shared->mailbox && (shared->mailbox->type == MUTT_IMAP))
2538 {
2539 const enum MxStatus check = mx_mbox_close(shared->mailbox);
2540 if (check == MX_STATUS_OK)
2541 {
2542 mview_free(&shared->mailbox_view);
2543 }
2544 else
2545 {
2546 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2547 {
2548 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2549 }
2552 return FR_ERROR;
2553 }
2554 }
2556 mutt_message(_("Logged out of IMAP servers"));
2559
2560 return FR_SUCCESS;
2561}
void imap_logout_all(void)
Close all open connections.
Definition: imap.c:546
+ Here is the call graph for this function:

◆ op_catchup()

static int op_catchup ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Mark all articles in newsgroup as read - Implements index_function_t -.

Definition at line 2566 of file functions.c.

2567{
2568 struct Mailbox *m = shared->mailbox;
2569 if (!m || (m->type != MUTT_NNTP))
2570 return FR_NO_ACTION;
2571
2572 struct NntpMboxData *mdata = m->mdata;
2573 if (mutt_newsgroup_catchup(m, mdata->adata, mdata->group))
2575
2576 return FR_SUCCESS;
2577}
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:49
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1300
void * mdata
Driver specific data.
Definition: mailbox.h:131
NNTP-specific Mailbox data -.
Definition: mdata.h:34
+ Here is the call graph for this function:

◆ op_get_children()

static int op_get_children ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Get all children of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_CHILDREN
  • OP_RECONSTRUCT_THREAD

Definition at line 2586 of file functions.c.

2588{
2589 struct Mailbox *m = shared->mailbox;
2590 if (m->type != MUTT_NNTP)
2591 return FR_ERROR;
2592
2593 struct Email *e = shared->email;
2594 if (!e)
2595 return FR_NO_ACTION;
2596
2597 char buf[PATH_MAX] = { 0 };
2598 int oldmsgcount = m->msg_count;
2599 int oldindex = e->index;
2600 int rc = 0;
2601
2602 if (!e->env->message_id)
2603 {
2604 mutt_error(_("No Message-Id. Unable to perform operation."));
2605 return FR_ERROR;
2606 }
2607
2608 mutt_message(_("Fetching message headers..."));
2609 if (!m->id_hash)
2610 m->id_hash = mutt_make_id_hash(m);
2611 mutt_str_copy(buf, e->env->message_id, sizeof(buf));
2612
2613 /* trying to find msgid of the root message */
2614 if (op == OP_RECONSTRUCT_THREAD)
2615 {
2616 struct ListNode *ref = NULL;
2617 STAILQ_FOREACH(ref, &e->env->references, entries)
2618 {
2619 if (!mutt_hash_find(m->id_hash, ref->data))
2620 {
2621 rc = nntp_check_msgid(m, ref->data);
2622 if (rc < 0)
2623 return FR_ERROR;
2624 }
2625
2626 /* the last msgid in References is the root message */
2627 if (!STAILQ_NEXT(ref, entries))
2628 mutt_str_copy(buf, ref->data, sizeof(buf));
2629 }
2630 }
2631
2632 /* fetching all child messages */
2633 rc = nntp_check_children(m, buf);
2634
2635 /* at least one message has been loaded */
2636 if (m->msg_count > oldmsgcount)
2637 {
2638 bool verbose = m->verbose;
2639
2640 if (rc < 0)
2641 m->verbose = false;
2642
2643 struct MailboxView *mv = shared->mailbox_view;
2644 mutt_sort_headers(mv, (op == OP_RECONSTRUCT_THREAD));
2645 m->verbose = verbose;
2646
2647 /* if the root message was retrieved, move to it */
2648 struct Email *e2 = mutt_hash_find(m->id_hash, buf);
2649 if (e2)
2650 {
2651 menu_set_index(priv->menu, e2->vnum);
2652 }
2653 else
2654 {
2655 /* try to restore old position */
2656 for (int i = 0; i < m->msg_count; i++)
2657 {
2658 e2 = m->emails[i];
2659 if (!e2)
2660 break;
2661 if (e2->index == oldindex)
2662 {
2663 menu_set_index(priv->menu, e2->vnum);
2664 /* as an added courtesy, recenter the menu
2665 * with the current entry at the middle of the screen */
2667 }
2668 }
2669 }
2671 }
2672 else if (rc >= 0)
2673 {
2674 mutt_error(_("No deleted messages found in the thread"));
2675 }
2676
2677 return FR_SUCCESS;
2678}
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:362
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition: move.c:464
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
Definition: mutt_thread.c:1699
int nntp_check_msgid(struct Mailbox *m, const char *msgid)
Fetch article by Message-ID.
Definition: nntp.c:2167
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition: nntp.c:2238
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define STAILQ_NEXT(elm, field)
Definition: queue.h:400
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
struct HashTable * id_hash
Hash Table: "message-id" -> Email.
Definition: mailbox.h:122
+ Here is the call graph for this function:

◆ op_get_message()

static int op_get_message ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Get parent of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_MESSAGE
  • OP_GET_PARENT

Definition at line 2687 of file functions.c.

2689{
2690 struct Mailbox *m = shared->mailbox;
2691 if (m->type != MUTT_NNTP)
2692 return FR_SUCCESS;
2693
2694 int rc = FR_ERROR;
2695 struct Buffer *buf = buf_pool_get();
2696
2697 if (op == OP_GET_MESSAGE)
2698 {
2699 if ((mw_get_field(_("Enter Message-Id: "), buf, MUTT_COMP_NO_FLAGS,
2700 HC_OTHER, NULL, NULL) != 0) ||
2701 buf_is_empty(buf))
2702 {
2703 goto done;
2704 }
2705 }
2706 else
2707 {
2708 struct Email *e = shared->email;
2709 if (!e || STAILQ_EMPTY(&e->env->references))
2710 {
2711 mutt_error(_("Article has no parent reference"));
2712 goto done;
2713 }
2714 buf_strcpy(buf, STAILQ_FIRST(&e->env->references)->data);
2715 }
2716
2717 if (!m->id_hash)
2718 m->id_hash = mutt_make_id_hash(m);
2719 struct Email *e = mutt_hash_find(m->id_hash, buf_string(buf));
2720 if (e)
2721 {
2722 if (e->vnum != -1)
2723 {
2724 menu_set_index(priv->menu, e->vnum);
2725 }
2726 else if (e->collapsed)
2727 {
2729 mutt_set_vnum(m);
2730 menu_set_index(priv->menu, e->vnum);
2731 }
2732 else
2733 {
2734 mutt_error(_("Message is not visible in limited view"));
2735 }
2736 }
2737 else
2738 {
2739 mutt_message(_("Fetching %s from server..."), buf_string(buf));
2740 int rc2 = nntp_check_msgid(m, buf_string(buf));
2741 if (rc2 == 0)
2742 {
2743 e = m->emails[m->msg_count - 1];
2744 struct MailboxView *mv = shared->mailbox_view;
2745 mutt_sort_headers(mv, false);
2746 menu_set_index(priv->menu, e->vnum);
2748 rc = FR_SUCCESS;
2749 }
2750 else if (rc2 > 0)
2751 {
2752 mutt_error(_("Article %s not found on the server"), buf_string(buf));
2753 }
2754 }
2755
2756done:
2757 buf_pool_release(&buf);
2758 return rc;
2759}
#define STAILQ_FIRST(head)
Definition: queue.h:350
+ Here is the call graph for this function:

◆ op_main_change_group()

static int op_main_change_group ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Open a different newsgroup - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_GROUP
  • OP_MAIN_CHANGE_GROUP_READONLY

Definition at line 2768 of file functions.c.

2770{
2771 struct Buffer *folderbuf = buf_pool_get();
2772 buf_alloc(folderbuf, PATH_MAX);
2773
2774 OptNews = false;
2775 bool read_only;
2776 char *cp = NULL;
2777 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
2778 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_GROUP_READONLY))
2779 {
2780 cp = _("Open newsgroup in read-only mode");
2781 read_only = true;
2782 }
2783 else
2784 {
2785 cp = _("Open newsgroup");
2786 read_only = false;
2787 }
2788
2789 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
2790 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
2791 {
2792 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
2793 buf_pretty_mailbox(folderbuf);
2794 }
2795
2796 OptNews = true;
2797 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
2798 if (!CurrentNewsSrv)
2799 CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false);
2800 if (!CurrentNewsSrv)
2801 goto changefoldercleanup2;
2802
2803 nntp_mailbox(shared->mailbox, folderbuf->data, folderbuf->dsize);
2804
2805 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
2806 MUTT_SEL_NO_FLAGS) == -1)
2807 {
2808 goto changefoldercleanup2;
2809 }
2810
2811 /* Selected directory is okay, let's save it. */
2813
2814 if (buf_is_empty(folderbuf))
2815 {
2816 msgwin_clear_text(NULL);
2817 goto changefoldercleanup2;
2818 }
2819
2820 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
2821 if (m)
2822 {
2823 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
2824 }
2825 else
2826 {
2827 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
2828 }
2829 struct MuttWindow *dlg = dialog_find(priv->win_index);
2830 dlg->help_data = IndexNewsHelp;
2831
2832changefoldercleanup2:
2833 buf_pool_release(&folderbuf);
2834 return FR_SUCCESS;
2835}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
const struct Mapping IndexNewsHelp[]
Help Bar for the News Index dialog.
Definition: dlg_index.c:113
bool OptNews
(pseudo) used to change reader mode
Definition: globals.c:75
void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen)
Get first newsgroup with new messages.
Definition: newsrc.c:1382
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition: nntp.c:77
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition: newsrc.c:1021
size_t dsize
Length of data.
Definition: buffer.h:37
char * data
Pointer to data.
Definition: buffer.h:35
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
+ Here is the call graph for this function:

◆ op_post()

static int op_post ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Followup to newsgroup - Implements index_function_t -.

This function handles:

  • OP_FOLLOWUP
  • OP_POST

Definition at line 2844 of file functions.c.

2845{
2846 if (!shared->email)
2847 return FR_NO_ACTION;
2848
2849 if ((op != OP_FOLLOWUP) || !shared->email->env->followup_to ||
2850 !mutt_istr_equal(shared->email->env->followup_to, "poster") ||
2851 (query_quadoption(_("Reply by mail as poster prefers?"), shared->sub,
2852 "followup_to_poster") != MUTT_YES))
2853 {
2854 if (shared->mailbox && (shared->mailbox->type == MUTT_NNTP) &&
2855 !((struct NntpMboxData *) shared->mailbox->mdata)->allowed &&
2856 (query_quadoption(_("Posting to this group not allowed, may be moderated. Continue?"),
2857 shared->sub, "post_moderated") != MUTT_YES))
2858 {
2859 return FR_ERROR;
2860 }
2861 if (op == OP_POST)
2862 {
2863 mutt_send_message(SEND_NEWS, NULL, NULL, shared->mailbox, NULL, shared->sub);
2864 }
2865 else
2866 {
2867 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2868 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2869 mutt_send_message(((op == OP_FOLLOWUP) ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS,
2870 NULL, NULL, shared->mailbox, &ea, shared->sub);
2871 ARRAY_FREE(&ea);
2872 }
2874 return FR_SUCCESS;
2875 }
2876
2877 return op_reply(shared, priv, OP_REPLY);
2878}
static int op_reply(struct AttachPrivateData *priv, int op)
reply to a message - Implements attach_function_t -
Definition: functions.c:597
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:775
#define SEND_NEWS
Reply to a news article.
Definition: send.h:53
char * followup_to
List of 'followup-to' fields.
Definition: envelope.h:80
+ Here is the call graph for this function:

◆ op_main_entire_thread()

static int op_main_entire_thread ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Read entire thread of the current message - Implements index_function_t -.

Definition at line 2884 of file functions.c.

2886{
2887 if (shared->mailbox->type != MUTT_NOTMUCH)
2888 {
2889 if (((shared->mailbox->type != MUTT_MH) && (shared->mailbox->type != MUTT_MAILDIR)) ||
2890 (!shared->email || !shared->email->env || !shared->email->env->message_id))
2891 {
2892 mutt_message(_("No virtual folder and no Message-Id, aborting"));
2893 return FR_ERROR;
2894 } // no virtual folder, but we have message-id, reconstruct thread on-the-fly
2895 char buf[PATH_MAX] = { 0 };
2896 strncpy(buf, "id:", sizeof(buf));
2897 int msg_id_offset = 0;
2898 if ((shared->email->env->message_id)[0] == '<')
2899 msg_id_offset = 1;
2900 mutt_str_cat(buf, sizeof(buf), (shared->email->env->message_id) + msg_id_offset);
2901 if (buf[strlen(buf) - 1] == '>')
2902 buf[strlen(buf) - 1] = '\0';
2903
2904 change_folder_notmuch(priv->menu, buf, sizeof(buf), &priv->oldcount, shared, false);
2905
2906 // If notmuch doesn't contain the message, we're left in an empty
2907 // vfolder. No messages are found, but nm_read_entire_thread assumes
2908 // a valid message-id and will throw a segfault.
2909 //
2910 // To prevent that, stay in the empty vfolder and print an error.
2911 if (shared->mailbox->msg_count == 0)
2912 {
2913 mutt_error(_("failed to find message in notmuch database. try running 'notmuch new'."));
2914 return FR_ERROR;
2915 }
2916 }
2917 priv->oldcount = shared->mailbox->msg_count;
2918 int index = menu_get_index(priv->menu);
2919 struct Email *e_oldcur = mutt_get_virt_email(shared->mailbox, index);
2920 if (!e_oldcur)
2921 return FR_ERROR;
2922
2923 if (nm_read_entire_thread(shared->mailbox, e_oldcur) < 0)
2924 {
2925 mutt_message(_("Failed to read thread, aborting"));
2926 return FR_ERROR;
2927 }
2928
2929 // nm_read_entire_thread() may modify msg_count and menu won't be updated.
2930 priv->menu->max = shared->mailbox->msg_count;
2931
2932 if (priv->oldcount < shared->mailbox->msg_count)
2933 {
2934 /* nm_read_entire_thread() triggers mutt_sort_headers() if necessary */
2935 index = e_oldcur->vnum;
2936 if (e_oldcur->collapsed || shared->mailbox_view->collapsed)
2937 {
2938 index = mutt_uncollapse_thread(e_oldcur);
2939 mutt_set_vnum(shared->mailbox);
2940 }
2941 menu_set_index(priv->menu, index);
2943 }
2944
2945 return FR_SUCCESS;
2946}
struct Mailbox * change_folder_notmuch(struct Menu *menu, char *buf, int buflen, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Notmuch Mailbox by string.
Definition: dlg_index.c:728
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:47
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:48
char * mutt_str_cat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:266
int nm_read_entire_thread(struct Mailbox *m, struct Email *e)
Get the entire thread of an email.
Definition: notmuch.c:1498
bool collapsed
Are all threads collapsed?
Definition: mview.h:48
+ Here is the call graph for this function:

◆ op_main_vfolder_from_query()

static int op_main_vfolder_from_query ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Generate virtual folder from query - Implements index_function_t -.

This function handles:

  • OP_MAIN_VFOLDER_FROM_QUERY
  • OP_MAIN_VFOLDER_FROM_QUERY_READONLY op_main_vfolder_from_query

Definition at line 2955 of file functions.c.

2957{
2958 int rc = FR_SUCCESS;
2959 struct Buffer *buf = buf_pool_get();
2960
2961 if ((mw_get_field("Query: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2962 &CompleteNmQueryOps, NULL) != 0) ||
2963 buf_is_empty(buf))
2964 {
2965 mutt_message(_("No query, aborting"));
2966 rc = FR_NO_ACTION;
2967 goto done;
2968 }
2969
2970 // Keep copy of user's query to name the mailbox
2971 char *query_unencoded = buf_strdup(buf);
2972
2973 buf_alloc(buf, PATH_MAX);
2974 struct Mailbox *m_query = change_folder_notmuch(priv->menu, buf->data, buf->dsize,
2975 &priv->oldcount, shared,
2976 (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY));
2977 if (m_query)
2978 {
2979 FREE(&m_query->name);
2980 m_query->name = query_unencoded;
2981 query_unencoded = NULL;
2982 rc = FR_SUCCESS;
2983 }
2984 else
2985 {
2986 FREE(&query_unencoded);
2987 }
2988
2989done:
2990 buf_pool_release(&buf);
2991 return rc;
2992}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:542
const struct CompleteOps CompleteNmQueryOps
Auto-Completion of NmQuerys.
Definition: complete.c:249
char * name
A short name for the Mailbox.
Definition: mailbox.h:82
+ Here is the call graph for this function:

◆ op_main_windowed_vfolder()

static int op_main_windowed_vfolder ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Shifts virtual folder time window - Implements index_function_t -.

This function handles:

  • OP_MAIN_WINDOWED_VFOLDER_BACKWARD
  • OP_MAIN_WINDOWED_VFOLDER_FORWARD
  • OP_MAIN_WINDOWED_VFOLDER_RESET

Definition at line 3002 of file functions.c.

3004{
3005 // Common guard clauses.
3007 {
3008 mutt_message(_("Windowed queries disabled"));
3009 return FR_ERROR;
3010 }
3011 const char *const c_nm_query_window_current_search = cs_subset_string(shared->sub, "nm_query_window_current_search");
3012 if (!c_nm_query_window_current_search)
3013 {
3014 mutt_message(_("No notmuch vfolder currently loaded"));
3015 return FR_ERROR;
3016 }
3017
3018 // Call the specific operation.
3019 switch (op)
3020 {
3021 case OP_MAIN_WINDOWED_VFOLDER_BACKWARD:
3023 break;
3024 case OP_MAIN_WINDOWED_VFOLDER_FORWARD:
3026 break;
3027 case OP_MAIN_WINDOWED_VFOLDER_RESET:
3029 break;
3030 }
3031
3032 // Common query window folder change.
3033 char buf[PATH_MAX] = { 0 };
3034 mutt_str_copy(buf, c_nm_query_window_current_search, sizeof(buf));
3035 change_folder_notmuch(priv->menu, buf, sizeof(buf), &priv->oldcount, shared, false);
3036
3037 return FR_SUCCESS;
3038}
void nm_query_window_reset(void)
Resets the vfolder window position to the present.
Definition: notmuch.c:1672
void nm_query_window_backward(void)
Function to move the current search window backward in time.
Definition: notmuch.c:1661
bool nm_query_window_available(void)
Are windowed queries enabled for use?
Definition: notmuch.c:1624
void nm_query_window_forward(void)
Function to move the current search window forward in time.
Definition: notmuch.c:1641
+ Here is the call graph for this function:

◆ op_main_fetch_mail()

static int op_main_fetch_mail ( struct IndexSharedData shared,
struct IndexPrivateData priv,
int  op 
)
static

Retrieve mail from POP server - Implements index_function_t -.

Definition at line 3044 of file functions.c.

3046{
3049 return FR_SUCCESS;
3050}
void pop_fetch_mail(void)
Fetch messages and save them in $spool_file.
Definition: pop.c:513
+ Here is the call graph for this function: