NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
functions.c File Reference

Attachment functions. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "functions.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attach.h"
#include "mutt_attach.h"
#include "opcodes.h"
#include "options.h"
#include "private_data.h"
#include "recvattach.h"
#include "recvcmd.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

static void attach_collapse (struct AttachCtx *actx, struct Menu *menu)
 Close the tree of the current attachment. More...
 
static bool check_attach (void)
 Check if in attach-message mode. More...
 
static bool check_readonly (struct Mailbox *m)
 Check if the Mailbox is readonly. More...
 
static void recvattach_extract_pgp_keys (struct AttachCtx *actx, struct Menu *menu)
 Extract PGP keys from attachments. More...
 
static int recvattach_pgp_check_traditional (struct AttachCtx *actx, struct Menu *menu)
 Is the Attachment inline PGP? More...
 
static int op_attachment_collapse (struct AttachPrivateData *priv, int op)
 toggle display of subparts - Implements attach_function_t - More...
 
static int op_attachment_delete (struct AttachPrivateData *priv, int op)
 delete the current entry - Implements attach_function_t - More...
 
static int op_attachment_edit_type (struct AttachPrivateData *priv, int op)
 edit attachment content type - Implements attach_function_t - More...
 
static int op_attachment_pipe (struct AttachPrivateData *priv, int op)
 pipe message/attachment to a shell command - Implements attach_function_t - More...
 
static int op_attachment_print (struct AttachPrivateData *priv, int op)
 print the current entry - Implements attach_function_t - More...
 
static int op_attachment_save (struct AttachPrivateData *priv, int op)
 save message/attachment to a mailbox/file - Implements attach_function_t - More...
 
static int op_attachment_undelete (struct AttachPrivateData *priv, int op)
 undelete the current entry - Implements attach_function_t - More...
 
static int op_attachment_view (struct AttachPrivateData *priv, int op)
 view attachment using mailcap entry if necessary - Implements attach_function_t - More...
 
static int op_attachment_view_mailcap (struct AttachPrivateData *priv, int op)
 force viewing of attachment using mailcap - Implements attach_function_t - More...
 
static int op_attachment_view_pager (struct AttachPrivateData *priv, int op)
 view attachment in pager using copiousoutput mailcap - Implements attach_function_t - More...
 
static int op_attachment_view_text (struct AttachPrivateData *priv, int op)
 view attachment as text - Implements attach_function_t - More...
 
static int op_bounce_message (struct AttachPrivateData *priv, int op)
 remail a message to another user - Implements attach_function_t - More...
 
static int op_check_traditional (struct AttachPrivateData *priv, int op)
 check for classic PGP - Implements attach_function_t - More...
 
static int op_compose_to_sender (struct AttachPrivateData *priv, int op)
 compose new message to the current message sender - Implements attach_function_t - More...
 
static int op_exit (struct AttachPrivateData *priv, int op)
 exit this menu - Implements attach_function_t - More...
 
static int op_extract_keys (struct AttachPrivateData *priv, int op)
 extract supported public keys - Implements attach_function_t - More...
 
static int op_forget_passphrase (struct AttachPrivateData *priv, int op)
 wipe passphrases from memory - Implements attach_function_t - More...
 
static int op_forward_message (struct AttachPrivateData *priv, int op)
 forward a message with comments - Implements attach_function_t - More...
 
static int op_list_subscribe (struct AttachPrivateData *priv, int op)
 subscribe to a mailing list - Implements attach_function_t - More...
 
static int op_list_unsubscribe (struct AttachPrivateData *priv, int op)
 unsubscribe from a mailing list - Implements attach_function_t - More...
 
static int op_reply (struct AttachPrivateData *priv, int op)
 reply to a message - Implements attach_function_t - More...
 
static int op_resend (struct AttachPrivateData *priv, int op)
 use the current message as a template for a new one - Implements attach_function_t - More...
 
static int op_followup (struct AttachPrivateData *priv, int op)
 followup to newsgroup - Implements attach_function_t - More...
 
static int op_forward_to_group (struct AttachPrivateData *priv, int op)
 forward to newsgroup - Implements attach_function_t - More...
 
int attach_function_dispatcher (struct MuttWindow *win, int op)
 Perform a Attach function - Implements function_dispatcher_t -. More...
 

Variables

static const char * Not_available_in_this_menu = N_("Not available in this menu")
 
static const char * Function_not_permitted_in_attach_message_mode
 
struct AttachFunction AttachFunctions []
 All the NeoMutt functions that the Attach supports. More...
 

Detailed Description

Attachment functions.

Authors
  • Richard Russon

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

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

Definition in file functions.c.

Function Documentation

◆ attach_collapse()

static void attach_collapse ( struct AttachCtx actx,
struct Menu menu 
)
static

Close the tree of the current attachment.

Parameters
actxAttachment context
menuMenu listing Attachments

Definition at line 59 of file functions.c.

60{
61 int rindex, curlevel;
62
63 struct AttachPtr *cur_att = current_attachment(actx, menu);
64 cur_att->collapsed = !cur_att->collapsed;
65 /* When expanding, expand all the children too */
66 if (cur_att->collapsed)
67 return;
68
69 curlevel = cur_att->level;
70 const int index = menu_get_index(menu);
71 rindex = actx->v2r[index] + 1;
72
73 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
74 while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
75 {
76 if (c_digest_collapse && (actx->idx[rindex]->body->type == TYPE_MULTIPART) &&
77 mutt_istr_equal(actx->idx[rindex]->body->subtype, "digest"))
78 {
79 actx->idx[rindex]->collapsed = true;
80 }
81 else
82 {
83 actx->idx[rindex]->collapsed = false;
84 }
85 rindex++;
86 }
87}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:819
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition: recvattach.c:69
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:55
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:59
An email to which things will be attached.
Definition: attach.h:35
struct Body * body
Attachment.
Definition: attach.h:36
bool collapsed
Group is collapsed.
Definition: attach.h:44
int level
Nesting depth of attachment.
Definition: attach.h:40
char * subtype
content-type subtype
Definition: body.h:60
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_attach()

static bool check_attach ( void  )
static

Check if in attach-message mode.

Return values
trueMailbox is readonly

Definition at line 93 of file functions.c.

94{
95 if (OptAttachMsg)
96 {
99 return true;
100 }
101
102 return false;
103}
static const char * Function_not_permitted_in_attach_message_mode
Definition: functions.c:51
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:592
#define mutt_error(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
bool OptAttachMsg
(pseudo) used by attach-message
Definition: options.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_readonly()

static bool check_readonly ( struct Mailbox m)
static

Check if the Mailbox is readonly.

Parameters
mMailbox
Return values
trueMailbox is readonly

Definition at line 110 of file functions.c.

111{
112 if (!m || m->readonly)
113 {
115 mutt_error(_("Mailbox is read-only"));
116 return true;
117 }
118
119 return false;
120}
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:115
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_extract_pgp_keys()

static void recvattach_extract_pgp_keys ( struct AttachCtx actx,
struct Menu menu 
)
static

Extract PGP keys from attachments.

Parameters
actxAttachment context
menuMenu listing attachments

Definition at line 127 of file functions.c.

128{
129 if (!menu->tag_prefix)
130 {
131 struct AttachPtr *cur_att = current_attachment(actx, menu);
133 }
134 else
135 {
136 for (int i = 0; i < actx->idxlen; i++)
137 {
138 if (actx->idx[i]->body->tagged)
139 {
141 }
142 }
143 }
144}
void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *top)
Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment()
Definition: cryptglue.c:395
short idxlen
Number of attachmentes.
Definition: attach.h:56
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
bool tagged
This attachment is tagged.
Definition: body.h:89
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_pgp_check_traditional()

static int recvattach_pgp_check_traditional ( struct AttachCtx actx,
struct Menu menu 
)
static

Is the Attachment inline PGP?

Parameters
actxAttachment to check
menuMenu listing Attachments
Return values
1The (tagged) Attachment(s) are inline PGP
Note
If the menu->tagprefix is set, all the tagged attachments will be checked.

Definition at line 154 of file functions.c.

155{
156 int rc = 0;
157
158 if (!menu->tag_prefix)
159 {
160 struct AttachPtr *cur_att = current_attachment(actx, menu);
161 rc = crypt_pgp_check_traditional(cur_att->fp, cur_att->body, true);
162 }
163 else
164 {
165 for (int i = 0; i < actx->idxlen; i++)
166 if (actx->idx[i]->body->tagged)
167 rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->body, true);
168 }
169
170 return rc;
171}
bool crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:283
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Not_available_in_this_menu

const char* Not_available_in_this_menu = N_("Not available in this menu")
static

Definition at line 50 of file functions.c.

◆ Function_not_permitted_in_attach_message_mode

const char* Function_not_permitted_in_attach_message_mode
static
Initial value:
= N_(
"Function not permitted in attach-message mode")
#define N_(a)
Definition: message.h:32

Definition at line 51 of file functions.c.

◆ AttachFunctions

struct AttachFunction AttachFunctions[]

All the NeoMutt functions that the Attach supports.

Definition at line 600 of file functions.c.