NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Envelope functions. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "gui/lib.h"
#include "functions.h"
#include "lib.h"
#include "browser/lib.h"
#include "editor/lib.h"
#include "history/lib.h"
#include "hooks/lib.h"
#include "key/lib.h"
#include "ncrypt/lib.h"
#include "question/lib.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "wdata.h"
#include "autocrypt/lib.h"
Include dependency graph for functions.c:

Go to the source code of this file.

Functions

static void autocrypt_compose_menu (struct Email *e, const struct ConfigSubset *sub)
 Autocrypt compose settings.
static bool edit_address_list (enum HeaderField field, struct AddressList *al)
 Let the user edit the address list.
void update_crypt_info (struct EnvelopeWindowData *wdata)
 Update the crypto info.
static int op_envelope_edit_bcc (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the BCC list - Implements envelope_function_t -.
static int op_envelope_edit_cc (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the CC list - Implements envelope_function_t -.
static int op_envelope_edit_fcc (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Enter a file to save a copy of this message in - Implements envelope_function_t -.
static int op_envelope_edit_from (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the from field - Implements envelope_function_t -.
static int op_envelope_edit_reply_to (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the Reply-To field - Implements envelope_function_t -.
static int op_envelope_edit_subject (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the subject of this message - Implements envelope_function_t -.
static int op_envelope_edit_to (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the TO list - Implements envelope_function_t -.
static int op_compose_pgp_menu (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Show PGP options - Implements envelope_function_t -.
static int op_compose_smime_menu (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Show S/MIME options - Implements envelope_function_t -.
static int op_compose_autocrypt_menu (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Show autocrypt compose menu options - Implements envelope_function_t -.
static int op_envelope_edit_followup_to (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the Followup-To field - Implements envelope_function_t -.
static int op_envelope_edit_newsgroups (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the newsgroups list - Implements envelope_function_t -.
static int op_envelope_edit_x_comment_to (struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
 Edit the X-Comment-To field - Implements envelope_function_t -.
int env_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform an Envelope function - Implements function_dispatcher_t -.

Variables

static const struct EnvelopeFunction EnvelopeFunctions []
 All the NeoMutt functions that the Envelope supports.

Detailed Description

Envelope functions.

Authors
  • Richard Russon
  • Pietro Cerutti

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

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

Definition in file functions.c.

Function Documentation

◆ autocrypt_compose_menu()

void autocrypt_compose_menu ( struct Email * e,
const struct ConfigSubset * sub )
static

Autocrypt compose settings.

Parameters
eEmail
subConfigSubset

Definition at line 63 of file functions.c.

64{
65 /* L10N: The compose menu autocrypt prompt.
66 (e)ncrypt enables encryption via autocrypt.
67 (c)lear sets cleartext.
68 (a)utomatic defers to the recommendation. */
69 const char *prompt = _("Autocrypt: (e)ncrypt, (c)lear, (a)utomatic?");
70
72
73 /* L10N: The letter corresponding to the compose menu autocrypt prompt
74 (e)ncrypt, (c)lear, (a)utomatic */
75 const char *letters = _("eca");
76
77 int choice = mw_multi_choice(prompt, letters);
78 switch (choice)
79 {
80 case 1:
83 break;
84 case 2:
87 break;
88 case 3:
89 {
91 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(sub, "crypt_opportunistic_encrypt");
92 if (c_crypt_opportunistic_encrypt)
94 break;
95 }
96
97 default:
98 break;
99 }
100}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
Definition question.c:62
#define _(a)
Definition message.h:28
@ SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition lib.h:100
@ SEC_SIGN
Email is signed.
Definition lib.h:93
@ SEC_INLINE
Email has an inline signature.
Definition lib.h:99
@ SEC_ENCRYPT
Email is encrypted.
Definition lib.h:92
@ SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition lib.h:101
@ SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
Definition lib.h:102
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:106
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition email.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ edit_address_list()

bool edit_address_list ( enum HeaderField field,
struct AddressList * al )
static

Let the user edit the address list.

Parameters
[in]fieldField to edit, e.g. HDR_FROM
[in,out]alAddressList to edit
Return values
trueThe address list was changed

Definition at line 109 of file functions.c.

110{
111 struct Buffer *old_list = buf_pool_get();
112 struct Buffer *new_list = buf_pool_get();
113
114 /* need to be large for alias expansion */
115 buf_alloc(old_list, 8192);
116 buf_alloc(new_list, 8192);
117
119 mutt_addrlist_write(al, new_list, false);
120 buf_fix_dptr(new_list);
121 if (!buf_is_empty(new_list))
122 buf_addstr(new_list, ", ");
123
124 buf_copy(old_list, new_list);
125 if (mw_get_field(_(Prompts[field]), new_list, MUTT_COMP_NONE, HC_ALIAS,
126 &CompleteAliasOps, NULL) == 0)
127 {
129 mutt_addrlist_parse2(al, buf_string(new_list));
131 }
132
133 char *err = NULL;
134 if (mutt_addrlist_to_intl(al, &err) != 0)
135 {
136 mutt_error(_("Bad IDN: '%s'"), err);
137 mutt_refresh();
138 FREE(&err);
139 }
140
141 const bool rc = !mutt_str_equal(buf_string(new_list), buf_string(old_list));
142 buf_pool_release(&old_list);
143 buf_pool_release(&new_list);
144 return rc;
145}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition address.c:1473
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition address.c:1389
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
Definition address.c:1217
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition address.c:651
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition address.c:1304
const struct CompleteOps CompleteAliasOps
Auto-Completion of Aliases.
Definition complete.c:108
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition alias.c:297
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:298
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition buffer.c:189
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition buffer.c:233
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition buffer.c:607
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:342
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
void mutt_refresh(void)
Force a refresh of the screen.
Definition curs_lib.c:78
@ MUTT_COMP_NONE
No flags are set.
Definition wdata.h:46
const char *const Prompts[]
Names of header fields used in the envelope, e.g. From:, To:
Definition window.c:89
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:502
#define mutt_error(...)
Definition logging2.h:94
@ HC_ALIAS
Aliases.
Definition lib.h:57
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_crypt_info()

void update_crypt_info ( struct EnvelopeWindowData * wdata)

Update the crypto info.

Parameters
wdataEnvelope Window data

Definition at line 151 of file functions.c.

152{
153 struct Email *e = wdata->email;
154
155 const bool c_crypt_opportunistic_encrypt = cs_subset_bool(wdata->sub, "crypt_opportunistic_encrypt");
156 if (c_crypt_opportunistic_encrypt)
158
159#ifdef USE_AUTOCRYPT
160 const bool c_autocrypt = cs_subset_bool(wdata->sub, "autocrypt");
161 if (c_autocrypt)
162 {
164
165 /* Anything that enables SEC_ENCRYPT or SEC_SIGN, or turns on SMIME
166 * overrides autocrypt, be it oppenc or the user having turned on
167 * those flags manually. */
169 {
171 }
172 else
173 {
175 {
176 if (wdata->autocrypt_rec == AUTOCRYPT_REC_YES)
177 {
180 }
181 else
182 {
184 }
185 }
186 }
187 }
188#endif
189}
@ AUTOCRYPT_REC_YES
Autocrypt should be used.
Definition lib.h:171
enum AutocryptRec mutt_autocrypt_ui_recommendation(const struct Email *e, char **keylist)
Get the recommended action for an Email.
Definition autocrypt.c:578
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition crypt.c:1052
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition lib.h:107
The envelope/body of an email.
Definition email.h:39
struct Email * email
Email being composed.
Definition wdata.h:40
struct ConfigSubset * sub
Inherited config items.
Definition wdata.h:39
enum AutocryptRec autocrypt_rec
Autocrypt recommendation.
Definition wdata.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ EnvelopeFunctions

const struct EnvelopeFunction EnvelopeFunctions[]
static
Initial value:
= {
{ OP_COMPOSE_AUTOCRYPT_MENU, op_compose_autocrypt_menu },
{ OP_COMPOSE_PGP_MENU, op_compose_pgp_menu },
{ OP_COMPOSE_SMIME_MENU, op_compose_smime_menu },
{ OP_ENVELOPE_EDIT_BCC, op_envelope_edit_bcc },
{ OP_ENVELOPE_EDIT_CC, op_envelope_edit_cc },
{ OP_ENVELOPE_EDIT_FCC, op_envelope_edit_fcc },
{ OP_ENVELOPE_EDIT_FOLLOWUP_TO, op_envelope_edit_followup_to },
{ OP_ENVELOPE_EDIT_FROM, op_envelope_edit_from },
{ OP_ENVELOPE_EDIT_NEWSGROUPS, op_envelope_edit_newsgroups },
{ OP_ENVELOPE_EDIT_REPLY_TO, op_envelope_edit_reply_to },
{ OP_ENVELOPE_EDIT_SUBJECT, op_envelope_edit_subject },
{ OP_ENVELOPE_EDIT_TO, op_envelope_edit_to },
{ OP_ENVELOPE_EDIT_X_COMMENT_TO, op_envelope_edit_x_comment_to },
{ 0, NULL },
}
static int op_envelope_edit_followup_to(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the Followup-To field - Implements envelope_function_t -.
Definition functions.c:440
static int op_envelope_edit_cc(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the CC list - Implements envelope_function_t -.
Definition functions.c:211
static int op_compose_pgp_menu(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Show PGP options - Implements envelope_function_t -.
Definition functions.c:323
static int op_envelope_edit_fcc(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Enter a file to save a copy of this message in - Implements envelope_function_t -.
Definition functions.c:226
static int op_envelope_edit_reply_to(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the Reply-To field - Implements envelope_function_t -.
Definition functions.c:268
static int op_envelope_edit_from(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the from field - Implements envelope_function_t -.
Definition functions.c:255
static int op_envelope_edit_subject(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the subject of this message - Implements envelope_function_t -.
Definition functions.c:281
static int op_compose_smime_menu(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Show S/MIME options - Implements envelope_function_t -.
Definition functions.c:361
static int op_envelope_edit_x_comment_to(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the X-Comment-To field - Implements envelope_function_t -.
Definition functions.c:488
static int op_envelope_edit_to(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the TO list - Implements envelope_function_t -.
Definition functions.c:308
static int op_envelope_edit_newsgroups(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the newsgroups list - Implements envelope_function_t -.
Definition functions.c:464
static int op_compose_autocrypt_menu(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Show autocrypt compose menu options - Implements envelope_function_t -.
Definition functions.c:401
static int op_envelope_edit_bcc(struct EnvelopeWindowData *wdata, const struct KeyEvent *event)
Edit the BCC list - Implements envelope_function_t -.
Definition functions.c:196

All the NeoMutt functions that the Envelope supports.

Definition at line 515 of file functions.c.

515 {
516// clang-format off
517#ifdef USE_AUTOCRYPT
518 { OP_COMPOSE_AUTOCRYPT_MENU, op_compose_autocrypt_menu },
519#endif
520 { OP_COMPOSE_PGP_MENU, op_compose_pgp_menu },
521 { OP_COMPOSE_SMIME_MENU, op_compose_smime_menu },
522 { OP_ENVELOPE_EDIT_BCC, op_envelope_edit_bcc },
523 { OP_ENVELOPE_EDIT_CC, op_envelope_edit_cc },
524 { OP_ENVELOPE_EDIT_FCC, op_envelope_edit_fcc },
525 { OP_ENVELOPE_EDIT_FOLLOWUP_TO, op_envelope_edit_followup_to },
526 { OP_ENVELOPE_EDIT_FROM, op_envelope_edit_from },
527 { OP_ENVELOPE_EDIT_NEWSGROUPS, op_envelope_edit_newsgroups },
528 { OP_ENVELOPE_EDIT_REPLY_TO, op_envelope_edit_reply_to },
529 { OP_ENVELOPE_EDIT_SUBJECT, op_envelope_edit_subject },
530 { OP_ENVELOPE_EDIT_TO, op_envelope_edit_to },
531 { OP_ENVELOPE_EDIT_X_COMMENT_TO, op_envelope_edit_x_comment_to },
532 { 0, NULL },
533 // clang-format on
534};