NeoMutt  2024-04-25-91-gb0e085
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Envelope Function API

Prototype for a Envelope Function. More...

+ Collaboration diagram for Envelope Function API:

Functions

static int op_envelope_edit_bcc (struct EnvelopeWindowData *wdata, int op)
 Edit the BCC list - Implements envelope_function_t -.
 
static int op_envelope_edit_cc (struct EnvelopeWindowData *wdata, int op)
 Edit the CC list - Implements envelope_function_t -.
 
static int op_envelope_edit_fcc (struct EnvelopeWindowData *wdata, int op)
 Enter a file to save a copy of this message in - Implements envelope_function_t -.
 
static int op_envelope_edit_from (struct EnvelopeWindowData *wdata, int op)
 Edit the from field - Implements envelope_function_t -.
 
static int op_envelope_edit_reply_to (struct EnvelopeWindowData *wdata, int op)
 Edit the Reply-To field - Implements envelope_function_t -.
 
static int op_envelope_edit_subject (struct EnvelopeWindowData *wdata, int op)
 Edit the subject of this message - Implements envelope_function_t -.
 
static int op_envelope_edit_to (struct EnvelopeWindowData *wdata, int op)
 Edit the TO list - Implements envelope_function_t -.
 
static int op_compose_pgp_menu (struct EnvelopeWindowData *wdata, int op)
 Show PGP options - Implements envelope_function_t -.
 
static int op_compose_smime_menu (struct EnvelopeWindowData *wdata, int op)
 Show S/MIME options - Implements envelope_function_t -.
 
static int op_compose_autocrypt_menu (struct EnvelopeWindowData *wdata, int op)
 Show autocrypt compose menu options - Implements envelope_function_t -.
 
static int op_envelope_edit_followup_to (struct EnvelopeWindowData *wdata, int op)
 Edit the Followup-To field - Implements envelope_function_t -.
 
static int op_envelope_edit_newsgroups (struct EnvelopeWindowData *wdata, int op)
 Edit the newsgroups list - Implements envelope_function_t -.
 
static int op_envelope_edit_x_comment_to (struct EnvelopeWindowData *wdata, int op)
 Edit the X-Comment-To field - Implements envelope_function_t -.
 

Detailed Description

Prototype for a Envelope Function.

Parameters
wdataEnvelope Window data
opOperation to perform, e.g. OP_ENVELOPE_EDIT_FROM
Return values
enumFunctionRetval

Function Documentation

◆ op_envelope_edit_bcc()

static int op_envelope_edit_bcc ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the BCC list - Implements envelope_function_t -.

Definition at line 190 of file functions.c.

191{
192 if (wdata->is_news)
193 return FR_NO_ACTION;
194 if (!edit_address_list(HDR_BCC, &wdata->email->env->bcc))
195 return FR_NO_ACTION;
196
197 update_crypt_info(wdata);
199 return FR_SUCCESS;
200}
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
static bool edit_address_list(enum HeaderField field, struct AddressList *al)
Let the user edit the address list.
Definition: functions.c:106
void update_crypt_info(struct EnvelopeWindowData *wdata)
Update the crypto info.
Definition: functions.c:145
@ HDR_BCC
"Bcc:" field
Definition: private.h:38
bool mutt_env_notify_send(struct Email *e, enum NotifyEnvelope type)
Send an Envelope change notification.
Definition: envelope.c:179
@ NT_ENVELOPE_BCC
"Bcc:" header has changed
Definition: envelope.h:137
struct Envelope * env
Envelope information.
Definition: email.h:68
bool is_news
Email is a news article.
Definition: wdata.h:48
struct Email * email
Email being composed.
Definition: wdata.h:40
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:62
+ Here is the call graph for this function:

◆ op_envelope_edit_cc()

static int op_envelope_edit_cc ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the CC list - Implements envelope_function_t -.

Definition at line 205 of file functions.c.

206{
207 if (wdata->is_news)
208 return FR_NO_ACTION;
209 if (!edit_address_list(HDR_CC, &wdata->email->env->cc))
210 return FR_NO_ACTION;
211
212 update_crypt_info(wdata);
214 return FR_SUCCESS;
215}
@ HDR_CC
"Cc:" field
Definition: private.h:37
@ NT_ENVELOPE_CC
"Cc:" header has changed
Definition: envelope.h:138
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:61
+ Here is the call graph for this function:

◆ op_envelope_edit_fcc()

static int op_envelope_edit_fcc ( struct EnvelopeWindowData wdata,
int  op 
)
static

Enter a file to save a copy of this message in - Implements envelope_function_t -.

Definition at line 220 of file functions.c.

221{
222 int rc = FR_NO_ACTION;
223 struct Buffer *fname = buf_pool_get();
224 buf_copy(fname, wdata->fcc);
225
226 struct FileCompletionData cdata = { false, NULL, NULL, NULL };
228 &CompleteMailboxOps, &cdata) != 0)
229 {
230 goto done; // aborted
231 }
232
233 if (mutt_str_equal(wdata->fcc->data, fname->data))
234 goto done; // no change
235
236 buf_copy(wdata->fcc, fname);
237 buf_pretty_mailbox(wdata->fcc);
239 rc = FR_SUCCESS;
240
241done:
242 buf_pool_release(&fname);
243 return rc;
244}
const struct CompleteOps CompleteMailboxOps
Auto-Completion of Files / Mailboxes.
Definition: complete.c:160
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:601
const char *const Prompts[]
Names of header fields used in the envelope, e.g. From:, To:
Definition: window.c:93
@ HDR_FCC
"Fcc:" (save folder) field
Definition: private.h:41
@ NT_ENVELOPE_FCC
"Fcc:" header has changed
Definition: envelope.h:139
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:274
@ HC_MAILBOX
Mailboxes.
Definition: lib.h:57
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
#define MUTT_COMP_CLEAR
Clear input if printable character is pressed.
Definition: mutt.h:57
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:519
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:36
char * data
Pointer to data.
Definition: buffer.h:37
struct Buffer * fcc
Where the outgoing Email will be saved.
Definition: wdata.h:41
Input for the file completion function.
Definition: curs_lib.h:40
+ Here is the call graph for this function:

◆ op_envelope_edit_from()

static int op_envelope_edit_from ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the from field - Implements envelope_function_t -.

Definition at line 249 of file functions.c.

250{
251 if (!edit_address_list(HDR_FROM, &wdata->email->env->from))
252 return FR_NO_ACTION;
253
254 update_crypt_info(wdata);
256 return FR_SUCCESS;
257}
@ HDR_FROM
"From:" field
Definition: private.h:35
@ NT_ENVELOPE_FROM
"From:" header has changed
Definition: envelope.h:141
struct AddressList from
Email's 'From' list.
Definition: envelope.h:59
+ Here is the call graph for this function:

◆ op_envelope_edit_reply_to()

static int op_envelope_edit_reply_to ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the Reply-To field - Implements envelope_function_t -.

Definition at line 262 of file functions.c.

263{
265 return FR_NO_ACTION;
266
268 return FR_SUCCESS;
269}
@ HDR_REPLYTO
"Reply-To:" field
Definition: private.h:40
@ NT_ENVELOPE_REPLY_TO
"Reply-To:" header has changed
Definition: envelope.h:143
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:64
+ Here is the call graph for this function:

◆ op_envelope_edit_subject()

static int op_envelope_edit_subject ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the subject of this message - Implements envelope_function_t -.

Definition at line 274 of file functions.c.

275{
276 int rc = FR_NO_ACTION;
277 struct Buffer *buf = buf_pool_get();
278
279 buf_strcpy(buf, wdata->email->env->subject);
280 if (mw_get_field(Prompts[HDR_SUBJECT], buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
281 {
282 goto done; // aborted
283 }
284
285 if (mutt_str_equal(wdata->email->env->subject, buf_string(buf)))
286 goto done; // no change
287
290 rc = FR_SUCCESS;
291
292done:
293 buf_pool_release(&buf);
294 return rc;
295}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
@ HDR_SUBJECT
"Subject:" field
Definition: private.h:39
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
Definition: envelope.c:69
@ NT_ENVELOPE_SUBJECT
"Subject:" header has changed
Definition: envelope.h:144
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:56
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
char *const subject
Email's subject.
Definition: envelope.h:70
+ Here is the call graph for this function:

◆ op_envelope_edit_to()

static int op_envelope_edit_to ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the TO list - Implements envelope_function_t -.

Definition at line 300 of file functions.c.

301{
302 if (wdata->is_news)
303 return FR_NO_ACTION;
304 if (!edit_address_list(HDR_TO, &wdata->email->env->to))
305 return FR_NO_ACTION;
306
307 update_crypt_info(wdata);
309 return FR_SUCCESS;
310}
@ HDR_TO
"To:" field
Definition: private.h:36
@ NT_ENVELOPE_TO
"To:" header has changed
Definition: envelope.h:145
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
+ Here is the call graph for this function:

◆ op_compose_pgp_menu()

static int op_compose_pgp_menu ( struct EnvelopeWindowData wdata,
int  op 
)
static

Show PGP options - Implements envelope_function_t -.

Definition at line 315 of file functions.c.

316{
317 const SecurityFlags old_flags = wdata->email->security;
319 return FR_NOT_IMPL;
321 {
322 mutt_error(_("No PGP backend configured"));
323 return FR_ERROR;
324 }
325 if (((WithCrypto & APPLICATION_SMIME) != 0) && (wdata->email->security & APPLICATION_SMIME))
326 {
327 if (wdata->email->security & (SEC_ENCRYPT | SEC_SIGN))
328 {
329 if (query_yesorno(_("S/MIME already selected. Clear and continue?"), MUTT_YES) != MUTT_YES)
330 {
332 return FR_NO_ACTION;
333 }
334 wdata->email->security &= ~(SEC_ENCRYPT | SEC_SIGN);
335 }
336 wdata->email->security &= ~APPLICATION_SMIME;
337 wdata->email->security |= APPLICATION_PGP;
338 update_crypt_info(wdata);
339 }
340 wdata->email->security = crypt_pgp_send_menu(wdata->email);
341 update_crypt_info(wdata);
342 if (wdata->email->security == old_flags)
343 return FR_NO_ACTION;
344
347 return FR_SUCCESS;
348}
bool crypt_has_module_backend(SecurityFlags type)
Is there a crypto backend for a given type?
Definition: cryptglue.c:170
SecurityFlags crypt_pgp_send_menu(struct Email *e)
Wrapper for CryptModuleSpecs::send_menu()
Definition: cryptglue.c:383
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition: dispatcher.h:36
@ NT_EMAIL_CHANGE
Email has changed.
Definition: email.h:186
#define mutt_error(...)
Definition: logging2.h:92
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:692
#define MUTT_SEND2_HOOK
send2-hook: when changing fields in the compose menu
Definition: hook.h:48
#define _(a)
Definition: message.h:28
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
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:76
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define WithCrypto
Definition: lib.h:116
#define SEC_SIGN
Email is signed.
Definition: lib.h:79
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition: notify_type.h:44
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition: question.c:326
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:43
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition: email.h:73
+ Here is the call graph for this function:

◆ op_compose_smime_menu()

static int op_compose_smime_menu ( struct EnvelopeWindowData wdata,
int  op 
)
static

Show S/MIME options - Implements envelope_function_t -.

Definition at line 353 of file functions.c.

354{
355 const SecurityFlags old_flags = wdata->email->security;
357 return FR_NOT_IMPL;
359 {
360 mutt_error(_("No S/MIME backend configured"));
361 return FR_ERROR;
362 }
363
364 if (((WithCrypto & APPLICATION_PGP) != 0) && (wdata->email->security & APPLICATION_PGP))
365 {
366 if (wdata->email->security & (SEC_ENCRYPT | SEC_SIGN))
367 {
368 if (query_yesorno(_("PGP already selected. Clear and continue?"), MUTT_YES) != MUTT_YES)
369 {
371 return FR_NO_ACTION;
372 }
373 wdata->email->security &= ~(SEC_ENCRYPT | SEC_SIGN);
374 }
375 wdata->email->security &= ~APPLICATION_PGP;
377 update_crypt_info(wdata);
378 }
379 wdata->email->security = crypt_smime_send_menu(wdata->email);
380 update_crypt_info(wdata);
381 if (wdata->email->security == old_flags)
382 return FR_NO_ACTION;
383
386 return FR_SUCCESS;
387}
SecurityFlags crypt_smime_send_menu(struct Email *e)
Wrapper for CryptModuleSpecs::send_menu()
Definition: cryptglue.c:527
+ Here is the call graph for this function:

◆ op_compose_autocrypt_menu()

static int op_compose_autocrypt_menu ( struct EnvelopeWindowData wdata,
int  op 
)
static

Show autocrypt compose menu options - Implements envelope_function_t -.

Definition at line 393 of file functions.c.

394{
395 const SecurityFlags old_flags = wdata->email->security;
396 const bool c_autocrypt = cs_subset_bool(wdata->sub, "autocrypt");
397 if (!c_autocrypt)
398 return FR_NO_ACTION;
399
401 {
402 if (wdata->email->security & (SEC_ENCRYPT | SEC_SIGN))
403 {
404 if (query_yesorno(_("S/MIME already selected. Clear and continue?"), MUTT_YES) != MUTT_YES)
405 {
407 return FR_NO_ACTION;
408 }
409 wdata->email->security &= ~(SEC_ENCRYPT | SEC_SIGN);
410 }
411 wdata->email->security &= ~APPLICATION_SMIME;
412 wdata->email->security |= APPLICATION_PGP;
413 update_crypt_info(wdata);
414 }
415 autocrypt_compose_menu(wdata->email, wdata->sub);
416 update_crypt_info(wdata);
417 if (wdata->email->security == old_flags)
418 return FR_NO_ACTION;
419
422 return FR_SUCCESS;
423}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
static void autocrypt_compose_menu(struct Email *e, const struct ConfigSubset *sub)
Autocrypt compose settings.
Definition: functions.c:63
struct ConfigSubset * sub
Inherited config items.
Definition: wdata.h:39
+ Here is the call graph for this function:

◆ op_envelope_edit_followup_to()

static int op_envelope_edit_followup_to ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the Followup-To field - Implements envelope_function_t -.

Definition at line 431 of file functions.c.

432{
433 if (!wdata->is_news)
434 return FR_NO_ACTION;
435
436 int rc = FR_NO_ACTION;
437 struct Buffer *buf = buf_pool_get();
438
439 buf_strcpy(buf, wdata->email->env->followup_to);
440 if (mw_get_field(Prompts[HDR_FOLLOWUPTO], buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
441 {
444 rc = FR_SUCCESS;
445 }
446
447 buf_pool_release(&buf);
448 return rc;
449}
@ HDR_FOLLOWUPTO
"Followup-To:" field
Definition: private.h:48
@ NT_ENVELOPE_FOLLOWUP_TO
"Followup-To:" header has changed
Definition: envelope.h:140
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:280
char * followup_to
List of 'followup-to' fields.
Definition: envelope.h:80
+ Here is the call graph for this function:

◆ op_envelope_edit_newsgroups()

static int op_envelope_edit_newsgroups ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the newsgroups list - Implements envelope_function_t -.

Definition at line 454 of file functions.c.

455{
456 if (!wdata->is_news)
457 return FR_NO_ACTION;
458
459 int rc = FR_NO_ACTION;
460 struct Buffer *buf = buf_pool_get();
461
462 buf_strcpy(buf, wdata->email->env->newsgroups);
463 if (mw_get_field(Prompts[HDR_NEWSGROUPS], buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
464 {
467 rc = FR_SUCCESS;
468 }
469
470 buf_pool_release(&buf);
471 return rc;
472}
@ HDR_NEWSGROUPS
"Newsgroups:" field
Definition: private.h:47
@ NT_ENVELOPE_NEWSGROUPS
"Newsgroups:" header has changed
Definition: envelope.h:142
char * newsgroups
List of newsgroups.
Definition: envelope.h:78
+ Here is the call graph for this function:

◆ op_envelope_edit_x_comment_to()

static int op_envelope_edit_x_comment_to ( struct EnvelopeWindowData wdata,
int  op 
)
static

Edit the X-Comment-To field - Implements envelope_function_t -.

Definition at line 477 of file functions.c.

478{
479 const bool c_x_comment_to = cs_subset_bool(wdata->sub, "x_comment_to");
480 if (!(wdata->is_news && c_x_comment_to))
481 return FR_NO_ACTION;
482
483 int rc = FR_NO_ACTION;
484 struct Buffer *buf = buf_pool_get();
485
486 buf_strcpy(buf, wdata->email->env->x_comment_to);
487 if (mw_get_field(Prompts[HDR_XCOMMENTTO], buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
488 {
491 rc = FR_SUCCESS;
492 }
493
494 buf_pool_release(&buf);
495 return rc;
496}
@ HDR_XCOMMENTTO
"X-Comment-To:" field
Definition: private.h:49
@ NT_ENVELOPE_X_COMMENT_TO
"X-Comment-To:" header has changed
Definition: envelope.h:146
char * x_comment_to
List of 'X-comment-to' fields.
Definition: envelope.h:81
+ Here is the call graph for this function: